Fix missing RequestBody.required of inline request body (#1847)

* Add test case that reproduce the issue #1782

* Fix missing RequestBody.required

* Update samples

./bin/utils/ensure-up-to-date

* Run ensure-up-to-date script

./bin/utils/ensure-up-to-date
This commit is contained in:
Akihito Nakano
2019-01-14 13:28:21 +09:00
committed by William Cheng
parent 1be9d66911
commit 7674d11d75
36 changed files with 470 additions and 97 deletions

View File

@@ -106,6 +106,7 @@ public class InlineModelResolver {
// create request body // create request body
RequestBody rb = new RequestBody(); RequestBody rb = new RequestBody();
rb.setRequired(requestBody.getRequired());
Content content = new Content(); Content content = new Content();
MediaType mt = new MediaType(); MediaType mt = new MediaType();
Schema schema = new Schema(); Schema schema = new Schema();

View File

@@ -328,6 +328,9 @@ public class InlineModelResolverTest {
RequestBody requestBodyReference = openAPI.getPaths().get("/resolve_inline_request_body_with_required").getPost().getRequestBody(); RequestBody requestBodyReference = openAPI.getPaths().get("/resolve_inline_request_body_with_required").getPost().getRequestBody();
assertTrue(requestBodyReference.getRequired()); assertTrue(requestBodyReference.getRequired());
RequestBody referencedRequestBody = ModelUtils.getReferencedRequestBody(openAPI, requestBodyReference);
assertTrue(referencedRequestBody.getRequired());
} }
@Test @Test

View File

@@ -26,12 +26,12 @@ public class AnotherFakeApiTest {
/** /**
* To test special tags * To test special tags
* *
* To test special tags * To test special tags and operation ID starting with number
*/ */
@Test @Test
public void testSpecialTagsTest() { public void call123testSpecialTagsTest() {
Client client = null; Client body = null;
// Client response = api.testSpecialTags(client); // Client response = api.call123testSpecialTags(body);
// TODO: test validations // TODO: test validations
} }

View File

@@ -51,8 +51,8 @@ public class FakeApiTest {
*/ */
@Test @Test
public void fakeOuterCompositeSerializeTest() { public void fakeOuterCompositeSerializeTest() {
OuterComposite outerComposite = null; OuterComposite body = null;
// OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite); // OuterComposite response = api.fakeOuterCompositeSerialize(body);
// TODO: test validations // TODO: test validations
} }
@@ -93,8 +93,8 @@ public class FakeApiTest {
*/ */
@Test @Test
public void testBodyWithFileSchemaTest() { public void testBodyWithFileSchemaTest() {
FileSchemaTestClass fileSchemaTestClass = null; FileSchemaTestClass body = null;
// api.testBodyWithFileSchema(fileSchemaTestClass); // api.testBodyWithFileSchema(body);
// TODO: test validations // TODO: test validations
} }
@@ -108,8 +108,8 @@ public class FakeApiTest {
@Test @Test
public void testBodyWithQueryParamsTest() { public void testBodyWithQueryParamsTest() {
String query = null; String query = null;
User user = null; User body = null;
// api.testBodyWithQueryParams(query, user); // api.testBodyWithQueryParams(query, body);
// TODO: test validations // TODO: test validations
} }
@@ -124,10 +124,10 @@ public class FakeApiTest {
*/ */
@Test @Test
public void testBodyWithQueryParamsTestQueryMap() { public void testBodyWithQueryParamsTestQueryMap() {
User user = null; User body = null;
FakeApi.TestBodyWithQueryParamsQueryParams queryParams = new FakeApi.TestBodyWithQueryParamsQueryParams() FakeApi.TestBodyWithQueryParamsQueryParams queryParams = new FakeApi.TestBodyWithQueryParamsQueryParams()
.query(null); .query(null);
// api.testBodyWithQueryParams(user, queryParams); // api.testBodyWithQueryParams(body, queryParams);
// TODO: test validations // TODO: test validations
} }
@@ -139,8 +139,8 @@ public class FakeApiTest {
*/ */
@Test @Test
public void testClientModelTest() { public void testClientModelTest() {
Client client = null; Client body = null;
// Client response = api.testClientModel(client); // Client response = api.testClientModel(body);
// TODO: test validations // TODO: test validations
} }
@@ -264,8 +264,8 @@ public class FakeApiTest {
*/ */
@Test @Test
public void testInlineAdditionalPropertiesTest() { public void testInlineAdditionalPropertiesTest() {
Map<String, String> requestBody = null; Map<String, String> param = null;
// api.testInlineAdditionalProperties(requestBody); // api.testInlineAdditionalProperties(param);
// TODO: test validations // TODO: test validations
} }

View File

@@ -30,8 +30,8 @@ public class FakeClassnameTags123ApiTest {
*/ */
@Test @Test
public void testClassnameTest() { public void testClassnameTest() {
Client client = null; Client body = null;
// Client response = api.testClassname(client); // Client response = api.testClassname(body);
// TODO: test validations // TODO: test validations
} }

View File

@@ -32,8 +32,8 @@ public class PetApiTest {
*/ */
@Test @Test
public void addPetTest() { public void addPetTest() {
Pet pet = null; Pet body = null;
// api.addPet(pet); // api.addPet(body);
// TODO: test validations // TODO: test validations
} }
@@ -135,8 +135,8 @@ public class PetApiTest {
*/ */
@Test @Test
public void updatePetTest() { public void updatePetTest() {
Pet pet = null; Pet body = null;
// api.updatePet(pet); // api.updatePet(body);
// TODO: test validations // 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
}
} }

View File

@@ -71,8 +71,8 @@ public class StoreApiTest {
*/ */
@Test @Test
public void placeOrderTest() { public void placeOrderTest() {
Order order = null; Order body = null;
// Order response = api.placeOrder(order); // Order response = api.placeOrder(body);
// TODO: test validations // TODO: test validations
} }

View File

@@ -30,8 +30,8 @@ public class UserApiTest {
*/ */
@Test @Test
public void createUserTest() { public void createUserTest() {
User user = null; User body = null;
// api.createUser(user); // api.createUser(body);
// TODO: test validations // TODO: test validations
} }
@@ -44,8 +44,8 @@ public class UserApiTest {
*/ */
@Test @Test
public void createUsersWithArrayInputTest() { public void createUsersWithArrayInputTest() {
List<User> user = null; List<User> body = null;
// api.createUsersWithArrayInput(user); // api.createUsersWithArrayInput(body);
// TODO: test validations // TODO: test validations
} }
@@ -58,8 +58,8 @@ public class UserApiTest {
*/ */
@Test @Test
public void createUsersWithListInputTest() { public void createUsersWithListInputTest() {
List<User> user = null; List<User> body = null;
// api.createUsersWithListInput(user); // api.createUsersWithListInput(body);
// TODO: test validations // TODO: test validations
} }
@@ -146,8 +146,8 @@ public class UserApiTest {
@Test @Test
public void updateUserTest() { public void updateUserTest() {
String username = null; String username = null;
User user = null; User body = null;
// api.updateUser(username, user); // api.updateUser(username, body);
// TODO: test validations // TODO: test validations
} }

View File

@@ -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

View File

@@ -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" "$@"

View File

@@ -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

View File

@@ -1 +1 @@
3.3.0-SNAPSHOT 4.0.0-SNAPSHOT

View File

@@ -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<Unit> {
return ResponseEntity(service.updateSysMailAtKey(key, sysMailFormData), HttpStatus.OK)
}
}

View File

@@ -0,0 +1,8 @@
package org.openapitools.api
import org.openapitools.model.SysMailFormData
interface DefaultApiService {
fun updateSysMailAtKey(key: String,sysMailFormData: SysMailFormData): Unit
}

View File

@@ -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")
}
}

View File

@@ -56,7 +56,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
@RequestMapping( @RequestMapping(
value = ["/pet/{petId}"], value = ["/pet/{petId}"],
method = [RequestMethod.DELETE]) 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<Unit> { 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<Unit> {
return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK) return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK)
} }
@@ -73,7 +73,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/findByStatus"], value = ["/pet/findByStatus"],
produces = ["application/xml", "application/json"], produces = ["application/xml", "application/json"],
method = [RequestMethod.GET]) 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<String>): ResponseEntity<List<Pet>> { 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<String>): ResponseEntity<List<Pet>> {
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK) return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK)
} }
@@ -90,7 +90,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/findByTags"], value = ["/pet/findByTags"],
produces = ["application/xml", "application/json"], produces = ["application/xml", "application/json"],
method = [RequestMethod.GET]) method = [RequestMethod.GET])
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: List<String>): ResponseEntity<List<Pet>> { fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true, defaultValue = "null") @Valid @RequestParam(value = "tags", required = true, defaultValue="null") tags: List<String>): ResponseEntity<List<Pet>> {
return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK) return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK)
} }
@@ -106,7 +106,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/{petId}"], value = ["/pet/{petId}"],
produces = ["application/xml", "application/json"], produces = ["application/xml", "application/json"],
method = [RequestMethod.GET]) method = [RequestMethod.GET])
fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: Long): ResponseEntity<Pet> { fun getPetById(@ApiParam(value = "ID of pet to return", required=true, defaultValue="null") @PathVariable("petId") petId: Long): ResponseEntity<Pet> {
return ResponseEntity(service.getPetById(petId), HttpStatus.OK) return ResponseEntity(service.getPetById(petId), HttpStatus.OK)
} }
@@ -136,7 +136,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/{petId}"], value = ["/pet/{petId}"],
consumes = ["application/x-www-form-urlencoded"], consumes = ["application/x-www-form-urlencoded"],
method = [RequestMethod.POST]) 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<Unit> { 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<Unit> {
return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK) return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK)
} }
@@ -153,7 +153,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
produces = ["application/json"], produces = ["application/json"],
consumes = ["multipart/form-data"], consumes = ["multipart/form-data"],
method = [RequestMethod.POST]) 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<ModelApiResponse> { 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<ModelApiResponse> {
return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK) return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK)
} }
} }

