diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java index 20120634dcd2..e7c2aaef7530 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java @@ -106,6 +106,7 @@ public class InlineModelResolver { // create request body RequestBody rb = new RequestBody(); + rb.setRequired(requestBody.getRequired()); Content content = new Content(); MediaType mt = new MediaType(); Schema schema = new Schema(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/InlineModelResolverTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/InlineModelResolverTest.java index 2735f15cb9de..de8015de9f6e 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/InlineModelResolverTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/InlineModelResolverTest.java @@ -328,6 +328,9 @@ public class InlineModelResolverTest { RequestBody requestBodyReference = openAPI.getPaths().get("/resolve_inline_request_body_with_required").getPost().getRequestBody(); assertTrue(requestBodyReference.getRequired()); + + RequestBody referencedRequestBody = ModelUtils.getReferencedRequestBody(openAPI, requestBodyReference); + assertTrue(referencedRequestBody.getRequired()); } @Test diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java index 9dbe5a227817..b5e26401d2f3 100644 --- a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java @@ -26,12 +26,12 @@ public class AnotherFakeApiTest { /** * To test special tags * - * To test special tags + * To test special tags and operation ID starting with number */ @Test - public void testSpecialTagsTest() { - Client client = null; - // Client response = api.testSpecialTags(client); + public void call123testSpecialTagsTest() { + Client body = null; + // Client response = api.call123testSpecialTags(body); // TODO: test validations } diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeApiTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeApiTest.java index bbb4a9bbc854..f454452f462e 100644 --- a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeApiTest.java @@ -51,8 +51,8 @@ public class FakeApiTest { */ @Test public void fakeOuterCompositeSerializeTest() { - OuterComposite outerComposite = null; - // OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite); + OuterComposite body = null; + // OuterComposite response = api.fakeOuterCompositeSerialize(body); // TODO: test validations } @@ -93,8 +93,8 @@ public class FakeApiTest { */ @Test public void testBodyWithFileSchemaTest() { - FileSchemaTestClass fileSchemaTestClass = null; - // api.testBodyWithFileSchema(fileSchemaTestClass); + FileSchemaTestClass body = null; + // api.testBodyWithFileSchema(body); // TODO: test validations } @@ -108,8 +108,8 @@ public class FakeApiTest { @Test public void testBodyWithQueryParamsTest() { String query = null; - User user = null; - // api.testBodyWithQueryParams(query, user); + User body = null; + // api.testBodyWithQueryParams(query, body); // TODO: test validations } @@ -124,10 +124,10 @@ public class FakeApiTest { */ @Test public void testBodyWithQueryParamsTestQueryMap() { - User user = null; + User body = null; FakeApi.TestBodyWithQueryParamsQueryParams queryParams = new FakeApi.TestBodyWithQueryParamsQueryParams() .query(null); - // api.testBodyWithQueryParams(user, queryParams); + // api.testBodyWithQueryParams(body, queryParams); // TODO: test validations } @@ -139,8 +139,8 @@ public class FakeApiTest { */ @Test public void testClientModelTest() { - Client client = null; - // Client response = api.testClientModel(client); + Client body = null; + // Client response = api.testClientModel(body); // TODO: test validations } @@ -264,8 +264,8 @@ public class FakeApiTest { */ @Test public void testInlineAdditionalPropertiesTest() { - Map requestBody = null; - // api.testInlineAdditionalProperties(requestBody); + Map param = null; + // api.testInlineAdditionalProperties(param); // TODO: test validations } diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java index 192ca5e1e30d..badb867ce81f 100644 --- a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java @@ -30,8 +30,8 @@ public class FakeClassnameTags123ApiTest { */ @Test public void testClassnameTest() { - Client client = null; - // Client response = api.testClassname(client); + Client body = null; + // Client response = api.testClassname(body); // TODO: test validations } diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/PetApiTest.java index a22f839b0db7..b42adee44e75 100644 --- a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/PetApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -32,8 +32,8 @@ public class PetApiTest { */ @Test public void addPetTest() { - Pet pet = null; - // api.addPet(pet); + Pet body = null; + // api.addPet(body); // TODO: test validations } @@ -135,8 +135,8 @@ public class PetApiTest { */ @Test public void updatePetTest() { - Pet pet = null; - // api.updatePet(pet); + Pet body = null; + // api.updatePet(body); // TODO: test validations } @@ -174,4 +174,20 @@ public class PetApiTest { } + /** + * uploads an image (required) + * + * + */ + @Test + public void uploadFileWithRequiredFileTest() { + Long petId = null; + File requiredFile = null; + String additionalMetadata = null; + // ModelApiResponse response = api.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); + + // TODO: test validations + } + + } diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/StoreApiTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/StoreApiTest.java index bdb0b7a1e096..07a48ec6e63c 100644 --- a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/StoreApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/StoreApiTest.java @@ -71,8 +71,8 @@ public class StoreApiTest { */ @Test public void placeOrderTest() { - Order order = null; - // Order response = api.placeOrder(order); + Order body = null; + // Order response = api.placeOrder(body); // TODO: test validations } diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/UserApiTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/UserApiTest.java index c1d841f1e8a4..2656fb4cc920 100644 --- a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/UserApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/api/UserApiTest.java @@ -30,8 +30,8 @@ public class UserApiTest { */ @Test public void createUserTest() { - User user = null; - // api.createUser(user); + User body = null; + // api.createUser(body); // TODO: test validations } @@ -44,8 +44,8 @@ public class UserApiTest { */ @Test public void createUsersWithArrayInputTest() { - List user = null; - // api.createUsersWithArrayInput(user); + List body = null; + // api.createUsersWithArrayInput(body); // TODO: test validations } @@ -58,8 +58,8 @@ public class UserApiTest { */ @Test public void createUsersWithListInputTest() { - List user = null; - // api.createUsersWithListInput(user); + List body = null; + // api.createUsersWithListInput(body); // TODO: test validations } @@ -146,8 +146,8 @@ public class UserApiTest { @Test public void updateUserTest() { String username = null; - User user = null; - // api.updateUser(username, user); + User body = null; + // api.updateUser(username, body); // TODO: test validations } diff --git a/samples/openapi3/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar b/samples/openapi3/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..1948b9074f10 Binary files /dev/null and b/samples/openapi3/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/openapi3/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties b/samples/openapi3/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..687a59667027 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/openapi3/client/petstore/kotlin/gradlew b/samples/openapi3/client/petstore/kotlin/gradlew new file mode 100755 index 000000000000..cccdd3d517fc --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; + 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" + which java >/dev/null 2>&1 || 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 + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/samples/openapi3/client/petstore/kotlin/gradlew.bat b/samples/openapi3/client/petstore/kotlin/gradlew.bat new file mode 100644 index 000000000000..e95643d6a2ca --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/gradlew.bat @@ -0,0 +1,84 @@ +@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=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +: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 %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="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! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/server/openapi3/petstore/kotlin-springboot/.openapi-generator/VERSION b/samples/server/openapi3/petstore/kotlin-springboot/.openapi-generator/VERSION index 6d94c9c2e12a..afa636560641 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/.openapi-generator/VERSION +++ b/samples/server/openapi3/petstore/kotlin-springboot/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.0-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApi.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApi.kt new file mode 100644 index 000000000000..4ca16d903e4f --- /dev/null +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApi.kt @@ -0,0 +1,46 @@ +package org.openapitools.api + +import org.openapitools.model.SysMailFormData +import io.swagger.annotations.* +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.stereotype.Controller +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestPart +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestHeader +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.web.multipart.MultipartFile +import org.springframework.beans.factory.annotation.Autowired + +import javax.validation.Valid +import javax.validation.constraints.* + +import kotlin.collections.List +import kotlin.collections.Map + +@Controller +@Validated +@Api(value = "Default", description = "The Default API") +@RequestMapping("\${api.base-path:/v2}") +class DefaultApiController(@Autowired(required = true) val service: DefaultApiService) { + + @ApiOperation( + value = "", + nickname = "updateSysMailAtKey", + notes = "Update SysMail template") + @ApiResponses( + value = [ApiResponse(code = 200, message = "OK")]) + @RequestMapping( + value = ["/sysmails/{key}"], + consumes = ["application/json"], + method = [RequestMethod.PUT]) + fun updateSysMailAtKey(@ApiParam(value = "", required=true, defaultValue="null") @PathVariable("key") key: String,@ApiParam(value = "" ,required=true ) @Valid @RequestBody sysMailFormData: SysMailFormData): ResponseEntity { + return ResponseEntity(service.updateSysMailAtKey(key, sysMailFormData), HttpStatus.OK) + } +} diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApiService.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApiService.kt new file mode 100644 index 000000000000..3fe465cfcb07 --- /dev/null +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApiService.kt @@ -0,0 +1,8 @@ +package org.openapitools.api + +import org.openapitools.model.SysMailFormData + +interface DefaultApiService { + + fun updateSysMailAtKey(key: String,sysMailFormData: SysMailFormData): Unit +} diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApiServiceImpl.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApiServiceImpl.kt new file mode 100644 index 000000000000..a8dffc147772 --- /dev/null +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/DefaultApiServiceImpl.kt @@ -0,0 +1,12 @@ +package org.openapitools.api + +import org.openapitools.model.SysMailFormData +import org.springframework.stereotype.Service + +@Service +class DefaultApiServiceImpl : DefaultApiService { + + override fun updateSysMailAtKey(key: String,sysMailFormData: SysMailFormData): Unit { + TODO("Implement me") + } +} diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt index 17b87c74fdfb..0a3515cb1ca6 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -56,7 +56,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { @RequestMapping( value = ["/pet/{petId}"], method = [RequestMethod.DELETE]) - fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: String?): ResponseEntity { + fun deletePet(@ApiParam(value = "Pet id to delete", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "" , defaultValue="null") @RequestHeader(value="api_key", required=false) apiKey: String): ResponseEntity { return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK) } @@ -73,7 +73,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/findByStatus"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: List): ResponseEntity> { + fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold", defaultValue = "null") @Valid @RequestParam(value = "status", required = true, defaultValue="null") status: List): ResponseEntity> { return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK) } @@ -90,7 +90,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/findByTags"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: List): ResponseEntity> { + fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true, defaultValue = "null") @Valid @RequestParam(value = "tags", required = true, defaultValue="null") tags: List): ResponseEntity> { return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK) } @@ -106,7 +106,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/{petId}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: Long): ResponseEntity { + fun getPetById(@ApiParam(value = "ID of pet to return", required=true, defaultValue="null") @PathVariable("petId") petId: Long): ResponseEntity { return ResponseEntity(service.getPetById(petId), HttpStatus.OK) } @@ -136,7 +136,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/{petId}"], consumes = ["application/x-www-form-urlencoded"], method = [RequestMethod.POST]) - fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity { + fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity { return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK) } @@ -153,7 +153,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { produces = ["application/json"], consumes = ["multipart/form-data"], method = [RequestMethod.POST]) - fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity { + fun uploadFile(@ApiParam(value = "ID of pet to update", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity { return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK) } } diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt index b31d96e91b73..c2e81c4c66b6 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt @@ -7,7 +7,7 @@ interface PetApiService { fun addPet(pet: Pet): Unit - fun deletePet(petId: Long,apiKey: String?): Unit + fun deletePet(petId: Long,apiKey: String): Unit fun findPetsByStatus(status: List): List diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt index 80b7d6e8fe1c..86ae8e063208 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt @@ -11,7 +11,7 @@ class PetApiServiceImpl : PetApiService { TODO("Implement me") } - override fun deletePet(petId: Long,apiKey: String?): Unit { + override fun deletePet(petId: Long,apiKey: String): Unit { TODO("Implement me") } diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt index f277e8089065..6931bd2500c7 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -39,7 +39,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic @RequestMapping( value = ["/store/order/{orderId}"], method = [RequestMethod.DELETE]) - fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: String): ResponseEntity { + fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true, defaultValue="null") @PathVariable("orderId") orderId: String): ResponseEntity { return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK) } @@ -71,7 +71,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = ["/store/order/{orderId}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: Long): ResponseEntity { + fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true, defaultValue="null") @PathVariable("orderId") orderId: Long): ResponseEntity { return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK) } diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt index 6822bccecafa..aff695572ada 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -81,7 +81,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/{username}"], method = [RequestMethod.DELETE]) - fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: String): ResponseEntity { + fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity { return ResponseEntity(service.deleteUser(username), HttpStatus.OK) } @@ -96,7 +96,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = ["/user/{username}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true) @PathVariable("username") username: String): ResponseEntity { + fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity { return ResponseEntity(service.getUserByName(username), HttpStatus.OK) } @@ -111,7 +111,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = ["/user/login"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: String): ResponseEntity { + fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String): ResponseEntity { return ResponseEntity(service.loginUser(username, password), HttpStatus.OK) } @@ -138,7 +138,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = ["/user/{username}"], consumes = ["application/json"], method = [RequestMethod.PUT]) - fun updateUser(@ApiParam(value = "name that need to be deleted", required=true) @PathVariable("username") username: String,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody user: User): ResponseEntity { + fun updateUser(@ApiParam(value = "name that need to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody user: User): ResponseEntity { return ResponseEntity(service.updateUser(username, user), HttpStatus.OK) } } diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt index da259e87b8e5..c34cec48df16 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt @@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty */ data class Category ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") val name: String? = null ) { diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Body.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/InlineObject.kt similarity index 70% rename from samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Body.kt rename to samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/InlineObject.kt index df03586b3835..3a1526a0db77 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Body.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/InlineObject.kt @@ -11,12 +11,12 @@ import io.swagger.annotations.ApiModelProperty * @param name Updated name of the pet * @param status Updated status of the pet */ -data class Body ( +data class InlineObject ( - @ApiModelProperty(value = "Updated name of the pet") + @ApiModelProperty(example = "null", value = "Updated name of the pet") @JsonProperty("name") val name: String? = null, - @ApiModelProperty(value = "Updated status of the pet") + @ApiModelProperty(example = "null", value = "Updated status of the pet") @JsonProperty("status") val status: String? = null ) { diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Body1.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/InlineObject1.kt similarity index 72% rename from samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Body1.kt rename to samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/InlineObject1.kt index 1e95e248d1cb..4600798bc9a1 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Body1.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/InlineObject1.kt @@ -11,12 +11,12 @@ import io.swagger.annotations.ApiModelProperty * @param additionalMetadata Additional data to pass to server * @param file file to upload */ -data class Body1 ( +data class InlineObject1 ( - @ApiModelProperty(value = "Additional data to pass to server") + @ApiModelProperty(example = "null", value = "Additional data to pass to server") @JsonProperty("additionalMetadata") val additionalMetadata: String? = null, - @ApiModelProperty(value = "file to upload") + @ApiModelProperty(example = "null", value = "file to upload") @JsonProperty("file") val file: java.io.File? = null ) { diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index e933f2436a43..17697fdfe8d4 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -14,13 +14,13 @@ import io.swagger.annotations.ApiModelProperty */ data class ModelApiResponse ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("code") val code: Int? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("type") val type: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("message") val message: String? = null ) { diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt index e1065f56bd32..be8e2f33fb37 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt @@ -18,22 +18,22 @@ import io.swagger.annotations.ApiModelProperty */ data class Order ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("petId") val petId: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("quantity") val quantity: Int? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, - @ApiModelProperty(value = "Order Status") + @ApiModelProperty(example = "null", value = "Order Status") @JsonProperty("status") val status: Order.Status? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("complete") val complete: Boolean? = null ) { diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt index 967bd0846b6e..80af728b7e49 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt @@ -25,19 +25,19 @@ data class Pet ( @JsonProperty("name") val name: String, @get:NotNull - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("photoUrls") val photoUrls: List, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("category") val category: Category? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("tags") val tags: List? = null, - @ApiModelProperty(value = "pet status in the store") + @ApiModelProperty(example = "null", value = "pet status in the store") @JsonProperty("status") val status: Pet.Status? = null ) { diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/SysMailFormData.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/SysMailFormData.kt new file mode 100644 index 000000000000..456a5ac13c3f --- /dev/null +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/SysMailFormData.kt @@ -0,0 +1,24 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.* +import io.swagger.annotations.ApiModelProperty + +/** + * Data to update a SysMail template. + * @param subject + * @param body + */ +data class SysMailFormData ( + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("subject") val subject: String? = null, + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("body") val body: String? = null +) { + +} + diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt index e40833c55fd0..70c706d00a6e 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt @@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty */ data class Tag ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") val name: String? = null ) { diff --git a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt index b9cc2886ea09..4cfaf0988746 100644 --- a/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/openapi3/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt @@ -19,28 +19,28 @@ import io.swagger.annotations.ApiModelProperty */ data class User ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("username") val username: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("firstName") val firstName: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("lastName") val lastName: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("email") val email: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("password") val password: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("phone") val phone: String? = null, - @ApiModelProperty(value = "User Status") + @ApiModelProperty(example = "null", value = "User Status") @JsonProperty("userStatus") val userStatus: Int? = null ) { diff --git a/samples/server/petstore/rust-server/output/rust-server-test/api/openapi.yaml b/samples/server/petstore/rust-server/output/rust-server-test/api/openapi.yaml index ed356b28eb0a..b2b215809d00 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/api/openapi.yaml +++ b/samples/server/petstore/rust-server/output/rust-server-test/api/openapi.yaml @@ -91,6 +91,7 @@ components: '*/*': schema: $ref: '#/components/schemas/inline_object' + required: true schemas: additionalPropertiesObject: additionalProperties: diff --git a/samples/server/petstore/rust-server/output/rust-server-test/examples/client.rs b/samples/server/petstore/rust-server/output/rust-server-test/examples/client.rs index 54377a219dc1..d43e0fea7f93 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/examples/client.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/examples/client.rs @@ -33,7 +33,6 @@ fn main() { .help("Sets the operation to run") .possible_values(&[ "DummyGet", - "DummyPut", "FileResponseGet", "HtmlPost", "RawJsonGet", @@ -82,10 +81,11 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); }, - Some("DummyPut") => { - let result = core.run(client.dummy_put(None)); - println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); - }, + // Disabled because there's no example. + // Some("DummyPut") => { + // let result = core.run(client.dummy_put(???)); + // println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); + // }, Some("FileResponseGet") => { let result = core.run(client.file_response_get()); diff --git a/samples/server/petstore/rust-server/output/rust-server-test/examples/server_lib/server.rs b/samples/server/petstore/rust-server/output/rust-server-test/examples/server_lib/server.rs index b9c7cfba79fc..38aa0d05c4e0 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/examples/server_lib/server.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/examples/server_lib/server.rs @@ -40,7 +40,7 @@ impl Api for Server where C: Has{ } - fn dummy_put(&self, nested_response: Option, context: &C) -> Box> { + fn dummy_put(&self, nested_response: models::InlineObject, context: &C) -> Box> { let context = context.clone(); println!("dummy_put({:?}) - X-Span-ID: {:?}", nested_response, context.get().0.clone()); Box::new(futures::failed("Generic failure".into())) diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs index c9c1c1169b88..5e3ae082ccf0 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs @@ -306,7 +306,7 @@ impl Api for Client where } - fn dummy_put(&self, param_nested_response: Option, context: &C) -> Box> { + fn dummy_put(&self, param_nested_response: models::InlineObject, context: &C) -> Box> { let uri = format!( @@ -321,14 +321,12 @@ impl Api for Client where let mut request = hyper::Request::new(hyper::Method::Put, uri); - let body = param_nested_response.map(|ref body| { - serde_json::to_string(body).expect("impossible to fail to serialize") - }); + let body = serde_json::to_string(¶m_nested_response).expect("impossible to fail to serialize"); + + + request.set_body(body.into_bytes()); -if let Some(body) = body { - request.set_body(body.into_bytes()); - } request.headers_mut().set(ContentType(mimetypes::requests::DUMMY_PUT.clone())); request.headers_mut().set(XSpanId((context as &Has).get().0.clone())); diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs index efae712e4ccb..5f9e44062b09 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs @@ -77,7 +77,7 @@ pub trait Api { fn dummy_get(&self, context: &C) -> Box>; - fn dummy_put(&self, nested_response: Option, context: &C) -> Box>; + fn dummy_put(&self, nested_response: models::InlineObject, context: &C) -> Box>; /// Get a file fn file_response_get(&self, context: &C) -> Box>; @@ -97,7 +97,7 @@ pub trait ApiNoContext { fn dummy_get(&self) -> Box>; - fn dummy_put(&self, nested_response: Option) -> Box>; + fn dummy_put(&self, nested_response: models::InlineObject) -> Box>; /// Get a file fn file_response_get(&self) -> Box>; @@ -130,7 +130,7 @@ impl<'a, T: Api, C> ApiNoContext for ContextWrapper<'a, T, C> { } - fn dummy_put(&self, nested_response: Option) -> Box> { + fn dummy_put(&self, nested_response: models::InlineObject) -> Box> { self.api().dummy_put(nested_response, &self.context()) } diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs index a889c6b85d04..3a9ba4b43c97 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs @@ -202,13 +202,16 @@ where unused_elements.push(path.to_string()); }) { Ok(param_nested_response) => param_nested_response, - - Err(_) => None, + Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse body parameter nested_response - doesn't match schema: {}", e)))), } } else { None }; + let param_nested_response = match param_nested_response { + Some(param_nested_response) => param_nested_response, + None => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body("Missing required body parameter nested_response"))), + }; Box::new(api_impl.dummy_put(param_nested_response, &context)