diff --git a/.gitignore b/.gitignore index 2146898f279..ceacfbcb75e 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ samples/client/petstore/java/default/build/ samples/client/petstore/scala/build/ samples/client/petstore/java/resttemplate/hello.txt samples/client/petstore/java/retrofit2/hello.txt +samples/client/petstore/java/feign/hello.txt #PHP samples/client/petstore/php/SwaggerClient-php/composer.lock diff --git a/README.md b/README.md index 4cc3194646f..a5300452279 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20 Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes -------------------------- | ------------ | -------------------------- | ----- -2.3.0 (upcoming minor release) | Apr/May 2017 | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes -2.2.3 (upcoming patch release) | TBD | 1.0, 1.1, 1.2, 2.0 | Patch release without breaking changes +2.3.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen/2.3.0-SNAPSHOT/)| Jul/Aug 2017 | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes +2.2.3 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen/2.2.3-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0 | Patch release without breaking changes [2.2.2](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.2) (**current stable**) | 2017-03-01 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.2](https://github.com/swagger-api/swagger-codegen/tree/v2.2.2) [2.2.1](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.1) | 2016-08-07 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.1](https://github.com/swagger-api/swagger-codegen/tree/v2.2.1) [2.1.6](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.1.6) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6) diff --git a/bin/spring-all-pestore.sh b/bin/spring-all-pestore.sh index 77d67ec37d7..8424569ce76 100755 --- a/bin/spring-all-pestore.sh +++ b/bin/spring-all-pestore.sh @@ -9,3 +9,4 @@ ./bin/spring-mvc-petstore-server.sh ./bin/springboot-petstore-server-beanvalidation.sh ./bin/springboot-petstore-server-implicitHeaders.sh +./bin/springboot-petstore-server-useOptional.sh diff --git a/bin/springboot-petstore-server-useOptional.json b/bin/springboot-petstore-server-useOptional.json new file mode 100644 index 00000000000..5a0c80d6b9c --- /dev/null +++ b/bin/springboot-petstore-server-useOptional.json @@ -0,0 +1,4 @@ +{ + "artifactId": "spring-boot-useoptional", + "useOptional": true +} diff --git a/bin/springboot-petstore-server-useOptional.sh b/bin/springboot-petstore-server-useOptional.sh new file mode 100755 index 00000000000..5b53bfbecf6 --- /dev/null +++ b/bin/springboot-petstore-server-useOptional.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -c bin/springboot-petstore-server-useOptional.json -o samples/server/petstore/springboot-useoptional -DhideGenerationTimestamp=true" + +echo "Removing files and folders under samples/server/petstore/springboot-useoptional/src/main" +rm -rf samples/server/petstore/springboot-useoptional/src/main +find samples/server/petstore/springboot-useoptional -maxdepth 1 -type f ! -name "README.md" -exec rm {} + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/swift3-petstore-all.sh b/bin/swift3-petstore-all.sh index 4f38026418d..8eb4a7c5f4f 100755 --- a/bin/swift3-petstore-all.sh +++ b/bin/swift3-petstore-all.sh @@ -38,3 +38,7 @@ java $JAVA_OPTS -jar $executable $ags ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-rxswift.json -o samples/client/petstore/swift3/rxswift" echo "#### Petstore Swift API client (rxswift) ####" java $JAVA_OPTS -jar $executable $ags + +ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-unwraprequired.json -o samples/client/petstore/swift3/unwraprequired" +echo "#### Petstore Swift API client (unwraprequired) ####" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/swift3-petstore-unwraprequired.json b/bin/swift3-petstore-unwraprequired.json new file mode 100644 index 00000000000..f077c429ee8 --- /dev/null +++ b/bin/swift3-petstore-unwraprequired.json @@ -0,0 +1,7 @@ +{ + "podSummary": "PetstoreClient", + "podHomepage": "https://github.com/swagger-api/swagger-codegen", + "podAuthors": "", + "projectName": "PetstoreClient", + "unwrapRequired": true +} \ No newline at end of file diff --git a/bin/swift3-petstore-unwraprequired.sh b/bin/swift3-petstore-unwraprequired.sh new file mode 100755 index 00000000000..65355a18ecf --- /dev/null +++ b/bin/swift3-petstore-unwraprequired.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-unwraprequired.json -o samples/client/petstore/swift3/unwraprequired" + +java $JAVA_OPTS -jar $executable $ags diff --git a/circle.yml b/circle.yml index a4e71cc09d1..1fb626bce55 100644 --- a/circle.yml +++ b/circle.yml @@ -32,14 +32,18 @@ dependencies: test: override: - # test with jdk8 + ## test with jdk8 - java -version - mvn -q clean verify -Psamples - # test with jdk7 + # skip the rest if previous mvn task fails + - if [ $? -ne 0 ]; then exit 1; fi + ## test with jdk7 - sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 - java -version - mvn -q clean verify -Psamples - # docker: build generator image and push to Docker Hub + # skip the rest if previous mvn task fails + - if [ $? -ne 0 ]; then exit 1; fi + ## docker: build generator image and push to Docker Hub - if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi - # docker: build cli image and push to Docker Hub + ## docker: build cli image and push to Docker Hub - if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index f500d72fc8f..b5726b57ea7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -607,7 +607,7 @@ public class DefaultCodegen { * @return properly-escaped pattern */ public String toRegularExpression(String pattern) { - return escapeText(addRegularExpressionDelimiter(pattern)); + return addRegularExpressionDelimiter(escapeText(pattern)); } /** @@ -3572,9 +3572,14 @@ public class DefaultCodegen { * @return the pattern with delimiter */ public String addRegularExpressionDelimiter(String pattern) { - if (pattern != null && !pattern.matches("^/.*")) { - return "/" + pattern + "/"; + if (StringUtils.isEmpty(pattern)) { + return pattern; } + + if (!pattern.matches("^/.*")) { + return "/" + pattern.replaceAll("/", "\\\\/") + "/"; + } + return pattern; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index 6053939fa4e..e1a79f4d576 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -312,10 +312,10 @@ public class CppRestClientCodegen extends DefaultCodegen implements CodegenConfi return "0.0"; } else if (p instanceof FloatProperty) { return "0.0f"; - } else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) { - return "0"; } else if (p instanceof LongProperty) { return "0L"; + } else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) { + return "0"; } else if (p instanceof DecimalProperty) { return "0.0"; } else if (p instanceof MapProperty) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PistacheServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PistacheServerCodegen.java index a56ef44710a..0eb83a5e2eb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PistacheServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PistacheServerCodegen.java @@ -286,10 +286,10 @@ public class PistacheServerCodegen extends DefaultCodegen implements CodegenConf return "0.0"; } else if (p instanceof FloatProperty) { return "0.0f"; - } else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) { - return "0"; } else if (p instanceof LongProperty) { return "0L"; + } else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) { + return "0"; } else if (p instanceof DecimalProperty) { return "0.0"; } else if (p instanceof MapProperty) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RestbedCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RestbedCodegen.java index 730d6e075b6..dcd4c75988a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RestbedCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RestbedCodegen.java @@ -318,10 +318,10 @@ public class RestbedCodegen extends DefaultCodegen implements CodegenConfig { return "0.0"; } else if (p instanceof FloatProperty) { return "0.0f"; - } else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) { - return "0"; } else if (p instanceof LongProperty) { return "0L"; + } else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) { + return "0"; } else if (p instanceof DecimalProperty) { return "0.0"; } else if (p instanceof MapProperty) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java index 2535a17ba0e..34aa46cd3f2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java @@ -4,6 +4,7 @@ import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template; import io.swagger.codegen.*; import io.swagger.codegen.languages.features.BeanValidationFeatures; +import io.swagger.codegen.languages.features.OptionalFeatures; import io.swagger.models.Operation; import io.swagger.models.Path; import io.swagger.models.Swagger; @@ -15,7 +16,8 @@ import java.util.*; import java.util.regex.Matcher; -public class SpringCodegen extends AbstractJavaCodegen implements BeanValidationFeatures { +public class SpringCodegen extends AbstractJavaCodegen + implements BeanValidationFeatures, OptionalFeatures { public static final String DEFAULT_LIBRARY = "spring-boot"; public static final String TITLE = "title"; public static final String CONFIG_PACKAGE = "configPackage"; @@ -45,6 +47,7 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation protected boolean useBeanValidation = true; protected boolean implicitHeaders = false; protected boolean swaggerDocketConfig = false; + protected boolean useOptional = false; public SpringCodegen() { super(); @@ -75,6 +78,8 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers.")); cliOptions.add(CliOption.newBoolean(SWAGGER_DOCKET_CONFIG, "Generate Spring Swagger Docket configuration class.")); + cliOptions.add(CliOption.newBoolean(USE_OPTIONAL, + "Use Optional container for optional parameters")); supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration."); supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration."); @@ -170,11 +175,14 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); } + if (additionalProperties.containsKey(USE_OPTIONAL)) { + this.setUseOptional(convertPropertyToBoolean(USE_OPTIONAL)); + } + if (useBeanValidation) { writePropertyBack(USE_BEANVALIDATION, useBeanValidation); } - if (additionalProperties.containsKey(IMPLICIT_HEADERS)) { this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString())); } @@ -185,6 +193,10 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation typeMapping.put("file", "Resource"); importMapping.put("Resource", "org.springframework.core.io.Resource"); + + if (useOptional) { + writePropertyBack(USE_OPTIONAL, useOptional); + } if (this.interfaceOnly && this.delegatePattern) { throw new IllegalArgumentException( @@ -649,4 +661,8 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation this.useBeanValidation = useBeanValidation; } + @Override + public void setUseOptional(boolean useOptional) { + this.useOptional = useOptional; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java index eb319344781..ab12f1a5b60 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java @@ -1,5 +1,9 @@ package io.swagger.codegen.languages; +import io.swagger.codegen.CodegenModel; +import io.swagger.codegen.CodegenParameter; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -9,7 +13,6 @@ import java.util.Date; import io.swagger.codegen.CliOption; import io.swagger.codegen.SupportingFile; -import io.swagger.models.properties.BooleanProperty; public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class); @@ -19,6 +22,7 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; public static final String SNAPSHOT = "snapshot"; + public static final String JQUERY_ALREADY_IMPORTED = "jqueryAlreadyImported"; protected String npmName = null; protected String npmVersion = "1.0.0"; @@ -26,6 +30,13 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg public TypeScriptJqueryClientCodegen() { super(); + + modelTemplateFiles.put("model.mustache", ".ts"); + apiTemplateFiles.put("api.mustache", ".ts"); + typeMapping.put("Date", "Date"); + apiPackage = "api"; + modelPackage = "model"; + outputFolder = "generated-code/typescript-jquery"; embeddedTemplateDir = templateDir = "typescript-jquery"; @@ -33,23 +44,75 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString())); + this.cliOptions.add(new CliOption(JQUERY_ALREADY_IMPORTED, "When using this in legacy app using mix of typescript and javascript, this will only declare jquery and not import it", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString())); } - @Override public void processOpts() { super.processOpts(); - supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts")); + supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts")); + supportingFiles.add(new SupportingFile("configuration.mustache", getIndexDirectory(), "configuration.ts")); + supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts")); + supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts")); LOGGER.warn("check additionals: " + additionalProperties.get(NPM_NAME)); - if(additionalProperties.containsKey(NPM_NAME)) { + if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } } + private String getIndexDirectory() { + String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.'))); + return indexPackage.replace('.', File.separatorChar); + } + + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + if (isLanguagePrimitive(swaggerType) || isLanguageGenericType(swaggerType)) { + return swaggerType; + } + return addModelPrefix(swaggerType); + } + + private String addModelPrefix(String swaggerType) { + String type = null; + if (typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + } else { + type = swaggerType; + } + + if (!isLanguagePrimitive(type) && !isLanguageGenericType(type)) { + type = "models." + swaggerType; + } + return type; + } + + private boolean isLanguagePrimitive(String type) { + return languageSpecificPrimitives.contains(type); + } + + private boolean isLanguageGenericType(String type) { + for (String genericType : languageGenericTypes) { + if (type.startsWith(genericType + "<")) { + return true; + } + } + return false; + } + + @Override + public void postProcessParameter(CodegenParameter parameter) { + super.postProcessParameter(parameter); + parameter.dataType = addModelPrefix(parameter.dataType); + } + private void addNpmPackageGeneration() { - if(additionalProperties.containsKey(NPM_NAME)) { + if (additionalProperties.containsKey(NPM_NAME)) { this.setNpmName(additionalProperties.get(NPM_NAME).toString()); } @@ -77,6 +140,12 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg return indexPackage.replace('.', File.separatorChar); } + @Override + protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, ModelImpl swaggerModel) { + codegenModel.additionalPropertiesType = getSwaggerType(swaggerModel.getAdditionalProperties()); + addImport(codegenModel, codegenModel.additionalPropertiesType); + } + @Override public String getName() { return "typescript-jquery"; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/OptionalFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/OptionalFeatures.java new file mode 100644 index 00000000000..5b83739c565 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/OptionalFeatures.java @@ -0,0 +1,10 @@ +package io.swagger.codegen.languages.features; + +public interface OptionalFeatures { + + // Language supports generating Optional Types + String USE_OPTIONAL = "useOptional"; + + void setUseOptional(boolean useOptional); + +} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache index ddf991b6a37..2bc2739b1fe 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache @@ -241,7 +241,7 @@ 4.3.9.RELEASE {{/generateSpringApplication}} {{#generateSpringBootApplication}} - 1.4.7.RELEASE + 1.5.4.RELEASE {{/generateSpringBootApplication}} 3.1.11 2.8.9 diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache index 94de93b8646..a1dd83d7657 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache @@ -26,6 +26,9 @@ import java.io.IOException; {{/useSpringCloudClient}} import java.util.List; +{{#useOptional}} +import java.util.Optional; +{{/useOptional}} {{#async}} import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; {{/async}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache index 13afce66110..019c7618e06 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache @@ -19,6 +19,9 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import java.util.List; +{{#useOptional}} +import java.util.Optional; +{{/useOptional}} {{#async}} import java.util.concurrent.Callable; {{/async}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/headerParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/headerParams.mustache index 535f2e6f2b3..89645c9436a 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/headerParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/headerParams.mustache @@ -1 +1 @@ -{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file +{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache index f42ea7adff8..86c50e3a387 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache @@ -9,12 +9,12 @@ {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} ${java.version} ${java.version} - 2.6.1 + 2.7.0 org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache index d47cb8524d6..b5687561a2a 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java @@ -25,7 +25,7 @@ org.springframework.cloud spring-cloud-starter-parent - Camden.SR1 + Dalston.SR1 pom import diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache index fc58cd9d2e5..307cf529bf6 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache @@ -159,7 +159,7 @@ 1.7.21 4.12 2.5 - 2.6.0 + 2.7.0 2.8.9 2.6.4 4.3.9.RELEASE diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/optionalDataType.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/optionalDataType.mustache new file mode 100644 index 00000000000..976950e27e8 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/optionalDataType.mustache @@ -0,0 +1 @@ +{{#useOptional}}{{#required}}{{{dataType}}}{{/required}}{{^required}}Optional<{{{dataType}}}>{{/required}}{{/useOptional}}{{^useOptional}}{{{dataType}}}{{/useOptional}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache index d577abfb25a..62342d01bfa 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache @@ -1 +1 @@ -{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}} \ No newline at end of file +{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/queryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/queryParams.mustache index 97ba247a1ee..222831b72f4 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/queryParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/queryParams.mustache @@ -1 +1 @@ -{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file +{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache b/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache index a6617ac8547..7501d1360e8 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache @@ -26,9 +26,9 @@ Gem::Specification.new do |s| s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}" s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' - s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3' + s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0' - s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0' + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1' s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3' s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6' diff --git a/modules/swagger-codegen/src/main/resources/tizen/api-body.mustache b/modules/swagger-codegen/src/main/resources/tizen/api-body.mustache index 5a2763e77e7..56d6983766c 100644 --- a/modules/swagger-codegen/src/main/resources/tizen/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/tizen/api-body.mustache @@ -50,7 +50,7 @@ static gpointer __{{classname}}threadFunc(gpointer data) {{#operation}} -bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { {{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* ) @@ -58,9 +58,6 @@ bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, vo {{^returnType}}void(* handler)(Error, void* ) = reinterpret_cast (voidHandler);{{/returnType}} JsonNode* pJson; char * data = p_chunk.memory; - {{#returnType}} - printf("%s\n", data); - {{/returnType}} {{#returnType}}{{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}{{/isMapContainer}} out;{{/returnContainer}} {{^returnContainer}}{{returnType}} out;{{/returnContainer}}{{/returnType}} @@ -137,7 +134,7 @@ bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, vo } } -bool {{nickname}}Helper(char * accessToken, +static bool {{nickname}}Helper(char * accessToken, {{#allParams}}{{#isContainer}}{{{dataType}}}<{{baseType}}> {{paramName}}{{/isContainer}}{{^isContainer}}{{{dataType}}} {{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}} {{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* ){{/returnType}} {{^returnType}}void(* handler)(Error, void* ) {{/returnType}}, void* userData, bool isAsync) @@ -159,8 +156,11 @@ bool {{nickname}}Helper(char * accessToken, headerList = curl_slist_append(headerList, itemAt); } {{/collectionFormat}}{{^collectionFormat}} - //TODO - should use value of paramname instead. Also check for empty not-required headers - headerList = curl_slist_append(headerList, "{{baseName}}: {{paramName}}"); + { + string headerString("{{baseName}}: "); + headerString.append(stringify(&{{paramName}}, "{{dataType}}")); + headerList = curl_slist_append(headerList, headerString.c_str()); + } {{/collectionFormat}} {{/headerParams}} @@ -204,7 +204,8 @@ bool {{nickname}}Helper(char * accessToken, string mBody = ""; JsonNode* node; JsonArray* json_array; - {{#bodyParams}} + {{#allParams}} + {{#isBodyParam}} {{#isContainer}} //TODO: Map Container {{#isListContainer}} @@ -256,17 +257,18 @@ bool {{nickname}}Helper(char * accessToken, if (isprimitive("{{baseType}}")) { node = converttoJson(&{{paramName}}, "{{baseType}}", ""); } - {{^isInteger}}{{^isDate}}{{^isLong}}{{^isBoolean}}{{^isFloat}}{{^isString}}{{^isDateTime}}{{^isDouble}} + {{^isPrimitiveType}}{{^isInteger}}{{^isDate}}{{^isLong}}{{^isBoolean}}{{^isFloat}}{{^isString}}{{^isDateTime}}{{^isDouble}} char *jsonStr = {{paramName}}.toJson(); node = json_from_string(jsonStr, NULL); g_free(static_cast(jsonStr)); - {{/isDouble}}{{/isDateTime}}{{/isString}}{{/isFloat}}{{/isBoolean}}{{/isLong}}{{/isDate}}{{/isInteger}} + {{/isDouble}}{{/isDateTime}}{{/isString}}{{/isFloat}}{{/isBoolean}}{{/isLong}}{{/isDate}}{{/isInteger}}{{/isPrimitiveType}} {{/isContainer}} char *jsonStr1 = json_to_string(node, false); mBody.append(jsonStr1); g_free(static_cast(jsonStr1)); - {{/bodyParams}} + {{/isBodyParam}} + {{/allParams}} string url("{{{path}}}"); int pos; diff --git a/modules/swagger-codegen/src/main/resources/tizen/api-header.mustache b/modules/swagger-codegen/src/main/resources/tizen/api-header.mustache index 1a29cb9428d..77366bde156 100644 --- a/modules/swagger-codegen/src/main/resources/tizen/api-header.mustache +++ b/modules/swagger-codegen/src/main/resources/tizen/api-header.mustache @@ -10,9 +10,18 @@ {{/imports}} #include "Error.h" +/** \defgroup Operations API Endpoints + * Classes containing all the functions for calling API endpoints + * + */ + namespace Tizen{ namespace {{prefix}} { {{#operations}} +/** \addtogroup {{{baseName}}} {{{baseName}}} + * \ingroup Operations + * @{ + */ class {{classname}} { public: {{classname}}(); @@ -44,6 +53,8 @@ bool {{nickname}}Async(char * accessToken, {{#allParams}}{{#isContainer}}{{{dataType}}}<{{baseType}}> {{paramName}}{{/isContainer}}{{^isContainer}}{{{dataType}}} {{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}} {{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* ){{/returnType}} {{^returnType}}void(* handler)(Error, void* ) {{/returnType}}, void* userData); + + {{/operation}} static std::string getBasePath() @@ -51,6 +62,7 @@ bool {{nickname}}Async(char * accessToken, return "{{{basePath}}}"; } }; +/** @}*/ {{/operations}} } diff --git a/modules/swagger-codegen/src/main/resources/tizen/doc-readme.mustache b/modules/swagger-codegen/src/main/resources/tizen/doc-readme.mustache index 3c82e6a7a7b..3a94698818d 100644 --- a/modules/swagger-codegen/src/main/resources/tizen/doc-readme.mustache +++ b/modules/swagger-codegen/src/main/resources/tizen/doc-readme.mustache @@ -1,4 +1,4 @@ -# Documentation for {{#swagger}}{{#info}}{{title}} {{version}} Tizen SDK{{/info}}{{/swagger}} +# Documentation for {{#swagger}}{{#info}}{{title}} {{version}} Tizen Client SDK{{/info}}{{/swagger}} ## How do I get the doc files? First generate source code by running `swagger-codegen` @@ -16,7 +16,7 @@ This is the structure of the doc folder: ├── Doxyfile \\Doxygen config files ├── generateDocumentation.sh \\Script to run to generate documentation ├── README.md \\This file -├── SDK \\Documentation for all classes in Tizen Client SDK for Artik Cloud. See ./html/index.html +├── SDK \\Documentation for all classes in {{#swagger}}{{#info}}{{title}} Tizen Client SDK{{/info}}{{/swagger}}. See ./html/index.html │   └── html ``` @@ -36,13 +36,19 @@ Doxygen is the de facto standard tool for generating/extracting documentation fr Check out [Doxygen](https://www.doxygen.org/) for additional information about the Doxygen project. ## I Don't want to run Doxygen. What are the API files for accessing the REST endpoints? +All URIs are relative to {{{scheme}}}://{{{host}}}{{{basePath}}} {{#apiInfo}}{{#apis}}{{#operations}} -* [{{classname}}](../src/{{classname}}.cpp) +### {{classname}} +Method | HTTP request | Description +------------- | ------------- | ------------- {{#operation}} - * *{{nickname}}Sync* / *{{nickname}}Async* - {{{summary}}}. - {{/operation}} +*{{nickname}}Sync* | *{{httpMethod}}* {{{path}}} | {{{summary}}}. +*{{nickname}}ASync* | *{{httpMethod}}* {{{path}}} | {{{summary}}}. +{{/operation}} {{/operations}}{{/apis}}{{/apiInfo}} ## What are the Model files for the data structures/objects? -{{#models}}{{#model}} -* [{{classname}}](../src/{{classname}}.cpp) - {{{description}}}{{/model}}{{/models}} +Class | Description +------------- | ------------- +{{#models}}{{#model}} *{{classname}}* | {{{description}}} +{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/tizen/helpers-body.mustache b/modules/swagger-codegen/src/main/resources/tizen/helpers-body.mustache index 457c9b06612..157842642a5 100644 --- a/modules/swagger-codegen/src/main/resources/tizen/helpers-body.mustache +++ b/modules/swagger-codegen/src/main/resources/tizen/helpers-body.mustache @@ -13,7 +13,7 @@ using namespace Tizen::{{prefix}}; void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_node,gpointer user_data) { - const gchar* member_string; + gchar* member_string; if (!JSON_NODE_HOLDS_VALUE(member_node)) { if (JSON_NODE_HOLDS_OBJECT(member_node)) { JsonNode* tempnode = json_node_alloc(); @@ -27,10 +27,42 @@ void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_ json_node_free(tempnode); } } else { - member_string = json_node_get_string(member_node); + member_string = (char*) json_node_get_string(member_node); + if (member_string == NULL) { + char * valueType = (char*) json_node_type_name(member_node); + if(strcmp(valueType,"Boolean") == 0){ + gboolean member_boolean = json_node_get_boolean(member_node); + if (member_boolean == 0) { + member_string = new char[std::strlen("false") + 1]; + strcpy(member_string, "false"); + } else { + member_string = new char[std::strlen("true") + 1]; + strcpy(member_string, "true"); + } + } + else if(strcmp(valueType,"Integer") == 0){ + long long int member_int = json_node_get_int(member_node); + ostringstream ss; + ss << member_int; + string temp_member = ss.str(); + const char * temp_char = temp_member.c_str(); + member_string = new char[strlen(temp_char) + 1]; + strcpy(member_string, temp_char); + } + else{ + double member_double = json_node_get_double(member_node); + ostringstream ss; + ss << member_double; + string temp_member = ss.str(); + const char * temp_char = temp_member.c_str(); + member_string = new char[strlen(temp_char) + 1]; + strcpy(member_string, temp_char); + } + } } map* new_map = static_cast*>(user_data); (*new_map)[string(member_name)] = string(member_string); + delete[] member_string; } char * json_to_string(JsonNode *node, gboolean pretty) @@ -64,7 +96,11 @@ json_from_string(const char *str, GError **mygerror) if (!json_parser_load_from_data(parser, str, -1, mygerror)) { g_object_unref(parser); - return NULL; + if(str == NULL) + return NULL; + retval = json_node_alloc(); + retval = json_node_init_string (retval, str); + return retval; } retval = json_node_copy(json_parser_get_root(parser)); diff --git a/modules/swagger-codegen/src/main/resources/tizen/model-header.mustache b/modules/swagger-codegen/src/main/resources/tizen/model-header.mustache index 9856ee6cfb2..307e759a021 100644 --- a/modules/swagger-codegen/src/main/resources/tizen/model-header.mustache +++ b/modules/swagger-codegen/src/main/resources/tizen/model-header.mustache @@ -14,11 +14,18 @@ {{/imports}} #include "Object.h" +/** \defgroup Models Data Structures for API + * Classes containing all the Data Structures needed for calling/returned by API endpoints + * + */ + namespace Tizen { namespace {{prefix}} { {{#models}}{{#model}} /*! \brief {{{description}}} + * + * \ingroup Models * */ diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache index 0eed43fd575..005c3a26df3 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache @@ -2,18 +2,18 @@ export interface ConfigurationParameters { apiKeys?: {[ key: string ]: string}; username?: string; password?: string; - accessToken?: string; + accessToken?: string | (() => string); basePath?: string; withCredentials?: boolean; } export class Configuration { - apiKeys: {[ key: string ]: string}; - username: string; - password: string; - accessToken: string | (() => string); - basePath: string; - withCredentials: boolean; + apiKeys?: {[ key: string ]: string}; + username?: string; + password?: string; + accessToken?: string | (() => string); + basePath?: string; + withCredentials?: boolean; constructor(configurationParameters: ConfigurationParameters = {}) { this.apiKeys = configurationParameters.apiKeys; diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache index 319c16e9bf8..ffa5128b4f5 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache @@ -1,176 +1,42 @@ +{{>licenseInfo}} + +{{#jqueryAlreadyImported}} +declare var $ : any; +{{/jqueryAlreadyImported}} +{{^jqueryAlreadyImported}} import * as $ from 'jquery'; +{{/jqueryAlreadyImported}} +import * as models from '../model/models'; +import { COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; -let defaultBasePath = '{{{basePath}}}'; +/* tslint:disable:no-unused-variable member-ordering */ -// =============================================== -// This file is autogenerated - Please do not edit -// =============================================== - -/* tslint:disable:no-unused-variable */ - -{{#models}} -{{#model}} -{{#description}} - /** - * {{{description}}} - */ -{{/description}} -export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ -{{#vars}} - {{#description}} - /** - * {{{description}}} - */ - {{/description}} - '{{name}}': {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; -{{/vars}} -} - -{{#hasEnums}} -export namespace {{classname}} { -{{#vars}} -{{#isEnum}} - export enum {{enumName}} { - {{#allowableValues}} - {{#enumVars}} - {{name}} = {{{value}}}{{^-last}},{{/-last}} - {{/enumVars}} - {{/allowableValues}} - } -{{/isEnum}} -{{/vars}} -} -{{/hasEnums}} -{{/model}} -{{/models}} - -export interface Authentication { - /** - * Apply authentication settings to header and query params. - */ - applyToRequest(requestOptions: JQueryAjaxSettings): void; -} - -export class HttpBasicAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: any): void { - requestOptions.username = this.username; - requestOptions.password = this.password; - } -} - -export class ApiKeyAuth implements Authentication { - public apiKey: string; - - constructor(private location: string, private paramName: string) { - } - - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers[this.paramName] = this.apiKey; - } -} - -export class OAuth implements Authentication { - public accessToken: string; - - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; - } -} - -export class VoidAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: JQueryAjaxSettings): void { - // Do nothing - } -} - -{{#apiInfo}} -{{#apis}} {{#operations}} + {{#description}} /** -* {{&description}} -*/ + * {{&description}} + */ {{/description}} -export enum {{classname}}ApiKeys { -{{#authMethods}} -{{#isApiKey}} - {{name}}, -{{/isApiKey}} -{{/authMethods}} -} - export class {{classname}} { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; + protected basePath = '{{{basePath}}}'; + public defaultHeaders: Array = []; + public configuration: Configuration = new Configuration(); - protected authentications = { - 'default': new VoidAuth(), -{{#authMethods}} -{{#isBasic}} - '{{name}}': new HttpBasicAuth(), -{{/isBasic}} -{{#isApiKey}} - '{{name}}': new ApiKeyAuth({{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{^isKeyInHeader}}'query'{{/isKeyInHeader}}, '{{keyParamName}}'), -{{/isApiKey}} -{{#isOAuth}} - '{{name}}': new OAuth(), -{{/isOAuth}} -{{/authMethods}} - } - - constructor(basePath?: string); -{{#authMethods}} -{{#isBasic}} - constructor(username: string, password: string, basePath?: string); -{{/isBasic}} -{{/authMethods}} - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { -{{#authMethods}} -{{#isBasic}} - this.username = basePathOrUsername; - this.password = password -{{/isBasic}} -{{/authMethods}} - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } + constructor(basePath?: string, configuration?: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; } } - public setApiKey(key: {{classname}}ApiKeys, value: string) { - this.authentications[{{classname}}ApiKeys[key]].apiKey = value; - } -{{#authMethods}} -{{#isBasic}} - - set username(username: string) { - this.authentications.{{name}}.username = username; - } - - set password(password: string) { - this.authentications.{{name}}.password = password; - } -{{/isBasic}} -{{#isOAuth}} - - set accessToken(token: string) { - this.authentications.{{name}}.accessToken = token; - } -{{/isOAuth}} -{{/authMethods}} private extendObj(objA: T2, objB: T2): T1|T2 { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; + for (let key in objB) { + if (objB.hasOwnProperty(key)) { + objA[key] = objB[key]; } } return objA; @@ -182,59 +48,149 @@ export class {{classname}} { * {{notes}} {{#allParams}}* @param {{paramName}} {{description}} {{/allParams}}*/ - public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : JQueryPromise<{ response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { - let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}} - .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): JQueryPromise<{ response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { + let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; -{{#allParams}}{{#required}} + let queryParameters: any = {}; + let headerParams: any = {}; +{{#hasFormParams}} + let formParams = new FormData(); + let reqHasFile = false; + +{{/hasFormParams}} +{{#allParams}} +{{#required}} // verify required parameter '{{paramName}}' is not null or undefined if ({{paramName}} === null || {{paramName}} === undefined) { throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); } -{{/required}}{{/allParams}} -{{#queryParams}} - if ({{paramName}} !== undefined) { - queryParameters['{{baseName}}'] = {{paramName}}; - } +{{/required}} +{{/allParams}} +{{#queryParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element: any) => { + queryParameters['{{baseName}}'].push(element); + }); + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + queryParameters['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== null && {{paramName}} !== undefined) { + {{#isDateTime}} + queryParameters['{{baseName}}'] = {{paramName}}.toISOString(); + {{/isDateTime}} + {{^isDateTime}} + {{#isDate}} + queryParameters['{{baseName}}'] = {{paramName}}.toISOString(); + {{/isDate}} + {{^isDate}} + queryParameters['{{baseName}}'] = {{paramName}}; + {{/isDate}} + {{/isDateTime}} + } + {{/isListContainer}} {{/queryParams}} localVarPath = localVarPath + "?" + $.param(queryParameters); - -{{#headerParams}} - headerParams['{{baseName}}'] = {{paramName}}; - -{{/headerParams}} - -{{^bodyParam}} - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); {{#formParams}} {{#isFile}} reqHasFile = true; {{/isFile}} - if ({{paramName}} !== undefined) { - reqFormData.append('{{baseName}}', {{paramName}}); - reqDict['{{baseName}}'] = {{paramName}}; + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element: any) => { + formParams.append('{{baseName}}', element); + }); + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); + {{/isCollectionFormatMulti}} } + {{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== null && {{paramName}} !== undefined) { + formParams.append('{{baseName}}', {{paramName}}); + } + {{/isListContainer}} {{/formParams}} -{{/bodyParam}} -{{#bodyParam}} - let reqDict = {{paramName}}; - let reqFormData = new FormData(); - reqFormData.append('{{paramName}}', {{paramName}}); -{{#isFile}} - let reqHasFile = true; -{{/isFile}} -{{^isFile}} - let reqHasFile = false; -{{/isFile}} -{{/bodyParam}} +{{#headerParams}} + {{#isListContainer}} + if ({{paramName}}) { + headerParams['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']); + } + {{/isListContainer}} + {{^isListContainer}} + headerParams['{{baseName}}'] = String({{paramName}}); + {{/isListContainer}} +{{/headerParams}} + // to determine the Content-Type header + let consumes: string[] = [ + {{#consumes}} + '{{{mediaType}}}'{{#hasMore}}, {{/hasMore}} + {{/consumes}} + ]; + + // to determine the Accept header + let produces: string[] = [ + {{#produces}} + '{{{mediaType}}}'{{#hasMore}}, {{/hasMore}} + {{/produces}} + ]; + +{{#authMethods}} + // authentication ({{name}}) required +{{#isApiKey}} +{{#isKeyInHeader}} + if (this.configuration.apiKey) { + headerParams['{{keyParamName}}'] = this.configuration.apiKey; + } + +{{/isKeyInHeader}} +{{#isKeyInQuery}} + if (this.configuration.apiKey) { + queryParameters.set('{{keyParamName}}', this.configuration.apiKey); + } + +{{/isKeyInQuery}} +{{/isApiKey}} +{{#isBasic}} + // http basic authentication required + if (this.configuration.username || this.configuration.password) { + headerParams['Authorization'] = 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password); + } + +{{/isBasic}} +{{#isOAuth}} + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + +{{/isOAuth}} +{{/authMethods}} +{{#hasFormParams}} + if (!reqHasFile) { + headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; + } + +{{/hasFormParams}} + +{{#bodyParam}} + headerParams['Content-Type'] = 'application/json'; + +{{/bodyParam}} let requestOptions: JQueryAjaxSettings = { url: localVarPath, type: '{{httpMethod}}', @@ -242,28 +198,29 @@ export class {{classname}} { processData: false }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; +{{#bodyParam}} + requestOptions.data = JSON.stringify({{paramName}}); +{{/bodyParam}} + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; } - -{{#authMethods}} - this.authentications.{{name}}.applyToRequest(requestOptions); - -{{/authMethods}} - this.authentications.default.applyToRequest(requestOptions); +{{#hasFormParams}} + requestOptions.data = formParams; + if (reqHasFile) { + requestOptions.contentType = false; + } +{{/hasFormParams}} let dfd = $.Deferred(); $.ajax(requestOptions).then( (data: {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), + dfd.resolve(jqXHR, data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) + dfd.reject(xhr, errorThrown) ); return dfd.promise(); } + {{/operation}} } {{/operations}} -{{/apis}} -{{/apiInfo}} diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/apis.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/apis.mustache new file mode 100644 index 00000000000..9d3e92349d0 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/apis.mustache @@ -0,0 +1,9 @@ +{{#apiInfo}} +{{#apis}} +{{#operations}} +export * from './{{ classFilename }}'; +import { {{ classname }} } from './{{ classFilename }}'; +{{/operations}} +{{/apis}} +export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}]; +{{/apiInfo}} diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/configuration.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/configuration.mustache new file mode 100644 index 00000000000..a566a180e4e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/configuration.mustache @@ -0,0 +1,6 @@ +export class Configuration { + apiKey: string; + username: string; + password: string; + accessToken: string | (() => string); +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/index.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/index.mustache new file mode 100644 index 00000000000..d097c728017 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/index.mustache @@ -0,0 +1,4 @@ +export * from './api/api'; +export * from './model/models'; +export * from './variables'; +export * from './configuration'; \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/licenseInfo.mustache new file mode 100644 index 00000000000..bbd8742e52a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/licenseInfo.mustache @@ -0,0 +1,11 @@ +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/masterApiEntry.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/masterApiEntry.mustache new file mode 100644 index 00000000000..e69de29bb2d diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/model.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/model.mustache new file mode 100644 index 00000000000..39fa04722e6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/model.mustache @@ -0,0 +1,13 @@ +{{>licenseInfo}} +import * as models from './models'; +{{#models}} +{{#model}} + +{{#description}} +/** + * {{{description}}} + */ +{{/description}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}} +{{/model}} +{{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/modelEnum.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/modelEnum.mustache new file mode 100644 index 00000000000..47886484118 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/modelEnum.mustache @@ -0,0 +1,12 @@ +{{#description}} + /** + * {{{description}}} + */ +{{/description}} +export enum {{classname}} { +{{#allowableValues}} +{{#enumVars}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/modelGeneric.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/modelGeneric.mustache new file mode 100644 index 00000000000..fbe96c21506 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/modelGeneric.mustache @@ -0,0 +1,28 @@ +export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}}{ +{{#additionalPropertiesType}} + [key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}}; + +{{/additionalPropertiesType}} +{{#vars}} + {{#description}} + /** + * {{{description}}} + */ + {{/description}} + {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; + +{{/vars}} +}{{#hasEnums}} +export namespace {{classname}} { +{{#vars}} + {{#isEnum}} + export enum {{enumName}} { + {{#allowableValues}} + {{#enumVars}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } + {{/isEnum}} +{{/vars}} +}{{/hasEnums}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/models.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/models.mustache new file mode 100644 index 00000000000..c6e732bffbb --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/models.mustache @@ -0,0 +1,5 @@ +{{#models}} +{{#model}} +export * from './{{{ classname }}}'; +{{/model}} +{{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/variables.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/variables.mustache new file mode 100644 index 00000000000..505ce9355e2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/variables.mustache @@ -0,0 +1,7 @@ + +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java index a78f3a7caf5..dcba427282e 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java @@ -21,6 +21,7 @@ public class SpringOptionsProvider extends JavaOptionsProvider { public static final String USE_BEANVALIDATION = "false"; public static final String IMPLICIT_HEADERS = "false"; public static final String SWAGGER_DOCKET_CONFIG = "false"; + public static final String USE_OPTIONAL = "false"; @Override public String getLanguage() { @@ -44,6 +45,7 @@ public class SpringOptionsProvider extends JavaOptionsProvider { options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION); options.put(SpringCodegen.IMPLICIT_HEADERS, IMPLICIT_HEADERS); options.put(SpringCodegen.SWAGGER_DOCKET_CONFIG, SWAGGER_DOCKET_CONFIG); + options.put(SpringCodegen.USE_OPTIONAL, USE_OPTIONAL); return options; } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/spring/SpringOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/spring/SpringOptionsTest.java index d0bd2e1a43c..55511c7beb2 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/spring/SpringOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/spring/SpringOptionsTest.java @@ -4,7 +4,6 @@ import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.java.JavaClientOptionsTest; import io.swagger.codegen.languages.SpringCodegen; import io.swagger.codegen.options.SpringOptionsProvider; - import mockit.Expectations; import mockit.Tested; @@ -77,6 +76,9 @@ public class SpringOptionsTest extends JavaClientOptionsTest { times = 1; clientCodegen.setSwaggerDocketConfig(Boolean.valueOf(SpringOptionsProvider.SWAGGER_DOCKET_CONFIG)); times = 1; + clientCodegen.setUseOptional( + Boolean.valueOf(SpringOptionsProvider.USE_OPTIONAL)); + times = 1; }}; } } diff --git a/pom.xml.circleci b/pom.xml.circleci index 33caa57c44f..4a93c2608fe 100644 --- a/pom.xml.circleci +++ b/pom.xml.circleci @@ -710,6 +710,18 @@ samples/server/petstore/spring-mvc + + springboot-useoptional + + + env + java + + + + samples/server/petstore/springboot-useoptional + + springboot-beanvalidation @@ -821,6 +833,7 @@ samples/client/petstore/spring-cloud samples/server/petstore/springboot samples/server/petstore/springboot-beanvalidation + samples/server/petstore/springboot-useoptional samples/server/petstore/jaxrs-cxf samples/server/petstore/jaxrs-cxf-annotated-base-path samples/server/petstore/jaxrs-cxf-cdi diff --git a/samples/client/petstore/cpprest/model/Category.cpp b/samples/client/petstore/cpprest/model/Category.cpp index 4d185607149..24bdc66c132 100644 --- a/samples/client/petstore/cpprest/model/Category.cpp +++ b/samples/client/petstore/cpprest/model/Category.cpp @@ -21,7 +21,7 @@ namespace model { Category::Category() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_Name = U(""); m_NameIsSet = false; diff --git a/samples/client/petstore/cpprest/model/Order.cpp b/samples/client/petstore/cpprest/model/Order.cpp index b205701b76f..24f3b7e46cc 100644 --- a/samples/client/petstore/cpprest/model/Order.cpp +++ b/samples/client/petstore/cpprest/model/Order.cpp @@ -21,9 +21,9 @@ namespace model { Order::Order() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; - m_PetId = 0; + m_PetId = 0L; m_PetIdIsSet = false; m_Quantity = 0; m_QuantityIsSet = false; diff --git a/samples/client/petstore/cpprest/model/Pet.cpp b/samples/client/petstore/cpprest/model/Pet.cpp index 5d8a4bb9725..a89406497f6 100644 --- a/samples/client/petstore/cpprest/model/Pet.cpp +++ b/samples/client/petstore/cpprest/model/Pet.cpp @@ -21,7 +21,7 @@ namespace model { Pet::Pet() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_CategoryIsSet = false; m_Name = U(""); diff --git a/samples/client/petstore/cpprest/model/Tag.cpp b/samples/client/petstore/cpprest/model/Tag.cpp index 6d5e350ab91..050bcc2d488 100644 --- a/samples/client/petstore/cpprest/model/Tag.cpp +++ b/samples/client/petstore/cpprest/model/Tag.cpp @@ -21,7 +21,7 @@ namespace model { Tag::Tag() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_Name = U(""); m_NameIsSet = false; diff --git a/samples/client/petstore/cpprest/model/User.cpp b/samples/client/petstore/cpprest/model/User.cpp index 3cf4e4258d5..9ec72d1ac98 100644 --- a/samples/client/petstore/cpprest/model/User.cpp +++ b/samples/client/petstore/cpprest/model/User.cpp @@ -21,7 +21,7 @@ namespace model { User::User() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_Username = U(""); m_UsernameIsSet = false; diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock index 18532818d14..e7791399b9a 100644 --- a/samples/client/petstore/ruby/Gemfile.lock +++ b/samples/client/petstore/ruby/Gemfile.lock @@ -2,49 +2,51 @@ PATH remote: . specs: petstore (1.0.0) - json (~> 1.8, >= 1.8.3) + json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) GEM remote: https://rubygems.org/ specs: - ZenTest (4.11.0) - addressable (2.3.8) + ZenTest (4.11.1) + addressable (2.5.1) + public_suffix (~> 2.0, >= 2.0.2) autotest (4.4.6) ZenTest (>= 4.4.1) autotest-fsevent (0.2.12) sys-uname autotest-growl (0.2.16) autotest-rails-pure (4.1.2) - crack (0.4.2) + crack (0.4.3) safe_yaml (~> 1.0.0) - diff-lcs (1.2.5) - ethon (0.8.1) + diff-lcs (1.3) + ethon (0.10.1) ffi (>= 1.3.0) - ffi (1.9.8) - hashdiff (0.3.0) - json (1.8.3) + ffi (1.9.18) + hashdiff (0.3.4) + json (2.1.0) + public_suffix (2.0.5) rake (12.0.0) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rspec (3.6.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-mocks (3.4.1) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) safe_yaml (1.0.4) sys-uname (1.0.3) ffi (>= 1.0.0) - typhoeus (1.0.1) - ethon (>= 0.8.0) - vcr (3.0.1) - webmock (1.24.5) + typhoeus (1.1.2) + ethon (>= 0.9.0) + vcr (3.0.3) + webmock (1.24.6) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff @@ -59,9 +61,6 @@ DEPENDENCIES autotest-rails-pure (~> 4.1, >= 4.1.2) petstore! rake (~> 12.0.0) - rspec (~> 3.4, >= 3.4.0) + rspec (~> 3.6, >= 3.6.0) vcr (~> 3.0, >= 3.0.1) webmock (~> 1.24, >= 1.24.3) - -BUNDLED WITH - 1.12.3 diff --git a/samples/client/petstore/ruby/docs/FakeApi.md b/samples/client/petstore/ruby/docs/FakeApi.md index 70cf50ad999..ebb6f8660fc 100644 --- a/samples/client/petstore/ruby/docs/FakeApi.md +++ b/samples/client/petstore/ruby/docs/FakeApi.md @@ -274,7 +274,7 @@ double = 1.2 # Float | None pattern_without_delimiter = "pattern_without_delimiter_example" # String | None -byte = "B" # String | None +byte = "byte_example" # String | None opts = { integer: 56, # Integer | None diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 7c896c33aa9..5c2e7513d4c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -198,6 +198,10 @@ module Petstore invalid_properties.push("invalid value for 'byte', byte cannot be nil.") end + if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/) + invalid_properties.push("invalid value for 'byte', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.") + end + if @date.nil? invalid_properties.push("invalid value for 'date', date cannot be nil.") end @@ -233,6 +237,7 @@ module Petstore return false if !@double.nil? && @double < 67.8 return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) return false if @byte.nil? + return false if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/) return false if @date.nil? return false if @password.nil? return false if @password.to_s.length > 64 @@ -329,6 +334,20 @@ module Petstore @string = string end + # Custom attribute writer method with validation + # @param [Object] byte Value to be assigned + def byte=(byte) + if byte.nil? + fail ArgumentError, "byte cannot be nil" + end + + if byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/) + fail ArgumentError, "invalid value for 'byte', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/." + end + + @byte = byte + end + # Custom attribute writer method with validation # @param [Object] password Value to be assigned def password=(password) diff --git a/samples/client/petstore/ruby/petstore.gemspec b/samples/client/petstore/ruby/petstore.gemspec index 846b2ac60ee..3dd54d3107f 100644 --- a/samples/client/petstore/ruby/petstore.gemspec +++ b/samples/client/petstore/ruby/petstore.gemspec @@ -29,9 +29,9 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 1.9" s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' - s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3' + s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0' - s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0' + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1' s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3' s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6' diff --git a/samples/client/petstore/spring-cloud/pom.xml b/samples/client/petstore/spring-cloud/pom.xml index 65849299023..b5e77c708c2 100644 --- a/samples/client/petstore/spring-cloud/pom.xml +++ b/samples/client/petstore/spring-cloud/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java @@ -25,7 +25,7 @@ org.springframework.cloud spring-cloud-starter-parent - Camden.SR1 + Dalston.SR1 pom import diff --git a/samples/client/petstore/spring-cloud/src/test/resources/application.yml b/samples/client/petstore/spring-cloud/src/test/resources/application.yml index ba42748f6ad..0386d07ce12 100644 --- a/samples/client/petstore/spring-cloud/src/test/resources/application.yml +++ b/samples/client/petstore/spring-cloud/src/test/resources/application.yml @@ -8,3 +8,4 @@ hystrix.command.default.execution.timeout.enabled: false logging.level.io.swagger.api: DEBUG +feign.hystrix.enabled: true diff --git a/samples/client/petstore/spring-stubs/pom.xml b/samples/client/petstore/spring-stubs/pom.xml index 52dd32b90f0..cfb1f67fdbd 100644 --- a/samples/client/petstore/spring-stubs/pom.xml +++ b/samples/client/petstore/spring-stubs/pom.xml @@ -42,9 +42,12 @@ - com.github.joschi.jackson - jackson-datatype-threetenbp - 2.6.4 + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + joda-time + joda-time diff --git a/samples/client/petstore/swift3/unwraprequired/.gitignore b/samples/client/petstore/swift3/unwraprequired/.gitignore new file mode 100644 index 00000000000..5e5d5cebcf4 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/.gitignore @@ -0,0 +1,63 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/samples/client/petstore/swift3/unwraprequired/.swagger-codegen-ignore b/samples/client/petstore/swift3/unwraprequired/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/swift3/unwraprequired/.swagger-codegen/VERSION b/samples/client/petstore/swift3/unwraprequired/.swagger-codegen/VERSION new file mode 100644 index 00000000000..f9f7450d135 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift3/unwraprequired/Cartfile b/samples/client/petstore/swift3/unwraprequired/Cartfile new file mode 100644 index 00000000000..3d90db16891 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/Cartfile @@ -0,0 +1 @@ +github "Alamofire/Alamofire" >= 3.1.0 diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient.podspec b/samples/client/petstore/swift3/unwraprequired/PetstoreClient.podspec new file mode 100644 index 00000000000..93a9da0c965 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = 'PetstoreClient' + s.ios.deployment_target = '9.0' + s.osx.deployment_target = '10.11' + s.version = '0.0.1' + s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' } + s.authors = '' + s.license = 'Proprietary' + s.homepage = 'https://github.com/swagger-api/swagger-codegen' + s.summary = 'PetstoreClient' + s.source_files = 'PetstoreClient/Classes/Swaggers/**/*.swift' + s.dependency 'Alamofire', '~> 4.0' +end diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIHelper.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIHelper.swift new file mode 100644 index 00000000000..b0bdb8a6c78 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIHelper.swift @@ -0,0 +1,79 @@ +// APIHelper.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + +class APIHelper { + static func rejectNil(_ source: [String:Any?]) -> [String:Any]? { + var destination = [String:Any]() + for (key, nillableValue) in source { + if let value: Any = nillableValue { + destination[key] = value + } + } + + if destination.isEmpty { + return nil + } + return destination + } + + static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] { + var destination = [String:String]() + for (key, nillableValue) in source { + if let value: Any = nillableValue { + destination[key] = "\(value)" + } + } + return destination + } + + static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? { + guard let source = source else { + return nil + } + var destination = [String:Any]() + let theTrue = NSNumber(value: true as Bool) + let theFalse = NSNumber(value: false as Bool) + for (key, value) in source { + switch value { + case let x where x as? NSNumber === theTrue || x as? NSNumber === theFalse: + destination[key] = "\(value as! Bool)" as Any? + default: + destination[key] = value + } + } + return destination + } + + static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? { + let returnValues = values + .filter { $0.1 != nil } + .map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in + if let value = item._value as? Array { + return value.map { (v) -> URLQueryItem in + URLQueryItem( + name: item._key, + value: v + ) + } + } else { + return [URLQueryItem( + name: item._key, + value: "\(item._value!)" + )] + } + } + .flatMap { $0 } + + if returnValues.count == 0 { + return nil + } + + return returnValues + } + +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs.swift new file mode 100644 index 00000000000..4edf5f440ba --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs.swift @@ -0,0 +1,77 @@ +// APIs.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + +open class PetstoreClientAPI { + open static var basePath = "http://petstore.swagger.io:80/v2" + open static var credential: URLCredential? + open static var customHeaders: [String:String] = [:] + open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() +} + +open class APIBase { + func toParameters(_ encodable: JSONEncodable?) -> [String: Any]? { + let encoded: Any? = encodable?.encodeToJSON() + + if encoded! is [Any] { + var dictionary = [String:Any]() + for (index, item) in (encoded as! [Any]).enumerated() { + dictionary["\(index)"] = item + } + return dictionary + } else { + return encoded as? [String:Any] + } + } +} + +open class RequestBuilder { + var credential: URLCredential? + var headers: [String:String] + let parameters: [String:Any]? + let isBody: Bool + let method: String + let URLString: String + + /// Optional block to obtain a reference to the request's progress instance when available. + public var onProgressReady: ((Progress) -> ())? + + required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) { + self.method = method + self.URLString = URLString + self.parameters = parameters + self.isBody = isBody + self.headers = headers + + addHeaders(PetstoreClientAPI.customHeaders) + } + + open func addHeaders(_ aHeaders:[String:String]) { + for (header, value) in aHeaders { + headers[header] = value + } + } + + open func execute(_ completion: @escaping (_ response: Response?, _ error: ErrorResponse?) -> Void) { } + + public func addHeader(name: String, value: String) -> Self { + if !value.isEmpty { + headers[name] = value + } + return self + } + + open func addCredential() -> Self { + self.credential = PetstoreClientAPI.credential + return self + } +} + +public protocol RequestBuilderFactory { + func getBuilder() -> RequestBuilder.Type +} + diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift new file mode 100644 index 00000000000..c85302a6dd5 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift @@ -0,0 +1,424 @@ +// +// FakeAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation +import Alamofire + + +open class FakeAPI: APIBase { + /** + - parameter body: (body) Input boolean as post body (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func fakeOuterBooleanSerialize(body: OuterBoolean? = nil, completion: @escaping ((_ data: OuterBoolean?, _ error: ErrorResponse?) -> Void)) { + fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + - POST /fake/outer/boolean + - Test serialization of outer boolean types + + - examples: [{contentType=application/json, example={ }}] + - parameter body: (body) Input boolean as post body (optional) + - returns: RequestBuilder + */ + open class func fakeOuterBooleanSerializeWithRequestBuilder(body: OuterBoolean? = nil) -> RequestBuilder { + let path = "/fake/outer/boolean" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + - parameter body: (body) Input composite as post body (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?, _ error: ErrorResponse?) -> Void)) { + fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + - POST /fake/outer/composite + - Test serialization of object with outer number type + + - examples: [{contentType=application/json, example={ + "my_string" : { }, + "my_number" : { }, + "my_boolean" : { } +}}] + - parameter body: (body) Input composite as post body (optional) + - returns: RequestBuilder + */ + open class func fakeOuterCompositeSerializeWithRequestBuilder(body: OuterComposite? = nil) -> RequestBuilder { + let path = "/fake/outer/composite" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + - parameter body: (body) Input number as post body (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func fakeOuterNumberSerialize(body: OuterNumber? = nil, completion: @escaping ((_ data: OuterNumber?, _ error: ErrorResponse?) -> Void)) { + fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + - POST /fake/outer/number + - Test serialization of outer number types + + - examples: [{contentType=application/json, example={ }}] + - parameter body: (body) Input number as post body (optional) + - returns: RequestBuilder + */ + open class func fakeOuterNumberSerializeWithRequestBuilder(body: OuterNumber? = nil) -> RequestBuilder { + let path = "/fake/outer/number" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + - parameter body: (body) Input string as post body (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func fakeOuterStringSerialize(body: OuterString? = nil, completion: @escaping ((_ data: OuterString?, _ error: ErrorResponse?) -> Void)) { + fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + - POST /fake/outer/string + - Test serialization of outer string types + + - examples: [{contentType=application/json, example={ }}] + - parameter body: (body) Input string as post body (optional) + - returns: RequestBuilder + */ + open class func fakeOuterStringSerializeWithRequestBuilder(body: OuterString? = nil) -> RequestBuilder { + let path = "/fake/outer/string" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + To test \"client\" model + - parameter body: (body) client model + - parameter completion: completion handler to receive the data and the error objects + */ + open class func testClientModel(body: Client, completion: @escaping ((_ data: Client?, _ error: ErrorResponse?) -> Void)) { + testClientModelWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + To test \"client\" model + - PATCH /fake + - To test \"client\" model + + - examples: [{contentType=application/json, example={ + "client" : "aeiou" +}}] + - parameter body: (body) client model + - returns: RequestBuilder + */ + open class func testClientModelWithRequestBuilder(body: Client) -> RequestBuilder { + let path = "/fake" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + - parameter number: (form) None + - parameter double: (form) None + - parameter patternWithoutDelimiter: (form) None + - parameter byte: (form) None + - parameter integer: (form) None (optional) + - parameter int32: (form) None (optional) + - parameter int64: (form) None (optional) + - parameter float: (form) None (optional) + - parameter string: (form) None (optional) + - parameter binary: (form) None (optional) + - parameter date: (form) None (optional) + - parameter dateTime: (form) None (optional) + - parameter password: (form) None (optional) + - parameter callback: (form) None (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int32? = nil, int32: Int32? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: ISOFullDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + - POST /fake + - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + - BASIC: + - type: basic + - name: http_basic_test + - parameter number: (form) None + - parameter double: (form) None + - parameter patternWithoutDelimiter: (form) None + - parameter byte: (form) None + - parameter integer: (form) None (optional) + - parameter int32: (form) None (optional) + - parameter int64: (form) None (optional) + - parameter float: (form) None (optional) + - parameter string: (form) None (optional) + - parameter binary: (form) None (optional) + - parameter date: (form) None (optional) + - parameter dateTime: (form) None (optional) + - parameter password: (form) None (optional) + - parameter callback: (form) None (optional) + - returns: RequestBuilder + */ + open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int32? = nil, int32: Int32? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: ISOFullDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder { + let path = "/fake" + let URLString = PetstoreClientAPI.basePath + path + let formParams: [String:Any?] = [ + "integer": integer?.encodeToJSON(), + "int32": int32?.encodeToJSON(), + "int64": int64?.encodeToJSON(), + "number": number, + "float": float, + "double": double, + "string": string, + "pattern_without_delimiter": patternWithoutDelimiter, + "byte": byte, + "binary": binary, + "date": date?.encodeToJSON(), + "dateTime": dateTime?.encodeToJSON(), + "password": password, + "callback": callback + ] + + let nonNullParameters = APIHelper.rejectNil(formParams) + let parameters = APIHelper.convertBoolToString(nonNullParameters) + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + * enum for parameter enumFormStringArray + */ + public enum EnumFormStringArray_testEnumParameters: String { + case greaterThan = ">" + case dollar = "$" + } + + /** + * enum for parameter enumFormString + */ + public enum EnumFormString_testEnumParameters: String { + case abc = "_abc" + case efg = "-efg" + case xyz = "(xyz)" + } + + /** + * enum for parameter enumHeaderStringArray + */ + public enum EnumHeaderStringArray_testEnumParameters: String { + case greaterThan = ">" + case dollar = "$" + } + + /** + * enum for parameter enumHeaderString + */ + public enum EnumHeaderString_testEnumParameters: String { + case abc = "_abc" + case efg = "-efg" + case xyz = "(xyz)" + } + + /** + * enum for parameter enumQueryStringArray + */ + public enum EnumQueryStringArray_testEnumParameters: String { + case greaterThan = ">" + case dollar = "$" + } + + /** + * enum for parameter enumQueryString + */ + public enum EnumQueryString_testEnumParameters: String { + case abc = "_abc" + case efg = "-efg" + case xyz = "(xyz)" + } + + /** + * enum for parameter enumQueryInteger + */ + public enum EnumQueryInteger_testEnumParameters: Int32 { + case _1 = 1 + case numberminus2 = -2 + } + + /** + * enum for parameter enumQueryDouble + */ + public enum EnumQueryDouble_testEnumParameters: Double { + case _11 = 1.1 + case numberminus12 = -1.2 + } + + /** + To test enum parameters + - parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional) + - parameter enumFormString: (form) Form parameter enum test (string) (optional, default to -efg) + - parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional) + - parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to -efg) + - parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional) + - parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to -efg) + - parameter enumQueryInteger: (query) Query parameter enum test (double) (optional) + - parameter enumQueryDouble: (form) Query parameter enum test (double) (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func testEnumParameters(enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + testEnumParametersWithRequestBuilder(enumFormStringArray: enumFormStringArray, enumFormString: enumFormString, enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + To test enum parameters + - GET /fake + - To test enum parameters + + - parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional) + - parameter enumFormString: (form) Form parameter enum test (string) (optional, default to -efg) + - parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional) + - parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to -efg) + - parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional) + - parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to -efg) + - parameter enumQueryInteger: (query) Query parameter enum test (double) (optional) + - parameter enumQueryDouble: (form) Query parameter enum test (double) (optional) + - returns: RequestBuilder + */ + open class func testEnumParametersWithRequestBuilder(enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil) -> RequestBuilder { + let path = "/fake" + let URLString = PetstoreClientAPI.basePath + path + let formParams: [String:Any?] = [ + "enum_form_string_array": enumFormStringArray, + "enum_form_string": enumFormString?.rawValue, + "enum_query_double": enumQueryDouble?.rawValue + ] + + let nonNullParameters = APIHelper.rejectNil(formParams) + let parameters = APIHelper.convertBoolToString(nonNullParameters) + + let url = NSURLComponents(string: URLString) + url?.queryItems = APIHelper.mapValuesToQueryItems(values:[ + "enum_query_string_array": enumQueryStringArray, + "enum_query_string": enumQueryString?.rawValue, + "enum_query_integer": enumQueryInteger?.rawValue + ]) + let nillableHeaders: [String: Any?] = [ + "enum_header_string_array": enumHeaderStringArray, + "enum_header_string": enumHeaderString?.rawValue + ] + let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters) + } + + /** + test json serialization of form data + - parameter param: (form) field1 + - parameter param2: (form) field2 + - parameter completion: completion handler to receive the data and the error objects + */ + open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + test json serialization of form data + - GET /fake/jsonFormData + - + + - parameter param: (form) field1 + - parameter param2: (form) field2 + - returns: RequestBuilder + */ + open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder { + let path = "/fake/jsonFormData" + let URLString = PetstoreClientAPI.basePath + path + let formParams: [String:Any?] = [ + "param": param, + "param2": param2 + ] + + let nonNullParameters = APIHelper.rejectNil(formParams) + let parameters = APIHelper.convertBoolToString(nonNullParameters) + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift new file mode 100644 index 00000000000..c8babad539f --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift @@ -0,0 +1,47 @@ +// +// Fake_classname_tags123API.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation +import Alamofire + + +open class Fake_classname_tags123API: APIBase { + /** + To test class name in snake case + - parameter body: (body) client model + - parameter completion: completion handler to receive the data and the error objects + */ + open class func testClassname(body: Client, completion: @escaping ((_ data: Client?, _ error: ErrorResponse?) -> Void)) { + testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + To test class name in snake case + - PATCH /fake_classname_test + + - examples: [{contentType=application/json, example={ + "client" : "aeiou" +}}] + - parameter body: (body) client model + - returns: RequestBuilder + */ + open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder { + let path = "/fake_classname_test" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift new file mode 100644 index 00000000000..23e2b0eb3b9 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -0,0 +1,473 @@ +// +// PetAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation +import Alamofire + + +open class PetAPI: APIBase { + /** + Add a new pet to the store + - parameter body: (body) Pet object that needs to be added to the store + - parameter completion: completion handler to receive the data and the error objects + */ + open class func addPet(body: Pet, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Add a new pet to the store + - POST /pet + - + - OAuth: + - type: oauth2 + - name: petstore_auth + - parameter body: (body) Pet object that needs to be added to the store + - returns: RequestBuilder + */ + open class func addPetWithRequestBuilder(body: Pet) -> RequestBuilder { + let path = "/pet" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + Deletes a pet + - parameter petId: (path) Pet id to delete + - parameter apiKey: (header) (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Deletes a pet + - DELETE /pet/{petId} + - + - OAuth: + - type: oauth2 + - name: petstore_auth + - parameter petId: (path) Pet id to delete + - parameter apiKey: (header) (optional) + - returns: RequestBuilder + */ + open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + let nillableHeaders: [String: Any?] = [ + "api_key": apiKey + ] + let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters) + } + + /** + * enum for parameter status + */ + public enum Status_findPetsByStatus: String { + case available = "available" + case pending = "pending" + case sold = "sold" + } + + /** + Finds Pets by status + - parameter status: (query) Status values that need to be considered for filter + - parameter completion: completion handler to receive the data and the error objects + */ + open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?, _ error: ErrorResponse?) -> Void)) { + findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Finds Pets by status + - GET /pet/findByStatus + - Multiple status values can be provided with comma separated strings + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{contentType=application/xml, example= + 123456789 + doggie + + aeiou + + + + aeiou +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= + 123456789 + doggie + + aeiou + + + + aeiou +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - parameter status: (query) Status values that need to be considered for filter + - returns: RequestBuilder<[Pet]> + */ + open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> { + let path = "/pet/findByStatus" + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + url?.queryItems = APIHelper.mapValuesToQueryItems(values:[ + "status": status + ]) + + let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Finds Pets by tags + - parameter tags: (query) Tags to filter by + - parameter completion: completion handler to receive the data and the error objects + */ + open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?, _ error: ErrorResponse?) -> Void)) { + findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Finds Pets by tags + - GET /pet/findByTags + - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{contentType=application/xml, example= + 123456789 + doggie + + aeiou + + + + aeiou +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= + 123456789 + doggie + + aeiou + + + + aeiou +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - parameter tags: (query) Tags to filter by + - returns: RequestBuilder<[Pet]> + */ + open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> { + let path = "/pet/findByTags" + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + url?.queryItems = APIHelper.mapValuesToQueryItems(values:[ + "tags": tags + ]) + + let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Find pet by ID + - parameter petId: (path) ID of pet to return + - parameter completion: completion handler to receive the data and the error objects + */ + open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?, _ error: ErrorResponse?) -> Void)) { + getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Find pet by ID + - GET /pet/{petId} + - Returns a single pet + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/xml, example= + 123456789 + doggie + + aeiou + + + + aeiou +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] + - examples: [{contentType=application/xml, example= + 123456789 + doggie + + aeiou + + + + aeiou +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] + - parameter petId: (path) ID of pet to return + - returns: RequestBuilder + */ + open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Update an existing pet + - parameter body: (body) Pet object that needs to be added to the store + - parameter completion: completion handler to receive the data and the error objects + */ + open class func updatePet(body: Pet, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Update an existing pet + - PUT /pet + - + - OAuth: + - type: oauth2 + - name: petstore_auth + - parameter body: (body) Pet object that needs to be added to the store + - returns: RequestBuilder + */ + open class func updatePetWithRequestBuilder(body: Pet) -> RequestBuilder { + let path = "/pet" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + Updates a pet in the store with form data + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet (optional) + - parameter status: (form) Updated status of the pet (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Updates a pet in the store with form data + - POST /pet/{petId} + - + - OAuth: + - type: oauth2 + - name: petstore_auth + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet (optional) + - parameter status: (form) Updated status of the pet (optional) + - returns: RequestBuilder + */ + open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let formParams: [String:Any?] = [ + "name": name, + "status": status + ] + + let nonNullParameters = APIHelper.rejectNil(formParams) + let parameters = APIHelper.convertBoolToString(nonNullParameters) + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + uploads an image + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server (optional) + - parameter file: (form) file to upload (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: ErrorResponse?) -> Void)) { + uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + uploads an image + - POST /pet/{petId}/uploadImage + - + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{contentType=application/json, example={ + "code" : 0, + "type" : "aeiou", + "message" : "aeiou" +}}] + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server (optional) + - parameter file: (form) file to upload (optional) + - returns: RequestBuilder + */ + open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder { + var path = "/pet/{petId}/uploadImage" + path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let formParams: [String:Any?] = [ + "additionalMetadata": additionalMetadata, + "file": file + ] + + let nonNullParameters = APIHelper.rejectNil(formParams) + let parameters = APIHelper.convertBoolToString(nonNullParameters) + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift new file mode 100644 index 00000000000..024c99c7453 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -0,0 +1,206 @@ +// +// StoreAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation +import Alamofire + + +open class StoreAPI: APIBase { + /** + Delete purchase order by ID + - parameter orderId: (path) ID of the order that needs to be deleted + - parameter completion: completion handler to receive the data and the error objects + */ + open class func deleteOrder(orderId: String, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Delete purchase order by ID + - DELETE /store/order/{order_id} + - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + + - parameter orderId: (path) ID of the order that needs to be deleted + - returns: RequestBuilder + */ + open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder { + var path = "/store/order/{order_id}" + path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Returns pet inventories by status + - parameter completion: completion handler to receive the data and the error objects + */ + open class func getInventory(completion: @escaping ((_ data: [String:Int32]?, _ error: ErrorResponse?) -> Void)) { + getInventoryWithRequestBuilder().execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Returns pet inventories by status + - GET /store/inventory + - Returns a map of status codes to quantities + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/json, example={ + "key" : 0 +}}] + - returns: RequestBuilder<[String:Int32]> + */ + open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int32]> { + let path = "/store/inventory" + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder<[String:Int32]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Find purchase order by ID + - parameter orderId: (path) ID of pet that needs to be fetched + - parameter completion: completion handler to receive the data and the error objects + */ + open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?, _ error: ErrorResponse?) -> Void)) { + getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Find purchase order by ID + - GET /store/order/{order_id} + - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + + - examples: [{contentType=application/xml, example= + 123456789 + 123456789 + 123 + 2000-01-23T04:56:07.000Z + aeiou + true +}, {contentType=application/json, example={ + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= + 123456789 + 123456789 + 123 + 2000-01-23T04:56:07.000Z + aeiou + true +}, {contentType=application/json, example={ + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - parameter orderId: (path) ID of pet that needs to be fetched + - returns: RequestBuilder + */ + open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder { + var path = "/store/order/{order_id}" + path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Place an order for a pet + - parameter body: (body) order placed for purchasing the pet + - parameter completion: completion handler to receive the data and the error objects + */ + open class func placeOrder(body: Order, completion: @escaping ((_ data: Order?, _ error: ErrorResponse?) -> Void)) { + placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Place an order for a pet + - POST /store/order + - + + - examples: [{contentType=application/xml, example= + 123456789 + 123456789 + 123 + 2000-01-23T04:56:07.000Z + aeiou + true +}, {contentType=application/json, example={ + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= + 123456789 + 123456789 + 123 + 2000-01-23T04:56:07.000Z + aeiou + true +}, {contentType=application/json, example={ + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - parameter body: (body) order placed for purchasing the pet + - returns: RequestBuilder + */ + open class func placeOrderWithRequestBuilder(body: Order) -> RequestBuilder { + let path = "/store/order" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift new file mode 100644 index 00000000000..2bf409fadfa --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -0,0 +1,320 @@ +// +// UserAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation +import Alamofire + + +open class UserAPI: APIBase { + /** + Create user + - parameter body: (body) Created user object + - parameter completion: completion handler to receive the data and the error objects + */ + open class func createUser(body: User, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + createUserWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Create user + - POST /user + - This can only be done by the logged in user. + + - parameter body: (body) Created user object + - returns: RequestBuilder + */ + open class func createUserWithRequestBuilder(body: User) -> RequestBuilder { + let path = "/user" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + Creates list of users with given input array + - parameter body: (body) List of user object + - parameter completion: completion handler to receive the data and the error objects + */ + open class func createUsersWithArrayInput(body: [User], completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + createUsersWithArrayInputWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Creates list of users with given input array + - POST /user/createWithArray + - + + - parameter body: (body) List of user object + - returns: RequestBuilder + */ + open class func createUsersWithArrayInputWithRequestBuilder(body: [User]) -> RequestBuilder { + let path = "/user/createWithArray" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + Creates list of users with given input array + - parameter body: (body) List of user object + - parameter completion: completion handler to receive the data and the error objects + */ + open class func createUsersWithListInput(body: [User], completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + createUsersWithListInputWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Creates list of users with given input array + - POST /user/createWithList + - + + - parameter body: (body) List of user object + - returns: RequestBuilder + */ + open class func createUsersWithListInputWithRequestBuilder(body: [User]) -> RequestBuilder { + let path = "/user/createWithList" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + + /** + Delete user + - parameter username: (path) The name that needs to be deleted + - parameter completion: completion handler to receive the data and the error objects + */ + open class func deleteUser(username: String, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Delete user + - DELETE /user/{username} + - This can only be done by the logged in user. + + - parameter username: (path) The name that needs to be deleted + - returns: RequestBuilder + */ + open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder { + var path = "/user/{username}" + path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Get user by user name + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + - parameter completion: completion handler to receive the data and the error objects + */ + open class func getUserByName(username: String, completion: @escaping ((_ data: User?, _ error: ErrorResponse?) -> Void)) { + getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Get user by user name + - GET /user/{username} + - + + - examples: [{contentType=application/xml, example= + 123456789 + aeiou + aeiou + aeiou + aeiou + aeiou + aeiou + 123 +}, {contentType=application/json, example={ + "firstName" : "aeiou", + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] + - examples: [{contentType=application/xml, example= + 123456789 + aeiou + aeiou + aeiou + aeiou + aeiou + aeiou + 123 +}, {contentType=application/json, example={ + "firstName" : "aeiou", + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + - returns: RequestBuilder + */ + open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder { + var path = "/user/{username}" + path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Logs user into the system + - parameter username: (query) The user name for login + - parameter password: (query) The password for login in clear text + - parameter completion: completion handler to receive the data and the error objects + */ + open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?, _ error: ErrorResponse?) -> Void)) { + loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in + completion(response?.body, error) + } + } + + + /** + Logs user into the system + - GET /user/login + - + + - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] + - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - parameter username: (query) The user name for login + - parameter password: (query) The password for login in clear text + - returns: RequestBuilder + */ + open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder { + let path = "/user/login" + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + url?.queryItems = APIHelper.mapValuesToQueryItems(values:[ + "username": username, + "password": password + ]) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Logs out current logged in user session + - parameter completion: completion handler to receive the data and the error objects + */ + open class func logoutUser(completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + logoutUserWithRequestBuilder().execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Logs out current logged in user session + - GET /user/logout + - + + - returns: RequestBuilder + */ + open class func logoutUserWithRequestBuilder() -> RequestBuilder { + let path = "/user/logout" + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) + } + + /** + Updated user + - parameter username: (path) name that need to be deleted + - parameter body: (body) Updated user object + - parameter completion: completion handler to receive the data and the error objects + */ + open class func updateUser(username: String, body: User, completion: @escaping ((_ error: ErrorResponse?) -> Void)) { + updateUserWithRequestBuilder(username: username, body: body).execute { (response, error) -> Void in + completion(error) + } + } + + + /** + Updated user + - PUT /user/{username} + - This can only be done by the logged in user. + + - parameter username: (path) name that need to be deleted + - parameter body: (body) Updated user object + - returns: RequestBuilder + */ + open class func updateUserWithRequestBuilder(username: String, body: User) -> RequestBuilder { + var path = "/user/{username}" + path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters = body.encodeToJSON() as? [String:AnyObject] + + let url = NSURLComponents(string: URLString) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) + } + +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift new file mode 100644 index 00000000000..fd981a05b05 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift @@ -0,0 +1,256 @@ +// AlamofireImplementations.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation +import Alamofire + +class AlamofireRequestBuilderFactory: RequestBuilderFactory { + func getBuilder() -> RequestBuilder.Type { + return AlamofireRequestBuilder.self + } +} + +private struct SynchronizedDictionary { + + private var dictionary = [K: V]() + private let queue = DispatchQueue( + label: "SynchronizedDictionary", + qos: DispatchQoS.userInitiated, + attributes: [DispatchQueue.Attributes.concurrent], + autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, + target: nil + ) + + public subscript(key: K) -> V? { + get { + var value: V? + + queue.sync { + value = self.dictionary[key] + } + + return value + } + set { + queue.sync(flags: DispatchWorkItemFlags.barrier) { + self.dictionary[key] = newValue + } + } + } + +} + +// Store manager to retain its reference +private var managerStore = SynchronizedDictionary() + +open class AlamofireRequestBuilder: RequestBuilder { + required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) { + super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers) + } + + /** + May be overridden by a subclass if you want to control the session + configuration. + */ + open func createSessionManager() -> Alamofire.SessionManager { + let configuration = URLSessionConfiguration.default + configuration.httpAdditionalHeaders = buildHeaders() + return Alamofire.SessionManager(configuration: configuration) + } + + /** + May be overridden by a subclass if you want to control the Content-Type + that is given to an uploaded form part. + + Return nil to use the default behavior (inferring the Content-Type from + the file extension). Return the desired Content-Type otherwise. + */ + open func contentTypeForFormPart(fileURL: URL) -> String? { + return nil + } + + /** + May be overridden by a subclass if you want to control the request + configuration (e.g. to override the cache policy). + */ + open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String:String]) -> DataRequest { + return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: headers) + } + + override open func execute(_ completion: @escaping (_ response: Response?, _ error: ErrorResponse?) -> Void) { + let managerId:String = UUID().uuidString + // Create a new manager for each request to customize its request header + let manager = createSessionManager() + managerStore[managerId] = manager + + let encoding:ParameterEncoding = isBody ? JSONEncoding() : URLEncoding() + + let xMethod = Alamofire.HTTPMethod(rawValue: method) + let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL } + .map { $0.0 } + + if fileKeys.count > 0 { + manager.upload(multipartFormData: { mpForm in + for (k, v) in self.parameters! { + switch v { + case let fileURL as URL: + if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) { + mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType) + } + else { + mpForm.append(fileURL, withName: k) + } + break + case let string as String: + mpForm.append(string.data(using: String.Encoding.utf8)!, withName: k) + break + case let number as NSNumber: + mpForm.append(number.stringValue.data(using: String.Encoding.utf8)!, withName: k) + break + default: + fatalError("Unprocessable value \(v) with key \(k)") + break + } + } + }, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in + switch encodingResult { + case .success(let upload, _, _): + if let onProgressReady = self.onProgressReady { + onProgressReady(upload.uploadProgress) + } + self.processRequest(request: upload, managerId, completion) + case .failure(let encodingError): + completion(nil, ErrorResponse.HttpError(statusCode: 415, data: nil, error: encodingError)) + } + }) + } else { + let request = makeRequest(manager: manager, method: xMethod!, encoding: encoding, headers: headers) + if let onProgressReady = self.onProgressReady { + onProgressReady(request.progress) + } + processRequest(request: request, managerId, completion) + } + + } + + private func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response?, _ error: ErrorResponse?) -> Void) { + if let credential = self.credential { + request.authenticate(usingCredential: credential) + } + + let cleanupRequest = { + managerStore[managerId] = nil + } + + let validatedRequest = request.validate() + + switch T.self { + case is String.Type: + validatedRequest.responseString(completionHandler: { (stringResponse) in + cleanupRequest() + + if stringResponse.result.isFailure { + completion( + nil, + ErrorResponse.HttpError(statusCode: stringResponse.response?.statusCode ?? 500, data: stringResponse.data, error: stringResponse.result.error as Error!) + ) + return + } + + completion( + Response( + response: stringResponse.response!, + body: ((stringResponse.result.value ?? "") as! T) + ), + nil + ) + }) + case is Void.Type: + validatedRequest.responseData(completionHandler: { (voidResponse) in + cleanupRequest() + + if voidResponse.result.isFailure { + completion( + nil, + ErrorResponse.HttpError(statusCode: voidResponse.response?.statusCode ?? 500, data: voidResponse.data, error: voidResponse.result.error!) + ) + return + } + + completion( + Response( + response: voidResponse.response!, + body: nil), + nil + ) + }) + case is Data.Type: + validatedRequest.responseData(completionHandler: { (dataResponse) in + cleanupRequest() + + if (dataResponse.result.isFailure) { + completion( + nil, + ErrorResponse.HttpError(statusCode: dataResponse.response?.statusCode ?? 500, data: dataResponse.data, error: dataResponse.result.error!) + ) + return + } + + completion( + Response( + response: dataResponse.response!, + body: (dataResponse.data as! T) + ), + nil + ) + }) + default: + validatedRequest.responseJSON(options: .allowFragments) { response in + cleanupRequest() + + if response.result.isFailure { + completion(nil, ErrorResponse.HttpError(statusCode: response.response?.statusCode ?? 500, data: response.data, error: response.result.error!)) + return + } + + // handle HTTP 204 No Content + // NSNull would crash decoders + if response.response?.statusCode == 204 && response.result.value is NSNull{ + completion(nil, nil) + return + } + + if () is T { + completion(Response(response: response.response!, body: (() as! T)), nil) + return + } + if let json: Any = response.result.value { + let decoded = Decoders.decode(clazz: T.self, source: json as AnyObject, instance: nil) + switch decoded { + case let .success(object): completion(Response(response: response.response!, body: object), nil) + case let .failure(error): completion(nil, ErrorResponse.DecodeError(response: response.data, decodeError: error)) + } + return + } else if "" is T { + // swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release + // https://github.com/swagger-api/swagger-parser/pull/34 + completion(Response(response: response.response!, body: ("" as! T)), nil) + return + } + + completion(nil, ErrorResponse.HttpError(statusCode: 500, data: nil, error: NSError(domain: "localhost", code: 500, userInfo: ["reason": "unreacheable code"]))) + } + } + } + + open func buildHeaders() -> [String: String] { + var httpHeaders = SessionManager.defaultHTTPHeaders + for (key, value) in self.headers { + httpHeaders[key] = value + } + return httpHeaders + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Extensions.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Extensions.swift new file mode 100644 index 00000000000..db5466651e1 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Extensions.swift @@ -0,0 +1,187 @@ +// Extensions.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation +import Alamofire + +extension Bool: JSONEncodable { + func encodeToJSON() -> Any { return self as Any } +} + +extension Float: JSONEncodable { + func encodeToJSON() -> Any { return self as Any } +} + +extension Int: JSONEncodable { + func encodeToJSON() -> Any { return self as Any } +} + +extension Int32: JSONEncodable { + func encodeToJSON() -> Any { return NSNumber(value: self as Int32) } +} + +extension Int64: JSONEncodable { + func encodeToJSON() -> Any { return NSNumber(value: self as Int64) } +} + +extension Double: JSONEncodable { + func encodeToJSON() -> Any { return self as Any } +} + +extension String: JSONEncodable { + func encodeToJSON() -> Any { return self as Any } +} + +private func encodeIfPossible(_ object: T) -> Any { + if let encodableObject = object as? JSONEncodable { + return encodableObject.encodeToJSON() + } else { + return object as Any + } +} + +extension Array: JSONEncodable { + func encodeToJSON() -> Any { + return self.map(encodeIfPossible) + } +} + +extension Dictionary: JSONEncodable { + func encodeToJSON() -> Any { + var dictionary = [AnyHashable: Any]() + for (key, value) in self { + dictionary[key as! NSObject] = encodeIfPossible(value) + } + return dictionary as Any + } +} + +extension Data: JSONEncodable { + func encodeToJSON() -> Any { + return self.base64EncodedString(options: Data.Base64EncodingOptions()) + } +} + +private let dateFormatter: DateFormatter = { + let fmt = DateFormatter() + fmt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + fmt.locale = Locale(identifier: "en_US_POSIX") + return fmt +}() + +extension Date: JSONEncodable { + func encodeToJSON() -> Any { + return dateFormatter.string(from: self) as Any + } +} + +extension UUID: JSONEncodable { + func encodeToJSON() -> Any { + return self.uuidString + } +} + +/// Represents an ISO-8601 full-date (RFC-3339). +/// ex: 12-31-1999 +/// https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14 +public final class ISOFullDate: CustomStringConvertible { + + public let year: Int + public let month: Int + public let day: Int + + public init(year: Int, month: Int, day: Int) { + self.year = year + self.month = month + self.day = day + } + + /** + Converts a Date to an ISOFullDate. Only interested in the year, month, day components. + + - parameter date: The date to convert. + + - returns: An ISOFullDate constructed from the year, month, day of the date. + */ + public static func from(date: Date) -> ISOFullDate? { + let calendar = Calendar(identifier: .gregorian) + + let components = calendar.dateComponents( + [ + .year, + .month, + .day, + ], + from: date + ) + + guard + let year = components.year, + let month = components.month, + let day = components.day + else { + return nil + } + + return ISOFullDate( + year: year, + month: month, + day: day + ) + } + + /** + Converts a ISO-8601 full-date string to an ISOFullDate. + + - parameter string: The ISO-8601 full-date format string to convert. + + - returns: An ISOFullDate constructed from the string. + */ + public static func from(string: String) -> ISOFullDate? { + let components = string + .characters + .split(separator: "-") + .map(String.init) + .flatMap { Int($0) } + guard components.count == 3 else { return nil } + + return ISOFullDate( + year: components[0], + month: components[1], + day: components[2] + ) + } + + /** + Converts the receiver to a Date, in the default time zone. + + - returns: A Date from the components of the receiver, in the default time zone. + */ + public func toDate() -> Date? { + var components = DateComponents() + components.year = year + components.month = month + components.day = day + components.timeZone = TimeZone.ReferenceType.default + let calendar = Calendar(identifier: .gregorian) + return calendar.date(from: components) + } + + // MARK: CustomStringConvertible + + public var description: String { + return "\(year)-\(month)-\(day)" + } + +} + +extension ISOFullDate: JSONEncodable { + public func encodeToJSON() -> Any { + return "\(year)-\(month)-\(day)" + } +} + + diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models.swift new file mode 100644 index 00000000000..1dbe5555d92 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models.swift @@ -0,0 +1,951 @@ +// Models.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + +protocol JSONEncodable { + func encodeToJSON() -> Any +} + +public enum ErrorResponse : Error { + case HttpError(statusCode: Int, data: Data?, error: Error) + case DecodeError(response: Data?, decodeError: DecodeError) +} + +open class Response { + open let statusCode: Int + open let header: [String: String] + open let body: T? + + public init(statusCode: Int, header: [String: String], body: T?) { + self.statusCode = statusCode + self.header = header + self.body = body + } + + public convenience init(response: HTTPURLResponse, body: T?) { + let rawHeader = response.allHeaderFields + var header = [String:String]() + for (key, value) in rawHeader { + header[key as! String] = value as? String + } + self.init(statusCode: response.statusCode, header: header, body: body) + } +} + +public enum Decoded { + case success(ValueType) + case failure(DecodeError) +} + +public extension Decoded { + var value: ValueType? { + switch self { + case let .success(value): + return value + case .failure: + return nil + } + } +} + +public enum DecodeError { + case typeMismatch(expected: String, actual: String) + case missingKey(key: String) + case parseError(message: String) +} + +private var once = Int() +class Decoders { + static fileprivate var decoders = Dictionary AnyObject)>() + + static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject, AnyObject?) -> Decoded)) { + let key = "\(T.self)" + decoders[key] = { decoder($0, $1) as AnyObject } + } + + static func decode(clazz: T.Type, discriminator: String, source: AnyObject) -> Decoded { + let key = discriminator + if let decoder = decoders[key], let value = decoder(source, nil) as? Decoded { + return value + } else { + return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source))) + } + } + + static func decode(clazz: [T].Type, source: AnyObject) -> Decoded<[T]> { + if let sourceArray = source as? [AnyObject] { + var values = [T]() + for sourceValue in sourceArray { + switch Decoders.decode(clazz: T.self, source: sourceValue, instance: nil) { + case let .success(value): + values.append(value) + case let .failure(error): + return .failure(error) + } + } + return .success(values) + } else { + return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source))) + } + } + + static func decode(clazz: [Key:T].Type, source: AnyObject) -> Decoded<[Key:T]> { + if let sourceDictionary = source as? [Key: AnyObject] { + var dictionary = [Key:T]() + for (key, value) in sourceDictionary { + switch Decoders.decode(clazz: T.self, source: value, instance: nil) { + case let .success(value): + dictionary[key] = value + case let .failure(error): + return .failure(error) + } + } + return .success(dictionary) + } else { + return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source))) + } + } + + static func decodeOptional(clazz: T.Type, source: AnyObject?) -> Decoded { + guard !(source is NSNull), source != nil else { return .success(nil) } + if let value = source as? T.RawValue { + if let enumValue = T.init(rawValue: value) { + return .success(enumValue) + } else { + return .failure(.typeMismatch(expected: "A value from the enumeration \(T.self)", actual: "\(value)")) + } + } else { + return .failure(.typeMismatch(expected: "\(T.RawValue.self) matching a case from the enumeration \(T.self)", actual: String(describing: type(of: source)))) + } + } + + static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded { + initialize() + if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type { + return .success(value) + } + if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type { + return .success(value) + } + if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type { + return .success(value) + } + if let value = source as? T { + return .success(value) + } + if let intermediate = source as? String, let value = Data(base64Encoded: intermediate) as? T { + return .success(value) + } + + let key = "\(T.self)" + if let decoder = decoders[key], let value = decoder(source, instance) as? Decoded { + return value + } else { + return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source))) + } + } + + //Convert a Decoded so that its value is optional. DO WE STILL NEED THIS? + static func toOptional(decoded: Decoded) -> Decoded { + return .success(decoded.value) + } + + static func decodeOptional(clazz: T.Type, source: AnyObject?) -> Decoded { + if let source = source, !(source is NSNull) { + switch Decoders.decode(clazz: clazz, source: source, instance: nil) { + case let .success(value): return .success(value) + case let .failure(error): return .failure(error) + } + } else { + return .success(nil) + } + } + + static func decodeOptional(clazz: [T].Type, source: AnyObject?) -> Decoded<[T]?> { + if let source = source as? [AnyObject] { + var values = [T]() + for sourceValue in source { + switch Decoders.decode(clazz: T.self, source: sourceValue, instance: nil) { + case let .success(value): values.append(value) + case let .failure(error): return .failure(error) + } + } + return .success(values) + } else { + return .success(nil) + } + } + + static func decodeOptional(clazz: [Key:T].Type, source: AnyObject?) -> Decoded<[Key:T]?> { + if let sourceDictionary = source as? [Key: AnyObject] { + var dictionary = [Key:T]() + for (key, value) in sourceDictionary { + switch Decoders.decode(clazz: T.self, source: value, instance: nil) { + case let .success(value): dictionary[key] = value + case let .failure(error): return .failure(error) + } + } + return .success(dictionary) + } else { + return .success(nil) + } + } + + static func decodeOptional(clazz: T, source: AnyObject) -> Decoded { + if let value = source as? U { + if let enumValue = T.init(rawValue: value) { + return .success(enumValue) + } else { + return .failure(.typeMismatch(expected: "A value from the enumeration \(T.self)", actual: "\(value)")) + } + } else { + return .failure(.typeMismatch(expected: "String", actual: String(describing: type(of: source)))) + } + } + + + private static var __once: () = { + let formatters = [ + "yyyy-MM-dd", + "yyyy-MM-dd'T'HH:mm:ssZZZZZ", + "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ", + "yyyy-MM-dd'T'HH:mm:ss'Z'", + "yyyy-MM-dd'T'HH:mm:ss.SSS", + "yyyy-MM-dd HH:mm:ss" + ].map { (format: String) -> DateFormatter in + let formatter = DateFormatter() + formatter.dateFormat = format + return formatter + } + // Decoder for Date + Decoders.addDecoder(clazz: Date.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceString = source as? String { + for formatter in formatters { + if let date = formatter.date(from: sourceString) { + return .success(date) + } + } + } + if let sourceInt = source as? Int { + // treat as a java date + return .success(Date(timeIntervalSince1970: Double(sourceInt / 1000) )) + } + if source is String || source is Int { + return .failure(.parseError(message: "Could not decode date")) + } else { + return .failure(.typeMismatch(expected: "String or Int", actual: "\(source)")) + } + } + + // Decoder for ISOFullDate + Decoders.addDecoder(clazz: ISOFullDate.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let string = source as? String, + let isoDate = ISOFullDate.from(string: string) { + return .success(isoDate) + } else { + return .failure(.typeMismatch(expected: "ISO date", actual: "\(source)")) + } + } + + // Decoder for AdditionalPropertiesClass + Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = AdditionalPropertiesClass() + switch Decoders.decodeOptional(clazz: [String:String].self, source: sourceDictionary["map_property"] as AnyObject?) { + case let .success(value): instance.mapProperty = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: [String:[String:String]].self, source: sourceDictionary["map_of_map_property"] as AnyObject?) { + case let .success(value): instance.mapOfMapProperty = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "AdditionalPropertiesClass", actual: "\(source)")) + } + } + // Decoder for Animal + Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + // Check discriminator to support inheritance + if let discriminator = sourceDictionary["className"] as? String, instance == nil && discriminator != "Animal"{ + return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source) + } + guard let classNameSource = sourceDictionary["className"] as AnyObject? else { + return .failure(.missingKey(key: "className")) + } + guard let className = Decoders.decode(clazz: String.self.self, source: classNameSource).value else { + return .failure(.typeMismatch(expected: "Animal", actual: "\(classNameSource)")) + } + let result = Animal(className: className) + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) { + case let .success(value): instance.color = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Animal", actual: "\(source)")) + } + } + // Decoder for ApiResponse + Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = ApiResponse() + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) { + case let .success(value): instance.code = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) { + case let .success(value): instance.type = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) { + case let .success(value): instance.message = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "ApiResponse", actual: "\(source)")) + } + } + // Decoder for ArrayOfArrayOfNumberOnly + Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = ArrayOfArrayOfNumberOnly() + switch Decoders.decodeOptional(clazz: [[Double]].self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) { + case let .success(value): instance.arrayArrayNumber = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "ArrayOfArrayOfNumberOnly", actual: "\(source)")) + } + } + // Decoder for ArrayOfNumberOnly + Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = ArrayOfNumberOnly() + switch Decoders.decodeOptional(clazz: [Double].self, source: sourceDictionary["ArrayNumber"] as AnyObject?) { + case let .success(value): instance.arrayNumber = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "ArrayOfNumberOnly", actual: "\(source)")) + } + } + // Decoder for ArrayTest + Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = ArrayTest() + switch Decoders.decodeOptional(clazz: [String].self, source: sourceDictionary["array_of_string"] as AnyObject?) { + case let .success(value): instance.arrayOfString = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: [[Int64]].self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) { + case let .success(value): instance.arrayArrayOfInteger = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: [[ReadOnlyFirst]].self, source: sourceDictionary["array_array_of_model"] as AnyObject?) { + case let .success(value): instance.arrayArrayOfModel = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "ArrayTest", actual: "\(source)")) + } + } + // Decoder for Capitalization + Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = Capitalization() + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) { + case let .success(value): instance.smallCamel = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) { + case let .success(value): instance.capitalCamel = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) { + case let .success(value): instance.smallSnake = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) { + case let .success(value): instance.capitalSnake = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) { + case let .success(value): instance.sCAETHFlowPoints = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) { + case let .success(value): instance.ATT_NAME = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Capitalization", actual: "\(source)")) + } + } + // Decoder for Category + Decoders.addDecoder(clazz: Category.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = Category() + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) { + case let .success(value): instance.id = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) { + case let .success(value): instance.name = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Category", actual: "\(source)")) + } + } + // Decoder for ClassModel + Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = ClassModel() + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) { + case let .success(value): instance._class = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "ClassModel", actual: "\(source)")) + } + } + // Decoder for Client + Decoders.addDecoder(clazz: Client.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = Client() + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) { + case let .success(value): instance.client = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Client", actual: "\(source)")) + } + } + // Decoder for EnumArrays + Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = EnumArrays() + switch Decoders.decodeOptional(clazz: EnumArrays.JustSymbol.self, source: sourceDictionary["just_symbol"] as AnyObject?) { + case let .success(value): instance.justSymbol = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_enum"] as AnyObject?) { + case let .success(value): instance.arrayEnum = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "EnumArrays", actual: "\(source)")) + } + } + // Decoder for EnumClass + Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + //TODO: I don't think we need this anymore + return Decoders.decode(clazz: EnumClass.self, source: source, instance: instance) + } + // Decoder for EnumTest + Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = EnumTest() + switch Decoders.decodeOptional(clazz: EnumTest.EnumString.self, source: sourceDictionary["enum_string"] as AnyObject?) { + case let .success(value): instance.enumString = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: EnumTest.EnumInteger.self, source: sourceDictionary["enum_integer"] as AnyObject?) { + case let .success(value): instance.enumInteger = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: EnumTest.EnumNumber.self, source: sourceDictionary["enum_number"] as AnyObject?) { + case let .success(value): instance.enumNumber = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) { + case let .success(value): instance.outerEnum = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "EnumTest", actual: "\(source)")) + } + } + // Decoder for FormatTest + Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + guard let numberSource = sourceDictionary["number"] as AnyObject? else { + return .failure(.missingKey(key: "number")) + } + guard let number = Decoders.decode(clazz: Double.self.self, source: numberSource).value else { + return .failure(.typeMismatch(expected: "FormatTest", actual: "\(numberSource)")) + } + guard let byteSource = sourceDictionary["byte"] as AnyObject? else { + return .failure(.missingKey(key: "byte")) + } + guard let byte = Decoders.decode(clazz: Data.self.self, source: byteSource).value else { + return .failure(.typeMismatch(expected: "FormatTest", actual: "\(byteSource)")) + } + guard let dateSource = sourceDictionary["date"] as AnyObject? else { + return .failure(.missingKey(key: "date")) + } + guard let date = Decoders.decode(clazz: ISOFullDate.self.self, source: dateSource).value else { + return .failure(.typeMismatch(expected: "FormatTest", actual: "\(dateSource)")) + } + guard let passwordSource = sourceDictionary["password"] as AnyObject? else { + return .failure(.missingKey(key: "password")) + } + guard let password = Decoders.decode(clazz: String.self.self, source: passwordSource).value else { + return .failure(.typeMismatch(expected: "FormatTest", actual: "\(passwordSource)")) + } + let result = FormatTest(number: number, byte: byte, date: date, password: password) + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) { + case let .success(value): instance.integer = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) { + case let .success(value): instance.int32 = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) { + case let .success(value): instance.int64 = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) { + case let .success(value): instance.float = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) { + case let .success(value): instance.double = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) { + case let .success(value): instance.string = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) { + case let .success(value): instance.binary = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) { + case let .success(value): instance.dateTime = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) { + case let .success(value): instance.uuid = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "FormatTest", actual: "\(source)")) + } + } + // Decoder for HasOnlyReadOnly + Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = HasOnlyReadOnly() + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) { + case let .success(value): instance.bar = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) { + case let .success(value): instance.foo = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "HasOnlyReadOnly", actual: "\(source)")) + } + } + // Decoder for List + Decoders.addDecoder(clazz: List.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = List() + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) { + case let .success(value): instance._123List = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "List", actual: "\(source)")) + } + } + // Decoder for MapTest + Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = MapTest() + switch Decoders.decodeOptional(clazz: [String:[String:String]].self, source: sourceDictionary["map_map_of_string"] as AnyObject?) { + case let .success(value): instance.mapMapOfString = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: MapTest.MapOfEnumString.self, source: sourceDictionary["map_of_enum_string"] as AnyObject?) { + case let .success(value): instance.mapOfEnumString = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "MapTest", actual: "\(source)")) + } + } + // Decoder for MixedPropertiesAndAdditionalPropertiesClass + Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = MixedPropertiesAndAdditionalPropertiesClass() + switch Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) { + case let .success(value): instance.uuid = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) { + case let .success(value): instance.dateTime = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: [String:Animal].self, source: sourceDictionary["map"] as AnyObject?) { + case let .success(value): instance.map = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "MixedPropertiesAndAdditionalPropertiesClass", actual: "\(source)")) + } + } + // Decoder for Model200Response + Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = Model200Response() + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) { + case let .success(value): instance.name = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) { + case let .success(value): instance._class = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Model200Response", actual: "\(source)")) + } + } + // Decoder for Name + Decoders.addDecoder(clazz: Name.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + guard let nameSource = sourceDictionary["name"] as AnyObject? else { + return .failure(.missingKey(key: "name")) + } + guard let name = Decoders.decode(clazz: Int32.self.self, source: nameSource).value else { + return .failure(.typeMismatch(expected: "Name", actual: "\(nameSource)")) + } + let result = Name(name: name) + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) { + case let .success(value): instance.snakeCase = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) { + case let .success(value): instance.property = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) { + case let .success(value): instance._123Number = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Name", actual: "\(source)")) + } + } + // Decoder for NumberOnly + Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = NumberOnly() + switch Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) { + case let .success(value): instance.justNumber = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "NumberOnly", actual: "\(source)")) + } + } + // Decoder for Order + Decoders.addDecoder(clazz: Order.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = Order() + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) { + case let .success(value): instance.id = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) { + case let .success(value): instance.petId = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) { + case let .success(value): instance.quantity = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) { + case let .success(value): instance.shipDate = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Order.Status.self, source: sourceDictionary["status"] as AnyObject?) { + case let .success(value): instance.status = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) { + case let .success(value): instance.complete = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Order", actual: "\(source)")) + } + } + // Decoder for OuterBoolean + Decoders.addDecoder(clazz: OuterBoolean.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let source = source as? Bool { + return .success(source) + } else { + return .failure(.typeMismatch(expected: "Typealias OuterBoolean", actual: "\(source)")) + } + } + // Decoder for OuterComposite + Decoders.addDecoder(clazz: OuterComposite.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = OuterComposite() + switch Decoders.decodeOptional(clazz: OuterNumber.self, source: sourceDictionary["my_number"] as AnyObject?) { + case let .success(value): instance.myNumber = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: OuterString.self, source: sourceDictionary["my_string"] as AnyObject?) { + case let .success(value): instance.myString = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: OuterBoolean.self, source: sourceDictionary["my_boolean"] as AnyObject?) { + case let .success(value): instance.myBoolean = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "OuterComposite", actual: "\(source)")) + } + } + // Decoder for OuterEnum + Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + //TODO: I don't think we need this anymore + return Decoders.decode(clazz: OuterEnum.self, source: source, instance: instance) + } + // Decoder for OuterNumber + Decoders.addDecoder(clazz: OuterNumber.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let source = source as? Double { + return .success(source) + } else { + return .failure(.typeMismatch(expected: "Typealias OuterNumber", actual: "\(source)")) + } + } + // Decoder for OuterString + Decoders.addDecoder(clazz: OuterString.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let source = source as? String { + return .success(source) + } else { + return .failure(.typeMismatch(expected: "Typealias OuterString", actual: "\(source)")) + } + } + // Decoder for Pet + Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + guard let nameSource = sourceDictionary["name"] as AnyObject? else { + return .failure(.missingKey(key: "name")) + } + guard let name = Decoders.decode(clazz: String.self.self, source: nameSource).value else { + return .failure(.typeMismatch(expected: "Pet", actual: "\(nameSource)")) + } + guard let photoUrlsSource = sourceDictionary["photoUrls"] as AnyObject? else { + return .failure(.missingKey(key: "photoUrls")) + } + guard let photoUrls = Decoders.decode(clazz: [String].self.self, source: photoUrlsSource).value else { + return .failure(.typeMismatch(expected: "Pet", actual: "\(photoUrlsSource)")) + } + let result = Pet(name: name, photoUrls: photoUrls) + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) { + case let .success(value): instance.id = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) { + case let .success(value): instance.category = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: [Tag].self, source: sourceDictionary["tags"] as AnyObject?) { + case let .success(value): instance.tags = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Pet.Status.self, source: sourceDictionary["status"] as AnyObject?) { + case let .success(value): instance.status = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Pet", actual: "\(source)")) + } + } + // Decoder for ReadOnlyFirst + Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = ReadOnlyFirst() + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) { + case let .success(value): instance.bar = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) { + case let .success(value): instance.baz = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "ReadOnlyFirst", actual: "\(source)")) + } + } + // Decoder for Return + Decoders.addDecoder(clazz: Return.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = Return() + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) { + case let .success(value): instance._return = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Return", actual: "\(source)")) + } + } + // Decoder for SpecialModelName + Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = SpecialModelName() + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) { + case let .success(value): instance.specialPropertyName = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "SpecialModelName", actual: "\(source)")) + } + } + // Decoder for Tag + Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = Tag() + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) { + case let .success(value): instance.id = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) { + case let .success(value): instance.name = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Tag", actual: "\(source)")) + } + } + // Decoder for User + Decoders.addDecoder(clazz: User.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + let result = User() + switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) { + case let .success(value): instance.id = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) { + case let .success(value): instance.username = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) { + case let .success(value): instance.firstName = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) { + case let .success(value): instance.lastName = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) { + case let .success(value): instance.email = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) { + case let .success(value): instance.password = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) { + case let .success(value): instance.phone = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) { + case let .success(value): instance.userStatus = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "User", actual: "\(source)")) + } + } + // Decoder for Cat + Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + guard let classNameSource = sourceDictionary["className"] as AnyObject? else { + return .failure(.missingKey(key: "className")) + } + guard let className = Decoders.decode(clazz: String.self.self, source: classNameSource).value else { + return .failure(.typeMismatch(expected: "Cat", actual: "\(classNameSource)")) + } + let result = Cat(className: className) + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) { + case let .success(value): instance.color = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) { + case let .success(value): instance.declawed = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Cat", actual: "\(source)")) + } + } + // Decoder for Dog + Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject, instance: AnyObject?) -> Decoded in + if let sourceDictionary = source as? [AnyHashable: Any] { + guard let classNameSource = sourceDictionary["className"] as AnyObject? else { + return .failure(.missingKey(key: "className")) + } + guard let className = Decoders.decode(clazz: String.self.self, source: classNameSource).value else { + return .failure(.typeMismatch(expected: "Dog", actual: "\(classNameSource)")) + } + let result = Dog(className: className) + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) { + case let .success(value): instance.color = value + case let .failure(error): return .failure(error) + } + switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) { + case let .success(value): instance.breed = value + case let .failure(error): return .failure(error) + } + return .success(result) + } else { + return .failure(.typeMismatch(expected: "Dog", actual: "\(source)")) + } + } + }() + + static fileprivate func initialize() { + _ = Decoders.__once + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/AdditionalPropertiesClass.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/AdditionalPropertiesClass.swift new file mode 100644 index 00000000000..73abbb57152 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/AdditionalPropertiesClass.swift @@ -0,0 +1,30 @@ +// +// AdditionalPropertiesClass.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class AdditionalPropertiesClass: JSONEncodable { + + public var mapProperty: [String:String]? + public var mapOfMapProperty: [String:[String:String]]? + + + public init(mapProperty: [String:String]?=nil, mapOfMapProperty: [String:[String:String]]?=nil) { + self.mapProperty = mapProperty + self.mapOfMapProperty = mapOfMapProperty + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["map_property"] = self.mapProperty?.encodeToJSON() + nillableDictionary["map_of_map_property"] = self.mapOfMapProperty?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Animal.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Animal.swift new file mode 100644 index 00000000000..43a7dbf80a1 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Animal.swift @@ -0,0 +1,30 @@ +// +// Animal.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Animal: JSONEncodable { + + public var className: String + public var color: String? + + + public init(className: String, color: String?=nil) { + self.className = className + self.color = color + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["className"] = self.className + nillableDictionary["color"] = self.color + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/AnimalFarm.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/AnimalFarm.swift new file mode 100644 index 00000000000..68308364894 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/AnimalFarm.swift @@ -0,0 +1,11 @@ +// +// AnimalFarm.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public typealias AnimalFarm = [Animal] diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ApiResponse.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ApiResponse.swift new file mode 100644 index 00000000000..1a90746de38 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ApiResponse.swift @@ -0,0 +1,33 @@ +// +// ApiResponse.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class ApiResponse: JSONEncodable { + + public var code: Int32? + public var type: String? + public var message: String? + + + public init(code: Int32?=nil, type: String?=nil, message: String?=nil) { + self.code = code + self.type = type + self.message = message + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["code"] = self.code?.encodeToJSON() + nillableDictionary["type"] = self.type + nillableDictionary["message"] = self.message + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayOfArrayOfNumberOnly.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayOfArrayOfNumberOnly.swift new file mode 100644 index 00000000000..4d2f38a6470 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayOfArrayOfNumberOnly.swift @@ -0,0 +1,27 @@ +// +// ArrayOfArrayOfNumberOnly.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class ArrayOfArrayOfNumberOnly: JSONEncodable { + + public var arrayArrayNumber: [[Double]]? + + + public init(arrayArrayNumber: [[Double]]?=nil) { + self.arrayArrayNumber = arrayArrayNumber + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["ArrayArrayNumber"] = self.arrayArrayNumber?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayOfNumberOnly.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayOfNumberOnly.swift new file mode 100644 index 00000000000..c59487b16b7 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayOfNumberOnly.swift @@ -0,0 +1,27 @@ +// +// ArrayOfNumberOnly.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class ArrayOfNumberOnly: JSONEncodable { + + public var arrayNumber: [Double]? + + + public init(arrayNumber: [Double]?=nil) { + self.arrayNumber = arrayNumber + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["ArrayNumber"] = self.arrayNumber?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayTest.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayTest.swift new file mode 100644 index 00000000000..a10ab9054c3 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ArrayTest.swift @@ -0,0 +1,33 @@ +// +// ArrayTest.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class ArrayTest: JSONEncodable { + + public var arrayOfString: [String]? + public var arrayArrayOfInteger: [[Int64]]? + public var arrayArrayOfModel: [[ReadOnlyFirst]]? + + + public init(arrayOfString: [String]?=nil, arrayArrayOfInteger: [[Int64]]?=nil, arrayArrayOfModel: [[ReadOnlyFirst]]?=nil) { + self.arrayOfString = arrayOfString + self.arrayArrayOfInteger = arrayArrayOfInteger + self.arrayArrayOfModel = arrayArrayOfModel + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["array_of_string"] = self.arrayOfString?.encodeToJSON() + nillableDictionary["array_array_of_integer"] = self.arrayArrayOfInteger?.encodeToJSON() + nillableDictionary["array_array_of_model"] = self.arrayArrayOfModel?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Capitalization.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Capitalization.swift new file mode 100644 index 00000000000..70d0ba69433 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Capitalization.swift @@ -0,0 +1,43 @@ +// +// Capitalization.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Capitalization: JSONEncodable { + + public var smallCamel: String? + public var capitalCamel: String? + public var smallSnake: String? + public var capitalSnake: String? + public var sCAETHFlowPoints: String? + /** Name of the pet */ + public var ATT_NAME: String? + + + public init(smallCamel: String?=nil, capitalCamel: String?=nil, smallSnake: String?=nil, capitalSnake: String?=nil, sCAETHFlowPoints: String?=nil, ATT_NAME: String?=nil) { + self.smallCamel = smallCamel + self.capitalCamel = capitalCamel + self.smallSnake = smallSnake + self.capitalSnake = capitalSnake + self.sCAETHFlowPoints = sCAETHFlowPoints + self.ATT_NAME = ATT_NAME + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["smallCamel"] = self.smallCamel + nillableDictionary["CapitalCamel"] = self.capitalCamel + nillableDictionary["small_Snake"] = self.smallSnake + nillableDictionary["Capital_Snake"] = self.capitalSnake + nillableDictionary["SCA_ETH_Flow_Points"] = self.sCAETHFlowPoints + nillableDictionary["ATT_NAME"] = self.ATT_NAME + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Cat.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Cat.swift new file mode 100644 index 00000000000..02ce420e9b2 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Cat.swift @@ -0,0 +1,27 @@ +// +// Cat.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Cat: Animal { + + public var declawed: Bool? + + + public init(className: String, color: String?=nil, declawed: Bool?=nil) { + self.declawed = declawed + } + // MARK: JSONEncodable + override open func encodeToJSON() -> Any { + var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]() + nillableDictionary["declawed"] = self.declawed + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Category.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Category.swift new file mode 100644 index 00000000000..a164fab10e6 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Category.swift @@ -0,0 +1,30 @@ +// +// Category.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Category: JSONEncodable { + + public var id: Int64? + public var name: String? + + + public init(id: Int64?=nil, name: String?=nil) { + self.id = id + self.name = name + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["name"] = self.name + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ClassModel.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ClassModel.swift new file mode 100644 index 00000000000..d3939062787 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ClassModel.swift @@ -0,0 +1,28 @@ +// +// ClassModel.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +/** Model for testing model with \"_class\" property */ +open class ClassModel: JSONEncodable { + + public var _class: String? + + + public init(_class: String?=nil) { + self._class = _class + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["_class"] = self._class + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Client.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Client.swift new file mode 100644 index 00000000000..7f941628b23 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Client.swift @@ -0,0 +1,27 @@ +// +// Client.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Client: JSONEncodable { + + public var client: String? + + + public init(client: String?=nil) { + self.client = client + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["client"] = self.client + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Dog.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Dog.swift new file mode 100644 index 00000000000..a62c07a35ef --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Dog.swift @@ -0,0 +1,27 @@ +// +// Dog.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Dog: Animal { + + public var breed: String? + + + public init(className: String, color: String?=nil, breed: String?=nil) { + self.breed = breed + } + // MARK: JSONEncodable + override open func encodeToJSON() -> Any { + var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]() + nillableDictionary["breed"] = self.breed + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumArrays.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumArrays.swift new file mode 100644 index 00000000000..3d46a616878 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumArrays.swift @@ -0,0 +1,38 @@ +// +// EnumArrays.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class EnumArrays: JSONEncodable { + + public enum JustSymbol: String { + case greaterThanOrEqualTo = ">=" + case dollar = "$" + } + public enum ArrayEnum: String { + case fish = "fish" + case crab = "crab" + } + public var justSymbol: JustSymbol? + public var arrayEnum: [ArrayEnum]? + + + public init(justSymbol: JustSymbol?=nil, arrayEnum: [ArrayEnum]?=nil) { + self.justSymbol = justSymbol + self.arrayEnum = arrayEnum + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["just_symbol"] = self.justSymbol?.rawValue + nillableDictionary["array_enum"] = self.arrayEnum?.map({$0.rawValue}).encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumClass.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumClass.swift new file mode 100644 index 00000000000..c72feaabbd5 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumClass.swift @@ -0,0 +1,17 @@ +// +// EnumClass.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public enum EnumClass: String { + case abc = "_abc" + case efg = "-efg" + case xyz = "(xyz)" + + func encodeToJSON() -> Any { return self.rawValue } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumTest.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumTest.swift new file mode 100644 index 00000000000..1ede77f5495 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/EnumTest.swift @@ -0,0 +1,49 @@ +// +// EnumTest.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class EnumTest: JSONEncodable { + + public enum EnumString: String { + case upper = "UPPER" + case lower = "lower" + case empty = "" + } + public enum EnumInteger: Int32 { + case _1 = 1 + case numberminus1 = -1 + } + public enum EnumNumber: Double { + case _11 = 1.1 + case numberminus12 = -1.2 + } + public var enumString: EnumString? + public var enumInteger: EnumInteger? + public var enumNumber: EnumNumber? + public var outerEnum: OuterEnum? + + + public init(enumString: EnumString?=nil, enumInteger: EnumInteger?=nil, enumNumber: EnumNumber?=nil, outerEnum: OuterEnum?=nil) { + self.enumString = enumString + self.enumInteger = enumInteger + self.enumNumber = enumNumber + self.outerEnum = outerEnum + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["enum_string"] = self.enumString?.rawValue + nillableDictionary["enum_integer"] = self.enumInteger?.rawValue + nillableDictionary["enum_number"] = self.enumNumber?.rawValue + nillableDictionary["outerEnum"] = self.outerEnum?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift new file mode 100644 index 00000000000..0b3c8871b5b --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift @@ -0,0 +1,63 @@ +// +// FormatTest.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class FormatTest: JSONEncodable { + + public var integer: Int32? + public var int32: Int32? + public var int64: Int64? + public var number: Double + public var float: Float? + public var double: Double? + public var string: String? + public var byte: Data + public var binary: Data? + public var date: ISOFullDate + public var dateTime: Date? + public var uuid: UUID? + public var password: String + + + public init(integer: Int32?=nil, int32: Int32?=nil, int64: Int64?=nil, number: Double, float: Float?=nil, double: Double?=nil, string: String?=nil, byte: Data, binary: Data?=nil, date: ISOFullDate, dateTime: Date?=nil, uuid: UUID?=nil, password: String) { + self.integer = integer + self.int32 = int32 + self.int64 = int64 + self.number = number + self.float = float + self.double = double + self.string = string + self.byte = byte + self.binary = binary + self.date = date + self.dateTime = dateTime + self.uuid = uuid + self.password = password + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["integer"] = self.integer?.encodeToJSON() + nillableDictionary["int32"] = self.int32?.encodeToJSON() + nillableDictionary["int64"] = self.int64?.encodeToJSON() + nillableDictionary["number"] = self.number + nillableDictionary["float"] = self.float + nillableDictionary["double"] = self.double + nillableDictionary["string"] = self.string + nillableDictionary["byte"] = self.byte.encodeToJSON() + nillableDictionary["binary"] = self.binary?.encodeToJSON() + nillableDictionary["date"] = self.date.encodeToJSON() + nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON() + nillableDictionary["uuid"] = self.uuid?.encodeToJSON() + nillableDictionary["password"] = self.password + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/HasOnlyReadOnly.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/HasOnlyReadOnly.swift new file mode 100644 index 00000000000..ef5790ab752 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/HasOnlyReadOnly.swift @@ -0,0 +1,30 @@ +// +// HasOnlyReadOnly.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class HasOnlyReadOnly: JSONEncodable { + + public var bar: String? + public var foo: String? + + + public init(bar: String?=nil, foo: String?=nil) { + self.bar = bar + self.foo = foo + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["bar"] = self.bar + nillableDictionary["foo"] = self.foo + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/List.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/List.swift new file mode 100644 index 00000000000..a2185ed62af --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/List.swift @@ -0,0 +1,27 @@ +// +// List.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class List: JSONEncodable { + + public var _123List: String? + + + public init(_123List: String?=nil) { + self._123List = _123List + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["123-list"] = self._123List + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/MapTest.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/MapTest.swift new file mode 100644 index 00000000000..78c8e226ee2 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/MapTest.swift @@ -0,0 +1,33 @@ +// +// MapTest.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class MapTest: JSONEncodable { + + public enum MapOfEnumString: String { + case upper = "UPPER" + case lower = "lower" + } + public var mapMapOfString: [String:[String:String]]? + public var mapOfEnumString: [String:String]? + + + public init(mapMapOfString: [String:[String:String]]?=nil, mapOfEnumString: [String:String]?=nil) { + self.mapMapOfString = mapMapOfString + self.mapOfEnumString = mapOfEnumString + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["map_map_of_string"] = self.mapMapOfString?.encodeToJSON()//TODO: handle enum map scenario + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/MixedPropertiesAndAdditionalPropertiesClass.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/MixedPropertiesAndAdditionalPropertiesClass.swift new file mode 100644 index 00000000000..1e5110aa950 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/MixedPropertiesAndAdditionalPropertiesClass.swift @@ -0,0 +1,33 @@ +// +// MixedPropertiesAndAdditionalPropertiesClass.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class MixedPropertiesAndAdditionalPropertiesClass: JSONEncodable { + + public var uuid: UUID? + public var dateTime: Date? + public var map: [String:Animal]? + + + public init(uuid: UUID?=nil, dateTime: Date?=nil, map: [String:Animal]?=nil) { + self.uuid = uuid + self.dateTime = dateTime + self.map = map + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["uuid"] = self.uuid?.encodeToJSON() + nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON() + nillableDictionary["map"] = self.map?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift new file mode 100644 index 00000000000..b97bc372c50 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift @@ -0,0 +1,31 @@ +// +// Model200Response.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +/** Model for testing model name starting with number */ +open class Model200Response: JSONEncodable { + + public var name: Int32? + public var _class: String? + + + public init(name: Int32?=nil, _class: String?=nil) { + self.name = name + self._class = _class + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["name"] = self.name?.encodeToJSON() + nillableDictionary["class"] = self._class + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Name.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Name.swift new file mode 100644 index 00000000000..b993aa3ad94 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Name.swift @@ -0,0 +1,37 @@ +// +// Name.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +/** Model for testing model name same as property name */ +open class Name: JSONEncodable { + + public var name: Int32 + public var snakeCase: Int32? + public var property: String? + public var _123Number: Int32? + + + public init(name: Int32, snakeCase: Int32?=nil, property: String?=nil, _123Number: Int32?=nil) { + self.name = name + self.snakeCase = snakeCase + self.property = property + self._123Number = _123Number + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["name"] = self.name.encodeToJSON() + nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON() + nillableDictionary["property"] = self.property + nillableDictionary["123Number"] = self._123Number?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/NumberOnly.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/NumberOnly.swift new file mode 100644 index 00000000000..5b4fe810f93 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/NumberOnly.swift @@ -0,0 +1,27 @@ +// +// NumberOnly.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class NumberOnly: JSONEncodable { + + public var justNumber: Double? + + + public init(justNumber: Double?=nil) { + self.justNumber = justNumber + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["JustNumber"] = self.justNumber + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Order.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Order.swift new file mode 100644 index 00000000000..659d9ecd972 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Order.swift @@ -0,0 +1,48 @@ +// +// Order.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Order: JSONEncodable { + + public enum Status: String { + case placed = "placed" + case approved = "approved" + case delivered = "delivered" + } + public var id: Int64? + public var petId: Int64? + public var quantity: Int32? + public var shipDate: Date? + /** Order Status */ + public var status: Status? + public var complete: Bool? + + + public init(id: Int64?=nil, petId: Int64?=nil, quantity: Int32?=nil, shipDate: Date?=nil, status: Status?=nil, complete: Bool?=nil) { + self.id = id + self.petId = petId + self.quantity = quantity + self.shipDate = shipDate + self.status = status + self.complete = complete + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["petId"] = self.petId?.encodeToJSON() + nillableDictionary["quantity"] = self.quantity?.encodeToJSON() + nillableDictionary["shipDate"] = self.shipDate?.encodeToJSON() + nillableDictionary["status"] = self.status?.rawValue + nillableDictionary["complete"] = self.complete + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterBoolean.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterBoolean.swift new file mode 100644 index 00000000000..3c49ad29400 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterBoolean.swift @@ -0,0 +1,11 @@ +// +// OuterBoolean.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public typealias OuterBoolean = Bool diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterComposite.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterComposite.swift new file mode 100644 index 00000000000..93d8b4b2d74 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterComposite.swift @@ -0,0 +1,33 @@ +// +// OuterComposite.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class OuterComposite: JSONEncodable { + + public var myNumber: OuterNumber? + public var myString: OuterString? + public var myBoolean: OuterBoolean? + + + public init(myNumber: OuterNumber?=nil, myString: OuterString?=nil, myBoolean: OuterBoolean?=nil) { + self.myNumber = myNumber + self.myString = myString + self.myBoolean = myBoolean + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["my_number"] = self.myNumber?.encodeToJSON() + nillableDictionary["my_string"] = self.myString?.encodeToJSON() + nillableDictionary["my_boolean"] = self.myBoolean?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterEnum.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterEnum.swift new file mode 100644 index 00000000000..3f6e50251e6 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterEnum.swift @@ -0,0 +1,17 @@ +// +// OuterEnum.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public enum OuterEnum: String { + case placed = "placed" + case approved = "approved" + case delivered = "delivered" + + func encodeToJSON() -> Any { return self.rawValue } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterNumber.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterNumber.swift new file mode 100644 index 00000000000..f285f4e5e29 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterNumber.swift @@ -0,0 +1,11 @@ +// +// OuterNumber.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public typealias OuterNumber = Double diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterString.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterString.swift new file mode 100644 index 00000000000..9da794627d6 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/OuterString.swift @@ -0,0 +1,11 @@ +// +// OuterString.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public typealias OuterString = String diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Pet.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Pet.swift new file mode 100644 index 00000000000..2fb770ce9f0 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Pet.swift @@ -0,0 +1,48 @@ +// +// Pet.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Pet: JSONEncodable { + + public enum Status: String { + case available = "available" + case pending = "pending" + case sold = "sold" + } + public var id: Int64? + public var category: Category? + public var name: String + public var photoUrls: [String] + public var tags: [Tag]? + /** pet status in the store */ + public var status: Status? + + + public init(id: Int64?=nil, category: Category?=nil, name: String, photoUrls: [String], tags: [Tag]?=nil, status: Status?=nil) { + self.id = id + self.category = category + self.name = name + self.photoUrls = photoUrls + self.tags = tags + self.status = status + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["category"] = self.category?.encodeToJSON() + nillableDictionary["name"] = self.name + nillableDictionary["photoUrls"] = self.photoUrls.encodeToJSON() + nillableDictionary["tags"] = self.tags?.encodeToJSON() + nillableDictionary["status"] = self.status?.rawValue + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ReadOnlyFirst.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ReadOnlyFirst.swift new file mode 100644 index 00000000000..5415e026fc1 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/ReadOnlyFirst.swift @@ -0,0 +1,30 @@ +// +// ReadOnlyFirst.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class ReadOnlyFirst: JSONEncodable { + + public var bar: String? + public var baz: String? + + + public init(bar: String?=nil, baz: String?=nil) { + self.bar = bar + self.baz = baz + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["bar"] = self.bar + nillableDictionary["baz"] = self.baz + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Return.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Return.swift new file mode 100644 index 00000000000..d84e8bdd4cc --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Return.swift @@ -0,0 +1,28 @@ +// +// Return.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +/** Model for testing reserved words */ +open class Return: JSONEncodable { + + public var _return: Int32? + + + public init(_return: Int32?=nil) { + self._return = _return + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["return"] = self._return?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift new file mode 100644 index 00000000000..0af1e75f050 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift @@ -0,0 +1,27 @@ +// +// SpecialModelName.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class SpecialModelName: JSONEncodable { + + public var specialPropertyName: Int64? + + + public init(specialPropertyName: Int64?=nil) { + self.specialPropertyName = specialPropertyName + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Tag.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Tag.swift new file mode 100644 index 00000000000..57d4a3e29c1 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/Tag.swift @@ -0,0 +1,30 @@ +// +// Tag.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class Tag: JSONEncodable { + + public var id: Int64? + public var name: String? + + + public init(id: Int64?=nil, name: String?=nil) { + self.id = id + self.name = name + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["name"] = self.name + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/User.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/User.swift new file mode 100644 index 00000000000..507ef89b644 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models/User.swift @@ -0,0 +1,49 @@ +// +// User.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +open class User: JSONEncodable { + + public var id: Int64? + public var username: String? + public var firstName: String? + public var lastName: String? + public var email: String? + public var password: String? + public var phone: String? + /** User Status */ + public var userStatus: Int32? + + + public init(id: Int64?=nil, username: String?=nil, firstName: String?=nil, lastName: String?=nil, email: String?=nil, password: String?=nil, phone: String?=nil, userStatus: Int32?=nil) { + self.id = id + self.username = username + self.firstName = firstName + self.lastName = lastName + self.email = email + self.password = password + self.phone = phone + self.userStatus = userStatus + } + // MARK: JSONEncodable + open func encodeToJSON() -> Any { + var nillableDictionary = [String:Any?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["username"] = self.username + nillableDictionary["firstName"] = self.firstName + nillableDictionary["lastName"] = self.lastName + nillableDictionary["email"] = self.email + nillableDictionary["password"] = self.password + nillableDictionary["phone"] = self.phone + nillableDictionary["userStatus"] = self.userStatus?.encodeToJSON() + + let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift3/unwraprequired/git_push.sh b/samples/client/petstore/swift3/unwraprequired/git_push.sh new file mode 100644 index 00000000000..ed374619b13 --- /dev/null +++ b/samples/client/petstore/swift3/unwraprequired/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/tizen/.swagger-codegen/VERSION b/samples/client/petstore/tizen/.swagger-codegen/VERSION index 7fea99011a6..f9f7450d135 100644 --- a/samples/client/petstore/tizen/.swagger-codegen/VERSION +++ b/samples/client/petstore/tizen/.swagger-codegen/VERSION @@ -1 +1 @@ -2.2.3-SNAPSHOT \ No newline at end of file +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/tizen/client/SamiApiResponse.h b/samples/client/petstore/tizen/client/SamiApiResponse.h deleted file mode 100644 index 19570f9c1f8..00000000000 --- a/samples/client/petstore/tizen/client/SamiApiResponse.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SamiApiResponse.h - * - * Describes the result of uploading an image resource - */ - -#ifndef SamiApiResponse_H_ -#define SamiApiResponse_H_ - -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" - -using namespace Tizen::Web::Json; - - -using Tizen::Base::Integer; -using Tizen::Base::String; - - -namespace Swagger { - -class SamiApiResponse: public SamiObject { -public: - SamiApiResponse(); - SamiApiResponse(String* json); - virtual ~SamiApiResponse(); - - void init(); - - void cleanup(); - - String asJson (); - - JsonObject* asJsonObject(); - - void fromJsonObject(IJsonValue* json); - - SamiApiResponse* fromJson(String* obj); - - Integer* getPCode(); - void setPCode(Integer* pCode); - String* getPType(); - void setPType(String* pType); - String* getPMessage(); - void setPMessage(String* pMessage); - -private: - Integer* pCode; -String* pType; -String* pMessage; -}; - -} /* namespace Swagger */ - -#endif /* SamiApiResponse_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiCategory.h b/samples/client/petstore/tizen/client/SamiCategory.h deleted file mode 100644 index b29d92e967f..00000000000 --- a/samples/client/petstore/tizen/client/SamiCategory.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SamiCategory.h - * - * A category for a pet - */ - -#ifndef SamiCategory_H_ -#define SamiCategory_H_ - -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" - -using namespace Tizen::Web::Json; - - -using Tizen::Base::Long; -using Tizen::Base::String; - - -namespace Swagger { - -class SamiCategory: public SamiObject { -public: - SamiCategory(); - SamiCategory(String* json); - virtual ~SamiCategory(); - - void init(); - - void cleanup(); - - String asJson (); - - JsonObject* asJsonObject(); - - void fromJsonObject(IJsonValue* json); - - SamiCategory* fromJson(String* obj); - - Long* getPId(); - void setPId(Long* pId); - String* getPName(); - void setPName(String* pName); - -private: - Long* pId; -String* pName; -}; - -} /* namespace Swagger */ - -#endif /* SamiCategory_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiOrder.h b/samples/client/petstore/tizen/client/SamiOrder.h deleted file mode 100644 index 5290bd6ef41..00000000000 --- a/samples/client/petstore/tizen/client/SamiOrder.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SamiOrder.h - * - * An order for a pets from the pet store - */ - -#ifndef SamiOrder_H_ -#define SamiOrder_H_ - -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" - -using namespace Tizen::Web::Json; - - -using Tizen::Base::Boolean; -using Tizen::Base::DateTime; -using Tizen::Base::Integer; -using Tizen::Base::Long; -using Tizen::Base::String; - - -namespace Swagger { - -class SamiOrder: public SamiObject { -public: - SamiOrder(); - SamiOrder(String* json); - virtual ~SamiOrder(); - - void init(); - - void cleanup(); - - String asJson (); - - JsonObject* asJsonObject(); - - void fromJsonObject(IJsonValue* json); - - SamiOrder* fromJson(String* obj); - - Long* getPId(); - void setPId(Long* pId); - Long* getPPetId(); - void setPPetId(Long* pPetId); - Integer* getPQuantity(); - void setPQuantity(Integer* pQuantity); - DateTime* getPShipDate(); - void setPShipDate(DateTime* pShipDate); - String* getPStatus(); - void setPStatus(String* pStatus); - Boolean* getPComplete(); - void setPComplete(Boolean* pComplete); - -private: - Long* pId; -Long* pPetId; -Integer* pQuantity; -DateTime* pShipDate; -String* pStatus; -Boolean* pComplete; -}; - -} /* namespace Swagger */ - -#endif /* SamiOrder_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiPet.h b/samples/client/petstore/tizen/client/SamiPet.h deleted file mode 100644 index 5c1dddece78..00000000000 --- a/samples/client/petstore/tizen/client/SamiPet.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SamiPet.h - * - * A pet for sale in the pet store - */ - -#ifndef SamiPet_H_ -#define SamiPet_H_ - -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" - -using namespace Tizen::Web::Json; - - -#include "SamiCategory.h" -#include "SamiTag.h" -using Tizen::Base::Collection::IList; -using Tizen::Base::Long; -using Tizen::Base::String; - - -namespace Swagger { - -class SamiPet: public SamiObject { -public: - SamiPet(); - SamiPet(String* json); - virtual ~SamiPet(); - - void init(); - - void cleanup(); - - String asJson (); - - JsonObject* asJsonObject(); - - void fromJsonObject(IJsonValue* json); - - SamiPet* fromJson(String* obj); - - Long* getPId(); - void setPId(Long* pId); - SamiCategory* getPCategory(); - void setPCategory(SamiCategory* pCategory); - String* getPName(); - void setPName(String* pName); - IList* getPPhotoUrls(); - void setPPhotoUrls(IList* pPhotoUrls); - IList* getPTags(); - void setPTags(IList* pTags); - String* getPStatus(); - void setPStatus(String* pStatus); - -private: - Long* pId; -SamiCategory* pCategory; -String* pName; -IList* pPhotoUrls; -IList* pTags; -String* pStatus; -}; - -} /* namespace Swagger */ - -#endif /* SamiPet_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiPetApi.h b/samples/client/petstore/tizen/client/SamiPetApi.h deleted file mode 100644 index 89bf5c6da65..00000000000 --- a/samples/client/petstore/tizen/client/SamiPetApi.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef SamiPetApi_H_ -#define SamiPetApi_H_ - -#include -#include "SamiApiClient.h" -#include "SamiError.h" - -using Tizen::Base::Long; -#include "SamiApiResponse.h" -#include "SamiFile.h" -#include "SamiPet.h" -using Tizen::Base::String; - -using namespace Tizen::Net::Http; - -namespace Swagger { - -class SamiPetApi { -public: - SamiPetApi(); - virtual ~SamiPetApi(); - - void - addPetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); - void - deletePetWithCompletion(Long* petId, String* apiKey, void(* handler)(SamiError*)); - IList* - findPetsByStatusWithCompletion(IList* status, void (* handler)(IList*, SamiError*)); - IList* - findPetsByTagsWithCompletion(IList* tags, void (* handler)(IList*, SamiError*)); - SamiPet* - getPetByIdWithCompletion(Long* petId, void (* handler)(SamiPet*, SamiError*)); - void - updatePetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); - void - updatePetWithFormWithCompletion(Long* petId, String* name, String* status, void(* handler)(SamiError*)); - SamiApiResponse* - uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void (* handler)(SamiApiResponse*, SamiError*)); - static String getBasePath() { - return L"http://petstore.swagger.io/v2"; - } - -private: - SamiApiClient* client; -}; - - -} /* namespace Swagger */ - -#endif /* SamiPetApi_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiStoreApi.h b/samples/client/petstore/tizen/client/SamiStoreApi.h deleted file mode 100644 index 4c419bf7a87..00000000000 --- a/samples/client/petstore/tizen/client/SamiStoreApi.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef SamiStoreApi_H_ -#define SamiStoreApi_H_ - -#include -#include "SamiApiClient.h" -#include "SamiError.h" - -using Tizen::Base::Integer; -using Tizen::Base::Long; -#include "SamiOrder.h" -using Tizen::Base::String; - -using namespace Tizen::Net::Http; - -namespace Swagger { - -class SamiStoreApi { -public: - SamiStoreApi(); - virtual ~SamiStoreApi(); - - void - deleteOrderWithCompletion(String* orderId, void(* handler)(SamiError*)); - HashMap* - getInventoryWithCompletion( void (* handler)(HashMap*, SamiError*)); - SamiOrder* - getOrderByIdWithCompletion(Long* orderId, void (* handler)(SamiOrder*, SamiError*)); - SamiOrder* - placeOrderWithCompletion(SamiOrder* body, void (* handler)(SamiOrder*, SamiError*)); - static String getBasePath() { - return L"http://petstore.swagger.io/v2"; - } - -private: - SamiApiClient* client; -}; - - -} /* namespace Swagger */ - -#endif /* SamiStoreApi_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiTag.h b/samples/client/petstore/tizen/client/SamiTag.h deleted file mode 100644 index 589a23a84c3..00000000000 --- a/samples/client/petstore/tizen/client/SamiTag.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SamiTag.h - * - * A tag for a pet - */ - -#ifndef SamiTag_H_ -#define SamiTag_H_ - -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" - -using namespace Tizen::Web::Json; - - -using Tizen::Base::Long; -using Tizen::Base::String; - - -namespace Swagger { - -class SamiTag: public SamiObject { -public: - SamiTag(); - SamiTag(String* json); - virtual ~SamiTag(); - - void init(); - - void cleanup(); - - String asJson (); - - JsonObject* asJsonObject(); - - void fromJsonObject(IJsonValue* json); - - SamiTag* fromJson(String* obj); - - Long* getPId(); - void setPId(Long* pId); - String* getPName(); - void setPName(String* pName); - -private: - Long* pId; -String* pName; -}; - -} /* namespace Swagger */ - -#endif /* SamiTag_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiUser.h b/samples/client/petstore/tizen/client/SamiUser.h deleted file mode 100644 index 6e575eb7bb9..00000000000 --- a/samples/client/petstore/tizen/client/SamiUser.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SamiUser.h - * - * A User who is purchasing from the pet store - */ - -#ifndef SamiUser_H_ -#define SamiUser_H_ - -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" - -using namespace Tizen::Web::Json; - - -using Tizen::Base::Integer; -using Tizen::Base::Long; -using Tizen::Base::String; - - -namespace Swagger { - -class SamiUser: public SamiObject { -public: - SamiUser(); - SamiUser(String* json); - virtual ~SamiUser(); - - void init(); - - void cleanup(); - - String asJson (); - - JsonObject* asJsonObject(); - - void fromJsonObject(IJsonValue* json); - - SamiUser* fromJson(String* obj); - - Long* getPId(); - void setPId(Long* pId); - String* getPUsername(); - void setPUsername(String* pUsername); - String* getPFirstName(); - void setPFirstName(String* pFirstName); - String* getPLastName(); - void setPLastName(String* pLastName); - String* getPEmail(); - void setPEmail(String* pEmail); - String* getPPassword(); - void setPPassword(String* pPassword); - String* getPPhone(); - void setPPhone(String* pPhone); - Integer* getPUserStatus(); - void setPUserStatus(Integer* pUserStatus); - -private: - Long* pId; -String* pUsername; -String* pFirstName; -String* pLastName; -String* pEmail; -String* pPassword; -String* pPhone; -Integer* pUserStatus; -}; - -} /* namespace Swagger */ - -#endif /* SamiUser_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiUserApi.h b/samples/client/petstore/tizen/client/SamiUserApi.h deleted file mode 100644 index f6ae0231e95..00000000000 --- a/samples/client/petstore/tizen/client/SamiUserApi.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef SamiUserApi_H_ -#define SamiUserApi_H_ - -#include -#include "SamiApiClient.h" -#include "SamiError.h" - -using Tizen::Base::Collection::IList; -#include "SamiUser.h" -using Tizen::Base::String; - -using namespace Tizen::Net::Http; - -namespace Swagger { - -class SamiUserApi { -public: - SamiUserApi(); - virtual ~SamiUserApi(); - - void - createUserWithCompletion(SamiUser* body, void(* handler)(SamiError*)); - void - createUsersWithArrayInputWithCompletion(IList* body, void(* handler)(SamiError*)); - void - createUsersWithListInputWithCompletion(IList* body, void(* handler)(SamiError*)); - void - deleteUserWithCompletion(String* username, void(* handler)(SamiError*)); - SamiUser* - getUserByNameWithCompletion(String* username, void (* handler)(SamiUser*, SamiError*)); - String* - loginUserWithCompletion(String* username, String* password, void (* handler)(String*, SamiError*)); - void - logoutUserWithCompletion( void(* handler)(SamiError*)); - void - updateUserWithCompletion(String* username, SamiUser* body, void(* handler)(SamiError*)); - static String getBasePath() { - return L"http://petstore.swagger.io/v2"; - } - -private: - SamiApiClient* client; -}; - - -} /* namespace Swagger */ - -#endif /* SamiUserApi_H_ */ diff --git a/samples/client/petstore/tizen/doc/README.md b/samples/client/petstore/tizen/doc/README.md index 6b90ef614aa..a6d3dd4976c 100644 --- a/samples/client/petstore/tizen/doc/README.md +++ b/samples/client/petstore/tizen/doc/README.md @@ -1,4 +1,4 @@ -# Documentation for Swagger Petstore 1.0.0 Tizen SDK +# Documentation for Swagger Petstore 1.0.0 Tizen Client SDK ## How do I get the doc files? First generate source code by running `swagger-codegen` @@ -16,7 +16,7 @@ This is the structure of the doc folder: ├── Doxyfile \\Doxygen config files ├── generateDocumentation.sh \\Script to run to generate documentation ├── README.md \\This file -├── SDK \\Documentation for all classes in Tizen Client SDK for Artik Cloud. See ./html/index.html +├── SDK \\Documentation for all classes in Swagger Petstore Tizen Client SDK. See ./html/index.html │   └── html ``` @@ -36,39 +36,68 @@ Doxygen is the de facto standard tool for generating/extracting documentation fr Check out [Doxygen](https://www.doxygen.org/) for additional information about the Doxygen project. ## I Don't want to run Doxygen. What are the API files for accessing the REST endpoints? +All URIs are relative to http://petstore.swagger.iohttp://petstore.swagger.io/v2 -* [PetManager](../src/PetManager.cpp) - * *addPetSync* / *addPetAsync* - Add a new pet to the store. - * *deletePetSync* / *deletePetAsync* - Deletes a pet. - * *findPetsByStatusSync* / *findPetsByStatusAsync* - Finds Pets by status. - * *findPetsByTagsSync* / *findPetsByTagsAsync* - Finds Pets by tags. - * *getPetByIdSync* / *getPetByIdAsync* - Find pet by ID. - * *updatePetSync* / *updatePetAsync* - Update an existing pet. - * *updatePetWithFormSync* / *updatePetWithFormAsync* - Updates a pet in the store with form data. - * *uploadFileSync* / *uploadFileAsync* - uploads an image. +### PetManager +Method | HTTP request | Description +------------- | ------------- | ------------- +*addPetSync* | *POST* /pet | Add a new pet to the store. +*addPetASync* | *POST* /pet | Add a new pet to the store. +*deletePetSync* | *DELETE* /pet/{petId} | Deletes a pet. +*deletePetASync* | *DELETE* /pet/{petId} | Deletes a pet. +*findPetsByStatusSync* | *GET* /pet/findByStatus | Finds Pets by status. +*findPetsByStatusASync* | *GET* /pet/findByStatus | Finds Pets by status. +*findPetsByTagsSync* | *GET* /pet/findByTags | Finds Pets by tags. +*findPetsByTagsASync* | *GET* /pet/findByTags | Finds Pets by tags. +*getPetByIdSync* | *GET* /pet/{petId} | Find pet by ID. +*getPetByIdASync* | *GET* /pet/{petId} | Find pet by ID. +*updatePetSync* | *PUT* /pet | Update an existing pet. +*updatePetASync* | *PUT* /pet | Update an existing pet. +*updatePetWithFormSync* | *POST* /pet/{petId} | Updates a pet in the store with form data. +*updatePetWithFormASync* | *POST* /pet/{petId} | Updates a pet in the store with form data. +*uploadFileSync* | *POST* /pet/{petId}/uploadImage | uploads an image. +*uploadFileASync* | *POST* /pet/{petId}/uploadImage | uploads an image. -* [StoreManager](../src/StoreManager.cpp) - * *deleteOrderSync* / *deleteOrderAsync* - Delete purchase order by ID. - * *getInventorySync* / *getInventoryAsync* - Returns pet inventories by status. - * *getOrderByIdSync* / *getOrderByIdAsync* - Find purchase order by ID. - * *placeOrderSync* / *placeOrderAsync* - Place an order for a pet. +### StoreManager +Method | HTTP request | Description +------------- | ------------- | ------------- +*deleteOrderSync* | *DELETE* /store/order/{orderId} | Delete purchase order by ID. +*deleteOrderASync* | *DELETE* /store/order/{orderId} | Delete purchase order by ID. +*getInventorySync* | *GET* /store/inventory | Returns pet inventories by status. +*getInventoryASync* | *GET* /store/inventory | Returns pet inventories by status. +*getOrderByIdSync* | *GET* /store/order/{orderId} | Find purchase order by ID. +*getOrderByIdASync* | *GET* /store/order/{orderId} | Find purchase order by ID. +*placeOrderSync* | *POST* /store/order | Place an order for a pet. +*placeOrderASync* | *POST* /store/order | Place an order for a pet. -* [UserManager](../src/UserManager.cpp) - * *createUserSync* / *createUserAsync* - Create user. - * *createUsersWithArrayInputSync* / *createUsersWithArrayInputAsync* - Creates list of users with given input array. - * *createUsersWithListInputSync* / *createUsersWithListInputAsync* - Creates list of users with given input array. - * *deleteUserSync* / *deleteUserAsync* - Delete user. - * *getUserByNameSync* / *getUserByNameAsync* - Get user by user name. - * *loginUserSync* / *loginUserAsync* - Logs user into the system. - * *logoutUserSync* / *logoutUserAsync* - Logs out current logged in user session. - * *updateUserSync* / *updateUserAsync* - Updated user. +### UserManager +Method | HTTP request | Description +------------- | ------------- | ------------- +*createUserSync* | *POST* /user | Create user. +*createUserASync* | *POST* /user | Create user. +*createUsersWithArrayInputSync* | *POST* /user/createWithArray | Creates list of users with given input array. +*createUsersWithArrayInputASync* | *POST* /user/createWithArray | Creates list of users with given input array. +*createUsersWithListInputSync* | *POST* /user/createWithList | Creates list of users with given input array. +*createUsersWithListInputASync* | *POST* /user/createWithList | Creates list of users with given input array. +*deleteUserSync* | *DELETE* /user/{username} | Delete user. +*deleteUserASync* | *DELETE* /user/{username} | Delete user. +*getUserByNameSync* | *GET* /user/{username} | Get user by user name. +*getUserByNameASync* | *GET* /user/{username} | Get user by user name. +*loginUserSync* | *GET* /user/login | Logs user into the system. +*loginUserASync* | *GET* /user/login | Logs user into the system. +*logoutUserSync* | *GET* /user/logout | Logs out current logged in user session. +*logoutUserASync* | *GET* /user/logout | Logs out current logged in user session. +*updateUserSync* | *PUT* /user/{username} | Updated user. +*updateUserASync* | *PUT* /user/{username} | Updated user. ## What are the Model files for the data structures/objects? +Class | Description +------------- | ------------- + *ApiResponse* | Describes the result of uploading an image resource + *Category* | A category for a pet + *Order* | An order for a pets from the pet store + *Pet* | A pet for sale in the pet store + *Tag* | A tag for a pet + *User* | A User who is purchasing from the pet store -* [ApiResponse](../src/ApiResponse.cpp) - Describes the result of uploading an image resource -* [Category](../src/Category.cpp) - A category for a pet -* [Order](../src/Order.cpp) - An order for a pets from the pet store -* [Pet](../src/Pet.cpp) - A pet for sale in the pet store -* [Tag](../src/Tag.cpp) - A tag for a pet -* [User](../src/User.cpp) - A User who is purchasing from the pet store diff --git a/samples/client/petstore/tizen/src/ApiResponse.h b/samples/client/petstore/tizen/src/ApiResponse.h index 025726c0b7d..31b9c46d860 100644 --- a/samples/client/petstore/tizen/src/ApiResponse.h +++ b/samples/client/petstore/tizen/src/ApiResponse.h @@ -11,11 +11,18 @@ #include #include "Object.h" +/** \defgroup Models Data Structures for API + * Classes containing all the Data Structures needed for calling/returned by API endpoints + * + */ + namespace Tizen { namespace ArtikCloud { /*! \brief Describes the result of uploading an image resource + * + * \ingroup Models * */ diff --git a/samples/client/petstore/tizen/src/Category.h b/samples/client/petstore/tizen/src/Category.h index a675512a7fa..dcc9aa19867 100644 --- a/samples/client/petstore/tizen/src/Category.h +++ b/samples/client/petstore/tizen/src/Category.h @@ -11,11 +11,18 @@ #include #include "Object.h" +/** \defgroup Models Data Structures for API + * Classes containing all the Data Structures needed for calling/returned by API endpoints + * + */ + namespace Tizen { namespace ArtikCloud { /*! \brief A category for a pet + * + * \ingroup Models * */ diff --git a/samples/client/petstore/tizen/src/Helpers.cpp b/samples/client/petstore/tizen/src/Helpers.cpp index 1f50bcc3260..7907152b3e9 100644 --- a/samples/client/petstore/tizen/src/Helpers.cpp +++ b/samples/client/petstore/tizen/src/Helpers.cpp @@ -13,7 +13,7 @@ using namespace Tizen::ArtikCloud; void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_node,gpointer user_data) { - const gchar* member_string; + gchar* member_string; if (!JSON_NODE_HOLDS_VALUE(member_node)) { if (JSON_NODE_HOLDS_OBJECT(member_node)) { JsonNode* tempnode = json_node_alloc(); @@ -27,10 +27,42 @@ void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_ json_node_free(tempnode); } } else { - member_string = json_node_get_string(member_node); + member_string = (char*) json_node_get_string(member_node); + if (member_string == NULL) { + char * valueType = (char*) json_node_type_name(member_node); + if(strcmp(valueType,"Boolean") == 0){ + gboolean member_boolean = json_node_get_boolean(member_node); + if (member_boolean == 0) { + member_string = new char[std::strlen("false") + 1]; + strcpy(member_string, "false"); + } else { + member_string = new char[std::strlen("true") + 1]; + strcpy(member_string, "true"); + } + } + else if(strcmp(valueType,"Integer") == 0){ + long long int member_int = json_node_get_int(member_node); + ostringstream ss; + ss << member_int; + string temp_member = ss.str(); + const char * temp_char = temp_member.c_str(); + member_string = new char[strlen(temp_char) + 1]; + strcpy(member_string, temp_char); + } + else{ + double member_double = json_node_get_double(member_node); + ostringstream ss; + ss << member_double; + string temp_member = ss.str(); + const char * temp_char = temp_member.c_str(); + member_string = new char[strlen(temp_char) + 1]; + strcpy(member_string, temp_char); + } + } } map* new_map = static_cast*>(user_data); (*new_map)[string(member_name)] = string(member_string); + delete[] member_string; } char * json_to_string(JsonNode *node, gboolean pretty) @@ -64,7 +96,11 @@ json_from_string(const char *str, GError **mygerror) if (!json_parser_load_from_data(parser, str, -1, mygerror)) { g_object_unref(parser); - return NULL; + if(str == NULL) + return NULL; + retval = json_node_alloc(); + retval = json_node_init_string (retval, str); + return retval; } retval = json_node_copy(json_parser_get_root(parser)); diff --git a/samples/client/petstore/tizen/src/Order.h b/samples/client/petstore/tizen/src/Order.h index 7a3413f55da..095833cb00e 100644 --- a/samples/client/petstore/tizen/src/Order.h +++ b/samples/client/petstore/tizen/src/Order.h @@ -11,11 +11,18 @@ #include #include "Object.h" +/** \defgroup Models Data Structures for API + * Classes containing all the Data Structures needed for calling/returned by API endpoints + * + */ + namespace Tizen { namespace ArtikCloud { /*! \brief An order for a pets from the pet store + * + * \ingroup Models * */ diff --git a/samples/client/petstore/tizen/src/Pet.h b/samples/client/petstore/tizen/src/Pet.h index fe223a74d72..71b0bc9f93b 100644 --- a/samples/client/petstore/tizen/src/Pet.h +++ b/samples/client/petstore/tizen/src/Pet.h @@ -14,11 +14,18 @@ #include #include "Object.h" +/** \defgroup Models Data Structures for API + * Classes containing all the Data Structures needed for calling/returned by API endpoints + * + */ + namespace Tizen { namespace ArtikCloud { /*! \brief A pet for sale in the pet store + * + * \ingroup Models * */ diff --git a/samples/client/petstore/tizen/src/PetManager.cpp b/samples/client/petstore/tizen/src/PetManager.cpp index 489c6663099..809e736a145 100644 --- a/samples/client/petstore/tizen/src/PetManager.cpp +++ b/samples/client/petstore/tizen/src/PetManager.cpp @@ -48,7 +48,7 @@ static gpointer __PetManagerthreadFunc(gpointer data) } -bool addPetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool addPetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -81,7 +81,7 @@ bool addPetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* us } } -bool addPetHelper(char * accessToken, +static bool addPetHelper(char * accessToken, Pet body, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -186,7 +186,7 @@ bool PetManager::addPetSync(char * accessToken, handler, userData, false); } -bool deletePetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool deletePetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -219,7 +219,7 @@ bool deletePetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* } } -bool deletePetHelper(char * accessToken, +static bool deletePetHelper(char * accessToken, long long petId, std::string apiKey, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -229,8 +229,11 @@ bool deletePetHelper(char * accessToken, struct curl_slist *headerList = NULL; - //TODO - should use value of paramname instead. Also check for empty not-required headers - headerList = curl_slist_append(headerList, "api_key: apiKey"); + { + string headerString("api_key: "); + headerString.append(stringify(&apiKey, "std::string")); + headerList = curl_slist_append(headerList, headerString.c_str()); + } string accessHeader = "Authorization: Bearer "; accessHeader.append(accessToken); @@ -319,7 +322,7 @@ bool PetManager::deletePetSync(char * accessToken, handler, userData, false); } -bool findPetsByStatusProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool findPetsByStatusProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(std::list, Error, void* ) @@ -327,7 +330,6 @@ bool findPetsByStatusProcessor(MemoryStruct_s p_chunk, long code, char* errormsg JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); std::list out; @@ -367,7 +369,7 @@ bool findPetsByStatusProcessor(MemoryStruct_s p_chunk, long code, char* errormsg } } -bool findPetsByStatusHelper(char * accessToken, +static bool findPetsByStatusHelper(char * accessToken, std::list status, void(* handler)(std::list, Error, void* ) , void* userData, bool isAsync) @@ -464,7 +466,7 @@ bool PetManager::findPetsByStatusSync(char * accessToken, handler, userData, false); } -bool findPetsByTagsProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool findPetsByTagsProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(std::list, Error, void* ) @@ -472,7 +474,6 @@ bool findPetsByTagsProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); std::list out; @@ -512,7 +513,7 @@ bool findPetsByTagsProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, } } -bool findPetsByTagsHelper(char * accessToken, +static bool findPetsByTagsHelper(char * accessToken, std::list tags, void(* handler)(std::list, Error, void* ) , void* userData, bool isAsync) @@ -609,7 +610,7 @@ bool PetManager::findPetsByTagsSync(char * accessToken, handler, userData, false); } -bool getPetByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool getPetByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(Pet, Error, void* ) @@ -617,7 +618,6 @@ bool getPetByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); Pet out; @@ -665,7 +665,7 @@ bool getPetByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void } } -bool getPetByIdHelper(char * accessToken, +static bool getPetByIdHelper(char * accessToken, long long petId, void(* handler)(Pet, Error, void* ) , void* userData, bool isAsync) @@ -762,7 +762,7 @@ bool PetManager::getPetByIdSync(char * accessToken, handler, userData, false); } -bool updatePetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool updatePetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -795,7 +795,7 @@ bool updatePetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* } } -bool updatePetHelper(char * accessToken, +static bool updatePetHelper(char * accessToken, Pet body, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -900,7 +900,7 @@ bool PetManager::updatePetSync(char * accessToken, handler, userData, false); } -bool updatePetWithFormProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool updatePetWithFormProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -933,7 +933,7 @@ bool updatePetWithFormProcessor(MemoryStruct_s p_chunk, long code, char* errorms } } -bool updatePetWithFormHelper(char * accessToken, +static bool updatePetWithFormHelper(char * accessToken, long long petId, std::string name, std::string status, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -1030,7 +1030,7 @@ bool PetManager::updatePetWithFormSync(char * accessToken, handler, userData, false); } -bool uploadFileProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool uploadFileProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(ApiResponse, Error, void* ) @@ -1038,7 +1038,6 @@ bool uploadFileProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); ApiResponse out; @@ -1086,7 +1085,7 @@ bool uploadFileProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void } } -bool uploadFileHelper(char * accessToken, +static bool uploadFileHelper(char * accessToken, long long petId, std::string additionalMetadata, std::string file, void(* handler)(ApiResponse, Error, void* ) , void* userData, bool isAsync) diff --git a/samples/client/petstore/tizen/src/PetManager.h b/samples/client/petstore/tizen/src/PetManager.h index 12eeb70e572..93f09544120 100644 --- a/samples/client/petstore/tizen/src/PetManager.h +++ b/samples/client/petstore/tizen/src/PetManager.h @@ -9,8 +9,17 @@ #include "Pet.h" #include "Error.h" +/** \defgroup Operations API Endpoints + * Classes containing all the functions for calling API endpoints + * + */ + namespace Tizen{ namespace ArtikCloud { +/** \addtogroup Pet Pet + * \ingroup Operations + * @{ + */ class PetManager { public: PetManager(); @@ -41,6 +50,8 @@ bool addPetAsync(char * accessToken, Pet body, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Deletes a pet. *Synchronous* * * @@ -68,6 +79,8 @@ bool deletePetAsync(char * accessToken, long long petId, std::string apiKey, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Finds Pets by status. *Synchronous* * * Multiple status values can be provided with comma separated strings @@ -93,6 +106,8 @@ bool findPetsByStatusAsync(char * accessToken, std::list status, void(* handler)(std::list, Error, void* ) , void* userData); + + /*! \brief Finds Pets by tags. *Synchronous* * * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -118,6 +133,8 @@ bool findPetsByTagsAsync(char * accessToken, std::list tags, void(* handler)(std::list, Error, void* ) , void* userData); + + /*! \brief Find pet by ID. *Synchronous* * * Returns a single pet @@ -143,6 +160,8 @@ bool getPetByIdAsync(char * accessToken, long long petId, void(* handler)(Pet, Error, void* ) , void* userData); + + /*! \brief Update an existing pet. *Synchronous* * * @@ -168,6 +187,8 @@ bool updatePetAsync(char * accessToken, Pet body, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Updates a pet in the store with form data. *Synchronous* * * @@ -197,6 +218,8 @@ bool updatePetWithFormAsync(char * accessToken, long long petId, std::string name, std::string status, void(* handler)(Error, void* ) , void* userData); + + /*! \brief uploads an image. *Synchronous* * * @@ -227,11 +250,14 @@ bool uploadFileAsync(char * accessToken, void(* handler)(ApiResponse, Error, void* ) , void* userData); + + static std::string getBasePath() { return "http://petstore.swagger.io/v2"; } }; +/** @}*/ } } diff --git a/samples/client/petstore/tizen/src/StoreManager.cpp b/samples/client/petstore/tizen/src/StoreManager.cpp index 76ad0e8af5a..8721032e57f 100644 --- a/samples/client/petstore/tizen/src/StoreManager.cpp +++ b/samples/client/petstore/tizen/src/StoreManager.cpp @@ -48,7 +48,7 @@ static gpointer __StoreManagerthreadFunc(gpointer data) } -bool deleteOrderProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool deleteOrderProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -81,7 +81,7 @@ bool deleteOrderProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, voi } } -bool deleteOrderHelper(char * accessToken, +static bool deleteOrderHelper(char * accessToken, std::string orderId, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -178,7 +178,7 @@ bool StoreManager::deleteOrderSync(char * accessToken, handler, userData, false); } -bool getInventoryProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool getInventoryProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(std::map, Error, void* ) @@ -186,7 +186,6 @@ bool getInventoryProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, vo JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); std::map out; @@ -212,7 +211,7 @@ bool getInventoryProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, vo } } -bool getInventoryHelper(char * accessToken, +static bool getInventoryHelper(char * accessToken, void(* handler)(std::map, Error, void* ) , void* userData, bool isAsync) @@ -303,7 +302,7 @@ bool StoreManager::getInventorySync(char * accessToken, handler, userData, false); } -bool getOrderByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool getOrderByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(Order, Error, void* ) @@ -311,7 +310,6 @@ bool getOrderByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, vo JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); Order out; @@ -359,7 +357,7 @@ bool getOrderByIdProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, vo } } -bool getOrderByIdHelper(char * accessToken, +static bool getOrderByIdHelper(char * accessToken, long long orderId, void(* handler)(Order, Error, void* ) , void* userData, bool isAsync) @@ -456,7 +454,7 @@ bool StoreManager::getOrderByIdSync(char * accessToken, handler, userData, false); } -bool placeOrderProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool placeOrderProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(Order, Error, void* ) @@ -464,7 +462,6 @@ bool placeOrderProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); Order out; @@ -512,7 +509,7 @@ bool placeOrderProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void } } -bool placeOrderHelper(char * accessToken, +static bool placeOrderHelper(char * accessToken, Order body, void(* handler)(Order, Error, void* ) , void* userData, bool isAsync) diff --git a/samples/client/petstore/tizen/src/StoreManager.h b/samples/client/petstore/tizen/src/StoreManager.h index 0d65e46b0de..9736475b381 100644 --- a/samples/client/petstore/tizen/src/StoreManager.h +++ b/samples/client/petstore/tizen/src/StoreManager.h @@ -9,8 +9,17 @@ #include #include "Error.h" +/** \defgroup Operations API Endpoints + * Classes containing all the functions for calling API endpoints + * + */ + namespace Tizen{ namespace ArtikCloud { +/** \addtogroup Store Store + * \ingroup Operations + * @{ + */ class StoreManager { public: StoreManager(); @@ -41,6 +50,8 @@ bool deleteOrderAsync(char * accessToken, std::string orderId, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Returns pet inventories by status. *Synchronous* * * Returns a map of status codes to quantities @@ -64,6 +75,8 @@ bool getInventoryAsync(char * accessToken, void(* handler)(std::map, Error, void* ) , void* userData); + + /*! \brief Find purchase order by ID. *Synchronous* * * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -89,6 +102,8 @@ bool getOrderByIdAsync(char * accessToken, long long orderId, void(* handler)(Order, Error, void* ) , void* userData); + + /*! \brief Place an order for a pet. *Synchronous* * * @@ -115,11 +130,14 @@ bool placeOrderAsync(char * accessToken, void(* handler)(Order, Error, void* ) , void* userData); + + static std::string getBasePath() { return "http://petstore.swagger.io/v2"; } }; +/** @}*/ } } diff --git a/samples/client/petstore/tizen/src/Tag.h b/samples/client/petstore/tizen/src/Tag.h index c52192d0147..a66f9fc6add 100644 --- a/samples/client/petstore/tizen/src/Tag.h +++ b/samples/client/petstore/tizen/src/Tag.h @@ -11,11 +11,18 @@ #include #include "Object.h" +/** \defgroup Models Data Structures for API + * Classes containing all the Data Structures needed for calling/returned by API endpoints + * + */ + namespace Tizen { namespace ArtikCloud { /*! \brief A tag for a pet + * + * \ingroup Models * */ diff --git a/samples/client/petstore/tizen/src/User.h b/samples/client/petstore/tizen/src/User.h index a0b401dda91..6e61d601103 100644 --- a/samples/client/petstore/tizen/src/User.h +++ b/samples/client/petstore/tizen/src/User.h @@ -11,11 +11,18 @@ #include #include "Object.h" +/** \defgroup Models Data Structures for API + * Classes containing all the Data Structures needed for calling/returned by API endpoints + * + */ + namespace Tizen { namespace ArtikCloud { /*! \brief A User who is purchasing from the pet store + * + * \ingroup Models * */ diff --git a/samples/client/petstore/tizen/src/UserManager.cpp b/samples/client/petstore/tizen/src/UserManager.cpp index 389033e8592..b87911169b7 100644 --- a/samples/client/petstore/tizen/src/UserManager.cpp +++ b/samples/client/petstore/tizen/src/UserManager.cpp @@ -48,7 +48,7 @@ static gpointer __UserManagerthreadFunc(gpointer data) } -bool createUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool createUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -81,7 +81,7 @@ bool createUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void } } -bool createUserHelper(char * accessToken, +static bool createUserHelper(char * accessToken, User body, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -185,7 +185,7 @@ bool UserManager::createUserSync(char * accessToken, handler, userData, false); } -bool createUsersWithArrayInputProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool createUsersWithArrayInputProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -218,7 +218,7 @@ bool createUsersWithArrayInputProcessor(MemoryStruct_s p_chunk, long code, char* } } -bool createUsersWithArrayInputHelper(char * accessToken, +static bool createUsersWithArrayInputHelper(char * accessToken, std::list body, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -334,7 +334,7 @@ bool UserManager::createUsersWithArrayInputSync(char * accessToken, handler, userData, false); } -bool createUsersWithListInputProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool createUsersWithListInputProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -367,7 +367,7 @@ bool createUsersWithListInputProcessor(MemoryStruct_s p_chunk, long code, char* } } -bool createUsersWithListInputHelper(char * accessToken, +static bool createUsersWithListInputHelper(char * accessToken, std::list body, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -483,7 +483,7 @@ bool UserManager::createUsersWithListInputSync(char * accessToken, handler, userData, false); } -bool deleteUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool deleteUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -516,7 +516,7 @@ bool deleteUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void } } -bool deleteUserHelper(char * accessToken, +static bool deleteUserHelper(char * accessToken, std::string username, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -613,7 +613,7 @@ bool UserManager::deleteUserSync(char * accessToken, handler, userData, false); } -bool getUserByNameProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool getUserByNameProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(User, Error, void* ) @@ -621,7 +621,6 @@ bool getUserByNameProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, v JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); User out; @@ -669,7 +668,7 @@ bool getUserByNameProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, v } } -bool getUserByNameHelper(char * accessToken, +static bool getUserByNameHelper(char * accessToken, std::string username, void(* handler)(User, Error, void* ) , void* userData, bool isAsync) @@ -766,7 +765,7 @@ bool UserManager::getUserByNameSync(char * accessToken, handler, userData, false); } -bool loginUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool loginUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { void(* handler)(std::string, Error, void* ) @@ -774,7 +773,6 @@ bool loginUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* JsonNode* pJson; char * data = p_chunk.memory; - printf("%s\n", data); std::string out; @@ -817,7 +815,7 @@ bool loginUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* } } -bool loginUserHelper(char * accessToken, +static bool loginUserHelper(char * accessToken, std::string username, std::string password, void(* handler)(std::string, Error, void* ) , void* userData, bool isAsync) @@ -916,7 +914,7 @@ bool UserManager::loginUserSync(char * accessToken, handler, userData, false); } -bool logoutUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool logoutUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -949,7 +947,7 @@ bool logoutUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void } } -bool logoutUserHelper(char * accessToken, +static bool logoutUserHelper(char * accessToken, void(* handler)(Error, void* ) , void* userData, bool isAsync) @@ -1040,7 +1038,7 @@ bool UserManager::logoutUserSync(char * accessToken, handler, userData, false); } -bool updateUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, +static bool updateUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData, void(* voidHandler)()) { @@ -1073,7 +1071,7 @@ bool updateUserProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, void } } -bool updateUserHelper(char * accessToken, +static bool updateUserHelper(char * accessToken, std::string username, User body, void(* handler)(Error, void* ) , void* userData, bool isAsync) diff --git a/samples/client/petstore/tizen/src/UserManager.h b/samples/client/petstore/tizen/src/UserManager.h index 01c1a45368f..4c9a3a5f7dd 100644 --- a/samples/client/petstore/tizen/src/UserManager.h +++ b/samples/client/petstore/tizen/src/UserManager.h @@ -9,8 +9,17 @@ #include #include "Error.h" +/** \defgroup Operations API Endpoints + * Classes containing all the functions for calling API endpoints + * + */ + namespace Tizen{ namespace ArtikCloud { +/** \addtogroup User User + * \ingroup Operations + * @{ + */ class UserManager { public: UserManager(); @@ -41,6 +50,8 @@ bool createUserAsync(char * accessToken, User body, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Creates list of users with given input array. *Synchronous* * * @@ -66,6 +77,8 @@ bool createUsersWithArrayInputAsync(char * accessToken, std::list body, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Creates list of users with given input array. *Synchronous* * * @@ -91,6 +104,8 @@ bool createUsersWithListInputAsync(char * accessToken, std::list body, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Delete user. *Synchronous* * * This can only be done by the logged in user. @@ -116,6 +131,8 @@ bool deleteUserAsync(char * accessToken, std::string username, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Get user by user name. *Synchronous* * * @@ -141,6 +158,8 @@ bool getUserByNameAsync(char * accessToken, std::string username, void(* handler)(User, Error, void* ) , void* userData); + + /*! \brief Logs user into the system. *Synchronous* * * @@ -168,6 +187,8 @@ bool loginUserAsync(char * accessToken, std::string username, std::string password, void(* handler)(std::string, Error, void* ) , void* userData); + + /*! \brief Logs out current logged in user session. *Synchronous* * * @@ -191,6 +212,8 @@ bool logoutUserAsync(char * accessToken, void(* handler)(Error, void* ) , void* userData); + + /*! \brief Updated user. *Synchronous* * * This can only be done by the logged in user. @@ -219,11 +242,14 @@ bool updateUserAsync(char * accessToken, void(* handler)(Error, void* ) , void* userData); + + static std::string getBasePath() { return "http://petstore.swagger.io/v2"; } }; +/** @}*/ } } diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts index ac63e3a84de..a4d0f87d9bc 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -47,7 +47,7 @@ export class PetApi implements PetApiInterface { * * @param body Pet object that needs to be added to the store */ - public addPet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> { + public addPet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { return this.addPetWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -80,7 +80,7 @@ export class PetApi implements PetApiInterface { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - public findPetsByStatus(status?: Array, extraHttpRequestParams?: any): Observable> { + public findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable> { return this.findPetsByStatusWithHttpInfo(status, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -96,7 +96,7 @@ export class PetApi implements PetApiInterface { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - public findPetsByTags(tags?: Array, extraHttpRequestParams?: any): Observable> { + public findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable> { return this.findPetsByTagsWithHttpInfo(tags, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -109,8 +109,8 @@ export class PetApi implements PetApiInterface { /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched + * Returns a single pet + * @param petId ID of pet to return */ public getPetById(petId: number, extraHttpRequestParams?: any): Observable { return this.getPetByIdWithHttpInfo(petId, extraHttpRequestParams) @@ -128,7 +128,7 @@ export class PetApi implements PetApiInterface { * * @param body Pet object that needs to be added to the store */ - public updatePet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> { + public updatePet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { return this.updatePetWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -146,7 +146,7 @@ export class PetApi implements PetApiInterface { * @param name Updated name of the pet * @param status Updated status of the pet */ - public updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> { + public updatePetWithForm(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> { return this.updatePetWithFormWithHttpInfo(petId, name, status, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -164,7 +164,7 @@ export class PetApi implements PetApiInterface { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable<{}> { + public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable { return this.uploadFileWithHttpInfo(petId, additionalMetadata, file, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -181,11 +181,15 @@ export class PetApi implements PetApiInterface { * * @param body Pet object that needs to be added to the store */ - public addPetWithHttpInfo(body?: models.Pet, extraHttpRequestParams?: any): Observable { + public addPetWithHttpInfo(body: models.Pet, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling addPet.'); + } // to determine the Content-Type header let consumes: string[] = [ 'application/json', @@ -282,15 +286,17 @@ export class PetApi implements PetApiInterface { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - public findPetsByStatusWithHttpInfo(status?: Array, extraHttpRequestParams?: any): Observable { + public findPetsByStatusWithHttpInfo(status: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/findByStatus'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); + } if (status) { - status.forEach((element) => { - queryParameters.append('status', element); - }) + queryParameters.set('status', status.join(COLLECTION_FORMATS['csv'])); } // to determine the Content-Type header @@ -331,15 +337,17 @@ export class PetApi implements PetApiInterface { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - public findPetsByTagsWithHttpInfo(tags?: Array, extraHttpRequestParams?: any): Observable { + public findPetsByTagsWithHttpInfo(tags: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/findByTags'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); + } if (tags) { - tags.forEach((element) => { - queryParameters.append('tags', element); - }) + queryParameters.set('tags', tags.join(COLLECTION_FORMATS['csv'])); } // to determine the Content-Type header @@ -377,8 +385,8 @@ export class PetApi implements PetApiInterface { /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched + * Returns a single pet + * @param petId ID of pet to return */ public getPetByIdWithHttpInfo(petId: number, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/${petId}' @@ -405,15 +413,6 @@ export class PetApi implements PetApiInterface { headers.set('api_key', this.configuration.apiKey); } - // authentication (petstore_auth) required - // oauth required - if (this.configuration.accessToken) { - let accessToken = typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; - headers.set('Authorization', 'Bearer ' + accessToken); - } - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -433,11 +432,15 @@ export class PetApi implements PetApiInterface { * * @param body Pet object that needs to be added to the store */ - public updatePetWithHttpInfo(body?: models.Pet, extraHttpRequestParams?: any): Observable { + public updatePetWithHttpInfo(body: models.Pet, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updatePet.'); + } // to determine the Content-Type header let consumes: string[] = [ 'application/json', @@ -483,7 +486,7 @@ export class PetApi implements PetApiInterface { * @param name Updated name of the pet * @param status Updated status of the pet */ - public updatePetWithFormWithHttpInfo(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable { + public updatePetWithFormWithHttpInfo(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/${petId}' .replace('${' + 'petId' + '}', String(petId)); diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApiInterface.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApiInterface.ts index d41a6388274..3f7c04d27db 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApiInterface.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApiInterface.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -28,7 +28,7 @@ export interface PetApiInterface { * * @param body Pet object that needs to be added to the store */ - addPet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}>; + addPet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}>; /** * Deletes a pet @@ -43,19 +43,19 @@ export interface PetApiInterface { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(status?: Array, extraHttpRequestParams?: any): Observable>; + findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable>; /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(tags?: Array, extraHttpRequestParams?: any): Observable>; + findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable>; /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched + * Returns a single pet + * @param petId ID of pet to return */ getPetById(petId: number, extraHttpRequestParams?: any): Observable; @@ -64,7 +64,7 @@ export interface PetApiInterface { * * @param body Pet object that needs to be added to the store */ - updatePet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}>; + updatePet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}>; /** * Updates a pet in the store with form data @@ -73,7 +73,7 @@ export interface PetApiInterface { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}>; + updatePetWithForm(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}>; /** * uploads an image @@ -82,6 +82,6 @@ export interface PetApiInterface { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable<{}>; + uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable; } diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts index ed76ded48e6..04d27c02f8d 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -78,7 +78,7 @@ export class StoreApi implements StoreApiInterface { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - public getOrderById(orderId: string, extraHttpRequestParams?: any): Observable { + public getOrderById(orderId: number, extraHttpRequestParams?: any): Observable { return this.getOrderByIdWithHttpInfo(orderId, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -94,7 +94,7 @@ export class StoreApi implements StoreApiInterface { * * @param body order placed for purchasing the pet */ - public placeOrder(body?: models.Order, extraHttpRequestParams?: any): Observable { + public placeOrder(body: models.Order, extraHttpRequestParams?: any): Observable { return this.placeOrderWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -188,7 +188,7 @@ export class StoreApi implements StoreApiInterface { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - public getOrderByIdWithHttpInfo(orderId: string, extraHttpRequestParams?: any): Observable { + public getOrderByIdWithHttpInfo(orderId: number, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/store/order/${orderId}' .replace('${' + 'orderId' + '}', String(orderId)); @@ -227,11 +227,15 @@ export class StoreApi implements StoreApiInterface { * * @param body order placed for purchasing the pet */ - public placeOrderWithHttpInfo(body?: models.Order, extraHttpRequestParams?: any): Observable { + public placeOrderWithHttpInfo(body: models.Order, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/store/order'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling placeOrder.'); + } // to determine the Content-Type header let consumes: string[] = [ ]; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApiInterface.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApiInterface.ts index e8fe0eb9a82..ca2476d8210 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApiInterface.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApiInterface.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -41,13 +41,13 @@ export interface StoreApiInterface { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(orderId: string, extraHttpRequestParams?: any): Observable; + getOrderById(orderId: number, extraHttpRequestParams?: any): Observable; /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(body?: models.Order, extraHttpRequestParams?: any): Observable; + placeOrder(body: models.Order, extraHttpRequestParams?: any): Observable; } diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts index 0bb23fb6c90..1a11e474c06 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -47,7 +47,7 @@ export class UserApi implements UserApiInterface { * This can only be done by the logged in user. * @param body Created user object */ - public createUser(body?: models.User, extraHttpRequestParams?: any): Observable<{}> { + public createUser(body: models.User, extraHttpRequestParams?: any): Observable<{}> { return this.createUserWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -63,7 +63,7 @@ export class UserApi implements UserApiInterface { * * @param body List of user object */ - public createUsersWithArrayInput(body?: Array, extraHttpRequestParams?: any): Observable<{}> { + public createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { return this.createUsersWithArrayInputWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -79,7 +79,7 @@ export class UserApi implements UserApiInterface { * * @param body List of user object */ - public createUsersWithListInput(body?: Array, extraHttpRequestParams?: any): Observable<{}> { + public createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { return this.createUsersWithListInputWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -128,7 +128,7 @@ export class UserApi implements UserApiInterface { * @param username The user name for login * @param password The password for login in clear text */ - public loginUser(username?: string, password?: string, extraHttpRequestParams?: any): Observable { + public loginUser(username: string, password: string, extraHttpRequestParams?: any): Observable { return this.loginUserWithHttpInfo(username, password, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -160,7 +160,7 @@ export class UserApi implements UserApiInterface { * @param username name that need to be deleted * @param body Updated user object */ - public updateUser(username: string, body?: models.User, extraHttpRequestParams?: any): Observable<{}> { + public updateUser(username: string, body: models.User, extraHttpRequestParams?: any): Observable<{}> { return this.updateUserWithHttpInfo(username, body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -177,11 +177,15 @@ export class UserApi implements UserApiInterface { * This can only be done by the logged in user. * @param body Created user object */ - public createUserWithHttpInfo(body?: models.User, extraHttpRequestParams?: any): Observable { + public createUserWithHttpInfo(body: models.User, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUser.'); + } // to determine the Content-Type header let consumes: string[] = [ ]; @@ -214,11 +218,15 @@ export class UserApi implements UserApiInterface { * * @param body List of user object */ - public createUsersWithArrayInputWithHttpInfo(body?: Array, extraHttpRequestParams?: any): Observable { + public createUsersWithArrayInputWithHttpInfo(body: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/createWithArray'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } // to determine the Content-Type header let consumes: string[] = [ ]; @@ -251,11 +259,15 @@ export class UserApi implements UserApiInterface { * * @param body List of user object */ - public createUsersWithListInputWithHttpInfo(body?: Array, extraHttpRequestParams?: any): Observable { + public createUsersWithListInputWithHttpInfo(body: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/createWithList'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); + } // to determine the Content-Type header let consumes: string[] = [ ]; @@ -367,11 +379,19 @@ export class UserApi implements UserApiInterface { * @param username The user name for login * @param password The password for login in clear text */ - public loginUserWithHttpInfo(username?: string, password?: string, extraHttpRequestParams?: any): Observable { + public loginUserWithHttpInfo(username: string, password: string, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/login'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling loginUser.'); + } + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new Error('Required parameter password was null or undefined when calling loginUser.'); + } if (username !== undefined) { queryParameters.set('username', username); } @@ -443,7 +463,7 @@ export class UserApi implements UserApiInterface { * @param username name that need to be deleted * @param body Updated user object */ - public updateUserWithHttpInfo(username: string, body?: models.User, extraHttpRequestParams?: any): Observable { + public updateUserWithHttpInfo(username: string, body: models.User, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/${username}' .replace('${' + 'username' + '}', String(username)); @@ -453,6 +473,10 @@ export class UserApi implements UserApiInterface { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updateUser.'); + } // to determine the Content-Type header let consumes: string[] = [ ]; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApiInterface.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApiInterface.ts index c882866c1c1..067befa18e7 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApiInterface.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApiInterface.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -28,21 +28,21 @@ export interface UserApiInterface { * This can only be done by the logged in user. * @param body Created user object */ - createUser(body?: models.User, extraHttpRequestParams?: any): Observable<{}>; + createUser(body: models.User, extraHttpRequestParams?: any): Observable<{}>; /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(body?: Array, extraHttpRequestParams?: any): Observable<{}>; + createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}>; /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(body?: Array, extraHttpRequestParams?: any): Observable<{}>; + createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}>; /** * Delete user @@ -64,7 +64,7 @@ export interface UserApiInterface { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(username?: string, password?: string, extraHttpRequestParams?: any): Observable; + loginUser(username: string, password: string, extraHttpRequestParams?: any): Observable; /** * Logs out current logged in user session @@ -78,6 +78,6 @@ export interface UserApiInterface { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(username: string, body?: models.User, extraHttpRequestParams?: any): Observable<{}>; + updateUser(username: string, body: models.User, extraHttpRequestParams?: any): Observable<{}>; } diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/model/ApiResponse.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/ApiResponse.ts new file mode 100644 index 00000000000..3af781cf580 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/ApiResponse.ts @@ -0,0 +1,25 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + + +/** + * Describes the result of uploading an image resource + */ +export interface ApiResponse { + code?: number; + + type?: string; + + message?: string; + +} diff --git a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts new file mode 100644 index 00000000000..fdf053b7303 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts @@ -0,0 +1,571 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +import * as $ from 'jquery'; +import * as models from '../model/models'; +import { COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + +/* tslint:disable:no-unused-variable member-ordering */ + + +export class PetApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Array = []; + public configuration: Configuration = new Configuration(); + + constructor(basePath?: string, configuration?: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + } + } + + private extendObj(objA: T2, objB: T2): T1|T2 { + for (let key in objB) { + if (objB.hasOwnProperty(key)) { + objA[key] = objB[key]; + } + } + return objA; + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + */ + public addPet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + 'application/json', + 'application/xml' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling deletePet.'); + } + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + headerParams['api_key'] = String(apiKey); + + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByStatus'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + if (status) { + status.forEach((element: any) => { + queryParameters['status'].push(element); + }); + } + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + */ + public findPetsByTags(tags?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByTags'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + if (tags) { + tags.forEach((element: any) => { + queryParameters['tags'].push(element); + }); + } + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + */ + public getPetById(petId: number): JQueryPromise<{ response: JQueryXHR; body: models.Pet; }> { + let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling getPetById.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (api_key) required + if (this.configuration.apiKey) { + headerParams['api_key'] = this.configuration.apiKey; + } + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.Pet, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + */ + public updatePet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + 'application/json', + 'application/xml' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + */ + public updatePetWithForm(petId: string, name?: string, status?: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + let formParams = new FormData(); + let reqHasFile = false; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + if (name !== null && name !== undefined) { + formParams.append('name', name); + } + + if (status !== null && status !== undefined) { + formParams.append('status', status); + } + + // to determine the Content-Type header + let consumes: string[] = [ + 'application/x-www-form-urlencoded' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + if (!reqHasFile) { + headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + requestOptions.data = formParams; + if (reqHasFile) { + requestOptions.contentType = false; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: any): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}/uploadImage'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + let formParams = new FormData(); + let reqHasFile = false; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); + } + + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + if (additionalMetadata !== null && additionalMetadata !== undefined) { + formParams.append('additionalMetadata', additionalMetadata); + } + + reqHasFile = true; + if (file !== null && file !== undefined) { + formParams.append('file', file); + } + + // to determine the Content-Type header + let consumes: string[] = [ + 'multipart/form-data' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + if (!reqHasFile) { + headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + requestOptions.data = formParams; + if (reqHasFile) { + requestOptions.contentType = false; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + +} diff --git a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts new file mode 100644 index 00000000000..a2495cc0f30 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts @@ -0,0 +1,239 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +import * as $ from 'jquery'; +import * as models from '../model/models'; +import { COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + +/* tslint:disable:no-unused-variable member-ordering */ + + +export class StoreApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Array = []; + public configuration: Configuration = new Configuration(); + + constructor(basePath?: string, configuration?: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + } + } + + private extendObj(objA: T2, objB: T2): T1|T2 { + for (let key in objB) { + if (objB.hasOwnProperty(key)) { + objA[key] = objB[key]; + } + } + return objA; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', String(orderId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + */ + public getInventory(): JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { + let localVarPath = this.basePath + '/store/inventory'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (api_key) required + if (this.configuration.apiKey) { + headerParams['api_key'] = this.configuration.apiKey; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: { [key: string]: number; }, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: string): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', String(orderId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + */ + public placeOrder(body?: models.Order): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + let localVarPath = this.basePath + '/store/order'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + +} diff --git a/samples/client/petstore/typescript-jquery/default/api/UserApi.ts b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts new file mode 100644 index 00000000000..53349124ed6 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts @@ -0,0 +1,437 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +import * as $ from 'jquery'; +import * as models from '../model/models'; +import { COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + +/* tslint:disable:no-unused-variable member-ordering */ + + +export class UserApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Array = []; + public configuration: Configuration = new Configuration(); + + constructor(basePath?: string, configuration?: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + } + } + + private extendObj(objA: T2, objB: T2): T1|T2 { + for (let key in objB) { + if (objB.hasOwnProperty(key)) { + objA[key] = objB[key]; + } + } + return objA; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + */ + public createUser(body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithArrayInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithArray'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithListInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithList'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + */ + public deleteUser(username: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling deleteUser.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string): JQueryPromise<{ response: JQueryXHR; body: models.User; }> { + let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling getUserByName.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.User, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username?: string, password?: string): JQueryPromise<{ response: JQueryXHR; body: string; }> { + let localVarPath = this.basePath + '/user/login'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + if (username !== null && username !== undefined) { + queryParameters['username'] = username; + } + if (password !== null && password !== undefined) { + queryParameters['password'] = password; + } + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: string, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Logs out current logged in user session + * + */ + public logoutUser(): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/logout'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser(username: string, body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling updateUser.'); + } + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + +} diff --git a/samples/client/petstore/typescript-jquery/default/api/api.ts b/samples/client/petstore/typescript-jquery/default/api/api.ts new file mode 100644 index 00000000000..4ddd9e29663 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/api/api.ts @@ -0,0 +1,7 @@ +export * from './PetApi'; +import { PetApi } from './PetApi'; +export * from './StoreApi'; +import { StoreApi } from './StoreApi'; +export * from './UserApi'; +import { UserApi } from './UserApi'; +export const APIS = [PetApi, StoreApi, UserApi]; diff --git a/samples/client/petstore/typescript-jquery/default/configuration.ts b/samples/client/petstore/typescript-jquery/default/configuration.ts new file mode 100644 index 00000000000..a566a180e4e --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/configuration.ts @@ -0,0 +1,6 @@ +export class Configuration { + apiKey: string; + username: string; + password: string; + accessToken: string | (() => string); +} \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/default/index.ts b/samples/client/petstore/typescript-jquery/default/index.ts new file mode 100644 index 00000000000..d097c728017 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/index.ts @@ -0,0 +1,4 @@ +export * from './api/api'; +export * from './model/models'; +export * from './variables'; +export * from './configuration'; \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/default/model/Category.ts b/samples/client/petstore/typescript-jquery/default/model/Category.ts new file mode 100644 index 00000000000..ffdacd4f707 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/Category.ts @@ -0,0 +1,20 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Category { + id?: number; + + name?: string; + +} diff --git a/samples/client/petstore/typescript-jquery/default/model/Order.ts b/samples/client/petstore/typescript-jquery/default/model/Order.ts new file mode 100644 index 00000000000..9c47071c5b6 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/Order.ts @@ -0,0 +1,38 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Order { + id?: number; + + petId?: number; + + quantity?: number; + + shipDate?: Date; + + /** + * Order Status + */ + status?: Order.StatusEnum; + + complete?: boolean; + +} +export namespace Order { + export enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } +} diff --git a/samples/client/petstore/typescript-jquery/default/model/Pet.ts b/samples/client/petstore/typescript-jquery/default/model/Pet.ts new file mode 100644 index 00000000000..d64dc809e53 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/Pet.ts @@ -0,0 +1,38 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Pet { + id?: number; + + category?: models.Category; + + name: string; + + photoUrls: Array; + + tags?: Array; + + /** + * pet status in the store + */ + status?: Pet.StatusEnum; + +} +export namespace Pet { + export enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } +} diff --git a/samples/client/petstore/typescript-jquery/default/model/Tag.ts b/samples/client/petstore/typescript-jquery/default/model/Tag.ts new file mode 100644 index 00000000000..8a3b99ae9ca --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/Tag.ts @@ -0,0 +1,20 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Tag { + id?: number; + + name?: string; + +} diff --git a/samples/client/petstore/typescript-jquery/default/model/User.ts b/samples/client/petstore/typescript-jquery/default/model/User.ts new file mode 100644 index 00000000000..43d00f7b318 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/User.ts @@ -0,0 +1,35 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface User { + id?: number; + + username?: string; + + firstName?: string; + + lastName?: string; + + email?: string; + + password?: string; + + phone?: string; + + /** + * User Status + */ + userStatus?: number; + +} diff --git a/samples/client/petstore/typescript-jquery/default/model/models.ts b/samples/client/petstore/typescript-jquery/default/model/models.ts new file mode 100644 index 00000000000..92dac02846c --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/models.ts @@ -0,0 +1,5 @@ +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-jquery/default/variables.ts b/samples/client/petstore/typescript-jquery/default/variables.ts new file mode 100644 index 00000000000..505ce9355e2 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/variables.ts @@ -0,0 +1,7 @@ + +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +} \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts new file mode 100644 index 00000000000..fdf053b7303 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts @@ -0,0 +1,571 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +import * as $ from 'jquery'; +import * as models from '../model/models'; +import { COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + +/* tslint:disable:no-unused-variable member-ordering */ + + +export class PetApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Array = []; + public configuration: Configuration = new Configuration(); + + constructor(basePath?: string, configuration?: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + } + } + + private extendObj(objA: T2, objB: T2): T1|T2 { + for (let key in objB) { + if (objB.hasOwnProperty(key)) { + objA[key] = objB[key]; + } + } + return objA; + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + */ + public addPet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + 'application/json', + 'application/xml' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling deletePet.'); + } + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + headerParams['api_key'] = String(apiKey); + + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByStatus'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + if (status) { + status.forEach((element: any) => { + queryParameters['status'].push(element); + }); + } + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + */ + public findPetsByTags(tags?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByTags'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + if (tags) { + tags.forEach((element: any) => { + queryParameters['tags'].push(element); + }); + } + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + */ + public getPetById(petId: number): JQueryPromise<{ response: JQueryXHR; body: models.Pet; }> { + let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling getPetById.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (api_key) required + if (this.configuration.apiKey) { + headerParams['api_key'] = this.configuration.apiKey; + } + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.Pet, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + */ + public updatePet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + 'application/json', + 'application/xml' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + */ + public updatePetWithForm(petId: string, name?: string, status?: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + let formParams = new FormData(); + let reqHasFile = false; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + if (name !== null && name !== undefined) { + formParams.append('name', name); + } + + if (status !== null && status !== undefined) { + formParams.append('status', status); + } + + // to determine the Content-Type header + let consumes: string[] = [ + 'application/x-www-form-urlencoded' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + if (!reqHasFile) { + headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + requestOptions.data = formParams; + if (reqHasFile) { + requestOptions.contentType = false; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: any): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}/uploadImage'.replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + let formParams = new FormData(); + let reqHasFile = false; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); + } + + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + if (additionalMetadata !== null && additionalMetadata !== undefined) { + formParams.append('additionalMetadata', additionalMetadata); + } + + reqHasFile = true; + if (file !== null && file !== undefined) { + formParams.append('file', file); + } + + // to determine the Content-Type header + let consumes: string[] = [ + 'multipart/form-data' + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headerParams['Authorization'] = 'Bearer ' + accessToken; + } + + if (!reqHasFile) { + headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + requestOptions.data = formParams; + if (reqHasFile) { + requestOptions.contentType = false; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + +} diff --git a/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts new file mode 100644 index 00000000000..a2495cc0f30 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts @@ -0,0 +1,239 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +import * as $ from 'jquery'; +import * as models from '../model/models'; +import { COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + +/* tslint:disable:no-unused-variable member-ordering */ + + +export class StoreApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Array = []; + public configuration: Configuration = new Configuration(); + + constructor(basePath?: string, configuration?: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + } + } + + private extendObj(objA: T2, objB: T2): T1|T2 { + for (let key in objB) { + if (objB.hasOwnProperty(key)) { + objA[key] = objB[key]; + } + } + return objA; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', String(orderId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + */ + public getInventory(): JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { + let localVarPath = this.basePath + '/store/inventory'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + // authentication (api_key) required + if (this.configuration.apiKey) { + headerParams['api_key'] = this.configuration.apiKey; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: { [key: string]: number; }, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: string): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', String(orderId)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + */ + public placeOrder(body?: models.Order): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + let localVarPath = this.basePath + '/store/order'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + +} diff --git a/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts new file mode 100644 index 00000000000..53349124ed6 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts @@ -0,0 +1,437 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +import * as $ from 'jquery'; +import * as models from '../model/models'; +import { COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + +/* tslint:disable:no-unused-variable member-ordering */ + + +export class UserApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Array = []; + public configuration: Configuration = new Configuration(); + + constructor(basePath?: string, configuration?: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + } + } + + private extendObj(objA: T2, objB: T2): T1|T2 { + for (let key in objB) { + if (objB.hasOwnProperty(key)) { + objA[key] = objB[key]; + } + } + return objA; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + */ + public createUser(body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithArrayInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithArray'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithListInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithList'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + */ + public deleteUser(username: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling deleteUser.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string): JQueryPromise<{ response: JQueryXHR; body: models.User; }> { + let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling getUserByName.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: models.User, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username?: string, password?: string): JQueryPromise<{ response: JQueryXHR; body: string; }> { + let localVarPath = this.basePath + '/user/login'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + + if (username !== null && username !== undefined) { + queryParameters['username'] = username; + } + if (password !== null && password !== undefined) { + queryParameters['password'] = password; + } + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: string, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Logs out current logged in user session + * + */ + public logoutUser(): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/logout'; + + let queryParameters: any = {}; + let headerParams: any = {}; + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser(username: string, body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = {}; + let headerParams: any = {}; + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling updateUser.'); + } + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + // to determine the Content-Type header + let consumes: string[] = [ + ]; + + // to determine the Accept header + let produces: string[] = [ + 'application/json', + 'application/xml' + ]; + + + headerParams['Content-Type'] = 'application/json'; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + requestOptions.data = JSON.stringify(body); + if (headerParams['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: any, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve(jqXHR, data), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject(xhr, errorThrown) + ); + return dfd.promise(); + } + +} diff --git a/samples/client/petstore/typescript-jquery/npm/api/api.ts b/samples/client/petstore/typescript-jquery/npm/api/api.ts new file mode 100644 index 00000000000..4ddd9e29663 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/api/api.ts @@ -0,0 +1,7 @@ +export * from './PetApi'; +import { PetApi } from './PetApi'; +export * from './StoreApi'; +import { StoreApi } from './StoreApi'; +export * from './UserApi'; +import { UserApi } from './UserApi'; +export const APIS = [PetApi, StoreApi, UserApi]; diff --git a/samples/client/petstore/typescript-jquery/npm/configuration.ts b/samples/client/petstore/typescript-jquery/npm/configuration.ts new file mode 100644 index 00000000000..a566a180e4e --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/configuration.ts @@ -0,0 +1,6 @@ +export class Configuration { + apiKey: string; + username: string; + password: string; + accessToken: string | (() => string); +} \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/npm/index.ts b/samples/client/petstore/typescript-jquery/npm/index.ts new file mode 100644 index 00000000000..d097c728017 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/index.ts @@ -0,0 +1,4 @@ +export * from './api/api'; +export * from './model/models'; +export * from './variables'; +export * from './configuration'; \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/npm/model/Category.ts b/samples/client/petstore/typescript-jquery/npm/model/Category.ts new file mode 100644 index 00000000000..ffdacd4f707 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/model/Category.ts @@ -0,0 +1,20 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Category { + id?: number; + + name?: string; + +} diff --git a/samples/client/petstore/typescript-jquery/npm/model/Order.ts b/samples/client/petstore/typescript-jquery/npm/model/Order.ts new file mode 100644 index 00000000000..9c47071c5b6 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/model/Order.ts @@ -0,0 +1,38 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Order { + id?: number; + + petId?: number; + + quantity?: number; + + shipDate?: Date; + + /** + * Order Status + */ + status?: Order.StatusEnum; + + complete?: boolean; + +} +export namespace Order { + export enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } +} diff --git a/samples/client/petstore/typescript-jquery/npm/model/Pet.ts b/samples/client/petstore/typescript-jquery/npm/model/Pet.ts new file mode 100644 index 00000000000..d64dc809e53 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/model/Pet.ts @@ -0,0 +1,38 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Pet { + id?: number; + + category?: models.Category; + + name: string; + + photoUrls: Array; + + tags?: Array; + + /** + * pet status in the store + */ + status?: Pet.StatusEnum; + +} +export namespace Pet { + export enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } +} diff --git a/samples/client/petstore/typescript-jquery/npm/model/Tag.ts b/samples/client/petstore/typescript-jquery/npm/model/Tag.ts new file mode 100644 index 00000000000..8a3b99ae9ca --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/model/Tag.ts @@ -0,0 +1,20 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface Tag { + id?: number; + + name?: string; + +} diff --git a/samples/client/petstore/typescript-jquery/npm/model/User.ts b/samples/client/petstore/typescript-jquery/npm/model/User.ts new file mode 100644 index 00000000000..43d00f7b318 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/model/User.ts @@ -0,0 +1,35 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@wordnik.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +export interface User { + id?: number; + + username?: string; + + firstName?: string; + + lastName?: string; + + email?: string; + + password?: string; + + phone?: string; + + /** + * User Status + */ + userStatus?: number; + +} diff --git a/samples/client/petstore/typescript-jquery/npm/model/models.ts b/samples/client/petstore/typescript-jquery/npm/model/models.ts new file mode 100644 index 00000000000..92dac02846c --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/model/models.ts @@ -0,0 +1,5 @@ +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-jquery/npm/variables.ts b/samples/client/petstore/typescript-jquery/npm/variables.ts new file mode 100644 index 00000000000..505ce9355e2 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/variables.ts @@ -0,0 +1,7 @@ + +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-cxf/.swagger-codegen-ignore b/samples/server/petstore/jaxrs-cxf/.swagger-codegen-ignore index 70b88e71039..e36d46f1344 100644 --- a/samples/server/petstore/jaxrs-cxf/.swagger-codegen-ignore +++ b/samples/server/petstore/jaxrs-cxf/.swagger-codegen-ignore @@ -22,4 +22,4 @@ # Then explicitly reverse the ignore rule for a single file: #!docs/README.md -**/impl/* \ No newline at end of file +#**/impl/* diff --git a/samples/server/petstore/jaxrs-cxf/.swagger-codegen/VERSION b/samples/server/petstore/jaxrs-cxf/.swagger-codegen/VERSION index 7fea99011a6..f9f7450d135 100644 --- a/samples/server/petstore/jaxrs-cxf/.swagger-codegen/VERSION +++ b/samples/server/petstore/jaxrs-cxf/.swagger-codegen/VERSION @@ -1 +1 @@ -2.2.3-SNAPSHOT \ No newline at end of file +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java index 6411e862c1c..1e201b5f14d 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java @@ -78,10 +78,18 @@ public interface FakeApi { @Path("/fake") @Consumes({ "*/*" }) @Produces({ "*/*" }) - @ApiOperation(value = "To test enum parameters", tags={ "fake" }) + @ApiOperation(value = "To test enum parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) public void testEnumParameters(@Multipart(value = "enum_form_string_array", required = false) List enumFormStringArray, @Multipart(value = "enum_form_string", required = false) String enumFormString, @HeaderParam("enum_header_string_array") List enumHeaderStringArray, @HeaderParam("enum_header_string") String enumHeaderString, @QueryParam("enum_query_string_array") List enumQueryStringArray, @QueryParam("enum_query_string") @DefaultValue("-efg") String enumQueryString, @QueryParam("enum_query_integer") Integer enumQueryInteger, @Multipart(value = "enum_query_double", required = false) Double enumQueryDouble); + + @GET + @Path("/fake/jsonFormData") + @Consumes({ "application/json" }) + @ApiOperation(value = "test json serialization of form data", tags={ "fake" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public void testJsonFormData(@Multipart(value = "param") String param, @Multipart(value = "param2") String param2); } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java index e0e30bba646..021e7eeb91f 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java @@ -17,6 +17,7 @@ import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponse; import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; +import javax.validation.Valid; @Path("/") @Api(value = "/", description = "") @@ -29,6 +30,6 @@ public interface FakeClassnameTags123Api { @ApiOperation(value = "To test class name in snake case", tags={ "fake_classname_tags 123#$%^" }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - public Client testClassname(Client body); + public Client testClassname(@Valid Client body); } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/FormatTest.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/FormatTest.java index cf49e7062ad..bbb02c85253 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/FormatTest.java @@ -179,7 +179,7 @@ public class FormatTest { * @return _byte **/ @NotNull - public byte[] getByte() { + @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java index 92699c3411b..b170bddee2d 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java @@ -4,9 +4,8 @@ import io.swagger.api.*; import java.math.BigDecimal; import io.swagger.model.Client; import java.util.Date; - -import io.swagger.model.OuterComposite; import org.joda.time.LocalDate; +import io.swagger.model.OuterComposite; import java.io.InputStream; import java.io.OutputStream; @@ -22,30 +21,30 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; public class FakeApiServiceImpl implements FakeApi { - @Override public Boolean fakeOuterBooleanSerialize(Boolean body) { // TODO: Implement... + return null; } - - @Override + public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) { // TODO: Implement... + return null; } - - @Override + public BigDecimal fakeOuterNumberSerialize(BigDecimal body) { // TODO: Implement... + return null; } - - @Override + public String fakeOuterStringSerialize(String body) { // TODO: Implement... + return null; } - + public Client testClientModel(Client body) { // TODO: Implement... @@ -64,5 +63,11 @@ public class FakeApiServiceImpl implements FakeApi { } + public void testJsonFormData(String param, String param2) { + // TODO: Implement... + + + } + } diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java index b851f348466..036292d5feb 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java @@ -96,12 +96,23 @@ public class FakeApi { @Consumes({ "*/*" }) @Produces({ "*/*" }) - @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", response = void.class, tags={ "fake" }) + @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", response = void.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request", response = void.class), @ApiResponse(code = 404, message = "Not found", response = void.class) }) public Response testEnumParameters(@FormParam(value = "enum_form_string_array") List enumFormStringArray,@FormParam(value = "enum_form_string") String enumFormString,@HeaderParam("enum_header_string_array") List enumHeaderStringArray,@HeaderParam("enum_header_string") String enumHeaderString,@QueryParam("enum_query_string_array") List enumQueryStringArray,@QueryParam("enum_query_string") @DefaultValue("-efg") String enumQueryString,@QueryParam("enum_query_integer") Integer enumQueryInteger,@FormParam(value = "enum_query_double") Double enumQueryDouble) { return Response.ok().entity("magic!").build(); } + + @GET + @Path("/jsonFormData") + @Consumes({ "application/json" }) + + @ApiOperation(value = "test json serialization of form data", notes = "", response = void.class, tags={ "fake" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = void.class) }) + public Response testJsonFormData(@FormParam(value = "param") String param,@FormParam(value = "param2") String param2) { + return Response.ok().entity("magic!").build(); + } } diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java index 8aee5ba7a4c..4041f6f5ec8 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java @@ -27,7 +27,7 @@ public class FakeClassnameTestApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) public Response testClassname(Client body) { - return Response.ok().entity("magic!").build(); + return Response.ok().entity("magic!").build(); } } diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java index a2f6796aac2..339ed6e5e5f 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java @@ -160,7 +160,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - public byte[] getByte() { + @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } public void setByte(byte[] _byte) { diff --git a/samples/server/petstore/jaxrs-spec/swagger.json b/samples/server/petstore/jaxrs-spec/swagger.json index 2b5d1b98b90..72cf38c2946 100644 --- a/samples/server/petstore/jaxrs-spec/swagger.json +++ b/samples/server/petstore/jaxrs-spec/swagger.json @@ -998,6 +998,33 @@ } } } + }, + "/fake/jsonFormData" : { + "get" : { + "tags" : [ "fake" ], + "summary" : "test json serialization of form data", + "description" : "", + "operationId" : "testJsonFormData", + "consumes" : [ "application/json" ], + "parameters" : [ { + "name" : "param", + "in" : "formData", + "description" : "field1", + "required" : true, + "type" : "string" + }, { + "name" : "param2", + "in" : "formData", + "description" : "field2", + "required" : true, + "type" : "string" + } ], + "responses" : { + "200" : { + "description" : "successful operation" + } + } + } } }, "securityDefinitions" : { @@ -1337,7 +1364,8 @@ }, "byte" : { "type" : "string", - "format" : "byte" + "format" : "byte", + "pattern" : "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" }, "binary" : { "type" : "string", diff --git a/samples/server/petstore/jaxrs/jersey2/.swagger-codegen/VERSION b/samples/server/petstore/jaxrs/jersey2/.swagger-codegen/VERSION index 7fea99011a6..f9f7450d135 100644 --- a/samples/server/petstore/jaxrs/jersey2/.swagger-codegen/VERSION +++ b/samples/server/petstore/jaxrs/jersey2/.swagger-codegen/VERSION @@ -1 +1 @@ -2.2.3-SNAPSHOT \ No newline at end of file +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApi.java b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApi.java index 6b9497fde67..8935f8b3d79 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApi.java @@ -166,4 +166,17 @@ public class FakeApi { throws NotFoundException { return delegate.testEnumParameters(enumFormStringArray,enumFormString,enumHeaderStringArray,enumHeaderString,enumQueryStringArray,enumQueryString,enumQueryInteger,enumQueryDouble,securityContext); } + @GET + @Path("/jsonFormData") + @Consumes({ "application/json" }) + + @io.swagger.annotations.ApiOperation(value = "test json serialization of form data", notes = "", response = void.class, tags={ "fake", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) + public Response testJsonFormData(@ApiParam(value = "field1", required=true) @FormParam("param") String param +,@ApiParam(value = "field2", required=true) @FormParam("param2") String param2 +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.testJsonFormData(param,param2,securityContext); + } } diff --git a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApiService.java b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApiService.java index 490647b96ab..71148802573 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApiService.java +++ b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeApiService.java @@ -27,4 +27,5 @@ public abstract class FakeApiService { public abstract Response testClientModel(Client body,SecurityContext securityContext) throws NotFoundException; public abstract Response testEndpointParameters(BigDecimal number,Double _double,String patternWithoutDelimiter,byte[] _byte,Integer integer,Integer int32,Long int64,Float _float,String string,byte[] binary,Date date,Date dateTime,String password,String paramCallback,SecurityContext securityContext) throws NotFoundException; public abstract Response testEnumParameters(List enumFormStringArray,String enumFormString,List enumHeaderStringArray,String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger,Double enumQueryDouble,SecurityContext securityContext) throws NotFoundException; + public abstract Response testJsonFormData(String param,String param2,SecurityContext securityContext) throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeClassnameTestApi.java index 9340a5f6027..c9a3713ce35 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/api/FakeClassnameTestApi.java @@ -17,6 +17,7 @@ import java.io.InputStream; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; +import javax.servlet.ServletConfig; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; @@ -29,7 +30,28 @@ import javax.validation.constraints.*; @io.swagger.annotations.Api(description = "the fake_classname_test API") public class FakeClassnameTestApi { - private final FakeClassnameTestApiService delegate = FakeClassnameTestApiServiceFactory.getFakeClassnameTestApi(); + private final FakeClassnameTestApiService delegate; + + public FakeClassnameTestApi(@Context ServletConfig servletContext) { + FakeClassnameTestApiService delegate = null; + + if (servletContext != null) { + String implClass = servletContext.getInitParameter("FakeClassnameTestApi.implementation"); + if (implClass != null && !"".equals(implClass.trim())) { + try { + delegate = (FakeClassnameTestApiService) Class.forName(implClass).newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + if (delegate == null) { + delegate = FakeClassnameTestApiServiceFactory.getFakeClassnameTestApi(); + } + + this.delegate = delegate; + } @PATCH diff --git a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/model/FormatTest.java b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/model/FormatTest.java index bdd53cb3e5d..8b5e5b18ec0 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/jaxrs/jersey2/src/gen/java/io/swagger/model/FormatTest.java @@ -223,7 +223,7 @@ public class FormatTest { @JsonProperty("byte") @ApiModelProperty(required = true, value = "") @NotNull - public byte[] getByte() { + @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } diff --git a/samples/server/petstore/jaxrs/jersey2/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java b/samples/server/petstore/jaxrs/jersey2/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java index 132991700c5..529420f7f70 100644 --- a/samples/server/petstore/jaxrs/jersey2/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/jersey2/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java @@ -55,4 +55,9 @@ public class FakeApiServiceImpl extends FakeApiService { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + @Override + public Response testJsonFormData(String param, String param2, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } } diff --git a/samples/server/petstore/pistache-server/model/Category.cpp b/samples/server/petstore/pistache-server/model/Category.cpp index 544f71241da..966fb4a2262 100644 --- a/samples/server/petstore/pistache-server/model/Category.cpp +++ b/samples/server/petstore/pistache-server/model/Category.cpp @@ -20,7 +20,7 @@ namespace model { Category::Category() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_Name = ""; m_NameIsSet = false; diff --git a/samples/server/petstore/pistache-server/model/Order.cpp b/samples/server/petstore/pistache-server/model/Order.cpp index 7e249eb341b..d1a94778deb 100644 --- a/samples/server/petstore/pistache-server/model/Order.cpp +++ b/samples/server/petstore/pistache-server/model/Order.cpp @@ -20,9 +20,9 @@ namespace model { Order::Order() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; - m_PetId = 0; + m_PetId = 0L; m_PetIdIsSet = false; m_Quantity = 0; m_QuantityIsSet = false; diff --git a/samples/server/petstore/pistache-server/model/Pet.cpp b/samples/server/petstore/pistache-server/model/Pet.cpp index 1f5cfe2d7e8..7fad21e5e61 100644 --- a/samples/server/petstore/pistache-server/model/Pet.cpp +++ b/samples/server/petstore/pistache-server/model/Pet.cpp @@ -20,7 +20,7 @@ namespace model { Pet::Pet() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_CategoryIsSet = false; m_Name = ""; diff --git a/samples/server/petstore/pistache-server/model/Tag.cpp b/samples/server/petstore/pistache-server/model/Tag.cpp index 0854613f58b..a020e73a139 100644 --- a/samples/server/petstore/pistache-server/model/Tag.cpp +++ b/samples/server/petstore/pistache-server/model/Tag.cpp @@ -20,7 +20,7 @@ namespace model { Tag::Tag() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_Name = ""; m_NameIsSet = false; diff --git a/samples/server/petstore/pistache-server/model/User.cpp b/samples/server/petstore/pistache-server/model/User.cpp index c916d14842e..052587ab16f 100644 --- a/samples/server/petstore/pistache-server/model/User.cpp +++ b/samples/server/petstore/pistache-server/model/User.cpp @@ -20,7 +20,7 @@ namespace model { User::User() { - m_Id = 0; + m_Id = 0L; m_IdIsSet = false; m_Username = ""; m_UsernameIsSet = false; diff --git a/samples/server/petstore/restbed/model/Category.cpp b/samples/server/petstore/restbed/model/Category.cpp index e5a38f26420..34f0bf8af0b 100644 --- a/samples/server/petstore/restbed/model/Category.cpp +++ b/samples/server/petstore/restbed/model/Category.cpp @@ -30,7 +30,7 @@ namespace model { Category::Category() { - m_Id = 0; + m_Id = 0L; m_Name = ""; } @@ -54,7 +54,7 @@ void Category::fromJsonString(std::string const& jsonString) std::stringstream ss(jsonString); ptree pt; read_json(ss,pt); - m_Id = pt.get("Id", 0); + m_Id = pt.get("Id", 0L); m_Name = pt.get("Name", ""); } diff --git a/samples/server/petstore/restbed/model/Order.cpp b/samples/server/petstore/restbed/model/Order.cpp index b6e97cecd1c..4c14639d10f 100644 --- a/samples/server/petstore/restbed/model/Order.cpp +++ b/samples/server/petstore/restbed/model/Order.cpp @@ -30,8 +30,8 @@ namespace model { Order::Order() { - m_Id = 0; - m_PetId = 0; + m_Id = 0L; + m_PetId = 0L; m_Quantity = 0; m_ShipDate = ""; m_Status = ""; @@ -62,8 +62,8 @@ void Order::fromJsonString(std::string const& jsonString) std::stringstream ss(jsonString); ptree pt; read_json(ss,pt); - m_Id = pt.get("Id", 0); - m_PetId = pt.get("PetId", 0); + m_Id = pt.get("Id", 0L); + m_PetId = pt.get("PetId", 0L); m_Quantity = pt.get("Quantity", 0); m_ShipDate = pt.get("ShipDate", ""); m_Status = pt.get("Status", ""); diff --git a/samples/server/petstore/restbed/model/Pet.cpp b/samples/server/petstore/restbed/model/Pet.cpp index 1889dc891a8..9f4ce7d6146 100644 --- a/samples/server/petstore/restbed/model/Pet.cpp +++ b/samples/server/petstore/restbed/model/Pet.cpp @@ -30,7 +30,7 @@ namespace model { Pet::Pet() { - m_Id = 0; + m_Id = 0L; m_Name = ""; m_Status = ""; @@ -56,7 +56,7 @@ void Pet::fromJsonString(std::string const& jsonString) std::stringstream ss(jsonString); ptree pt; read_json(ss,pt); - m_Id = pt.get("Id", 0); + m_Id = pt.get("Id", 0L); m_Name = pt.get("Name", ""); m_Status = pt.get("Status", ""); } diff --git a/samples/server/petstore/restbed/model/Tag.cpp b/samples/server/petstore/restbed/model/Tag.cpp index a23bb9f767f..ac2fb1f3f4b 100644 --- a/samples/server/petstore/restbed/model/Tag.cpp +++ b/samples/server/petstore/restbed/model/Tag.cpp @@ -30,7 +30,7 @@ namespace model { Tag::Tag() { - m_Id = 0; + m_Id = 0L; m_Name = ""; } @@ -54,7 +54,7 @@ void Tag::fromJsonString(std::string const& jsonString) std::stringstream ss(jsonString); ptree pt; read_json(ss,pt); - m_Id = pt.get("Id", 0); + m_Id = pt.get("Id", 0L); m_Name = pt.get("Name", ""); } diff --git a/samples/server/petstore/restbed/model/User.cpp b/samples/server/petstore/restbed/model/User.cpp index be22d9bc9ef..d80b59b38e3 100644 --- a/samples/server/petstore/restbed/model/User.cpp +++ b/samples/server/petstore/restbed/model/User.cpp @@ -30,7 +30,7 @@ namespace model { User::User() { - m_Id = 0; + m_Id = 0L; m_Username = ""; m_FirstName = ""; m_LastName = ""; @@ -66,7 +66,7 @@ void User::fromJsonString(std::string const& jsonString) std::stringstream ss(jsonString); ptree pt; read_json(ss,pt); - m_Id = pt.get("Id", 0); + m_Id = pt.get("Id", 0L); m_Username = pt.get("Username", ""); m_FirstName = pt.get("FirstName", ""); m_LastName = pt.get("LastName", ""); diff --git a/samples/server/petstore/spring-mvc-j8-async/pom.xml b/samples/server/petstore/spring-mvc-j8-async/pom.xml index f55765b7a03..689bcb91b80 100644 --- a/samples/server/petstore/spring-mvc-j8-async/pom.xml +++ b/samples/server/petstore/spring-mvc-j8-async/pom.xml @@ -139,7 +139,7 @@ 1.7.21 4.12 2.5 - 2.6.0 + 2.7.0 2.8.9 2.6.4 4.3.9.RELEASE diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index 940b3be2960..673178a791b 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -139,7 +139,7 @@ 1.7.21 4.12 2.5 - 2.6.0 + 2.7.0 2.8.9 2.6.4 4.3.9.RELEASE diff --git a/samples/server/petstore/springboot-beanvalidation/pom.xml b/samples/server/petstore/springboot-beanvalidation/pom.xml index 5e6452410f4..35c7e3849c0 100644 --- a/samples/server/petstore/springboot-beanvalidation/pom.xml +++ b/samples/server/petstore/springboot-beanvalidation/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.6.1 + 2.7.0 org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java diff --git a/samples/server/petstore/springboot-delegate-j8/pom.xml b/samples/server/petstore/springboot-delegate-j8/pom.xml index ba9be83fe8a..4729f8cf400 100644 --- a/samples/server/petstore/springboot-delegate-j8/pom.xml +++ b/samples/server/petstore/springboot-delegate-j8/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.6.1 + 2.7.0 org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java diff --git a/samples/server/petstore/springboot-delegate/pom.xml b/samples/server/petstore/springboot-delegate/pom.xml index a4dfc993091..df779d931dd 100644 --- a/samples/server/petstore/springboot-delegate/pom.xml +++ b/samples/server/petstore/springboot-delegate/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.6.1 + 2.7.0 org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java diff --git a/samples/server/petstore/springboot-implicitHeaders/pom.xml b/samples/server/petstore/springboot-implicitHeaders/pom.xml index a4dfc993091..df779d931dd 100644 --- a/samples/server/petstore/springboot-implicitHeaders/pom.xml +++ b/samples/server/petstore/springboot-implicitHeaders/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.6.1 + 2.7.0 org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java diff --git a/samples/server/petstore/springboot-useoptional/.swagger-codegen-ignore b/samples/server/petstore/springboot-useoptional/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/springboot-useoptional/.swagger-codegen/VERSION b/samples/server/petstore/springboot-useoptional/.swagger-codegen/VERSION new file mode 100644 index 00000000000..7fea99011a6 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/springboot-useoptional/README.md b/samples/server/petstore/springboot-useoptional/README.md new file mode 100644 index 00000000000..a2e8a9f7b84 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/README.md @@ -0,0 +1,18 @@ +# Swagger generated server + +Spring Boot Server + + +## Overview +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. +By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. +This is an example of building a swagger-enabled server in Java using the SpringBoot framework. + +The underlying library integrating swagger to SpringBoot is [springfox](https://github.com/springfox/springfox) + +Start your server as an simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:8080/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/server/petstore/springboot-useoptional/pom.xml b/samples/server/petstore/springboot-useoptional/pom.xml new file mode 100644 index 00000000000..b7a0f8dd770 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + io.swagger + spring-boot-useoptional + jar + spring-boot-useoptional + 1.0.0 + + 1.7 + ${java.version} + ${java.version} + 2.6.1 + + + org.springframework.boot + spring-boot-starter-parent + 1.4.7.RELEASE + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + io.springfox + springfox-swagger2 + ${springfox-version} + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + joda-time + joda-time + + + + javax.validation + validation-api + 1.1.0.Final + provided + + + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/RFC3339DateFormat.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/RFC3339DateFormat.java new file mode 100644 index 00000000000..0c3d276d2d4 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/RFC3339DateFormat.java @@ -0,0 +1,20 @@ +package io.swagger; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + +import java.text.FieldPosition; +import java.util.Date; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/Swagger2SpringBoot.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/Swagger2SpringBoot.java new file mode 100644 index 00000000000..75d822f027e --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/Swagger2SpringBoot.java @@ -0,0 +1,36 @@ +package io.swagger; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@SpringBootApplication +@EnableSwagger2 +@ComponentScan(basePackages = "io.swagger") +public class Swagger2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(Swagger2SpringBoot.class).run(args); + } + + class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiException.java new file mode 100644 index 00000000000..97e535d3c21 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + + +public class ApiException extends Exception{ + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiOriginFilter.java new file mode 100644 index 00000000000..62646761f5a --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -0,0 +1,27 @@ +package io.swagger.api; + +import java.io.IOException; + +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + + +public class ApiOriginFilter implements javax.servlet.Filter { + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiResponseMessage.java new file mode 100644 index 00000000000..162678c57e3 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package io.swagger.api; + +import javax.xml.bind.annotation.XmlTransient; + + +@javax.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java new file mode 100644 index 00000000000..bc294e8627c --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java @@ -0,0 +1,105 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import java.math.BigDecimal; +import io.swagger.model.Client; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import io.swagger.model.OuterComposite; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "fake", description = "the fake API") +public interface FakeApi { + + @ApiOperation(value = "", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + + @RequestMapping(value = "/fake/outer/boolean", + method = RequestMethod.POST) + ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); + + + @ApiOperation(value = "", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + + @RequestMapping(value = "/fake/outer/composite", + method = RequestMethod.POST) + ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); + + + @ApiOperation(value = "", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + + @RequestMapping(value = "/fake/outer/number", + method = RequestMethod.POST) + ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); + + + @ApiOperation(value = "", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Output string", response = String.class) }) + + @RequestMapping(value = "/fake/outer/string", + method = RequestMethod.POST) + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); + + + @ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + + @RequestMapping(value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + + + @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = { + @Authorization(value = "http_basic_test") + }, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + + @RequestMapping(value = "/fake", + produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, + consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); + + + @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", response = Void.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid request", response = Void.class), + @ApiResponse(code = 404, message = "Not found", response = Void.class) }) + + @RequestMapping(value = "/fake", + produces = { "*/*" }, + consumes = { "*/*" }, + method = RequestMethod.GET) + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java new file mode 100644 index 00000000000..0fd5a81fbb3 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java @@ -0,0 +1,87 @@ +package io.swagger.api; + +import java.math.BigDecimal; +import io.swagger.model.Client; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import io.swagger.model.OuterComposite; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class FakeApiController implements FakeApi { + + + + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, + @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, + @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, + @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, + @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, + @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, + @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, + @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, + @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, + @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, + @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, + @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime, + @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, + @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, + @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/NotFoundException.java new file mode 100644 index 00000000000..b28b67ea4b2 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/NotFoundException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + + +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java new file mode 100644 index 00000000000..e20c099c8a8 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java @@ -0,0 +1,157 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; +import org.springframework.core.io.Resource; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "pet", description = "the pet API") +public interface PetApi { + + @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + + @RequestMapping(value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.POST) + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); + + + @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) + + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey); + + + @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid status value", response = Void.class) }) + + @RequestMapping(value = "/pet/findByStatus", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status); + + + @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid tag value", response = Void.class) }) + + @RequestMapping(value = "/pet/findByTags", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); + + + @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { + @Authorization(value = "api_key") + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Pet not found", response = Void.class) }) + + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + + + @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Pet not found", response = Void.class), + @ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) + + @RequestMapping(value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.PUT) + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); + + + @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + consumes = { "application/x-www-form-urlencoded" }, + method = RequestMethod.POST) + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); + + + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + + @RequestMapping(value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java new file mode 100644 index 00000000000..1d2e53e931b --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java @@ -0,0 +1,75 @@ +package io.swagger.api; + +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; +import org.springframework.core.io.Resource; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class PetApiController implements PetApi { + + + + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { + // do some magic! + return new ResponseEntity>(HttpStatus.OK); + } + + public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { + // do some magic! + return new ResponseEntity>(HttpStatus.OK); + } + + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, + @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java new file mode 100644 index 00000000000..380c4e6d1b4 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java @@ -0,0 +1,75 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "store", description = "the store API") +public interface StoreApi { + + @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) + + @RequestMapping(value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId); + + + @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { + @Authorization(value = "api_key") + }, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") }) + + @RequestMapping(value = "/store/inventory", + produces = { "application/json" }, + method = RequestMethod.GET) + ResponseEntity> getInventory(); + + + @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) + + @RequestMapping(value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId); + + + @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid Order", response = Void.class) }) + + @RequestMapping(value = "/store/order", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java new file mode 100644 index 00000000000..3f3b773052d --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java @@ -0,0 +1,49 @@ +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class StoreApiController implements StoreApi { + + + + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity> getInventory() { + // do some magic! + return new ResponseEntity>(HttpStatus.OK); + } + + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java new file mode 100644 index 00000000000..4311795201e --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java @@ -0,0 +1,114 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import java.util.List; +import io.swagger.model.User; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "user", description = "the user API") +public interface UserApi { + + @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + + @RequestMapping(value = "/user", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); + + + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + + @RequestMapping(value = "/user/createWithArray", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + + + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + + @RequestMapping(value = "/user/createWithList", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + + + @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username); + + + @ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = User.class), + @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + + + @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = String.class), + @ApiResponse(code = 400, message = "Invalid username/password supplied", response = Void.class) }) + + @RequestMapping(value = "/user/login", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); + + + @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + + @RequestMapping(value = "/user/logout", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity logoutUser(); + + + @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.PUT) + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java new file mode 100644 index 00000000000..3be2578a194 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java @@ -0,0 +1,71 @@ +package io.swagger.api; + +import java.util.List; +import io.swagger.model.User; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Optional; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class UserApiController implements UserApi { + + + + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, + @NotNull@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity logoutUser() { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/configuration/HomeController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/configuration/HomeController.java new file mode 100644 index 00000000000..f8328099284 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/configuration/HomeController.java @@ -0,0 +1,16 @@ +package io.swagger.configuration; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Home redirection to swagger api documentation + */ +@Controller +public class HomeController { + @RequestMapping(value = "/") + public String index() { + System.out.println("swagger-ui.html"); + return "redirect:swagger-ui.html"; + } +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java new file mode 100644 index 00000000000..5658793e134 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java @@ -0,0 +1,40 @@ +package io.swagger.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + + +@Configuration +public class SwaggerDocumentationConfig { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("Swagger Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache 2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "apiteam@swagger.io")) + .build(); + } + + @Bean + public Docket customImplementation(){ + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("io.swagger.api")) + .build() + .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/AdditionalPropertiesClass.java new file mode 100644 index 00000000000..532576aad86 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/AdditionalPropertiesClass.java @@ -0,0 +1,123 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * AdditionalPropertiesClass + */ + +public class AdditionalPropertiesClass { + @JsonProperty("map_property") + private Map mapProperty = null; + + @JsonProperty("map_of_map_property") + private Map> mapOfMapProperty = null; + + public AdditionalPropertiesClass mapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + return this; + } + + public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) { + if (this.mapProperty == null) { + this.mapProperty = new HashMap(); + } + this.mapProperty.put(key, mapPropertyItem); + return this; + } + + /** + * Get mapProperty + * @return mapProperty + **/ + @ApiModelProperty(value = "") + + + public Map getMapProperty() { + return mapProperty; + } + + public void setMapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + } + + public AdditionalPropertiesClass mapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + return this; + } + + public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map mapOfMapPropertyItem) { + if (this.mapOfMapProperty == null) { + this.mapOfMapProperty = new HashMap>(); + } + this.mapOfMapProperty.put(key, mapOfMapPropertyItem); + return this; + } + + /** + * Get mapOfMapProperty + * @return mapOfMapProperty + **/ + @ApiModelProperty(value = "") + + @Valid + + public Map> getMapOfMapProperty() { + return mapOfMapProperty; + } + + public void setMapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapProperty, additionalPropertiesClass.mapProperty) && + Objects.equals(this.mapOfMapProperty, additionalPropertiesClass.mapOfMapProperty); + } + + @Override + public int hashCode() { + return Objects.hash(mapProperty, mapOfMapProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapProperty: ").append(toIndentedString(mapProperty)).append("\n"); + sb.append(" mapOfMapProperty: ").append(toIndentedString(mapOfMapProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Animal.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Animal.java new file mode 100644 index 00000000000..a59dc766c51 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Animal.java @@ -0,0 +1,111 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Animal + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "className", visible = true ) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), +}) + +public class Animal { + @JsonProperty("className") + private String className = null; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + **/ + @ApiModelProperty(value = "") + + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/AnimalFarm.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/AnimalFarm.java new file mode 100644 index 00000000000..9fa4159f203 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/AnimalFarm.java @@ -0,0 +1,52 @@ +package io.swagger.model; + +import java.util.Objects; +import io.swagger.model.Animal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * AnimalFarm + */ + +public class AnimalFarm extends ArrayList { + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 00000000000..ecff36e416a --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,90 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * ArrayOfArrayOfNumberOnly + */ + +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + **/ + @ApiModelProperty(value = "") + + @Valid + + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayOfNumberOnly.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayOfNumberOnly.java new file mode 100644 index 00000000000..a08ff749ee1 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayOfNumberOnly.java @@ -0,0 +1,90 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * ArrayOfNumberOnly + */ + +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + **/ + @ApiModelProperty(value = "") + + @Valid + + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayTest.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayTest.java new file mode 100644 index 00000000000..e9022fd0285 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ArrayTest.java @@ -0,0 +1,157 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.ReadOnlyFirst; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * ArrayTest + */ + +public class ArrayTest { + @JsonProperty("array_of_string") + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + **/ + @ApiModelProperty(value = "") + + + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + **/ + @ApiModelProperty(value = "") + + @Valid + + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + **/ + @ApiModelProperty(value = "") + + @Valid + + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Capitalization.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Capitalization.java new file mode 100644 index 00000000000..d59005adf17 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Capitalization.java @@ -0,0 +1,203 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Capitalization + */ + +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel = null; + + @JsonProperty("CapitalCamel") + private String capitalCamel = null; + + @JsonProperty("small_Snake") + private String smallSnake = null; + + @JsonProperty("Capital_Snake") + private String capitalSnake = null; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints = null; + + @JsonProperty("ATT_NAME") + private String ATT_NAME = null; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + **/ + @ApiModelProperty(value = "") + + + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + **/ + @ApiModelProperty(value = "") + + + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + **/ + @ApiModelProperty(value = "") + + + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + **/ + @ApiModelProperty(value = "") + + + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + **/ + @ApiModelProperty(value = "") + + + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + **/ + @ApiModelProperty(value = "Name of the pet ") + + + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_NAME)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Cat.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Cat.java new file mode 100644 index 00000000000..28016fa5ad6 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Cat.java @@ -0,0 +1,80 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Animal; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Cat + */ + +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed = null; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + **/ + @ApiModelProperty(value = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Category.java new file mode 100644 index 00000000000..e2a67cf25d8 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Category.java @@ -0,0 +1,103 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Category + */ + +public class Category { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("name") + private String name = null; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ClassModel.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ClassModel.java new file mode 100644 index 00000000000..a5ef34a2331 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ClassModel.java @@ -0,0 +1,79 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Model for testing model with \"_class\" property + */ +@ApiModel(description = "Model for testing model with \"_class\" property") + +public class ClassModel { + @JsonProperty("_class") + private String propertyClass = null; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + **/ + @ApiModelProperty(value = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Client.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Client.java new file mode 100644 index 00000000000..aaa03c570f2 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Client.java @@ -0,0 +1,78 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Client + */ + +public class Client { + @JsonProperty("client") + private String client = null; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + **/ + @ApiModelProperty(value = "") + + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Dog.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Dog.java new file mode 100644 index 00000000000..8ebd0f46a62 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Dog.java @@ -0,0 +1,80 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Animal; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Dog + */ + +public class Dog extends Animal { + @JsonProperty("breed") + private String breed = null; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + **/ + @ApiModelProperty(value = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumArrays.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumArrays.java new file mode 100644 index 00000000000..4d79aa66c54 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumArrays.java @@ -0,0 +1,176 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * EnumArrays + */ + +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String text) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol = null; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String text) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("array_enum") + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + **/ + @ApiModelProperty(value = "") + + + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + **/ + @ApiModelProperty(value = "") + + + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumClass.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumClass.java new file mode 100644 index 00000000000..4cfbe4b9fcf --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumClass.java @@ -0,0 +1,43 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.validation.Valid; +import javax.validation.constraints.*; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String text) { + for (EnumClass b : EnumClass.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumTest.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumTest.java new file mode 100644 index 00000000000..a072f992671 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/EnumTest.java @@ -0,0 +1,251 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.OuterEnum; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * EnumTest + */ + +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String text) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString = null; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(String text) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger = null; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(String text) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber = null; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum = null; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + **/ + @ApiModelProperty(value = "") + + + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + **/ + @ApiModelProperty(value = "") + + + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + **/ + @ApiModelProperty(value = "") + + + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + **/ + @ApiModelProperty(value = "") + + @Valid + + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/FormatTest.java new file mode 100644 index 00000000000..d88a4882efc --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/FormatTest.java @@ -0,0 +1,400 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.util.UUID; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * FormatTest + */ + +public class FormatTest { + @JsonProperty("integer") + private Integer integer = null; + + @JsonProperty("int32") + private Integer int32 = null; + + @JsonProperty("int64") + private Long int64 = null; + + @JsonProperty("number") + private BigDecimal number = null; + + @JsonProperty("float") + private Float _float = null; + + @JsonProperty("double") + private Double _double = null; + + @JsonProperty("string") + private String string = null; + + @JsonProperty("byte") + private byte[] _byte = null; + + @JsonProperty("binary") + private byte[] binary = null; + + @JsonProperty("date") + private LocalDate date = null; + + @JsonProperty("dateTime") + private DateTime dateTime = null; + + @JsonProperty("uuid") + private UUID uuid = null; + + @JsonProperty("password") + private String password = null; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + **/ + @ApiModelProperty(value = "") + + @Min(10) @Max(100) + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + **/ + @ApiModelProperty(value = "") + + @Min(20) @Max(200) + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + **/ + @ApiModelProperty(value = "") + + + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + + @Valid + @DecimalMin("32.1") @DecimalMax("543.2") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + **/ + @ApiModelProperty(value = "") + + @DecimalMin("54.3") @DecimalMax("987.6") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + **/ + @ApiModelProperty(value = "") + + @DecimalMin("67.8") @DecimalMax("123.4") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + **/ + @ApiModelProperty(value = "") + + @Pattern(regexp="/[a-z]/i") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + + @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(byte[] binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + **/ + @ApiModelProperty(value = "") + + + public byte[] getBinary() { + return binary; + } + + public void setBinary(byte[] binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + + @Valid + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(DateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + **/ + @ApiModelProperty(value = "") + + @Valid + + public DateTime getDateTime() { + return dateTime; + } + + public void setDateTime(DateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + **/ + @ApiModelProperty(value = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + + @Size(min=10,max=64) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Objects.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/HasOnlyReadOnly.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/HasOnlyReadOnly.java new file mode 100644 index 00000000000..dc59cf9c78c --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/HasOnlyReadOnly.java @@ -0,0 +1,103 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * HasOnlyReadOnly + */ + +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar = null; + + @JsonProperty("foo") + private String foo = null; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + **/ + @ApiModelProperty(readOnly = true, value = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + **/ + @ApiModelProperty(readOnly = true, value = "") + + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/MapTest.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/MapTest.java new file mode 100644 index 00000000000..f179e8e4233 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/MapTest.java @@ -0,0 +1,155 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * MapTest + */ + +public class MapTest { + @JsonProperty("map_map_of_string") + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String text) { + for (InnerEnum b : InnerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("map_of_enum_string") + private Map mapOfEnumString = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + **/ + @ApiModelProperty(value = "") + + @Valid + + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + **/ + @ApiModelProperty(value = "") + + + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 00000000000..d25bba89a9c --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,145 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Animal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.joda.time.DateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ + +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid = null; + + @JsonProperty("dateTime") + private DateTime dateTime = null; + + @JsonProperty("map") + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + **/ + @ApiModelProperty(value = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + **/ + @ApiModelProperty(value = "") + + @Valid + + public DateTime getDateTime() { + return dateTime; + } + + public void setDateTime(DateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + **/ + @ApiModelProperty(value = "") + + @Valid + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Model200Response.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Model200Response.java new file mode 100644 index 00000000000..c00e48ea6c7 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Model200Response.java @@ -0,0 +1,104 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Model for testing model name starting with number + */ +@ApiModel(description = "Model for testing model name starting with number") + +public class Model200Response { + @JsonProperty("name") + private Integer name = null; + + @JsonProperty("class") + private String propertyClass = null; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + **/ + @ApiModelProperty(value = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200Response = (Model200Response) o; + return Objects.equals(this.name, _200Response.name) && + Objects.equals(this.propertyClass, _200Response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..1df487b3539 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,128 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * ModelApiResponse + */ + +public class ModelApiResponse { + @JsonProperty("code") + private Integer code = null; + + @JsonProperty("type") + private String type = null; + + @JsonProperty("message") + private String message = null; + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @ApiModelProperty(value = "") + + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(value = "") + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @ApiModelProperty(value = "") + + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ModelReturn.java new file mode 100644 index 00000000000..3b05293b830 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ModelReturn.java @@ -0,0 +1,79 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Model for testing reserved words + */ +@ApiModel(description = "Model for testing reserved words") + +public class ModelReturn { + @JsonProperty("return") + private Integer _return = null; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + **/ + @ApiModelProperty(value = "") + + + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Name.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Name.java new file mode 100644 index 00000000000..a9835f910ac --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Name.java @@ -0,0 +1,155 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Model for testing model name same as property name + */ +@ApiModel(description = "Model for testing model name same as property name") + +public class Name { + @JsonProperty("name") + private Integer name = null; + + @JsonProperty("snake_case") + private Integer snakeCase = null; + + @JsonProperty("property") + private String property = null; + + @JsonProperty("123Number") + private Integer _123Number = null; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + **/ + @ApiModelProperty(readOnly = true, value = "") + + + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + **/ + @ApiModelProperty(value = "") + + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123Number(Integer _123Number) { + this._123Number = _123Number; + return this; + } + + /** + * Get _123Number + * @return _123Number + **/ + @ApiModelProperty(readOnly = true, value = "") + + + public Integer get123Number() { + return _123Number; + } + + public void set123Number(Integer _123Number) { + this._123Number = _123Number; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123Number, name._123Number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123Number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123Number: ").append(toIndentedString(_123Number)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/NumberOnly.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/NumberOnly.java new file mode 100644 index 00000000000..a990653f20d --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/NumberOnly.java @@ -0,0 +1,80 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * NumberOnly + */ + +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber = null; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + **/ + @ApiModelProperty(value = "") + + @Valid + + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Order.java new file mode 100644 index 00000000000..5bfcf28b3ea --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Order.java @@ -0,0 +1,239 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.joda.time.DateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Order + */ + +public class Order { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("petId") + private Long petId = null; + + @JsonProperty("quantity") + private Integer quantity = null; + + @JsonProperty("shipDate") + private DateTime shipDate = null; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + @JsonProperty("complete") + private Boolean complete = false; + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + **/ + @ApiModelProperty(value = "") + + + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + **/ + @ApiModelProperty(value = "") + + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order shipDate(DateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + **/ + @ApiModelProperty(value = "") + + @Valid + + public DateTime getShipDate() { + return shipDate; + } + + public void setShipDate(DateTime shipDate) { + this.shipDate = shipDate; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + **/ + @ApiModelProperty(value = "Order Status") + + + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + **/ + @ApiModelProperty(value = "") + + + public Boolean getComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/OuterComposite.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/OuterComposite.java new file mode 100644 index 00000000000..bd384f3dcd2 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/OuterComposite.java @@ -0,0 +1,130 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * OuterComposite + */ + +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber = null; + + @JsonProperty("my_string") + private String myString = null; + + @JsonProperty("my_boolean") + private Boolean myBoolean = null; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + **/ + @ApiModelProperty(value = "") + + @Valid + + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + **/ + @ApiModelProperty(value = "") + + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + **/ + @ApiModelProperty(value = "") + + + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/OuterEnum.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/OuterEnum.java new file mode 100644 index 00000000000..f3c6d31fb86 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/OuterEnum.java @@ -0,0 +1,43 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.validation.Valid; +import javax.validation.constraints.*; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String text) { + for (OuterEnum b : OuterEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Pet.java new file mode 100644 index 00000000000..38d92a5b917 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Pet.java @@ -0,0 +1,258 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Pet + */ + +public class Pet { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("category") + private Category category = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("photoUrls") + private List photoUrls = new ArrayList(); + + @JsonProperty("tags") + private List tags = null; + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE("available"), + + PENDING("pending"), + + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + @ApiModelProperty(value = "") + + @Valid + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "doggie", required = true, value = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + + + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @ApiModelProperty(value = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + **/ + @ApiModelProperty(value = "pet status in the store") + + + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ReadOnlyFirst.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ReadOnlyFirst.java new file mode 100644 index 00000000000..1ff292f1851 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/ReadOnlyFirst.java @@ -0,0 +1,103 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * ReadOnlyFirst + */ + +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar = null; + + @JsonProperty("baz") + private String baz = null; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + **/ + @ApiModelProperty(readOnly = true, value = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + **/ + @ApiModelProperty(value = "") + + + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/SpecialModelName.java new file mode 100644 index 00000000000..9eabbe3eca4 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/SpecialModelName.java @@ -0,0 +1,78 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * SpecialModelName + */ + +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long specialPropertyName = null; + + public SpecialModelName specialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + return this; + } + + /** + * Get specialPropertyName + * @return specialPropertyName + **/ + @ApiModelProperty(value = "") + + + public Long getSpecialPropertyName() { + return specialPropertyName; + } + + public void setSpecialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName specialModelName = (SpecialModelName) o; + return Objects.equals(this.specialPropertyName, specialModelName.specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash(specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Tag.java new file mode 100644 index 00000000000..b3d49a2dc6a --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/Tag.java @@ -0,0 +1,103 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * Tag + */ + +public class Tag { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("name") + private String name = null; + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/User.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/User.java new file mode 100644 index 00000000000..ef3270b7aff --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/User.java @@ -0,0 +1,253 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.Valid; +import javax.validation.constraints.*; + +/** + * User + */ + +public class User { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("username") + private String username = null; + + @JsonProperty("firstName") + private String firstName = null; + + @JsonProperty("lastName") + private String lastName = null; + + @JsonProperty("email") + private String email = null; + + @JsonProperty("password") + private String password = null; + + @JsonProperty("phone") + private String phone = null; + + @JsonProperty("userStatus") + private Integer userStatus = null; + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @ApiModelProperty(value = "") + + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @ApiModelProperty(value = "") + + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @ApiModelProperty(value = "") + + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + @ApiModelProperty(value = "") + + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(value = "") + + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + **/ + @ApiModelProperty(value = "") + + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + **/ + @ApiModelProperty(value = "User Status") + + + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/resources/application.properties b/samples/server/petstore/springboot-useoptional/src/main/resources/application.properties new file mode 100644 index 00000000000..a72d110dea9 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/resources/application.properties @@ -0,0 +1,5 @@ +springfox.documentation.swagger.v2.path=/api-docs +server.contextPath=/v2 +server.port=80 +spring.jackson.date-format=io.swagger.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false \ No newline at end of file diff --git a/samples/server/petstore/springboot/pom.xml b/samples/server/petstore/springboot/pom.xml index a4dfc993091..df779d931dd 100644 --- a/samples/server/petstore/springboot/pom.xml +++ b/samples/server/petstore/springboot/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.6.1 + 2.7.0 org.springframework.boot spring-boot-starter-parent - 1.4.7.RELEASE + 1.5.4.RELEASE src/main/java