View File

@@ -7,7 +7,7 @@ interface PetApiService {
fun addPet(pet: Pet): Unit fun addPet(pet: Pet): Unit
fun deletePet(petId: Long,apiKey: String?): Unit fun deletePet(petId: Long,apiKey: String): Unit
fun findPetsByStatus(status: List<String>): List<Pet> fun findPetsByStatus(status: List<String>): List<Pet>

View File

@@ -11,7 +11,7 @@ class PetApiServiceImpl : PetApiService {
TODO("Implement me") TODO("Implement me")
} }
override fun deletePet(petId: Long,apiKey: String?): Unit { override fun deletePet(petId: Long,apiKey: String): Unit {
TODO("Implement me") TODO("Implement me")
} }

View File

@@ -39,7 +39,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
@RequestMapping( @RequestMapping(
value = ["/store/order/{orderId}"], value = ["/store/order/{orderId}"],
method = [RequestMethod.DELETE]) method = [RequestMethod.DELETE])
fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: String): ResponseEntity<Unit> { fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true, defaultValue="null") @PathVariable("orderId") orderId: String): ResponseEntity<Unit> {
return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK) return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK)
} }
@@ -71,7 +71,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
value = ["/store/order/{orderId}"], value = ["/store/order/{orderId}"],
produces = ["application/xml", "application/json"], produces = ["application/xml", "application/json"],
method = [RequestMethod.GET]) 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<Order> { 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<Order> {
return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK) return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK)
} }

