diff --git a/bin/configs/kotlin-spring-cloud-4.yaml b/bin/configs/kotlin-spring-cloud-4.yaml new file mode 100644 index 000000000000..d60afa47c48d --- /dev/null +++ b/bin/configs/kotlin-spring-cloud-4.yaml @@ -0,0 +1,13 @@ +generatorName: kotlin-spring +outputDir: samples/server/petstore/kotlin-spring-cloud-4 +library: spring-cloud +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/kotlin-spring +additionalProperties: + documentationProvider: none + annotationLibrary: none + useSwaggerUI: "false" + serializableModel: "true" + useBeanValidation: "true" + interfaceOnly: "true" + useSpringBoot4: "true" diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache index 4324adc2b447..ee0a2a9178bd 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache @@ -34,7 +34,7 @@ org.springframework.cloud - spring-cloud-starter-parent + spring-cloud-dependencies 2025.1.0 pom import diff --git a/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator-ignore b/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator/FILES b/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator/FILES new file mode 100644 index 000000000000..9c277d3ed4a8 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator/FILES @@ -0,0 +1,22 @@ +README.md +build.gradle.kts +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/kotlin/org/openapitools/api/PetApi.kt +src/main/kotlin/org/openapitools/api/PetApiClient.kt +src/main/kotlin/org/openapitools/api/StoreApi.kt +src/main/kotlin/org/openapitools/api/StoreApiClient.kt +src/main/kotlin/org/openapitools/api/UserApi.kt +src/main/kotlin/org/openapitools/api/UserApiClient.kt +src/main/kotlin/org/openapitools/configuration/ApiKeyRequestInterceptor.kt +src/main/kotlin/org/openapitools/configuration/ClientConfiguration.kt +src/main/kotlin/org/openapitools/model/Category.kt +src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +src/main/kotlin/org/openapitools/model/Order.kt +src/main/kotlin/org/openapitools/model/Pet.kt +src/main/kotlin/org/openapitools/model/Tag.kt +src/main/kotlin/org/openapitools/model/User.kt diff --git a/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator/VERSION b/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator/VERSION new file mode 100644 index 000000000000..8fc8df61083a --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.25.0-SNAPSHOT diff --git a/samples/server/petstore/kotlin-spring-cloud-4/README.md b/samples/server/petstore/kotlin-spring-cloud-4/README.md new file mode 100644 index 000000000000..a462be951ace --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/README.md @@ -0,0 +1,26 @@ +# OpenAPI generated API stub + +Spring Framework stub + + +## Overview +This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub. +This is an example of building API stub interfaces in Java using the Spring framework. + +The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints +by adding ```@Controller``` classes that implement the interface. Eg: +```java +@Controller +public class PetController implements PetApi { +// implement all PetApi methods +} +``` + +You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg: +```java +@FeignClient(name="pet", url="http://petstore.swagger.io/v2") +public interface PetClient extends PetApi { + +} +``` diff --git a/samples/server/petstore/kotlin-spring-cloud-4/build.gradle.kts b/samples/server/petstore/kotlin-spring-cloud-4/build.gradle.kts new file mode 100644 index 000000000000..ce19f0a90dab --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/build.gradle.kts @@ -0,0 +1,58 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +group = "org.openapitools" +version = "1.0.0" +java.sourceCompatibility = JavaVersion.VERSION_17 + +repositories { + mavenCentral() +} + +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } +} + +plugins { + val kotlinVersion = "2.2.0" + id("org.jetbrains.kotlin.jvm") version kotlinVersion + id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion + id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion + id("org.springframework.boot") version "4.0.1" + id("io.spring.dependency-management") version "1.1.7" +} + +tasks.getByName("bootJar") { + enabled = false +} + +tasks.getByName("jar") { + enabled = true +} + +dependencyManagement { + imports { + mavenBom("org.springframework.cloud:spring-cloud-dependencies:2025.1.0") + } +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib") + implementation("org.jetbrains.kotlin:kotlin-reflect") + implementation("org.springframework.boot:spring-boot-starter-webmvc") + + implementation("com.google.code.findbugs:jsr305:3.0.2") + val jackson3Version = "3.1.0" + implementation("tools.jackson.dataformat:jackson-dataformat-yaml:$jackson3Version") + implementation("tools.jackson.dataformat:jackson-dataformat-xml:$jackson3Version") + implementation("tools.jackson.module:jackson-module-kotlin:$jackson3Version") + + implementation("org.springframework.cloud:spring-cloud-starter-openfeign") + implementation("org.springframework.boot:spring-boot-starter-oauth2-client") + + implementation("jakarta.validation:jakarta.validation-api") + + implementation("jakarta.annotation:jakarta.annotation-api:3.0.0") + +} \ No newline at end of file diff --git a/samples/server/petstore/kotlin-spring-cloud-4/gradle/wrapper/gradle-wrapper.jar b/samples/server/petstore/kotlin-spring-cloud-4/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..e6441136f3d4 Binary files /dev/null and b/samples/server/petstore/kotlin-spring-cloud-4/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/server/petstore/kotlin-spring-cloud-4/gradle/wrapper/gradle-wrapper.properties b/samples/server/petstore/kotlin-spring-cloud-4/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..ca025c83a7cc --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/server/petstore/kotlin-spring-cloud-4/gradlew b/samples/server/petstore/kotlin-spring-cloud-4/gradlew new file mode 100644 index 000000000000..9d0ce634cb11 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/server/petstore/kotlin-spring-cloud-4/gradlew.bat b/samples/server/petstore/kotlin-spring-cloud-4/gradlew.bat new file mode 100644 index 000000000000..25da30dbdeee --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/server/petstore/kotlin-spring-cloud-4/pom.xml b/samples/server/petstore/kotlin-spring-cloud-4/pom.xml new file mode 100644 index 000000000000..54f1e792ebad --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/pom.xml @@ -0,0 +1,156 @@ + + 4.0.0 + org.openapitools + openapi-spring + jar + openapi-spring + 1.0.0 + + 3.0.2 + 3.1.0 + 3.0.0 + 2.2.0 + + 2.2.0 + UTF-8 + + + org.springframework.boot + spring-boot-starter-parent + 4.0.1 + + + + + org.springframework.cloud + spring-cloud-dependencies + 2025.1.0 + pom + import + + + + + ${project.basedir}/src/main/kotlin + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + spring + + 17 + + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + org.springframework.boot + spring-boot-starter-webmvc + + + + + + + com.google.code.findbugs + jsr305 + ${findbugs-jsr305.version} + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.boot + spring-boot-starter-oauth2-client + + + tools.jackson.dataformat + jackson-dataformat-yaml + ${jackson3.version} + + + tools.jackson.dataformat + jackson-dataformat-xml + ${jackson3.version} + + + tools.jackson.module + jackson-module-kotlin + ${jackson3.version} + + + + jakarta.validation + jakarta.validation-api + + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation.version} + provided + + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlin-test-junit5.version} + test + + + org.springframework.boot + spring-boot-starter-test + test + + + \ No newline at end of file diff --git a/samples/server/petstore/kotlin-spring-cloud-4/settings.gradle b/samples/server/petstore/kotlin-spring-cloud-4/settings.gradle new file mode 100644 index 000000000000..14844905cd40 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/settings.gradle @@ -0,0 +1,15 @@ +pluginManagement { + repositories { + maven { url = uri("https://repo.spring.io/snapshot") } + maven { url = uri("https://repo.spring.io/milestone") } + gradlePluginPortal() + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "org.springframework.boot") { + useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}") + } + } + } +} +rootProject.name = "openapi-spring" diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/PetApi.kt new file mode 100644 index 000000000000..0720cce9702c --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -0,0 +1,158 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.25.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.ModelApiResponse +import org.openapitools.model.Pet +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +interface PetApi { + + + @RequestMapping( + method = [RequestMethod.POST], + // "/pet" + value = [PATH_ADD_PET], + produces = ["application/xml", "application/json"], + consumes = ["application/json", "application/xml"] + ) + fun addPet( + @Valid @RequestBody pet: Pet + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.DELETE], + // "/pet/{petId}" + value = [PATH_DELETE_PET] + ) + fun deletePet( + @PathVariable("petId") petId: kotlin.Long, + @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String? + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.GET], + // "/pet/findByStatus" + value = [PATH_FIND_PETS_BY_STATUS], + produces = ["application/xml", "application/json"] + ) + fun findPetsByStatus( + @NotNull @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List + ): ResponseEntity> { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @Deprecated(message="Operation is deprecated") + @RequestMapping( + method = [RequestMethod.GET], + // "/pet/findByTags" + value = [PATH_FIND_PETS_BY_TAGS], + produces = ["application/xml", "application/json"] + ) + fun findPetsByTags( + @NotNull @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List + ): ResponseEntity> { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.GET], + // "/pet/{petId}" + value = [PATH_GET_PET_BY_ID], + produces = ["application/xml", "application/json"] + ) + fun getPetById( + @PathVariable("petId") petId: kotlin.Long + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.PUT], + // "/pet" + value = [PATH_UPDATE_PET], + produces = ["application/xml", "application/json"], + consumes = ["application/json", "application/xml"] + ) + fun updatePet( + @Valid @RequestBody pet: Pet + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.POST], + // "/pet/{petId}" + value = [PATH_UPDATE_PET_WITH_FORM], + consumes = ["application/x-www-form-urlencoded"] + ) + fun updatePetWithForm( + @PathVariable("petId") petId: kotlin.Long, + @Valid @RequestParam(value = "name", required = false) name: kotlin.String?, + @Valid @RequestParam(value = "status", required = false) status: kotlin.String? + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.POST], + // "/pet/{petId}/uploadImage" + value = [PATH_UPLOAD_FILE], + produces = ["application/json"], + consumes = ["multipart/form-data"] + ) + fun uploadFile( + @PathVariable("petId") petId: kotlin.Long, + @Valid @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String?, + @Valid @RequestPart("file", required = false) file: org.springframework.web.multipart.MultipartFile + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + companion object { + //for your own safety never directly reuse these path definitions in tests + const val PATH_ADD_PET: String = "/pet" + const val PATH_DELETE_PET: String = "/pet/{petId}" + const val PATH_FIND_PETS_BY_STATUS: String = "/pet/findByStatus" + const val PATH_FIND_PETS_BY_TAGS: String = "/pet/findByTags" + const val PATH_GET_PET_BY_ID: String = "/pet/{petId}" + const val PATH_UPDATE_PET: String = "/pet" + const val PATH_UPDATE_PET_WITH_FORM: String = "/pet/{petId}" + const val PATH_UPLOAD_FILE: String = "/pet/{petId}/uploadImage" + } +} diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/PetApiClient.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/PetApiClient.kt new file mode 100644 index 000000000000..8373f9aa9393 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/PetApiClient.kt @@ -0,0 +1,11 @@ +package org.openapitools.api + +import org.springframework.cloud.openfeign.FeignClient +import org.openapitools.configuration.ClientConfiguration + +@FeignClient( + name="\${pet.name:pet}", + url="\${pet.url:http://petstore.swagger.io/v2}", + configuration = [ClientConfiguration::class] +) +interface PetApiClient : PetApi diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/StoreApi.kt new file mode 100644 index 000000000000..757fa44ed34e --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -0,0 +1,91 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.25.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.Order +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +interface StoreApi { + + + @RequestMapping( + method = [RequestMethod.DELETE], + // "/store/order/{orderId}" + value = [PATH_DELETE_ORDER] + ) + fun deleteOrder( + @PathVariable("orderId") orderId: kotlin.String + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.GET], + // "/store/inventory" + value = [PATH_GET_INVENTORY], + produces = ["application/json"] + ) + fun getInventory(): ResponseEntity> { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.GET], + // "/store/order/{orderId}" + value = [PATH_GET_ORDER_BY_ID], + produces = ["application/xml", "application/json"] + ) + fun getOrderById( + @Min(value=1L) @Max(value=5L) @PathVariable("orderId") orderId: kotlin.Long + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.POST], + // "/store/order" + value = [PATH_PLACE_ORDER], + produces = ["application/xml", "application/json"], + consumes = ["application/json"] + ) + fun placeOrder( + @Valid @RequestBody order: Order + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + companion object { + //for your own safety never directly reuse these path definitions in tests + const val PATH_DELETE_ORDER: String = "/store/order/{orderId}" + const val PATH_GET_INVENTORY: String = "/store/inventory" + const val PATH_GET_ORDER_BY_ID: String = "/store/order/{orderId}" + const val PATH_PLACE_ORDER: String = "/store/order" + } +} diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/StoreApiClient.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/StoreApiClient.kt new file mode 100644 index 000000000000..e3d21e46f0c7 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/StoreApiClient.kt @@ -0,0 +1,11 @@ +package org.openapitools.api + +import org.springframework.cloud.openfeign.FeignClient +import org.openapitools.configuration.ClientConfiguration + +@FeignClient( + name="\${store.name:store}", + url="\${store.url:http://petstore.swagger.io/v2}", + configuration = [ClientConfiguration::class] +) +interface StoreApiClient : StoreApi diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/UserApi.kt new file mode 100644 index 000000000000..6a9ed3623513 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -0,0 +1,147 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.25.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.User +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +interface UserApi { + + + @RequestMapping( + method = [RequestMethod.POST], + // "/user" + value = [PATH_CREATE_USER], + consumes = ["application/json"] + ) + fun createUser( + @Valid @RequestBody user: User + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.POST], + // "/user/createWithArray" + value = [PATH_CREATE_USERS_WITH_ARRAY_INPUT], + consumes = ["application/json"] + ) + fun createUsersWithArrayInput( + @Valid @RequestBody user: kotlin.collections.List + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.POST], + // "/user/createWithList" + value = [PATH_CREATE_USERS_WITH_LIST_INPUT], + consumes = ["application/json"] + ) + fun createUsersWithListInput( + @Valid @RequestBody user: kotlin.collections.List + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.DELETE], + // "/user/{username}" + value = [PATH_DELETE_USER] + ) + fun deleteUser( + @PathVariable("username") username: kotlin.String + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.GET], + // "/user/{username}" + value = [PATH_GET_USER_BY_NAME], + produces = ["application/xml", "application/json"] + ) + fun getUserByName( + @PathVariable("username") username: kotlin.String + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.GET], + // "/user/login" + value = [PATH_LOGIN_USER], + produces = ["application/xml", "application/json"] + ) + fun loginUser( + @NotNull @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Valid @RequestParam(value = "username", required = true) username: kotlin.String, + @NotNull @Valid @RequestParam(value = "password", required = true) password: kotlin.String + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.GET], + // "/user/logout" + value = [PATH_LOGOUT_USER] + ) + fun logoutUser(): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.PUT], + // "/user/{username}" + value = [PATH_UPDATE_USER], + consumes = ["application/json"] + ) + fun updateUser( + @PathVariable("username") username: kotlin.String, + @Valid @RequestBody user: User + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + companion object { + //for your own safety never directly reuse these path definitions in tests + const val PATH_CREATE_USER: String = "/user" + const val PATH_CREATE_USERS_WITH_ARRAY_INPUT: String = "/user/createWithArray" + const val PATH_CREATE_USERS_WITH_LIST_INPUT: String = "/user/createWithList" + const val PATH_DELETE_USER: String = "/user/{username}" + const val PATH_GET_USER_BY_NAME: String = "/user/{username}" + const val PATH_LOGIN_USER: String = "/user/login" + const val PATH_LOGOUT_USER: String = "/user/logout" + const val PATH_UPDATE_USER: String = "/user/{username}" + } +} diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/UserApiClient.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/UserApiClient.kt new file mode 100644 index 000000000000..0d7af2aeaa3d --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/api/UserApiClient.kt @@ -0,0 +1,11 @@ +package org.openapitools.api + +import org.springframework.cloud.openfeign.FeignClient +import org.openapitools.configuration.ClientConfiguration + +@FeignClient( + name="\${user.name:user}", + url="\${user.url:http://petstore.swagger.io/v2}", + configuration = [ClientConfiguration::class] +) +interface UserApiClient : UserApi diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/configuration/ApiKeyRequestInterceptor.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/configuration/ApiKeyRequestInterceptor.kt new file mode 100644 index 000000000000..b9129a3b0074 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/configuration/ApiKeyRequestInterceptor.kt @@ -0,0 +1,19 @@ +package org.openapitools.configuration + +import feign.RequestInterceptor +import feign.RequestTemplate + +class ApiKeyRequestInterceptor( + private val location: String, + private val name: String, + private val value: String, +) : RequestInterceptor { + + override fun apply(requestTemplate: RequestTemplate) { + if (location == "header") { + requestTemplate.header(name, value) + } else if (location == "query") { + requestTemplate.query(name, value) + } + } +} diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/configuration/ClientConfiguration.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/configuration/ClientConfiguration.kt new file mode 100644 index 000000000000..111871c7bdf1 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/configuration/ClientConfiguration.kt @@ -0,0 +1,82 @@ +package org.openapitools.configuration + +import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty + + + +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +import org.springframework.security.authentication.AnonymousAuthenticationToken +import org.springframework.security.oauth2.client.AuthorizedClientServiceOAuth2AuthorizedClientManager +import org.springframework.security.oauth2.client.OAuth2AuthorizeRequest +import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager +import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService +import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository +import org.springframework.security.oauth2.core.OAuth2AuthenticationException +import org.springframework.security.oauth2.core.OAuth2AccessToken +import org.springframework.security.core.authority.AuthorityUtils +import org.springframework.http.HttpHeaders + +import feign.RequestInterceptor +import feign.RequestTemplate + +@Configuration +class ClientConfiguration { + + + @Bean + @ConditionalOnProperty(prefix = "spring.security.oauth2.client.registration.petstore_authImplicit", name = ["enabled"], havingValue = "true") + fun implicitOAuth2RequestInterceptor(implicitAuthorizedClientManager: OAuth2AuthorizedClientManager): OAuth2RequestInterceptor { + return OAuth2RequestInterceptor( + OAuth2AuthorizeRequest.withClientRegistrationId("petstore_authImplicit") + .principal(AnonymousAuthenticationToken(CLIENT_PRINCIPAL_IMPLICIT, CLIENT_PRINCIPAL_IMPLICIT, AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"))) + .build(), + implicitAuthorizedClientManager + ) + } + + @Bean + @ConditionalOnProperty(prefix = "spring.security.oauth2.client.registration.petstore_authImplicit", name = ["enabled"], havingValue = "true") + fun implicitAuthorizedClientManager( + clientRegistrationRepository: ClientRegistrationRepository, + authorizedClientService: OAuth2AuthorizedClientService + ): OAuth2AuthorizedClientManager { + return AuthorizedClientServiceOAuth2AuthorizedClientManager(clientRegistrationRepository, authorizedClientService) + } + + @Value("\${openapipetstore.security.api_key.key:}") + private lateinit var apiKeyKey: String + + @Bean + @ConditionalOnProperty("openapipetstore.security.api_key.key") + fun apiKeyRequestInterceptor(): ApiKeyRequestInterceptor { + return ApiKeyRequestInterceptor("header", "api_key", this.apiKeyKey) + } + + class OAuth2RequestInterceptor( + private val oAuth2AuthorizeRequest: OAuth2AuthorizeRequest, + private val oAuth2AuthorizedClientManager: OAuth2AuthorizedClientManager + ) : RequestInterceptor { + + override fun apply(template: RequestTemplate) { + template.header(HttpHeaders.AUTHORIZATION, getBearerToken()) + } + + fun getAccessToken(): OAuth2AccessToken { + val authorizedClient = oAuth2AuthorizedClientManager.authorize(oAuth2AuthorizeRequest) + ?: throw OAuth2AuthenticationException("Client failed to authenticate") + return authorizedClient.accessToken + } + + fun getBearerToken(): String { + val accessToken = getAccessToken() + return String.format(java.util.Locale.ROOT, "%s %s", accessToken.tokenType?.value, accessToken.tokenValue) + } + } + + companion object { + private const val CLIENT_PRINCIPAL_IMPLICIT = "oauth2FeignClient" + } +} diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Category.kt new file mode 100644 index 000000000000..f44ed4c7ace6 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Category.kt @@ -0,0 +1,41 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +/** + * A category for a pet + * @param id + * @param name + */ +data class Category( + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("id") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("name") + @get:JsonProperty("name") val name: kotlin.String? = null +) : java.io.Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt new file mode 100644 index 000000000000..8d84914db2ba --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -0,0 +1,46 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +/** + * Describes the result of uploading an image resource + * @param code + * @param type + * @param message + */ +data class ModelApiResponse( + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("code") + @get:JsonProperty("code") val code: kotlin.Int? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("type") + @get:JsonProperty("type") val type: kotlin.String? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("message") + @get:JsonProperty("message") val message: kotlin.String? = null +) : java.io.Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Order.kt new file mode 100644 index 000000000000..486848e14599 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Order.kt @@ -0,0 +1,86 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +/** + * An order for a pets from the pet store + * @param id + * @param petId + * @param quantity + * @param shipDate + * @param status Order Status + * @param complete + */ +data class Order( + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("id") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("petId") + @get:JsonProperty("petId") val petId: kotlin.Long? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("quantity") + @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("shipDate") + @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("status") + @get:JsonProperty("status") val status: Order.Status? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("complete") + @get:JsonProperty("complete") val complete: kotlin.Boolean? = false +) : java.io.Serializable { + + /** + * Order Status + * Values: placed,approved,delivered + */ + enum class Status(@get:JsonValue val value: kotlin.String) { + + placed("placed"), + approved("approved"), + delivered("delivered"); + + companion object { + @JvmStatic + @JsonCreator + fun forValue(value: kotlin.String): Status { + return values().firstOrNull{it -> it.value == value} + ?: throw IllegalArgumentException("Unexpected value '$value' for enum 'Status'") + } + } + } + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Pet.kt new file mode 100644 index 000000000000..56c523367969 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Pet.kt @@ -0,0 +1,87 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls +import org.openapitools.model.Category +import org.openapitools.model.Tag +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +/** + * A pet for sale in the pet store + * @param name + * @param photoUrls + * @param id + * @param category + * @param tags + * @param status pet status in the store + */ +data class Pet( + + @param:JsonProperty("name") + @get:JsonProperty("name", required = true) val name: kotlin.String, + + @param:JsonProperty("photoUrls") + @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("id") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @field:Valid + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("category") + @get:JsonProperty("category") val category: Category? = null, + + @field:Valid + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("tags") + @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, + + @Deprecated(message = "") + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("status") + @get:JsonProperty("status") val status: Pet.Status? = null +) : java.io.Serializable { + + /** + * pet status in the store + * Values: available,pending,sold + */ + enum class Status(@get:JsonValue val value: kotlin.String) { + + available("available"), + pending("pending"), + sold("sold"); + + companion object { + @JvmStatic + @JsonCreator + fun forValue(value: kotlin.String): Status { + return values().firstOrNull{it -> it.value == value} + ?: throw IllegalArgumentException("Unexpected value '$value' for enum 'Status'") + } + } + } + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Tag.kt new file mode 100644 index 000000000000..e3ec341838e6 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/Tag.kt @@ -0,0 +1,40 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +/** + * A tag for a pet + * @param id + * @param name + */ +data class Tag( + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("id") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("name") + @get:JsonProperty("name") val name: kotlin.String? = null +) : java.io.Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/User.kt new file mode 100644 index 000000000000..93294737c422 --- /dev/null +++ b/samples/server/petstore/kotlin-spring-cloud-4/src/main/kotlin/org/openapitools/model/User.kt @@ -0,0 +1,76 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +/** + * A User who is purchasing from the pet store + * @param id + * @param username + * @param firstName + * @param lastName + * @param email + * @param password + * @param phone + * @param userStatus User Status + */ +data class User( + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("id") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("username") + @get:JsonProperty("username") val username: kotlin.String? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("firstName") + @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("lastName") + @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("email") + @get:JsonProperty("email") val email: kotlin.String? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("password") + @get:JsonProperty("password") val password: kotlin.String? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("phone") + @get:JsonProperty("phone") val phone: kotlin.String? = null, + + @field:JsonInclude(JsonInclude.Include.NON_NULL) + @field:JsonSetter(nulls = Nulls.SKIP) + @param:JsonProperty("userStatus") + @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null +) : java.io.Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} +