View File

@@ -81,7 +81,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@RequestMapping( @RequestMapping(
value = ["/user/{username}"], value = ["/user/{username}"],
method = [RequestMethod.DELETE]) method = [RequestMethod.DELETE])
fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: String): ResponseEntity<Unit> { fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity<Unit> {
return ResponseEntity(service.deleteUser(username), HttpStatus.OK) return ResponseEntity(service.deleteUser(username), HttpStatus.OK)
} }
@@ -96,7 +96,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
value = ["/user/{username}"], value = ["/user/{username}"],
produces = ["application/xml", "application/json"], produces = ["application/xml", "application/json"],
method = [RequestMethod.GET]) 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<User> { fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity<User> {
return ResponseEntity(service.getUserByName(username), HttpStatus.OK) return ResponseEntity(service.getUserByName(username), HttpStatus.OK)
} }
@@ -111,7 +111,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
value = ["/user/login"], value = ["/user/login"],
produces = ["application/xml", "application/json"], produces = ["application/xml", "application/json"],
method = [RequestMethod.GET]) 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<String> { 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<String> {
return ResponseEntity(service.loginUser(username, password), HttpStatus.OK) return ResponseEntity(service.loginUser(username, password), HttpStatus.OK)
} }
@@ -138,7 +138,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
value = ["/user/{username}"], value = ["/user/{username}"],
consumes = ["application/json"], consumes = ["application/json"],
method = [RequestMethod.PUT]) 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<Unit> { 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<Unit> {
return ResponseEntity(service.updateUser(username, user), HttpStatus.OK) return ResponseEntity(service.updateUser(username, user), HttpStatus.OK)
} }
} }

View File

@@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty
*/ */
data class Category ( data class Category (
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null, @JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("name") val name: String? = null @JsonProperty("name") val name: String? = null
) { ) {

View File

@@ -11,12 +11,12 @@ import io.swagger.annotations.ApiModelProperty
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status 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, @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 @JsonProperty("status") val status: String? = null
) { ) {

View File

@@ -11,12 +11,12 @@ import io.swagger.annotations.ApiModelProperty
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @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, @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 @JsonProperty("file") val file: java.io.File? = null
) { ) {

View File

@@ -14,13 +14,13 @@ import io.swagger.annotations.ApiModelProperty
*/ */
data class ModelApiResponse ( data class ModelApiResponse (
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("code") val code: Int? = null, @JsonProperty("code") val code: Int? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("type") val type: String? = null, @JsonProperty("type") val type: String? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("message") val message: String? = null @JsonProperty("message") val message: String? = null
) { ) {

View File

@@ -18,22 +18,22 @@ import io.swagger.annotations.ApiModelProperty
*/ */
data class Order ( data class Order (
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null, @JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("petId") val petId: Long? = null, @JsonProperty("petId") val petId: Long? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("quantity") val quantity: Int? = null, @JsonProperty("quantity") val quantity: Int? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @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, @JsonProperty("status") val status: Order.Status? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("complete") val complete: Boolean? = null @JsonProperty("complete") val complete: Boolean? = null
) { ) {

View File

@@ -25,19 +25,19 @@ data class Pet (
@JsonProperty("name") val name: String, @JsonProperty("name") val name: String,
@get:NotNull @get:NotNull
@ApiModelProperty(required = true, value = "") @ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls") val photoUrls: List<String>, @JsonProperty("photoUrls") val photoUrls: List<String>,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null, @JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("category") val category: Category? = null, @JsonProperty("category") val category: Category? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("tags") val tags: List<Tag>? = null, @JsonProperty("tags") val tags: List<Tag>? = null,
@ApiModelProperty(value = "pet status in the store") @ApiModelProperty(example = "null", value = "pet status in the store")
@JsonProperty("status") val status: Pet.Status? = null @JsonProperty("status") val status: Pet.Status? = null
) { ) {

View File

@@ -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
) {
}

View File

@@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty
*/ */
data class Tag ( data class Tag (
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null, @JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("name") val name: String? = null @JsonProperty("name") val name: String? = null
) { ) {

View File

@@ -19,28 +19,28 @@ import io.swagger.annotations.ApiModelProperty
*/ */
data class User ( data class User (
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null, @JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("username") val username: String? = null, @JsonProperty("username") val username: String? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("firstName") val firstName: String? = null, @JsonProperty("firstName") val firstName: String? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("lastName") val lastName: String? = null, @JsonProperty("lastName") val lastName: String? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("email") val email: String? = null, @JsonProperty("email") val email: String? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("password") val password: String? = null, @JsonProperty("password") val password: String? = null,
@ApiModelProperty(value = "") @ApiModelProperty(example = "null", value = "")
@JsonProperty("phone") val phone: String? = null, @JsonProperty("phone") val phone: String? = null,
@ApiModelProperty(value = "User Status") @ApiModelProperty(example = "null", value = "User Status")
@JsonProperty("userStatus") val userStatus: Int? = null @JsonProperty("userStatus") val userStatus: Int? = null
) { ) {

View File

@@ -91,6 +91,7 @@ components:
'*/*': '*/*':
schema: schema:
$ref: '#/components/schemas/inline_object' $ref: '#/components/schemas/inline_object'
required: true
schemas: schemas:
additionalPropertiesObject: additionalPropertiesObject:
additionalProperties: additionalProperties:

View File

@@ -33,7 +33,6 @@ fn main() {
.help("Sets the operation to run") .help("Sets the operation to run")
.possible_values(&[ .possible_values(&[
"DummyGet", "DummyGet",
"DummyPut",
"FileResponseGet", "FileResponseGet",
"HtmlPost", "HtmlPost",
"RawJsonGet", "RawJsonGet",
@@ -82,10 +81,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone()); println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone());
}, },
Some("DummyPut") => { // Disabled because there's no example.
let result = core.run(client.dummy_put(None)); // Some("DummyPut") => {
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone()); // let result = core.run(client.dummy_put(???));
}, // println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone());
// },
Some("FileResponseGet") => { Some("FileResponseGet") => {
let result = core.run(client.file_response_get()); let result = core.run(client.file_response_get());

View File

@@ -40,7 +40,7 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
} }
fn dummy_put(&self, nested_response: Option<models::InlineObject>, context: &C) -> Box<Future<Item=DummyPutResponse, Error=ApiError>> { fn dummy_put(&self, nested_response: models::InlineObject, context: &C) -> Box<Future<Item=DummyPutResponse, Error=ApiError>> {
let context = context.clone(); let context = context.clone();
println!("dummy_put({:?}) - X-Span-ID: {:?}", nested_response, context.get().0.clone()); println!("dummy_put({:?}) - X-Span-ID: {:?}", nested_response, context.get().0.clone());
Box::new(futures::failed("Generic failure".into())) Box::new(futures::failed("Generic failure".into()))

View File

@@ -306,7 +306,7 @@ impl<F, C> Api<C> for Client<F> where
} }
fn dummy_put(&self, param_nested_response: Option<models::InlineObject>, context: &C) -> Box<Future<Item=DummyPutResponse, Error=ApiError>> { fn dummy_put(&self, param_nested_response: models::InlineObject, context: &C) -> Box<Future<Item=DummyPutResponse, Error=ApiError>> {
let uri = format!( let uri = format!(
@@ -321,14 +321,12 @@ impl<F, C> Api<C> for Client<F> where
let mut request = hyper::Request::new(hyper::Method::Put, uri); 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(&param_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(ContentType(mimetypes::requests::DUMMY_PUT.clone()));
request.headers_mut().set(XSpanId((context as &Has<XSpanIdString>).get().0.clone())); request.headers_mut().set(XSpanId((context as &Has<XSpanIdString>).get().0.clone()));

View File

@@ -77,7 +77,7 @@ pub trait Api<C> {
fn dummy_get(&self, context: &C) -> Box<Future<Item=DummyGetResponse, Error=ApiError>>; fn dummy_get(&self, context: &C) -> Box<Future<Item=DummyGetResponse, Error=ApiError>>;
fn dummy_put(&self, nested_response: Option<models::InlineObject>, context: &C) -> Box<Future<Item=DummyPutResponse, Error=ApiError>>; fn dummy_put(&self, nested_response: models::InlineObject, context: &C) -> Box<Future<Item=DummyPutResponse, Error=ApiError>>;
/// Get a file /// Get a file
fn file_response_get(&self, context: &C) -> Box<Future<Item=FileResponseGetResponse, Error=ApiError>>; fn file_response_get(&self, context: &C) -> Box<Future<Item=FileResponseGetResponse, Error=ApiError>>;
@@ -97,7 +97,7 @@ pub trait ApiNoContext {
fn dummy_get(&self) -> Box<Future<Item=DummyGetResponse, Error=ApiError>>; fn dummy_get(&self) -> Box<Future<Item=DummyGetResponse, Error=ApiError>>;
fn dummy_put(&self, nested_response: Option<models::InlineObject>) -> Box<Future<Item=DummyPutResponse, Error=ApiError>>; fn dummy_put(&self, nested_response: models::InlineObject) -> Box<Future<Item=DummyPutResponse, Error=ApiError>>;
/// Get a file /// Get a file
fn file_response_get(&self) -> Box<Future<Item=FileResponseGetResponse, Error=ApiError>>; fn file_response_get(&self) -> Box<Future<Item=FileResponseGetResponse, Error=ApiError>>;
@@ -130,7 +130,7 @@ impl<'a, T: Api<C>, C> ApiNoContext for ContextWrapper<'a, T, C> {
} }
fn dummy_put(&self, nested_response: Option<models::InlineObject>) -> Box<Future<Item=DummyPutResponse, Error=ApiError>> { fn dummy_put(&self, nested_response: models::InlineObject) -> Box<Future<Item=DummyPutResponse, Error=ApiError>> {
self.api().dummy_put(nested_response, &self.context()) self.api().dummy_put(nested_response, &self.context())
} }

View File

@@ -202,13 +202,16 @@ where
unused_elements.push(path.to_string()); unused_elements.push(path.to_string());
}) { }) {
Ok(param_nested_response) => param_nested_response, Ok(param_nested_response) => param_nested_response,
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)))),
Err(_) => None,
} }
} else { } else {
None 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) Box::new(api_impl.dummy_put(param_nested_response, &context)