diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 78cb721df027..a6064478b971 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,5 +6,5 @@ - [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md). - [ ] If contributing template-only or documentation-only changes which will change sample output, [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) before. - [ ] Run the shell script(s) under `./bin/` (or Windows batch scripts under`.\bin\windows`) to update Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run `./bin/{LANG}-petstore.sh`, `./bin/openapi3/{LANG}-petstore.sh` if updating the code or mustache templates for a language (`{LANG}`) (e.g. php, ruby, python, etc). -- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `4.1.x`, `5.0.x`. Default: `master`. +- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `4.3.x`, `5.0.x`. Default: `master`. - [ ] Copy the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language. diff --git a/.travis.yml b/.travis.yml index 2e034e8a7c8e..cc0654536bbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -138,6 +138,7 @@ script: # test maven plugin - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml + - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml # test gradle plugin - (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk) - (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate) diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java index 2b32dccf324a..a3febe1fba1e 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java @@ -128,8 +128,6 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) //empty } }); - // the API call should be executed asynchronously, so result should be empty at the moment - assertTrue(result.isEmpty()); // wait for the asynchronous call to finish (at most 10 seconds) final int maxTry = 10; diff --git a/README.md b/README.md index 6e781a7e585f..83aa2847ccfe 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ [![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu) [![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/master)](https://cloud.drone.io/OpenAPITools/openapi-generator) +[`4.3.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.3.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/4.3.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) +[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/4.3.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator) +[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=4.3.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator) +[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=4.3.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu) +[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/4.3.x)](https://cloud.drone.io/OpenAPITools/openapi-generator) + [`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/5.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) [![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/5.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator) [![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=5.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator) @@ -516,7 +522,7 @@ Please refer to [customization.md](docs/customization.md) on how to customize th ### [3.2 - Workflow Integration (Maven, Gradle, Github, CI/CD)](#table-of-contents) -Please refer to [integration.md](docs/integration.md) on how to integrate OpenAPI generator with Maven, Gradle, Github and CI/CD. +Please refer to [integration.md](docs/integration.md) on how to integrate OpenAPI generator with Maven, Gradle, sbt, Bazel, Github and CI/CD. ### [3.3 - Online OpenAPI generator](#table-of-contents) @@ -578,6 +584,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - [Element AI](https://www.elementai.com/) - [Fenergo](https://www.fenergo.com/) - [FormAPI](https://formapi.io/) +- [FreshCells](https://www.freshcells.de/) - [Fuse](https://www.fuse.no/) - [Gantner](https://www.gantner.com) - [GenFlow](https://github.com/RepreZen/GenFlow) @@ -587,6 +594,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - [IBM](https://www.ibm.com/) - [JustStar](https://www.juststarinfo.com) - [Klarna](https://www.klarna.com/) +- [Kronsoft Development](https://www.kronsoft.ro/home/) - [Médiavision](https://www.mediavision.fr/) - [Metaswitch](https://www.metaswitch.com/) - [Myworkout](https://myworkout.com) @@ -596,6 +604,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - [Ponicode](https://ponicode.dev/) - [Pricefx](https://www.pricefx.com/) - [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager) +- [QEDIT](https://qed-it.com) +- [Qulix Systems](https://www.qulix.com) - [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch) - [RedHat](https://www.redhat.com) - [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development) @@ -678,6 +688,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - 2019-10-16 - [How to ship APIs faster?](https://medium.com/@accounts_76224/how-to-ship-apis-faster-cabef2f819e4) by [Simon Guilliams @ PoniCode](https://ponicode.dev) - 2019-10-22 - [OpenAPI + Spring Boot(Kotlin)でファイルダウンロードAPIを作成する](https://qiita.com/boronngo/items/4b78b92526209daeaee9) by [Yuki Furukawa](https://twitter.com/yuki_furukawa5) - 2019-10-24 - [Microprofile OpenAPI - Code First or Design First?](https://github.com/pe-st/apidocs/blob/master/MicroProfile-OpenAPI-all-slides.pdf) by [Peter [pɛʃə] Steiner](https://twitter.com/pesche) at [eclipsecon Europe 2019](https://www.eclipsecon.org/europe2019/sessions/microprofile-openapi-code-first-or-design-first) +- 2019-11-06 - [Generating API clients based on OpenAPI v3 specifications](https://98elements.com/blog/generating-api-clients-based-on-openapi-v3-specifications) by [Dominik Jastrzębski @ 98elements](https://98elements.com) ## [6 - About Us](#table-of-contents) diff --git a/bin/kotlin-client-all.sh b/bin/kotlin-client-all.sh index 175752d797f1..a6f26163295d 100755 --- a/bin/kotlin-client-all.sh +++ b/bin/kotlin-client-all.sh @@ -1,5 +1,6 @@ #!/bin/sh +./bin/kotlin-client-gson.sh ./bin/kotlin-client-nonpublic.sh ./bin/kotlin-client-okhttp3.sh ./bin/kotlin-client-petstore-multiplatform.sh diff --git a/bin/kotlin-client-gson.sh b/bin/kotlin-client-gson.sh new file mode 100755 index 000000000000..f178cb880389 --- /dev/null +++ b/bin/kotlin-client-gson.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +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/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn -B clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-gson --additional-properties serializationLibrary=gson -o samples/client/petstore/kotlin-gson $@" + +java ${JAVA_OPTS} -jar ${executable} ${ags} diff --git a/bin/kotlin-client-nonpublic.sh b/bin/kotlin-client-nonpublic.sh index 620a6fe3c8cc..16c366ef673b 100755 --- a/bin/kotlin-client-nonpublic.sh +++ b/bin/kotlin-client-nonpublic.sh @@ -30,5 +30,3 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-nonpublic --additional-properties nonPublicApi=true -o samples/client/petstore/kotlin-nonpublic $@" java ${JAVA_OPTS} -jar ${executable} ${ags} - -cp CI/samples.ci/client/petstore/kotlin-string/pom.xml samples/client/petstore/kotlin-string/pom.xml diff --git a/bin/kotlin-client-okhttp3.sh b/bin/kotlin-client-okhttp3.sh index c2fbb3008748..3f1cc101700d 100755 --- a/bin/kotlin-client-okhttp3.sh +++ b/bin/kotlin-client-okhttp3.sh @@ -30,5 +30,3 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-okhttp3 --library jvm-okhttp3 -o samples/client/petstore/kotlin-okhttp3 $@" java ${JAVA_OPTS} -jar ${executable} ${ags} - -#cp CI/samples.ci/client/petstore/kotlin-okhttp3/pom.xml samples/client/petstore/kotlin-okhttp3/pom.xml diff --git a/bin/meta-codegen-kotlin.sh b/bin/meta-codegen-kotlin.sh new file mode 100755 index 000000000000..5df67a9dab5c --- /dev/null +++ b/bin/meta-codegen-kotlin.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +if ! command -v gradle > /dev/null; then + echo "[WARN] This script requires a system gradle to be installed. Not treating this as an error." + exit 0 +fi + +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/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + ./mvnw -B clean package +fi + +\rm -rf "samples/meta-codegen-kotlin/lib" + +export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="meta -n myClientCodegen -t DOCUMENTATION -p com.my.company.codegen -o samples/meta-codegen-kotlin/lib -l kotlin $@" + +java $JAVA_OPTS -jar $executable $ags + +if [ ! -f samples/meta-codegen-kotlin/gradle/wrapper/gradle-wrapper.jar ]; then + (cd samples/meta-codegen-kotlin/ && gradle wrapper --gradle-version 5.6.2 --distribution-type bin) +fi + + +(cp samples/meta-codegen-kotlin/gradlew samples/meta-codegen-kotlin/lib/ && \ + cp -R samples/meta-codegen-kotlin/gradle samples/meta-codegen-kotlin/lib/ && \ + cd samples/meta-codegen-kotlin/lib && \ + ./gradlew shadowJar) + +ags2="generate -g myClientCodegen -i modules/openapi-generator/src/test/resources/2_0/petstore.json -o samples/meta-codegen-kotlin/usage $@" + +java $JAVA_OPTS -cp samples/meta-codegen-kotlin/lib/build/libs/my-client-codegen-openapi-generator-1.0-SNAPSHOT-all.jar:$executable org.openapitools.codegen.OpenAPIGenerator $ags2 diff --git a/bin/utils/openapi-generator-cli.sh b/bin/utils/openapi-generator-cli.sh index fcca6b35ec76..4fea493715ff 100644 --- a/bin/utils/openapi-generator-cli.sh +++ b/bin/utils/openapi-generator-cli.sh @@ -22,7 +22,7 @@ set -o pipefail for cmd in {mvn,jq,curl}; do if ! command -v ${cmd} > /dev/null; then - >&2 echo "This script requires '${cmd}' to be installed." + >&2 echo "This script requires '${cmd}' to be installed." exit 1 fi done @@ -42,7 +42,18 @@ artifactid=openapi-generator-cli ver=${OPENAPI_GENERATOR_VERSION:-$(latest.tag $ghrepo)} jar=${artifactid}-${ver}.jar -DIR=${OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"} + +# TODO: Remove OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR for release 5.0 +if [ -n "${OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR}" ]; then + >&2 printf "[WARN] Variable OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR is misspelled.\nPlease change to OPENAPI_GENERATOR_DOWNLOAD_CACHE_DIR. This option will be removed in the 5.0 release.\n" +fi +cachedir=${OPENAPI_GENERATOR_DOWNLOAD_CACHE_DIR:-"$OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR"} + +DIR=${cachedir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"} + +if [ ! -d "${DIR}" ]; then + mkdir -p "${DIR}" +fi if [ ! -f ${DIR}/${jar} ]; then repo="central::default::https://repo1.maven.org/maven2/" diff --git a/docs/generators/csharp-netcore.md b/docs/generators/csharp-netcore.md index 62b36ff6769c..346932bc6e3f 100644 --- a/docs/generators/csharp-netcore.md +++ b/docs/generators/csharp-netcore.md @@ -19,6 +19,7 @@ sidebar_label: csharp-netcore |returnICollection|Return ICollection<T> instead of the concrete type.| |false| |optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true| |optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true| +|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false| |optionalProjectFile|Generate {PackageName}.csproj.| |true| |nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| diff --git a/docs/generators/go-server.md b/docs/generators/go-server.md index a2094d82603a..a602a39c42bb 100644 --- a/docs/generators/go-server.md +++ b/docs/generators/go-server.md @@ -10,3 +10,4 @@ sidebar_label: go-server |hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true| |sourceFolder|source folder for generated code| |go| |serverPort|The network port the generated server binds to| |8080| +|featureCORS|Enable Cross-Origin Resource Sharing middleware| |false| diff --git a/docs/integration.md b/docs/integration.md index 0ab59c547b4b..fdf2898646d2 100644 --- a/docs/integration.md +++ b/docs/integration.md @@ -19,6 +19,14 @@ Supported tasks include: See the [openapi-generator-maven-plugin README](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md) for details related to configuring and using the Maven Plugin. +### sbt Integration + +Please refer to https://github.com/upstart-commerce/sbt-openapi-generator + +### Bazel Integration + +Please refer to https://github.com/OpenAPITools/openapi-generator-bazel + ### GitHub Integration To push the auto-generated SDK to GitHub, we provide `git_push.sh` to streamline the process. For example: diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java index 4ec67be8914d..e16b281d6d3e 100644 --- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java +++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java @@ -72,15 +72,34 @@ public class Meta implements Runnable { allowedValues = {"CLIENT", "SERVER", "DOCUMENTATION", "CONFIG", "OTHER"}) private String type = "OTHER"; + @Option(name = {"-l", "--language"}, title = "language", + description = "the implementation language for the generator class", + allowedValues = {"java", "kotlin"} + ) + private String language = "java"; + @Override public void run() { final File targetDir = new File(outputFolder); LOGGER.info("writing to folder [{}]", targetDir.getAbsolutePath()); String mainClass = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name) + "Generator"; + String kebabName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name); - List supportingFiles = + List supportingFiles = "kotlin".equals(language) ? ImmutableList.of( + new SupportingFile("kotlin/build_gradle.mustache", "", "build.gradle.kts"), + new SupportingFile("kotlin/gradle.properties", "", "gradle.properties"), + new SupportingFile("kotlin/settings.mustache", "", "settings.gradle"), + new SupportingFile("kotlin/generatorClass.mustache", on(File.separator).join("src/main/kotlin", asPath(targetPackage)), mainClass.concat(".kt")), + new SupportingFile("kotlin/generatorClassTest.mustache", on(File.separator).join("src/test/kotlin", asPath(targetPackage)), mainClass.concat("Test.kt")), + new SupportingFile("kotlin/README.mustache", "", "README.md"), + + new SupportingFile("api.template", "src/main/resources" + File.separator + name,"api.mustache"), + new SupportingFile("model.template", "src/main/resources" + File.separator + name,"model.mustache"), + new SupportingFile("myFile.template", String.join(File.separator, "src", "main", "resources", name), "myFile.mustache"), + new SupportingFile("services.mustache", "src/main/resources/META-INF/services", CodegenConfig.class.getCanonicalName())) + : ImmutableList.of( new SupportingFile("pom.mustache", "", "pom.xml"), new SupportingFile("generatorClass.mustache", on(File.separator).join("src/main/java", asPath(targetPackage)), mainClass.concat(".java")), new SupportingFile("generatorClassTest.mustache", on(File.separator).join("src/test/java", asPath(targetPackage)), mainClass.concat("Test.java")), @@ -97,6 +116,7 @@ public void run() { .put("generatorPackage", targetPackage) .put("generatorClass", mainClass) .put("name", name) + .put("kebabName", kebabName) .put("generatorType", type) .put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass) .put("openapiGeneratorVersion", currentVersion).build(); diff --git a/modules/openapi-generator-maven-plugin/examples/kotlin.xml b/modules/openapi-generator-maven-plugin/examples/kotlin.xml new file mode 100644 index 000000000000..83b54be3daba --- /dev/null +++ b/modules/openapi-generator-maven-plugin/examples/kotlin.xml @@ -0,0 +1,237 @@ + + 4.0.0 + org.openapitools + sample-project + jar + 1.0-SNAPSHOT + sample-project + http://maven.apache.org + + + + + + org.openapitools + openapi-generator-maven-plugin + + 4.2.1-SNAPSHOT + + + + default + + generate + + + + ${project.basedir}/swagger.yaml + + + kotlin + + + + + + true + + + + + + kotlin + generate-sources + + generate + + + + https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml + + + + kotlin + + + + + + true + + + ${project.build.directory}/generated-sources/kotlin + kotlintest.org.openapitools.client.api + kotlintest.org.openapitools.client.model + kotlintest.org.openapitools.client + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + none + + + + kotlin-maven-plugin + org.jetbrains.kotlin + + ${kotlinJvmTarget} + + + + + compile + + compile + + + + ${project.build.directory}/generated-sources/kotlin/src/main/kotlin + + + + + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + + + + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + + + + + + org.glassfish.jersey.core + jersey-client + ${jersey-version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey-version} + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey-version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-base + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson-version} + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + ${jackson-version} + + + joda-time + joda-time + ${jodatime-version} + + + + + com.brsanthu + migbase64 + ${migbase64.version} + + + com.squareup.moshi + moshi-kotlin + ${moshi-kotlin.version} + + + com.squareup.moshi + moshi-adapters + ${moshi-kotlin.version} + + + com.squareup.okhttp3 + okhttp + 4.2.2 + + + + + 1.5.8 + 2.27 + 2.8.9 + 0.2.0 + 2.7 + 1.0.0 + 4.8.1 + 1.3.50 + 1.8 + 1.8.0 + 2.2 + + diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java index ea3549712027..ea51d6ff5593 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java @@ -17,6 +17,7 @@ package org.openapitools.codegen; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -38,7 +39,7 @@ public class CodegenSecurity { // Oauth specific public String flow, authorizationUrl, tokenUrl; public List> scopes; - public Boolean isCode, isPassword, isApplication, isImplicit, hasScopes; + public Boolean isCode, isPassword, isApplication, isImplicit; @Override public String toString() { @@ -100,4 +101,47 @@ public int hashCode() { isImplicit, scopes); } + + // Return a copy of the security object, filtering out any scopes from the passed-in list. + public CodegenSecurity filterByScopeNames(List filterScopes) { + CodegenSecurity filteredSecurity = new CodegenSecurity(); + // Copy all fields except the scopes. + filteredSecurity.name = name; + filteredSecurity.type = type; + filteredSecurity.hasMore = false; + filteredSecurity.isBasic = isBasic; + filteredSecurity.isBasicBasic = isBasicBasic; + filteredSecurity.isBasicBearer = isBasicBearer; + filteredSecurity.isApiKey = isApiKey; + filteredSecurity.isOAuth = isOAuth; + filteredSecurity.keyParamName = keyParamName; + filteredSecurity.isCode = isCode; + filteredSecurity.isImplicit = isImplicit; + filteredSecurity.isApplication = isApplication; + filteredSecurity.isPassword = isPassword; + filteredSecurity.isKeyInCookie = isKeyInCookie; + filteredSecurity.isKeyInHeader = isKeyInHeader; + filteredSecurity.isKeyInQuery = isKeyInQuery; + filteredSecurity.flow = flow; + filteredSecurity.tokenUrl = tokenUrl; + filteredSecurity.authorizationUrl = authorizationUrl; + // It is not possible to deep copy the extensions, as we have no idea what types they are. + // So the filtered method *will* refer to the original extensions, if any. + filteredSecurity.vendorExtensions = new HashMap(vendorExtensions); + List> returnedScopes = new ArrayList>(); + Map lastScope = null; + for (String filterScopeName : filterScopes) { + for (Map scope : scopes) { + String name = (String) scope.get("scope"); + if (filterScopeName.equals(name)) { + returnedScopes.add(scope); + lastScope = scope; + break; + } + } + } + filteredSecurity.scopes = returnedScopes; + + return filteredSecurity; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 98a0226afa28..7f56122e52c4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -1057,55 +1057,21 @@ private void processOperation(String resourcePath, String httpMethod, Operation } Map authMethods = getAuthMethods(securities, securitySchemes); - if (authMethods == null || authMethods.isEmpty()) { - authMethods = getAuthMethods(globalSecurities, securitySchemes); - } if (authMethods != null && !authMethods.isEmpty()) { - codegenOperation.authMethods = config.fromSecurity(authMethods); - List> scopes = new ArrayList>(); - if (codegenOperation.authMethods != null) { - for (CodegenSecurity security : codegenOperation.authMethods) { - if (security != null && security.isBasicBearer != null && security.isBasicBearer && - securities != null) { - for (SecurityRequirement req : securities) { - if (req == null) continue; - for (String key : req.keySet()) { - if (security.name != null && key.equals(security.name)) { - int count = 0; - for (String sc : req.get(key)) { - Map scope = new HashMap(); - scope.put("scope", sc); - scope.put("description", ""); - count++; - if (req.get(key) != null && count < req.get(key).size()) { - scope.put("hasMore", "true"); - } else { - scope.put("hasMore", null); - } - scopes.add(scope); - } - //end this inner for - break; - } - } - - } - security.hasScopes = scopes.size() > 0; - security.scopes = scopes; - } - } - } + List fullAuthMethods = config.fromSecurity(authMethods); + codegenOperation.authMethods = filterAuthMethods(fullAuthMethods, securities); codegenOperation.hasAuthMethods = true; - } + } else { + authMethods = getAuthMethods(globalSecurities, securitySchemes); - /* TODO need to revise the logic below - Map securitySchemeMap = openAPI.getComponents().getSecuritySchemes(); - if (securitySchemeMap != null && !securitySchemeMap.isEmpty()) { - codegenOperation.authMethods = config.fromSecurity(securitySchemeMap); - codegenOperation.hasAuthMethods = true; + if (authMethods != null && !authMethods.isEmpty()) { + List fullAuthMethods = config.fromSecurity(authMethods); + codegenOperation.authMethods = filterAuthMethods(fullAuthMethods, globalSecurities); + codegenOperation.hasAuthMethods = true; + } } - */ + } catch (Exception ex) { String msg = "Could not process operation:\n" // + " Tag: " + tag + "\n"// @@ -1311,6 +1277,40 @@ private static OAuthFlow cloneOAuthFlow(OAuthFlow originFlow, List opera .scopes(newScopes); } + private List filterAuthMethods(List authMethods, List securities) { + if (securities == null || securities.isEmpty() || authMethods == null) { + return authMethods; + } + + List result = new ArrayList(); + + for (CodegenSecurity security : authMethods) { + boolean filtered = false; + if (security != null && security.scopes != null) { + for (SecurityRequirement requirement : securities) { + List opScopes = requirement.get(security.name); + if (opScopes != null) { + // We have operation-level scopes for this method, so filter the auth method to + // describe the operation auth method with only the scopes that it requires. + // We have to create a new auth method instance because the original object must + // not be modified. + CodegenSecurity opSecurity = security.filterByScopeNames(opScopes); + result.add(opSecurity); + filtered = true; + break; + } + } + } + + // If we didn't get a filtered version, then we can keep the original auth method. + if (!filtered) { + result.add(security); + } + } + + return result; + } + private boolean hasOAuthMethods(List authMethods) { for (CodegenSecurity cs : authMethods) { if (Boolean.TRUE.equals(cs.isOAuth)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java index 57c45a76fb03..b861a390cf76 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java @@ -434,19 +434,19 @@ public void processOpts() { } if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) { - this.setSerializableModel(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL))); + this.setSerializableModel(getBooleanOption(CodegenConstants.SERIALIZABLE_MODEL)); } else { additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); } if (additionalProperties.containsKey(CodegenConstants.PARCELIZE_MODELS)) { - this.setParcelizeModels(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.PARCELIZE_MODELS))); + this.setParcelizeModels(getBooleanOption(CodegenConstants.PARCELIZE_MODELS)); } else { additionalProperties.put(CodegenConstants.PARCELIZE_MODELS, parcelizeModels); } if (additionalProperties.containsKey(CodegenConstants.NON_PUBLIC_API)) { - this.setNonPublicApi(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.NON_PUBLIC_API))); + this.setNonPublicApi(getBooleanOption(CodegenConstants.NON_PUBLIC_API)); } else { additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi); } @@ -458,6 +458,18 @@ public void processOpts() { additionalProperties.put("modelDocPath", modelDocPath); } + private boolean getBooleanOption(String key) { + final Object booleanValue = additionalProperties.get(key); + Boolean result = Boolean.FALSE; + if (booleanValue instanceof Boolean) { + result = (Boolean) booleanValue; + } else if (booleanValue instanceof String) { + result = Boolean.parseBoolean((String) booleanValue); + } + additionalProperties.put(key, result); + return result; + } + public void setArtifactId(String artifactId) { this.artifactId = artifactId; } @@ -501,7 +513,7 @@ public boolean isSerializableModel() { public void setSerializableModel(boolean serializableModel) { this.serializableModel = serializableModel; } - + public boolean nonPublicApi() { return nonPublicApi; } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java index abdac22c763d..845341f3b709 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java @@ -211,6 +211,10 @@ public CSharpNetCoreClientCodegen() { CodegenConstants.OPTIONAL_ASSEMBLY_INFO_DESC, this.optionalAssemblyInfoFlag); + addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, + CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC, + this.optionalEmitDefaultValuesFlag); + addSwitch(CodegenConstants.OPTIONAL_PROJECT_FILE, CodegenConstants.OPTIONAL_PROJECT_FILE_DESC, this.optionalProjectFileFlag); @@ -396,6 +400,8 @@ public String modelTestFileFolder() { @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { postProcessPattern(property.pattern, property.vendorExtensions); + postProcessEmitDefaultValue(property.vendorExtensions); + super.postProcessModelProperty(model, property); } @@ -429,6 +435,7 @@ public Map postProcessOperationsWithModels(Map o @Override public void postProcessParameter(CodegenParameter parameter) { postProcessPattern(parameter.pattern, parameter.vendorExtensions); + postProcessEmitDefaultValue(parameter.vendorExtensions); super.postProcessParameter(parameter); if (!parameter.required && nullableType.contains(parameter.dataType)) { //optional @@ -472,6 +479,10 @@ public void postProcessPattern(String pattern, Map vendorExtensi } } + public void postProcessEmitDefaultValue(Map vendorExtensions) { + vendorExtensions.put("x-emit-default-value", optionalEmitDefaultValuesFlag); + } + @Override public Mustache.Compiler processCompiler(Mustache.Compiler compiler) { // To avoid unexpected behaviors when options are passed programmatically such as { "supportsAsync": "" } @@ -491,6 +502,13 @@ public void processOpts() { * if (additionalProperties.containsKey(prop)) convertPropertyToBooleanAndWriteBack(prop); */ + if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)) { + setOptionalEmitDefaultValuesFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)); + } else { + additionalProperties.put(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, optionalEmitDefaultValuesFlag); + } + + if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) { setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING)); } @@ -636,6 +654,10 @@ public void setOptionalAssemblyInfoFlag(boolean flag) { this.optionalAssemblyInfoFlag = flag; } + public void setOptionalEmitDefaultValuesFlag(boolean flag){ + this.optionalEmitDefaultValuesFlag = flag; + } + public void setOptionalProjectFileFlag(boolean flag) { this.optionalProjectFileFlag = flag; } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java index 6b6c2e0cefef..b8122cf3aa81 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java @@ -41,6 +41,7 @@ public class GoServerCodegen extends AbstractGoCodegen { protected int serverPort = 8080; protected String projectName = "openapi-server"; protected String sourceFolder = "go"; + protected Boolean corsFeatureEnabled = false; public GoServerCodegen() { @@ -68,15 +69,20 @@ public GoServerCodegen() { // set the output folder here outputFolder = "generated-code/go"; - + cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC) .defaultValue(sourceFolder)); - + CliOption optServerPort = new CliOption("serverPort", "The network port the generated server binds to"); optServerPort.setType("int"); optServerPort.defaultValue(Integer.toString(serverPort)); cliOptions.add(optServerPort); + CliOption optFeatureCORS = new CliOption("featureCORS", "Enable Cross-Origin Resource Sharing middleware"); + optFeatureCORS.setType("bool"); + optFeatureCORS.defaultValue(corsFeatureEnabled.toString()); + cliOptions.add(optFeatureCORS); + /* * Models. You can write model files using the modelTemplateFiles map. * if you want to create one template for file, you can do so here. @@ -133,8 +139,8 @@ public GoServerCodegen() { @Override public void processOpts() { super.processOpts(); - - + + /* * Additional Properties. These values can be passed to the templates and * are available in models, apis, and supporting files @@ -145,25 +151,31 @@ public void processOpts() { setPackageName("openapi"); additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); } - + if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) { this.setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION)); } else { additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); } - + if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } else { additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder); } - + if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof Integer) { this.setServerPort((int) additionalProperties.get("serverPort")); } else { additionalProperties.put("serverPort", serverPort); } + if (additionalProperties.containsKey("featureCORS")) { + this.setFeatureCORS(convertPropertyToBooleanAndWriteBack("featureCORS")); + } else { + additionalProperties.put("featureCORS", corsFeatureEnabled); + } + modelPackage = packageName; apiPackage = packageName; @@ -273,7 +285,7 @@ public String apiFileFolder() { public String modelFileFolder() { return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar); } - + public void setSourceFolder(String sourceFolder) { this.sourceFolder = sourceFolder; } @@ -284,5 +296,9 @@ public void setPackageVersion(String packageVersion) { public void setServerPort(int serverPort) { this.serverPort = serverPort; - } + } + + public void setFeatureCORS(Boolean featureCORS) { + this.corsFeatureEnabled = featureCORS; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java index 8db3856c03bc..5b744f9ae2da 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java @@ -31,6 +31,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class KotlinClientCodegen extends AbstractKotlinCodegen { @@ -215,6 +217,10 @@ public void processOpts() { supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt")); supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt")); supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt")); + if (getSerializationLibrary() == SERIALIZATION_LIBRARY_TYPE.gson) { + supportingFiles.add(new SupportingFile("infrastructure/DateAdapter.kt.mustache", infrastructureFolder, + "DateAdapter.kt")); + } } else if (MULTIPLATFORM.equals(getLibrary())) { additionalProperties.put(MULTIPLATFORM, true); @@ -316,15 +322,20 @@ public Map postProcessModels(Map objs) { CodegenModel cm = (CodegenModel) mo.get("model"); // escape the variable base name for use as a string literal - if (cm.requiredVars != null) { - for (CodegenProperty var : cm.requiredVars) { - var.vendorExtensions.put(VENDOR_EXTENSION_BASE_NAME_LITERAL, var.baseName.replace("$", "\\$")); - } - } - if (cm.optionalVars != null) { - for (CodegenProperty var : cm.optionalVars) { - var.vendorExtensions.put(VENDOR_EXTENSION_BASE_NAME_LITERAL, var.baseName.replace("$", "\\$")); - } + List vars = Stream.of( + cm.vars, + cm.allVars, + cm.optionalVars, + cm.requiredVars, + cm.readOnlyVars, + cm.readWriteVars, + cm.parentVars + ) + .flatMap(List::stream) + .collect(Collectors.toList()); + + for (CodegenProperty var : vars) { + var.vendorExtensions.put(VENDOR_EXTENSION_BASE_NAME_LITERAL, var.baseName.replace("$", "\\$")); } } diff --git a/modules/openapi-generator/src/main/resources/Groovy/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Groovy/build.gradle.mustache index a5733e22fba8..5fb591199776 100644 --- a/modules/openapi-generator/src/main/resources/Groovy/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Groovy/build.gradle.mustache @@ -28,6 +28,7 @@ repositories { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" + jackson_databind_version = "2.9.10.1" } dependencies { @@ -35,7 +36,7 @@ dependencies { compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" - compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version" compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version" compile 'io.github.http-builder-ng:http-builder-ng-core:1.0.3' diff --git a/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache index 2fa658683573..47059d550b1d 100644 --- a/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache @@ -137,7 +137,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" jersey_version = "1.19.4" jodatime_version = "2.9.9" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache index 9c8d7a8d30e6..57deb75c560c 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache @@ -121,7 +121,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" google_api_client_version = "1.23.0" jersey_common_version = "2.25.1" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.sbt.mustache index 2c1ff450e944..2af4dd8dfdb8 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.sbt.mustache @@ -14,7 +14,7 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.core" % "jersey-common" % "2.25.1", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", {{#withXml}} "com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.9.10" % "compile", {{/withXml}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache index 7be1da91a4e1..89f8be6132ce 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache @@ -307,7 +307,7 @@ 1.30.2 2.25.1 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 {{#joda}} 2.9.9 diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache index ec3b383eea0d..998d6ebc8b48 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache @@ -120,7 +120,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" {{#supportJava6}} jersey_version = "2.6" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache index e31be933919d..61f8e283787a 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache @@ -15,7 +15,7 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}}, "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", {{#joda}} "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.10" % "compile", {{/joda}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache index 31a1843080e5..5a108ed6ee4e 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache @@ -361,7 +361,7 @@ 3.6 {{/supportJava6}} 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 {{#threetenbp}} 2.9.10 diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache index e45659de5241..bf9f5408c2a1 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache @@ -120,7 +120,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" threetenbp_version = "2.9.10" resteasy_version = "3.1.3.Final" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.sbt.mustache index bcedcaec343f..95ab58d1f9da 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.sbt.mustache @@ -15,7 +15,7 @@ lazy val root = (project in file(".")). "org.jboss.resteasy" % "resteasy-jackson2-provider" % "3.1.3.Final" % "compile", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile", {{#java8}} "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile", diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache index 1a12889b965c..16a1a3fe1fa9 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache @@ -295,7 +295,7 @@ 1.5.22 3.1.3.Final 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 2.9.10 {{^java8}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache index 7601a8180d15..1c631f1a5579 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache @@ -121,7 +121,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" spring_web_version = "4.3.9.RELEASE" jodatime_version = "2.9.9" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache index a717eb441270..eb3ddfb12f9f 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache @@ -310,7 +310,7 @@ 1.5.22 4.3.9.RELEASE 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 {{#joda}} 2.9.9 diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index e7f778ba5a0f..ddeb061cd028 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -132,7 +132,7 @@ ext { {{/play25}} {{#play26}} jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" play_version = "2.6.7" {{/play26}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache index c6fc88aa0aa1..ecae66c6a853 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache @@ -25,7 +25,7 @@ lazy val root = (project in file(".")). "com.typesafe.play" % "play-java-ws_2.11" % "2.5.15" % "compile", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", {{/play25}} {{#play26}} "com.typesafe.play" % "play-ahc-ws_2.12" % "2.6.7" % "compile", diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache index d32445d02f1b..428e42037634 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -375,7 +375,7 @@ 1.8.3 1.5.22 {{#usePlayWS}} - 2.9.10 + 2.9.10.1 {{#play24}} 2.6.6 2.4.11 diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/build.gradle.mustache index 68dce22f06ab..862aee9f7850 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/build.gradle.mustache @@ -29,7 +29,7 @@ task execute(type:JavaExec) { ext { swagger_annotations_version = "1.5.21" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" vertx_version = "3.4.2" junit_version = "4.12" } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache index df5588613876..cdbb87d18008 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache @@ -290,7 +290,7 @@ 3.4.2 1.5.22 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 4.12 diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/pom.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/pom.mustache index a81ab0fbed08..4ea71205974f 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/pom.mustache @@ -10,7 +10,7 @@ UTF-8 2.22.0 true - 0.25.0 + 0.27.0 3.8.1 1.8 UTF-8 @@ -105,21 +105,6 @@ - - io.quarkus - quarkus-maven-plugin - ${quarkus.version} - - - - native-image - - - true - - - - maven-failsafe-plugin ${surefire-plugin.version} @@ -139,6 +124,9 @@ + + native + diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache index 842a9926d18c..156ba47b04db 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache @@ -248,7 +248,7 @@ org.springframework.hateoas spring-hateoas - 0.25.0.RELEASE + 1.0.1.RELEASE {{/hateoas}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache index 60d7d41fe48d..fbe3a9f1445d 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache @@ -25,7 +25,7 @@ import javax.xml.bind.annotation.*; {{/withXml}} {{^parent}} {{#hateoas}} -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; {{/hateoas}} {{/parent}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache index 29c35fbc1d73..5ccc8a8c9368 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache @@ -3,7 +3,7 @@ */{{#description}} @ApiModel(description = "{{{description}}}"){{/description}} {{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} -public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}}{{#hateoas}}extends ResourceSupport {{/hateoas}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { +public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}}{{#hateoas}}extends RepresentationModel<{{classname}}> {{/hateoas}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#serializableModel}} private static final long serialVersionUID = 1L; diff --git a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/modelGeneric.mustache index a1ada9997363..143ca85238c4 100644 --- a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/modelGeneric.mustache @@ -23,5 +23,5 @@ export type {{classname}} = { */ {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{/vars}} -} +}{{#parent}} & {{parent}}{{/parent}} diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache index 99492c9a6040..19a6acbc53e0 100644 --- a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache +++ b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache @@ -33,9 +33,15 @@ namespace {{apiPackage}} /// {{description}}{{/allParams}}{{#responses}} /// {{message}}{{/responses}} [{{httpMethod}}] - [Route("{{{basePathWithoutHost}}}{{{path}}}")]{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}} - [Authorize(Policy = "{{name}}")]{{/isApiKey}}{{#isBasicBearer}} - [Authorize{{#hasScopes}}(Roles = "{{#scopes}}{{scope}}{{#hasMore}},{{/hasMore}}{{/scopes}}"){{/hasScopes}}]{{/isBasicBearer}}{{/authMethods}}{{/hasAuthMethods}} + [Route("{{{basePathWithoutHost}}}{{{path}}}")] +{{#authMethods}} +{{#isApiKey}} + [Authorize(Policy = "{{name}}")] +{{/isApiKey}} +{{#isBasicBearer}} + [Authorize{{#scopes}}{{#-first}}(Roles = "{{/-first}}{{scope}}{{^-last}},{{/-last}}{{#-last}}"){{/-last}}{{/scopes}}] +{{/isBasicBearer}} +{{/authMethods}} [ValidateModelState]{{#useSwashbuckle}} [SwaggerOperation("{{operationId}}")]{{#responses}}{{#dataType}} [SwaggerResponse(statusCode: {{code}}, type: typeof({{&dataType}}), description: "{{message}}")]{{/dataType}}{{^dataType}}{{/dataType}}{{/responses}}{{/useSwashbuckle}}{{^useSwashbuckle}}{{#responses}}{{#dataType}} diff --git a/modules/openapi-generator/src/main/resources/codegen/kotlin/README.mustache b/modules/openapi-generator/src/main/resources/codegen/kotlin/README.mustache new file mode 100644 index 000000000000..940ebbc0fa47 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/codegen/kotlin/README.mustache @@ -0,0 +1,60 @@ +# {{kebabName}}-openapi-generator + +## Requirements + +* Gradle 5.x +* Java 8+ + +## Getting Started + +* Initialize the gradle wrapper: + ```bash + gradle wrapper --gradle-version 5.6.2 + ``` +* Modify the codegen class and associated templates +* Compile with `./gradlew standalone` +* Verify: + ```bash + java -jar build/libs/{{kebabName}}-openapi-generator-standalone.jar config-help -g {{name}} + ``` + +## Building + +### Standalone + +As seen in "Getting Started", the generator may be built as a standalone customized version of OpenAPI Generator's CLI. This may be the simplest option for developers who are unfamiliar with working in the JVM. Please be aware of any licensing concerns before distributing this "uber-jar". + +To build as a standalone, run: + +```bash +./gradlew standalone +``` + +To list generators via OpenAPI Generator CLI: + +```bash +java -jar build/libs/{{kebabName}}-openapi-generator-standalone.jar list --include all +``` + +### ShadowJar + +This generator supports building as a lightweight "fat-jar". This option includes Kotlin or any other `implementation` dependencies you'll add. This will simplify publishing if your generator has many dependencies. + +To build as a shadowJar, run: + +```bash +./gradlew shadowJar +``` + +To list generators via OpenAPI Generator CLI, you must refer to the CLI jar explicitly. We add a custom copy task which includes the CLI jar in the build output directory: + +```bash +java -cp build/libs/openapi-generator-cli-4.1.3.jar:build/libs/{{kebabName}}-openapi-generator-1.0-SNAPSHOT-all.jar org.openapitools.codegen.OpenAPIGenerator list +``` + +Notice that this command _must_ pass classpath via `-cp` and include OpenAPI Generator CLI as well as the artifact built from this project. Also notice that the manifest class must be passed explicitly as `org.openapitools.codegen.OpenAPIGenerator`. + +## See Also + +* [Customization docs](https://openapi-generator.tech/docs/customization) +* [Templating docs](https://openapi-generator.tech/docs/templating) diff --git a/modules/openapi-generator/src/main/resources/codegen/kotlin/build_gradle.mustache b/modules/openapi-generator/src/main/resources/codegen/kotlin/build_gradle.mustache new file mode 100644 index 000000000000..60ec7dd944fe --- /dev/null +++ b/modules/openapi-generator/src/main/resources/codegen/kotlin/build_gradle.mustache @@ -0,0 +1,62 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("jvm") version "1.3.41" + id("com.github.johnrengelman.shadow") version("5.0.0") +} + +group = "org.openapitools" +version = "1.0-SNAPSHOT" + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + val openapiGeneratorVersion = "4.1.3" + + implementation(kotlin("stdlib-jdk8")) + implementation("org.openapitools:openapi-generator:$openapiGeneratorVersion") + + runtime("org.openapitools:openapi-generator-cli:$openapiGeneratorVersion") + + testImplementation("org.junit.jupiter:junit-jupiter:5.5.2") +} + +tasks.test { + useJUnitPlatform() + testLogging { + events("passed", "skipped", "failed") + } +} + +tasks.register("copyToLib") { + from(project.configurations.runtime) + into(File(buildDir, "libs")) +} + +tasks.register("standalone") { + archiveFileName.set("{{name}}-openapi-generator-standalone.jar") + archiveClassifier.set("all") + + from(sourceSets["main"].output) + + configurations.add(project.configurations["runtimeClasspath"]) + configurations.add(project.configurations["runtime"]) + + mergeServiceFiles() + + manifest.attributes(mapOf("Main-Class" to "org.openapitools.codegen.OpenAPIGenerator")) +} + +tasks.withType { + kotlinOptions.jvmTarget = "1.8" +} + +tasks.wrapper { + this.distributionType = Wrapper.DistributionType.BIN +} + +tasks.named("shadowJar") { dependsOn("copyToLib") } diff --git a/modules/openapi-generator/src/main/resources/codegen/kotlin/generatorClass.mustache b/modules/openapi-generator/src/main/resources/codegen/kotlin/generatorClass.mustache new file mode 100644 index 000000000000..b65939e23f73 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/codegen/kotlin/generatorClass.mustache @@ -0,0 +1,183 @@ +@file:JvmName("{{generatorClass}}") +package {{generatorPackage}} + +import org.openapitools.codegen.* + +import java.util.* +import java.io.File + +open class {{generatorClass}}() : DefaultCodegen(), CodegenConfig { + + // source folder where files are written + private var sourceFolder = "src" + private var apiVersion = "1.0.0" + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see org.openapitools.codegen.CodegenType + */ + override fun getTag(): CodegenType { + return CodegenType.{{generatorType}} + } + + /** + * Configures a friendly name for the generator. This will be used by the generator + * to select the library with the -g flag. + * + * @return the friendly name for the generator + */ + override fun getName(): String { + return "{{name}}" + } + + /** + * Provides an opportunity to inspect and modify operation data before the code is generated. + */ + @Suppress("UNCHECKED_CAST") + override fun postProcessOperationsWithModels(objs: Map, allModels: List?): Map { + val results = super.postProcessOperationsWithModels(objs, allModels) + + val ops = results["operations"] as Map + val opList = ops["operation"] as ArrayList + + // iterate over the operation and perhaps modify something + for (co: CodegenOperation in opList) { + // example: + // co.httpMethod = co.httpMethod.toLowerCase(); + } + + return results + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + override fun getHelp(): String { + return "Generates a {{name}} client library." + } + + init { + // set the output folder here + outputFolder = "generated-code/{{name}}" + + /** + * Models. You can write model files using the modelTemplateFiles map. + * if you want to create one template for file, you can do so here. + * for multiple files for model, just put another entry in the `modelTemplateFiles` with + * a different extension + */ + modelTemplateFiles["model.mustache"] = ".sample" // the extension for each file to write + + /** + * Api classes. You can write classes for each Api file with the apiTemplateFiles map. + * as with models, add multiple entries with different extensions for multiple files per + * class + */ + apiTemplateFiles["api.mustache"] = ".sample" // the extension for each file to write + + /** + * Template Location. This is the location which templates will be read from. The generator + * will use the resource stream to attempt to read the templates. + */ + templateDir = "{{name}}" + + /** + * Api Package. Optional, if needed, this can be used in templates + */ + apiPackage = "org.openapitools.api" + + /** + * Model Package. Optional, if needed, this can be used in templates + */ + modelPackage = "org.openapitools.model" + + /** + * Reserved words. Override this with reserved words specific to your language + */ + reservedWords = HashSet( + listOf("sample1", "sample2") + ) + + /** + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ + additionalProperties["apiVersion"] = apiVersion + + /** + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ + supportingFiles.add( + SupportingFile( + "myFile.mustache", // the input template or file + "", // the destination folder, relative `outputFolder` + "myFile.sample" + ) // the output file + ) + + /** + * Language Specific Primitives. These types will not trigger imports by + * the client generator + */ + languageSpecificPrimitives = HashSet( + listOf("Type1", "Type2") + ) + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping + * those terms here. This logic is only called if a variable matches the reserved words + * + * @return the escaped term + */ + override fun escapeReservedWord(name: String?): String { + // add an underscore to the name if it exists. + return if (name == null) "" else "_$name" + } + + /** + * Location to write model files. You can use the modelPackage() as defined when the class is + * instantiated + */ + override fun modelFileFolder(): String { + return """$outputFolder/$sourceFolder/${modelPackage().replace('.', File.separatorChar)}""" + } + + /** + * Location to write api files. You can use the apiPackage() as defined when the class is + * instantiated + */ + override fun apiFileFolder(): String { + return """$outputFolder/$sourceFolder/${apiPackage().replace('.', File.separatorChar)}""" + } + + /** + * override with any special text escaping logic to handle unsafe + * characters so as to avoid code injection + * + * @param input String to be cleaned up + * @return string with unsafe characters removed or escaped + */ + override fun escapeUnsafeCharacters(input: String): String { + //TODO: check that this logic is safe to escape unsafe characters to avoid code injection + return input + } + + /** + * Escape single and/or double quote to avoid code injection + * + * @param input String to be cleaned up + * @return string with quotation mark removed or escaped + */ + override fun escapeQuotationMark(input: String): String { + //TODO: check that this logic is safe to escape quotation mark to avoid code injection + return with(input) { replace("\"", "\\\"") } + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/codegen/kotlin/generatorClassTest.mustache b/modules/openapi-generator/src/main/resources/codegen/kotlin/generatorClassTest.mustache new file mode 100644 index 000000000000..c1276791bccf --- /dev/null +++ b/modules/openapi-generator/src/main/resources/codegen/kotlin/generatorClassTest.mustache @@ -0,0 +1,26 @@ +package {{generatorPackage}} + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.openapitools.codegen.ClientOptInput +import org.openapitools.codegen.DefaultGenerator +import org.openapitools.codegen.config.CodegenConfigurator + +internal class {{generatorClass}}Test { + + // use this test to launch you code generator in the debugger. + // this allows you to easily set break points in MyclientcodegenGenerator. + @Test + fun launchCodeGenerator() { + // to understand how the 'openapi-generator-cli' module is using 'CodegenConfigurator', have a look at the 'Generate' class: + // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java + val configurator: CodegenConfigurator = CodegenConfigurator() + .setGeneratorName("{{name}}") + .setInputSpec("https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // or from the server + .setOutputDir("out/{{name}}") + + val clientOptInput: ClientOptInput = configurator.toClientOptInput() + val generator = DefaultGenerator() + generator.opts(clientOptInput).generate() + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/codegen/kotlin/gradle.properties b/modules/openapi-generator/src/main/resources/codegen/kotlin/gradle.properties new file mode 100644 index 000000000000..7fc6f1ff272e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/codegen/kotlin/gradle.properties @@ -0,0 +1 @@ +kotlin.code.style=official diff --git a/modules/openapi-generator/src/main/resources/codegen/kotlin/settings.mustache b/modules/openapi-generator/src/main/resources/codegen/kotlin/settings.mustache new file mode 100644 index 000000000000..423981313810 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/codegen/kotlin/settings.mustache @@ -0,0 +1 @@ +rootProject.name = '{{kebabName}}-openapi-generator' diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache index 2ad6f17868fd..8fc1b19b7e74 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.2) project(api-server) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pg -g3" ) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pg -g3" ) {{#addExternalLibs}} include(ExternalProject) diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache index f5275022a716..881220143731 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache @@ -20,6 +20,27 @@ namespace {{this}} { {{/cppNamespaceDeclarations}} + template QString + toStringValue(const QList &val); + + template + bool fromStringValue(const QList &inStr, QList &val); + + template + bool fromStringValue(const QMap &inStr, QMap &val); + + template + QJsonValue toJsonValue(const QList &val); + + template + QJsonValue toJsonValue(const QMap &val); + + template + bool fromJsonValue(QList &val, const QJsonValue &jval); + + template + bool fromJsonValue(QMap &val, const QJsonValue &jval); + QString toStringValue(const QString &value); QString toStringValue(const QDateTime &value); QString toStringValue(const QByteArray &value); @@ -128,7 +149,7 @@ namespace {{this}} { bool fromJsonValue(QList &val, const QJsonValue &jval) { bool ok = true; if(jval.isArray()){ - for(const auto& jitem : jval.toArray()){ + for(const auto jitem : jval.toArray()){ T item; ok &= fromJsonValue(item, jitem); val.push_back(item); diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache index 0f71c97ca6c8..ea1e8e1411b8 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache @@ -14,12 +14,12 @@ namespace {{this}} { {{/cppNamespaceDeclarations}} {{classname}}::{{classname}}(QString json) { - this->init(); + this->initializeModel(); this->fromJson(json); } {{classname}}::{{classname}}() { - this->init(); + this->initializeModel(); } {{classname}}::~{{classname}}() { @@ -27,15 +27,14 @@ namespace {{this}} { } void -{{classname}}::init() { +{{classname}}::initializeModel() { {{^isEnum}}{{#vars}} m_{{name}}_isSet = false; m_{{name}}_isValid = false; {{/vars}}{{/isEnum}}{{#isEnum}} m_value_isSet = false; m_value_isValid = false; - m_value = e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED; - {{/isEnum}} + m_value = e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED;{{/isEnum}} } void @@ -46,22 +45,27 @@ void this->fromJsonObject(jsonObject);{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{#enumVars}} {{#-first}}if{{/-first}}{{^-first}}else if{{/-first}} ( jsonString.compare({{#isString}}"{{value}}"{{/isString}}{{^isString}}QString::number({{value}}){{/isString}}, Qt::CaseInsensitive) == 0) { m_value = e{{classname}}::{{name}}; - m_value_isValid = true; + m_value_isSet = m_value_isValid = true; }{{/enumVars}}{{/allowableValues}}{{/isEnum}} } void {{classname}}::fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) { - {{^isEnum}}{{#vars}} - {{^isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/isContainer}} - {{#isContainer}}{{^items.isContainer}}m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}} + {{^isEnum}}{{#vars}}{{^isContainer}} + m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]); + m_{{name}}_isSet = !json[QString("{{baseName}}")].isNull() && m_{{name}}_isValid;{{/isContainer}}{{#isContainer}}{{^items.isContainer}} + m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]); + m_{{name}}_isSet = !json[QString("{{baseName}}")].isNull() && m_{{name}}_isValid;{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}} if(json["{{baseName}}"].isArray()){ auto arr = json["{{baseName}}"].toArray(); m_{{name}}_isValid = true; - for (const QJsonValue & jval : arr) { - {{^items.isContainer}}{{items.baseType}}{{/items.isContainer}}{{#items.isListContainer}}QList<{{items.items.baseType}}>{{/items.isListContainer}}{{#items.isMapContainer}}QMap{{/items.isMapContainer}} item; - m_{{name}}_isValid &= ::{{cppNamespace}}::fromJsonValue(item, jval) - {{name}}.push_back(item); + if(arr.count() > 0) { + for (const QJsonValue jval : arr) { + {{^items.isContainer}}{{items.baseType}}{{/items.isContainer}}{{#items.isListContainer}}QList<{{items.items.baseType}}>{{/items.isListContainer}}{{#items.isMapContainer}}QMap{{/items.isMapContainer}} item; + m_{{name}}_isValid &= ::{{cppNamespace}}::fromJsonValue(item, jval); + m_{{name}}_isSet = !jval.isNull() && m_{{name}}_isValid; + {{name}}.push_back(item); + } } }{{/isListContainer}}{{#isMapContainer}} if(json["{{baseName}}"].isObject()){ @@ -72,6 +76,7 @@ void {{^items.isContainer}}{{items.baseType}}{{/items.isContainer}}{{#items.isListContainer}}QList<{{items.items.baseType}}>{{/items.isListContainer}}{{#items.isMapContainer}}QMap{{/items.isMapContainer}} item; auto jval = QJsonValue::fromVariant(varmap.value(val)); m_{{name}}_isValid &= ::{{cppNamespace}}::fromJsonValue(item, jval); + m_{{name}}_isSet &= !jval.isNull() && m_{{name}}_isValid; {{name}}.insert({{name}}.end(), val, item); } } diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache index 3c83c1f0d534..27a7c09c7cc8 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache @@ -59,7 +59,7 @@ public: virtual bool isValid() const override; private: - void init(); + void initializeModel(); {{^isEnum}}{{#vars}} {{{dataType}}} {{name}}; bool m_{{name}}_isSet; diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache index 45d075c16e8e..78738eeb1f31 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache @@ -33,7 +33,7 @@ {{#description}} /// {{description}} {{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})] + [DataMember(Name="{{baseName}}", EmitDefaultValue={{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/vendorExtensions.x-emit-default-value}})] public {{#complexType}}{{{complexType}}}{{/complexType}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} { get; set; } {{/isEnum}} {{/vars}} @@ -116,7 +116,7 @@ /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} /// {{#description}} /// {{description}}{{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]{{#isDate}} + [DataMember(Name="{{baseName}}", EmitDefaultValue={{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/vendorExtensions.x-emit-default-value}})]{{#isDate}} [JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}} public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } diff --git a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache index 61875a3de610..710c4088fd6f 100644 --- a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache @@ -81,5 +81,5 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) }{{/operation}}{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/go-server/routers.mustache b/modules/openapi-generator/src/main/resources/go-server/routers.mustache index 941790cac37e..c1b4215376eb 100644 --- a/modules/openapi-generator/src/main/resources/go-server/routers.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/routers.mustache @@ -7,7 +7,9 @@ import ( "net/http" "os" "strconv" - + {{#featureCORS}} + "github.com/gorilla/handlers" + {{/featureCORS}} "github.com/gorilla/mux" ) @@ -35,6 +37,9 @@ func NewRouter(routers ...Router) *mux.Router { var handler http.Handler handler = route.HandlerFunc handler = Logger(handler, route.Name) + {{#featureCORS}} + handler = handlers.CORS()(handler) + {{/featureCORS}} router. Methods(route.Method). diff --git a/modules/openapi-generator/src/main/resources/java-undertow-server/pom.mustache b/modules/openapi-generator/src/main/resources/java-undertow-server/pom.mustache index d11a2ce7c898..575b55d6e57f 100644 --- a/modules/openapi-generator/src/main/resources/java-undertow-server/pom.mustache +++ b/modules/openapi-generator/src/main/resources/java-undertow-server/pom.mustache @@ -17,7 +17,7 @@ UTF-8 0.1.1 2.9.10 - 2.9.10 + 2.9.10.1 1.7.21 0.5.2 4.5.3 diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache index 46319b16e835..b182e1940080 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache @@ -62,17 +62,17 @@ import {{packageName}}.infrastructure.toMultiValue query = localVariableQuery, headers = localVariableHeaders ) - val response = request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Any?{{/returnType}}>( + val localVarResponse = request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Any?{{/returnType}}>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> {{#returnType}}(response as Success<*>).data as {{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} + return when (localVarResponse.responseType) { + ResponseType.Success -> {{#returnType}}(localVarResponse as Success<*>).data as {{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache index b17954c6e14f..32d352d2717e 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache @@ -7,7 +7,7 @@ wrapper { } buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { mavenCentral() @@ -30,19 +30,21 @@ test { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + {{#moshi}} compile "com.squareup.moshi:moshi-kotlin:1.8.0" compile "com.squareup.moshi:moshi-adapters:1.8.0" + {{/moshi}} {{#gson}} - implementation "com.google.code.gson:gson:2.8.5" + compile "com.google.code.gson:gson:2.8.6" {{/gson}} {{#jvm-okhttp3}} - compile "com.squareup.okhttp3:okhttp:3.12.4" + compile "com.squareup.okhttp3:okhttp:3.12.6" {{/jvm-okhttp3}} {{#jvm-okhttp4}} - compile "com.squareup.okhttp3:okhttp:4.2.0" + compile "com.squareup.okhttp3:okhttp:4.2.2" {{/jvm-okhttp4}} {{#threetenbp}} compile "org.threeten:threetenbp:1.4.0" {{/threetenbp}} - testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" + testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache index e7fcabf7ddfc..ff7e68a98fc7 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache @@ -71,11 +71,16 @@ import java.io.File } {{#jvm-okhttp3}} mediaType == JsonMediaType -> RequestBody.create( + {{#moshi}} MediaType.parse(mediaType), Serializer.moshi.adapter(T::class.java).toJson(content) + {{/moshi}} + {{#gson}} + MediaType.parse(mediaType), Serializer.gson.toJson(content, T::class.java) + {{/gson}} ) {{/jvm-okhttp3}} {{#jvm-okhttp4}} - mediaType == JsonMediaType -> Serializer.moshi.adapter(T::class.java).toJson(content).toRequestBody( + mediaType == JsonMediaType -> {{#moshi}}Serializer.moshi.adapter(T::class.java).toJson(content){{/moshi}}{{#gson}}Serializer.gson.toJson(content, T::class.java){{/gson}}.toRequestBody( mediaType.toMediaTypeOrNull() ) {{/jvm-okhttp4}} @@ -93,7 +98,7 @@ import java.io.File return null } return when(mediaType) { - JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(bodyContent) + JsonMediaType -> {{#moshi}}Serializer.moshi.adapter(T::class.java).fromJson(bodyContent){{/moshi}}{{#gson}}Serializer.gson.fromJson(bodyContent, T::class.java){{/gson}} else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.") } } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache index aacd100ea7aa..9f56848226c1 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache @@ -1,12 +1,50 @@ package {{packageName}}.infrastructure +{{#moshi}} import com.squareup.moshi.FromJson import com.squareup.moshi.ToJson +{{/moshi}} +{{#gson}} +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +{{/gson}} +{{#moshi}} {{#nonPublicApi}}internal {{/nonPublicApi}}class ByteArrayAdapter { @ToJson fun toJson(data: ByteArray): String = String(data) @FromJson fun fromJson(data: String): ByteArray = data.toByteArray() -} \ No newline at end of file +} +{{/moshi}} +{{#gson}} +{{#nonPublicApi}}internal {{/nonPublicApi}}class ByteArrayAdapter : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: ByteArray?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(String(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): ByteArray? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return out.nextString().toByteArray() + } + } + } +} +{{/gson}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/DateAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/DateAdapter.kt.mustache new file mode 100644 index 000000000000..7e7e35b74bdb --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/DateAdapter.kt.mustache @@ -0,0 +1,37 @@ +package {{packageName}}.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.text.DateFormat +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale + +{{#nonPublicApi}}internal {{/nonPublicApi}}class DateAdapter(val formatter: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault())) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: Date?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): Date? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return formatter.parse(out.nextString()) + } + } + } +} diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache index 84635bd2f123..152266a5964c 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache @@ -1,7 +1,16 @@ package {{packageName}}.infrastructure +{{#moshi}} import com.squareup.moshi.FromJson import com.squareup.moshi.ToJson +{{/moshi}} +{{#gson}} +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +{{/gson}} {{^threetenbp}} import java.time.LocalDate import java.time.format.DateTimeFormatter @@ -11,6 +20,7 @@ import org.threeten.bp.LocalDate import org.threeten.bp.format.DateTimeFormatter {{/threetenbp}} +{{#moshi}} {{#nonPublicApi}}internal {{/nonPublicApi}}class LocalDateAdapter { @ToJson fun toJson(value: LocalDate): String { @@ -23,3 +33,31 @@ import org.threeten.bp.format.DateTimeFormatter } } +{{/moshi}} +{{#gson}} +{{#nonPublicApi}}internal {{/nonPublicApi}}class LocalDateAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDate?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDate? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDate.parse(out.nextString(), formatter) + } + } + } +} +{{/gson}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache index 48f40dbe7c07..0935b0053e50 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache @@ -1,7 +1,16 @@ package {{packageName}}.infrastructure +{{#moshi}} import com.squareup.moshi.FromJson import com.squareup.moshi.ToJson +{{/moshi}} +{{#gson}} +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +{{/gson}} {{^threetenbp}} import java.time.LocalDateTime import java.time.format.DateTimeFormatter @@ -11,6 +20,7 @@ import org.threeten.bp.LocalDateTime import org.threeten.bp.format.DateTimeFormatter {{/threetenbp}} +{{#moshi}} {{#nonPublicApi}}internal {{/nonPublicApi}}class LocalDateTimeAdapter { @ToJson fun toJson(value: LocalDateTime): String { @@ -23,3 +33,31 @@ import org.threeten.bp.format.DateTimeFormatter } } +{{/moshi}} +{{#gson}} +{{#nonPublicApi}}internal {{/nonPublicApi}}class LocalDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDateTime?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDateTime? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDateTime.parse(out.nextString(), formatter) + } + } + } +} +{{/gson}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache index 699a78f923f4..df4c33c26d27 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache @@ -1,11 +1,27 @@ package {{packageName}}.infrastructure +{{#moshi}} import com.squareup.moshi.Moshi import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory +{{/moshi}} +{{#gson}} +import com.google.gson.Gson +import com.google.gson.GsonBuilder +{{^threetenbp}} +import java.time.LocalDate +import java.time.LocalDateTime +{{/threetenbp}} +{{#threetenbp}} +import org.threeten.bp.LocalDate +import org.threeten.bp.LocalDateTime +{{/threetenbp}} +import java.util.UUID +{{/gson}} import java.util.Date {{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer { +{{#moshi}} @JvmStatic val moshi: Moshi = Moshi.Builder() .add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe()) @@ -15,4 +31,15 @@ import java.util.Date .add(ByteArrayAdapter()) .add(KotlinJsonAdapterFactory()) .build() +{{/moshi}} +{{#gson}} + @JvmStatic + val gson: Gson = GsonBuilder() + .registerTypeAdapter(Date::class.java, DateAdapter()) + .registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter()) + .registerTypeAdapter(LocalDate::class.java, LocalDateAdapter()) + .registerTypeAdapter(UUID::class.java, UUIDAdapter()) + .registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter()) + .create() +{{/gson}} } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache index a1ebc2cfced3..ad442305b174 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache @@ -1,9 +1,19 @@ package {{packageName}}.infrastructure +{{#moshi}} import com.squareup.moshi.FromJson import com.squareup.moshi.ToJson +{{/moshi}} +{{#gson}} +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +{{/gson}} import java.util.UUID +{{#moshi}} {{#nonPublicApi}}internal {{/nonPublicApi}}class UUIDAdapter { @ToJson fun toJson(uuid: UUID) = uuid.toString() @@ -11,3 +21,31 @@ import java.util.UUID @FromJson fun fromJson(s: String) = UUID.fromString(s) } +{{/moshi}} +{{#gson}} +{{#nonPublicApi}}internal {{/nonPublicApi}}class UUIDAdapter : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: UUID?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(value.toString()) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): UUID? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return UUID.fromString(out.nextString()) + } + } + } +} +{{/gson}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index 790ec2204613..3bf085e1904b 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -629,11 +629,11 @@ class ApiClient(object): return data kwargs = {} - if klass.openapi_types is not None: + if (data is not None and + klass.openapi_types is not None and + isinstance(data, (list, dict))): for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache index aec1ef375366..25ca4b5043ff 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache @@ -346,18 +346,19 @@ class ApiClient(object): _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _check_type) - else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, _check_type)) - return thread + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _check_type)) def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, diff --git a/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache b/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache index 0a663ef944aa..cf4a62a99eb2 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache @@ -87,7 +87,11 @@ hash = {{^parent}}{}{{/parent}}{{#parent}}super{{/parent}} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache index f0d7c40a5bce..536d8f2926be 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache @@ -51,6 +51,17 @@ } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + {{#vars}} + {{#isNullable}} + :'{{{name}}}'{{#hasMore}},{{/hasMore}} + {{/isNullable}} + {{/vars}} + ]) + end + {{#anyOf}} {{#-first}} # List of class defined in anyOf (OpenAPI v3) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache index 0db1d9a5a805..b08c8f24dc1a 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache @@ -19,6 +19,6 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole return json as {{classname}}; } -export function {{classname}}ToJSON(value?: {{classname}}): any { +export function {{classname}}ToJSON(value?: {{classname}} | null): any { return value as any; } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 013bf40a47b2..ca1837946ea7 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -63,10 +63,10 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole {{#vars}} {{#isPrimitiveType}} {{#isDate}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}new Date(json['{{baseName}}']), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}new Date(json['{{baseName}}'])), {{/isDate}} {{#isDateTime}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}new Date(json['{{baseName}}']), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}new Date(json['{{baseName}}'])), {{/isDateTime}} {{^isDate}} {{^isDateTime}} @@ -76,10 +76,10 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isListContainer}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}(json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}(json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON)), {{/isListContainer}} {{#isMapContainer}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}mapValues(json['{{baseName}}'], {{#items}}{{datatype}}{{/items}}FromJSON), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}mapValues(json['{{baseName}}'], {{#items}}{{datatype}}{{/items}}FromJSON)), {{/isMapContainer}} {{^isListContainer}} {{^isMapContainer}} @@ -116,14 +116,14 @@ export function {{classname}}ToJSON(value?: {{classname}} | null): any { {{#vars}} {{^isReadOnly}} {{#isPrimitiveType}} - '{{baseName}}': {{#isDate}}{{^required}}value.{{name}} == null ? undefined : {{/required}}value.{{name}}.toISOString().substr(0,10){{/isDate}}{{#isDateTime}}{{^required}}value.{{name}} == null ? undefined : {{/required}}value.{{name}}.toISOString(){{/isDateTime}}{{^isDate}}{{^isDateTime}}value.{{name}}{{/isDateTime}}{{/isDate}}, + '{{baseName}}': {{#isDate}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}value.{{name}}.toISOString().substr(0,10)){{/isDate}}{{#isDateTime}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}value.{{name}}.toISOString()){{/isDateTime}}{{^isDate}}{{^isDateTime}}value.{{name}}{{/isDateTime}}{{/isDate}}, {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isListContainer}} - '{{baseName}}': {{^required}}value.{{name}} == null ? undefined : {{/required}}(value.{{name}} as Array).map({{#items}}{{datatype}}{{/items}}ToJSON), + '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}(value.{{name}} as Array).map({{#items}}{{datatype}}{{/items}}ToJSON)), {{/isListContainer}} {{#isMapContainer}} - '{{baseName}}': {{^required}}value.{{name}} == null ? undefined : {{/required}}mapValues(value.{{name}}, {{#items}}{{datatype}}{{/items}}ToJSON), + '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}mapValues(value.{{name}}, {{#items}}{{datatype}}{{/items}}ToJSON)), {{/isMapContainer}} {{^isListContainer}} {{^isMapContainer}} @@ -134,7 +134,7 @@ export function {{classname}}ToJSON(value?: {{classname}} | null): any { '{{baseName}}': value.{{name}}, {{/isFreeFormObject}} {{/isMapContainer}} - {{/isListContainer}} + {{/isListContainer}} {{/isPrimitiveType}} {{/isReadOnly}} {{/vars}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java index ff23d307d907..90c8acff528e 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java @@ -1,5 +1,6 @@ package org.openapitools.codegen.kotlin; +import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.languages.AbstractKotlinCodegen; import org.testng.Assert; @@ -53,7 +54,7 @@ public void pascalCaseEnumConverter() { } @Test - public void toEnumValue(){ + public void toEnumValue() { assertEquals(codegen.toEnumValue("1", "kotlin.Int"), "1"); assertEquals(codegen.toEnumValue("1", "kotlin.Double"), "1.0"); assertEquals(codegen.toEnumValue("1.3", "kotlin.Double"), "1.3"); @@ -81,14 +82,14 @@ public String getHelp() { } @Test - public void isDataTypeString(){ + public void isDataTypeString() { assertFalse(codegen.isDataTypeString("kotlin.Int")); assertTrue(codegen.isDataTypeString("kotlin.String")); assertTrue(codegen.isDataTypeString("String")); } @Test - public void toModelNameShouldUseProvidedMapping() { + public void toModelNameShouldUseProvidedMapping() { codegen.importMapping().put("json_myclass", "com.test.MyClass"); assertEquals("com.test.MyClass", codegen.toModelName("json_myclass")); } @@ -155,5 +156,45 @@ public void apiTestFileFolder() { Assert.assertEquals(codegen.apiTestFileFolder(), "/User/open/api/tools/test/folder/org/openapitools/codegen/api".replace('/', File.separatorChar)); } + @Test + public void processOptsBooleanTrueFromString() { + codegen.additionalProperties().put(CodegenConstants.SERIALIZABLE_MODEL, "true"); + codegen.processOpts(); + Assert.assertTrue((boolean) codegen.additionalProperties().get(CodegenConstants.SERIALIZABLE_MODEL)); + } + + @Test + public void processOptsBooleanTrueFromBoolean() { + codegen.additionalProperties().put(CodegenConstants.SERIALIZABLE_MODEL, true); + codegen.processOpts(); + Assert.assertTrue((boolean) codegen.additionalProperties().get(CodegenConstants.SERIALIZABLE_MODEL)); + } + + @Test + public void processOptsBooleanFalseFromString() { + codegen.additionalProperties().put(CodegenConstants.SERIALIZABLE_MODEL, "false"); + codegen.processOpts(); + Assert.assertFalse((boolean) codegen.additionalProperties().get(CodegenConstants.SERIALIZABLE_MODEL)); + } + @Test + public void processOptsBooleanFalseFromBoolean() { + codegen.additionalProperties().put(CodegenConstants.SERIALIZABLE_MODEL, false); + codegen.processOpts(); + Assert.assertFalse((boolean) codegen.additionalProperties().get(CodegenConstants.SERIALIZABLE_MODEL)); + } + + @Test + public void processOptsBooleanFalseFromGarbage() { + codegen.additionalProperties().put(CodegenConstants.SERIALIZABLE_MODEL, "blibb"); + codegen.processOpts(); + Assert.assertFalse((boolean) codegen.additionalProperties().get(CodegenConstants.SERIALIZABLE_MODEL)); + } + + @Test + public void processOptsBooleanFalseFromNumeric() { + codegen.additionalProperties().put(CodegenConstants.SERIALIZABLE_MODEL, 42L); + codegen.processOpts(); + Assert.assertFalse((boolean) codegen.additionalProperties().get(CodegenConstants.SERIALIZABLE_MODEL)); + } } \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml b/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml index 661961cd9778..2e558056871a 100644 --- a/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml @@ -101,6 +101,20 @@ paths: responses: '200': description: 'OK' + /readonly_auth_scheme: + get: + security: + - authScheme: ["test.read"] + responses: + 200: + description: Check that limiting to a single required auth scheme works + /multiple_auth_scheme: + get: + security: + - authScheme: ["test.read", "test.write"] + responses: + 200: + description: Check that limiting to multiple required auth schemes works /responses_with_headers: get: responses: @@ -123,7 +137,18 @@ paths: Failure-Info: schema: type: String + components: + securitySchemes: + authScheme: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: 'http://example.org' + tokenUrl: 'http://example.org' + scopes: + test.read: Allowed to read state. + test.write: Allowed to change state. schemas: UuidObject: description: Test a model containing a UUID diff --git a/pom.xml b/pom.xml index 804877bfc976..400391c3f883 100644 --- a/pom.xml +++ b/pom.xml @@ -1251,6 +1251,8 @@ samples/client/petstore/erlang-proper samples/client/petstore/kotlin-multiplatform samples/client/petstore/kotlin/ + samples/client/petstore/kotlin-gson/ + samples/client/petstore/kotlin-nonpublic/ samples/client/petstore/kotlin-okhttp3/ samples/client/petstore/kotlin-threetenbp/ samples/client/petstore/kotlin-string/ diff --git a/samples/client/petstore/cpp-qt5/.openapi-generator/VERSION b/samples/client/petstore/cpp-qt5/.openapi-generator/VERSION index c3a2c7076fa8..d168f1d8bdaa 100644 --- a/samples/client/petstore/cpp-qt5/.openapi-generator/VERSION +++ b/samples/client/petstore/cpp-qt5/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +4.2.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/cpp-qt5/client/OAIApiResponse.cpp b/samples/client/petstore/cpp-qt5/client/OAIApiResponse.cpp index 233f607a9cfc..d284b568e684 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIApiResponse.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAIApiResponse.cpp @@ -23,12 +23,12 @@ namespace OpenAPI { OAIApiResponse::OAIApiResponse(QString json) { - this->init(); + this->initializeModel(); this->fromJson(json); } OAIApiResponse::OAIApiResponse() { - this->init(); + this->initializeModel(); } OAIApiResponse::~OAIApiResponse() { @@ -36,7 +36,7 @@ OAIApiResponse::~OAIApiResponse() { } void -OAIApiResponse::init() { +OAIApiResponse::initializeModel() { m_code_isSet = false; m_code_isValid = false; @@ -46,7 +46,8 @@ OAIApiResponse::init() { m_message_isSet = false; m_message_isValid = false; - } + +} void OAIApiResponse::fromJson(QString jsonString) { @@ -60,13 +61,13 @@ void OAIApiResponse::fromJsonObject(QJsonObject json) { m_code_isValid = ::OpenAPI::fromJsonValue(code, json[QString("code")]); - + m_code_isSet = !json[QString("code")].isNull() && m_code_isValid; m_type_isValid = ::OpenAPI::fromJsonValue(type, json[QString("type")]); - + m_type_isSet = !json[QString("type")].isNull() && m_type_isValid; m_message_isValid = ::OpenAPI::fromJsonValue(message, json[QString("message")]); - + m_message_isSet = !json[QString("message")].isNull() && m_message_isValid; } diff --git a/samples/client/petstore/cpp-qt5/client/OAIApiResponse.h b/samples/client/petstore/cpp-qt5/client/OAIApiResponse.h index 7e4d74603831..c227094882c8 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIApiResponse.h +++ b/samples/client/petstore/cpp-qt5/client/OAIApiResponse.h @@ -59,7 +59,7 @@ class OAIApiResponse: public OAIObject { virtual bool isValid() const override; private: - void init(); + void initializeModel(); qint32 code; bool m_code_isSet; diff --git a/samples/client/petstore/cpp-qt5/client/OAICategory.cpp b/samples/client/petstore/cpp-qt5/client/OAICategory.cpp index 571dc37b6fa7..4e77a5a6601d 100644 --- a/samples/client/petstore/cpp-qt5/client/OAICategory.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAICategory.cpp @@ -23,12 +23,12 @@ namespace OpenAPI { OAICategory::OAICategory(QString json) { - this->init(); + this->initializeModel(); this->fromJson(json); } OAICategory::OAICategory() { - this->init(); + this->initializeModel(); } OAICategory::~OAICategory() { @@ -36,14 +36,15 @@ OAICategory::~OAICategory() { } void -OAICategory::init() { +OAICategory::initializeModel() { m_id_isSet = false; m_id_isValid = false; m_name_isSet = false; m_name_isValid = false; - } + +} void OAICategory::fromJson(QString jsonString) { @@ -57,10 +58,10 @@ void OAICategory::fromJsonObject(QJsonObject json) { m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]); - + m_id_isSet = !json[QString("id")].isNull() && m_id_isValid; m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]); - + m_name_isSet = !json[QString("name")].isNull() && m_name_isValid; } diff --git a/samples/client/petstore/cpp-qt5/client/OAICategory.h b/samples/client/petstore/cpp-qt5/client/OAICategory.h index 8cfc76f4305c..180533007c62 100644 --- a/samples/client/petstore/cpp-qt5/client/OAICategory.h +++ b/samples/client/petstore/cpp-qt5/client/OAICategory.h @@ -55,7 +55,7 @@ class OAICategory: public OAIObject { virtual bool isValid() const override; private: - void init(); + void initializeModel(); qint64 id; bool m_id_isSet; diff --git a/samples/client/petstore/cpp-qt5/client/OAIHelpers.h b/samples/client/petstore/cpp-qt5/client/OAIHelpers.h index a2992183298d..a96955f24236 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIHelpers.h +++ b/samples/client/petstore/cpp-qt5/client/OAIHelpers.h @@ -29,6 +29,27 @@ namespace OpenAPI { + template QString + toStringValue(const QList &val); + + template + bool fromStringValue(const QList &inStr, QList &val); + + template + bool fromStringValue(const QMap &inStr, QMap &val); + + template + QJsonValue toJsonValue(const QList &val); + + template + QJsonValue toJsonValue(const QMap &val); + + template + bool fromJsonValue(QList &val, const QJsonValue &jval); + + template + bool fromJsonValue(QMap &val, const QJsonValue &jval); + QString toStringValue(const QString &value); QString toStringValue(const QDateTime &value); QString toStringValue(const QByteArray &value); @@ -137,7 +158,7 @@ namespace OpenAPI { bool fromJsonValue(QList &val, const QJsonValue &jval) { bool ok = true; if(jval.isArray()){ - for(const auto& jitem : jval.toArray()){ + for(const auto jitem : jval.toArray()){ T item; ok &= fromJsonValue(item, jitem); val.push_back(item); diff --git a/samples/client/petstore/cpp-qt5/client/OAIOrder.cpp b/samples/client/petstore/cpp-qt5/client/OAIOrder.cpp index a6f0fb92d97b..d0b69d326c48 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIOrder.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAIOrder.cpp @@ -23,12 +23,12 @@ namespace OpenAPI { OAIOrder::OAIOrder(QString json) { - this->init(); + this->initializeModel(); this->fromJson(json); } OAIOrder::OAIOrder() { - this->init(); + this->initializeModel(); } OAIOrder::~OAIOrder() { @@ -36,7 +36,7 @@ OAIOrder::~OAIOrder() { } void -OAIOrder::init() { +OAIOrder::initializeModel() { m_id_isSet = false; m_id_isValid = false; @@ -55,7 +55,8 @@ OAIOrder::init() { m_complete_isSet = false; m_complete_isValid = false; - } + +} void OAIOrder::fromJson(QString jsonString) { @@ -69,22 +70,22 @@ void OAIOrder::fromJsonObject(QJsonObject json) { m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]); - + m_id_isSet = !json[QString("id")].isNull() && m_id_isValid; m_pet_id_isValid = ::OpenAPI::fromJsonValue(pet_id, json[QString("petId")]); - + m_pet_id_isSet = !json[QString("petId")].isNull() && m_pet_id_isValid; m_quantity_isValid = ::OpenAPI::fromJsonValue(quantity, json[QString("quantity")]); - + m_quantity_isSet = !json[QString("quantity")].isNull() && m_quantity_isValid; m_ship_date_isValid = ::OpenAPI::fromJsonValue(ship_date, json[QString("shipDate")]); - + m_ship_date_isSet = !json[QString("shipDate")].isNull() && m_ship_date_isValid; m_status_isValid = ::OpenAPI::fromJsonValue(status, json[QString("status")]); - + m_status_isSet = !json[QString("status")].isNull() && m_status_isValid; m_complete_isValid = ::OpenAPI::fromJsonValue(complete, json[QString("complete")]); - + m_complete_isSet = !json[QString("complete")].isNull() && m_complete_isValid; } diff --git a/samples/client/petstore/cpp-qt5/client/OAIOrder.h b/samples/client/petstore/cpp-qt5/client/OAIOrder.h index 7acf2ab0a32d..e6a1ef1899d5 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIOrder.h +++ b/samples/client/petstore/cpp-qt5/client/OAIOrder.h @@ -72,7 +72,7 @@ class OAIOrder: public OAIObject { virtual bool isValid() const override; private: - void init(); + void initializeModel(); qint64 id; bool m_id_isSet; diff --git a/samples/client/petstore/cpp-qt5/client/OAIPet.cpp b/samples/client/petstore/cpp-qt5/client/OAIPet.cpp index 8a6cfec0319d..cac236460949 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIPet.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAIPet.cpp @@ -23,12 +23,12 @@ namespace OpenAPI { OAIPet::OAIPet(QString json) { - this->init(); + this->initializeModel(); this->fromJson(json); } OAIPet::OAIPet() { - this->init(); + this->initializeModel(); } OAIPet::~OAIPet() { @@ -36,7 +36,7 @@ OAIPet::~OAIPet() { } void -OAIPet::init() { +OAIPet::initializeModel() { m_id_isSet = false; m_id_isValid = false; @@ -55,7 +55,8 @@ OAIPet::init() { m_status_isSet = false; m_status_isValid = false; - } + +} void OAIPet::fromJson(QString jsonString) { @@ -69,22 +70,22 @@ void OAIPet::fromJsonObject(QJsonObject json) { m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]); - + m_id_isSet = !json[QString("id")].isNull() && m_id_isValid; m_category_isValid = ::OpenAPI::fromJsonValue(category, json[QString("category")]); - + m_category_isSet = !json[QString("category")].isNull() && m_category_isValid; m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]); - - + m_name_isSet = !json[QString("name")].isNull() && m_name_isValid; m_photo_urls_isValid = ::OpenAPI::fromJsonValue(photo_urls, json[QString("photoUrls")]); - + m_photo_urls_isSet = !json[QString("photoUrls")].isNull() && m_photo_urls_isValid; m_tags_isValid = ::OpenAPI::fromJsonValue(tags, json[QString("tags")]); + m_tags_isSet = !json[QString("tags")].isNull() && m_tags_isValid; m_status_isValid = ::OpenAPI::fromJsonValue(status, json[QString("status")]); - + m_status_isSet = !json[QString("status")].isNull() && m_status_isValid; } diff --git a/samples/client/petstore/cpp-qt5/client/OAIPet.h b/samples/client/petstore/cpp-qt5/client/OAIPet.h index c2577bfc5a25..13825cf706b7 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIPet.h +++ b/samples/client/petstore/cpp-qt5/client/OAIPet.h @@ -74,7 +74,7 @@ class OAIPet: public OAIObject { virtual bool isValid() const override; private: - void init(); + void initializeModel(); qint64 id; bool m_id_isSet; diff --git a/samples/client/petstore/cpp-qt5/client/OAITag.cpp b/samples/client/petstore/cpp-qt5/client/OAITag.cpp index d986ce63b144..ee39ccf585c4 100644 --- a/samples/client/petstore/cpp-qt5/client/OAITag.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAITag.cpp @@ -23,12 +23,12 @@ namespace OpenAPI { OAITag::OAITag(QString json) { - this->init(); + this->initializeModel(); this->fromJson(json); } OAITag::OAITag() { - this->init(); + this->initializeModel(); } OAITag::~OAITag() { @@ -36,14 +36,15 @@ OAITag::~OAITag() { } void -OAITag::init() { +OAITag::initializeModel() { m_id_isSet = false; m_id_isValid = false; m_name_isSet = false; m_name_isValid = false; - } + +} void OAITag::fromJson(QString jsonString) { @@ -57,10 +58,10 @@ void OAITag::fromJsonObject(QJsonObject json) { m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]); - + m_id_isSet = !json[QString("id")].isNull() && m_id_isValid; m_name_isValid = ::OpenAPI::fromJsonValue(name, json[QString("name")]); - + m_name_isSet = !json[QString("name")].isNull() && m_name_isValid; } diff --git a/samples/client/petstore/cpp-qt5/client/OAITag.h b/samples/client/petstore/cpp-qt5/client/OAITag.h index 2c8eb291d0ff..fbb5c6a75557 100644 --- a/samples/client/petstore/cpp-qt5/client/OAITag.h +++ b/samples/client/petstore/cpp-qt5/client/OAITag.h @@ -55,7 +55,7 @@ class OAITag: public OAIObject { virtual bool isValid() const override; private: - void init(); + void initializeModel(); qint64 id; bool m_id_isSet; diff --git a/samples/client/petstore/cpp-qt5/client/OAIUser.cpp b/samples/client/petstore/cpp-qt5/client/OAIUser.cpp index 2afe6d808eb4..12fc195f83da 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIUser.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAIUser.cpp @@ -23,12 +23,12 @@ namespace OpenAPI { OAIUser::OAIUser(QString json) { - this->init(); + this->initializeModel(); this->fromJson(json); } OAIUser::OAIUser() { - this->init(); + this->initializeModel(); } OAIUser::~OAIUser() { @@ -36,7 +36,7 @@ OAIUser::~OAIUser() { } void -OAIUser::init() { +OAIUser::initializeModel() { m_id_isSet = false; m_id_isValid = false; @@ -61,7 +61,8 @@ OAIUser::init() { m_user_status_isSet = false; m_user_status_isValid = false; - } + +} void OAIUser::fromJson(QString jsonString) { @@ -75,28 +76,28 @@ void OAIUser::fromJsonObject(QJsonObject json) { m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]); - + m_id_isSet = !json[QString("id")].isNull() && m_id_isValid; m_username_isValid = ::OpenAPI::fromJsonValue(username, json[QString("username")]); - + m_username_isSet = !json[QString("username")].isNull() && m_username_isValid; m_first_name_isValid = ::OpenAPI::fromJsonValue(first_name, json[QString("firstName")]); - + m_first_name_isSet = !json[QString("firstName")].isNull() && m_first_name_isValid; m_last_name_isValid = ::OpenAPI::fromJsonValue(last_name, json[QString("lastName")]); - + m_last_name_isSet = !json[QString("lastName")].isNull() && m_last_name_isValid; m_email_isValid = ::OpenAPI::fromJsonValue(email, json[QString("email")]); - + m_email_isSet = !json[QString("email")].isNull() && m_email_isValid; m_password_isValid = ::OpenAPI::fromJsonValue(password, json[QString("password")]); - + m_password_isSet = !json[QString("password")].isNull() && m_password_isValid; m_phone_isValid = ::OpenAPI::fromJsonValue(phone, json[QString("phone")]); - + m_phone_isSet = !json[QString("phone")].isNull() && m_phone_isValid; m_user_status_isValid = ::OpenAPI::fromJsonValue(user_status, json[QString("userStatus")]); - + m_user_status_isSet = !json[QString("userStatus")].isNull() && m_user_status_isValid; } diff --git a/samples/client/petstore/cpp-qt5/client/OAIUser.h b/samples/client/petstore/cpp-qt5/client/OAIUser.h index 29da83043b6b..b28f8474aa9b 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIUser.h +++ b/samples/client/petstore/cpp-qt5/client/OAIUser.h @@ -79,7 +79,7 @@ class OAIUser: public OAIObject { virtual bool isValid() const override; private: - void init(); + void initializeModel(); qint64 id; bool m_id_isSet; diff --git a/samples/client/petstore/groovy/build.gradle b/samples/client/petstore/groovy/build.gradle index baf222ae11c4..884cb75a2ba4 100644 --- a/samples/client/petstore/groovy/build.gradle +++ b/samples/client/petstore/groovy/build.gradle @@ -28,6 +28,7 @@ repositories { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" + jackson_databind_version = "2.9.10.1" } dependencies { @@ -35,7 +36,7 @@ dependencies { compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" - compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version" compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version" compile 'io.github.http-builder-ng:http-builder-ng-core:1.0.3' diff --git a/samples/client/petstore/java/google-api-client/build.gradle b/samples/client/petstore/java/google-api-client/build.gradle index b321101fa135..a84e8f600209 100644 --- a/samples/client/petstore/java/google-api-client/build.gradle +++ b/samples/client/petstore/java/google-api-client/build.gradle @@ -97,7 +97,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" google_api_client_version = "1.23.0" jersey_common_version = "2.25.1" diff --git a/samples/client/petstore/java/google-api-client/build.sbt b/samples/client/petstore/java/google-api-client/build.sbt index 6997a7b4aa4e..010aeb2783dd 100644 --- a/samples/client/petstore/java/google-api-client/build.sbt +++ b/samples/client/petstore/java/google-api-client/build.sbt @@ -14,7 +14,7 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.core" % "jersey-common" % "2.25.1", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile", "junit" % "junit" % "4.12" % "test", "com.novocode" % "junit-interface" % "0.10" % "test" diff --git a/samples/client/petstore/java/google-api-client/pom.xml b/samples/client/petstore/java/google-api-client/pom.xml index 593b8d20ffc4..e99897809e89 100644 --- a/samples/client/petstore/java/google-api-client/pom.xml +++ b/samples/client/petstore/java/google-api-client/pom.xml @@ -259,7 +259,7 @@ 1.30.2 2.25.1 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 2.9.10 1.0.0 diff --git a/samples/client/petstore/java/jersey1/build.gradle b/samples/client/petstore/java/jersey1/build.gradle index c915acb96a62..2c4a3af46cbe 100644 --- a/samples/client/petstore/java/jersey1/build.gradle +++ b/samples/client/petstore/java/jersey1/build.gradle @@ -113,7 +113,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" jersey_version = "1.19.4" jodatime_version = "2.9.9" diff --git a/samples/client/petstore/java/jersey2-java6/build.sbt b/samples/client/petstore/java/jersey2-java6/build.sbt index c79af88c5873..3bb20e3d1b57 100644 --- a/samples/client/petstore/java/jersey2-java6/build.sbt +++ b/samples/client/petstore/java/jersey2-java6/build.sbt @@ -15,7 +15,7 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.6", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile", "com.brsanthu" % "migbase64" % "2.2", "org.apache.commons" % "commons-lang3" % "3.6", diff --git a/samples/client/petstore/java/jersey2-java6/pom.xml b/samples/client/petstore/java/jersey2-java6/pom.xml index 19754477d9db..70150988b352 100644 --- a/samples/client/petstore/java/jersey2-java6/pom.xml +++ b/samples/client/petstore/java/jersey2-java6/pom.xml @@ -291,7 +291,7 @@ 2.5 3.6 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 2.9.10 1.0.0 diff --git a/samples/client/petstore/java/jersey2-java8/build.gradle b/samples/client/petstore/java/jersey2-java8/build.gradle index 646b451a5437..1c2b2d6f3367 100644 --- a/samples/client/petstore/java/jersey2-java8/build.gradle +++ b/samples/client/petstore/java/jersey2-java8/build.gradle @@ -96,7 +96,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" jersey_version = "2.27" junit_version = "4.12" diff --git a/samples/client/petstore/java/jersey2-java8/build.sbt b/samples/client/petstore/java/jersey2-java8/build.sbt index b07ce9ccc081..d4c35713aeff 100644 --- a/samples/client/petstore/java/jersey2-java8/build.sbt +++ b/samples/client/petstore/java/jersey2-java8/build.sbt @@ -15,7 +15,7 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.25.1", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile", "junit" % "junit" % "4.12" % "test", "com.novocode" % "junit-interface" % "0.10" % "test" diff --git a/samples/client/petstore/java/jersey2-java8/pom.xml b/samples/client/petstore/java/jersey2-java8/pom.xml index b81f6e210a3c..475b490728ec 100644 --- a/samples/client/petstore/java/jersey2-java8/pom.xml +++ b/samples/client/petstore/java/jersey2-java8/pom.xml @@ -278,7 +278,7 @@ 1.5.22 2.27 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 1.0.0 4.12 diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle index d46e3b0a8b17..ac168318d962 100644 --- a/samples/client/petstore/java/jersey2/build.gradle +++ b/samples/client/petstore/java/jersey2/build.gradle @@ -96,7 +96,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" jersey_version = "2.27" junit_version = "4.12" diff --git a/samples/client/petstore/java/jersey2/build.sbt b/samples/client/petstore/java/jersey2/build.sbt index 20b9bf856800..88c2bdfba5ce 100644 --- a/samples/client/petstore/java/jersey2/build.sbt +++ b/samples/client/petstore/java/jersey2/build.sbt @@ -15,7 +15,7 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.25.1", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile", "com.brsanthu" % "migbase64" % "2.2", "junit" % "junit" % "4.12" % "test", diff --git a/samples/client/petstore/java/jersey2/pom.xml b/samples/client/petstore/java/jersey2/pom.xml index 6770d11afa67..6e341a40e8f2 100644 --- a/samples/client/petstore/java/jersey2/pom.xml +++ b/samples/client/petstore/java/jersey2/pom.xml @@ -284,7 +284,7 @@ 1.5.22 2.27 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 2.9.10 1.0.0 diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java index 2b32dccf324a..a3febe1fba1e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -128,8 +128,6 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) //empty } }); - // the API call should be executed asynchronously, so result should be empty at the moment - assertTrue(result.isEmpty()); // wait for the asynchronous call to finish (at most 10 seconds) final int maxTry = 10; diff --git a/samples/client/petstore/java/resteasy/build.gradle b/samples/client/petstore/java/resteasy/build.gradle index 888078679923..bd2a69eafa2e 100644 --- a/samples/client/petstore/java/resteasy/build.gradle +++ b/samples/client/petstore/java/resteasy/build.gradle @@ -96,7 +96,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" threetenbp_version = "2.9.10" resteasy_version = "3.1.3.Final" diff --git a/samples/client/petstore/java/resteasy/build.sbt b/samples/client/petstore/java/resteasy/build.sbt index 970818ece934..b94b8b1e7e38 100644 --- a/samples/client/petstore/java/resteasy/build.sbt +++ b/samples/client/petstore/java/resteasy/build.sbt @@ -15,7 +15,7 @@ lazy val root = (project in file(".")). "org.jboss.resteasy" % "resteasy-jackson2-provider" % "3.1.3.Final" % "compile", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile", "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.10" % "compile", "joda-time" % "joda-time" % "2.9.9" % "compile", diff --git a/samples/client/petstore/java/resteasy/pom.xml b/samples/client/petstore/java/resteasy/pom.xml index eae70733febd..1051701e8601 100644 --- a/samples/client/petstore/java/resteasy/pom.xml +++ b/samples/client/petstore/java/resteasy/pom.xml @@ -244,7 +244,7 @@ 1.5.22 3.1.3.Final 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 2.9.10 2.9.9 diff --git a/samples/client/petstore/java/resttemplate-withXml/build.gradle b/samples/client/petstore/java/resttemplate-withXml/build.gradle index bf15581bd7a8..b857b47737bf 100644 --- a/samples/client/petstore/java/resttemplate-withXml/build.gradle +++ b/samples/client/petstore/java/resttemplate-withXml/build.gradle @@ -97,7 +97,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" spring_web_version = "4.3.9.RELEASE" jodatime_version = "2.9.9" diff --git a/samples/client/petstore/java/resttemplate-withXml/pom.xml b/samples/client/petstore/java/resttemplate-withXml/pom.xml index f1a9c4611186..f498ec40eeb4 100644 --- a/samples/client/petstore/java/resttemplate-withXml/pom.xml +++ b/samples/client/petstore/java/resttemplate-withXml/pom.xml @@ -268,7 +268,7 @@ 1.5.22 4.3.9.RELEASE 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 2.9.10 1.0.0 diff --git a/samples/client/petstore/java/resttemplate/build.gradle b/samples/client/petstore/java/resttemplate/build.gradle index 183613ceea31..848d01a1a126 100644 --- a/samples/client/petstore/java/resttemplate/build.gradle +++ b/samples/client/petstore/java/resttemplate/build.gradle @@ -97,7 +97,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" spring_web_version = "4.3.9.RELEASE" jodatime_version = "2.9.9" diff --git a/samples/client/petstore/java/resttemplate/pom.xml b/samples/client/petstore/java/resttemplate/pom.xml index db01327bc5ad..ac33a8e2360c 100644 --- a/samples/client/petstore/java/resttemplate/pom.xml +++ b/samples/client/petstore/java/resttemplate/pom.xml @@ -260,7 +260,7 @@ 1.5.22 4.3.9.RELEASE 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 2.9.10 1.0.0 diff --git a/samples/client/petstore/java/retrofit2-play24/pom.xml b/samples/client/petstore/java/retrofit2-play24/pom.xml index 329612aa1920..6ba692a3eb6f 100644 --- a/samples/client/petstore/java/retrofit2-play24/pom.xml +++ b/samples/client/petstore/java/retrofit2-play24/pom.xml @@ -279,7 +279,7 @@ ${java.version} 1.8.3 1.5.22 - 2.9.10 + 2.9.10.1 2.6.6 2.4.11 0.2.0 diff --git a/samples/client/petstore/java/retrofit2-play25/build.sbt b/samples/client/petstore/java/retrofit2-play25/build.sbt index 46cbd0af51ac..fe180418e7d9 100644 --- a/samples/client/petstore/java/retrofit2-play25/build.sbt +++ b/samples/client/petstore/java/retrofit2-play25/build.sbt @@ -14,7 +14,7 @@ lazy val root = (project in file(".")). "com.typesafe.play" % "play-java-ws_2.11" % "2.5.15" % "compile", "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10.1" % "compile", "com.squareup.retrofit2" % "converter-jackson" % "2.3.0" % "compile", "io.swagger" % "swagger-annotations" % "1.5.21" % "compile", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile", diff --git a/samples/client/petstore/java/retrofit2-play25/pom.xml b/samples/client/petstore/java/retrofit2-play25/pom.xml index c78aec11c65f..5b16aa6a53f1 100644 --- a/samples/client/petstore/java/retrofit2-play25/pom.xml +++ b/samples/client/petstore/java/retrofit2-play25/pom.xml @@ -284,7 +284,7 @@ ${java.version} 1.8.3 1.5.22 - 2.9.10 + 2.9.10.1 2.9.10 2.5.15 0.2.0 diff --git a/samples/client/petstore/java/retrofit2-play26/build.gradle b/samples/client/petstore/java/retrofit2-play26/build.gradle index 179857ed9f04..541c3fa8032a 100644 --- a/samples/client/petstore/java/retrofit2-play26/build.gradle +++ b/samples/client/petstore/java/retrofit2-play26/build.gradle @@ -98,7 +98,7 @@ ext { oltu_version = "1.0.1" retrofit_version = "2.3.0" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" play_version = "2.6.7" swagger_annotations_version = "1.5.22" diff --git a/samples/client/petstore/java/retrofit2-play26/pom.xml b/samples/client/petstore/java/retrofit2-play26/pom.xml index bd49c056813b..a5dbd177064e 100644 --- a/samples/client/petstore/java/retrofit2-play26/pom.xml +++ b/samples/client/petstore/java/retrofit2-play26/pom.xml @@ -289,7 +289,7 @@ ${java.version} 1.8.3 1.5.22 - 2.9.10 + 2.9.10.1 2.9.10 2.6.7 0.2.0 diff --git a/samples/client/petstore/java/vertx/build.gradle b/samples/client/petstore/java/vertx/build.gradle index 1d51eb1193c3..379110a52414 100644 --- a/samples/client/petstore/java/vertx/build.gradle +++ b/samples/client/petstore/java/vertx/build.gradle @@ -29,7 +29,7 @@ task execute(type:JavaExec) { ext { swagger_annotations_version = "1.5.21" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" vertx_version = "3.4.2" junit_version = "4.12" } diff --git a/samples/client/petstore/java/vertx/pom.xml b/samples/client/petstore/java/vertx/pom.xml index 54e985acc850..d7e3842ebc55 100644 --- a/samples/client/petstore/java/vertx/pom.xml +++ b/samples/client/petstore/java/vertx/pom.xml @@ -267,7 +267,7 @@ 3.4.2 1.5.22 2.9.10 - 2.9.10 + 2.9.10.1 0.2.0 4.12 diff --git a/samples/client/petstore/java/webclient/build.gradle b/samples/client/petstore/java/webclient/build.gradle index 69b9c9a948c2..dc82478f47a5 100644 --- a/samples/client/petstore/java/webclient/build.gradle +++ b/samples/client/petstore/java/webclient/build.gradle @@ -113,7 +113,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.22" jackson_version = "2.9.10" - jackson_databind_version = "2.9.10" + jackson_databind_version = "2.9.10.1" jackson_databind_nullable_version = "0.2.0" jersey_version = "1.19.4" jodatime_version = "2.9.9" diff --git a/samples/client/petstore/kotlin-gson/.openapi-generator-ignore b/samples/client/petstore/kotlin-gson/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/kotlin-gson/.openapi-generator/VERSION b/samples/client/petstore/kotlin-gson/.openapi-generator/VERSION new file mode 100644 index 000000000000..d168f1d8bdaa --- /dev/null +++ b/samples/client/petstore/kotlin-gson/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.2.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/README.md b/samples/client/petstore/kotlin-gson/README.md new file mode 100644 index 000000000000..aef4ea15beed --- /dev/null +++ b/samples/client/petstore/kotlin-gson/README.md @@ -0,0 +1,90 @@ +# org.openapitools.client - Kotlin client library for OpenAPI Petstore + +## Requires + +* Kotlin 1.3.41 +* Gradle 4.9 + +## Build + +First, create the gradle wrapper script: + +``` +gradle wrapper +``` + +Then, run: + +``` +./gradlew check assemble +``` + +This runs all tests and packages the library. + +## Features/Implementation Notes + +* Supports JSON inputs/outputs, File inputs, and Form inputs. +* Supports collection formats for query parameters: csv, tsv, ssv, pipes. +* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions. +* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets. + + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + + +## Documentation for Models + + - [org.openapitools.client.models.ApiResponse](docs/ApiResponse.md) + - [org.openapitools.client.models.Category](docs/Category.md) + - [org.openapitools.client.models.Order](docs/Order.md) + - [org.openapitools.client.models.Pet](docs/Pet.md) + - [org.openapitools.client.models.Tag](docs/Tag.md) + - [org.openapitools.client.models.User](docs/User.md) + + + +## Documentation for Authorization + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + diff --git a/samples/client/petstore/kotlin-gson/build.gradle b/samples/client/petstore/kotlin-gson/build.gradle new file mode 100644 index 000000000000..2b9750602421 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/build.gradle @@ -0,0 +1,36 @@ +group 'org.openapitools' +version '1.0.0' + +wrapper { + gradleVersion = '4.9' + distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" +} + +buildscript { + ext.kotlin_version = '1.3.50' + + repositories { + mavenCentral() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' + +repositories { + mavenCentral() +} + +test { + useJUnitPlatform() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + compile "com.google.code.gson:gson:2.8.6" + compile "com.squareup.okhttp3:okhttp:4.2.2" + testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" +} diff --git a/samples/client/petstore/kotlin-gson/docs/ApiResponse.md b/samples/client/petstore/kotlin-gson/docs/ApiResponse.md new file mode 100644 index 000000000000..6b4c6bf27795 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/ApiResponse.md @@ -0,0 +1,12 @@ + +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **kotlin.Int** | | [optional] +**type** | **kotlin.String** | | [optional] +**message** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-gson/docs/Category.md b/samples/client/petstore/kotlin-gson/docs/Category.md new file mode 100644 index 000000000000..2c28a670fc79 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/Category.md @@ -0,0 +1,11 @@ + +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-gson/docs/Order.md b/samples/client/petstore/kotlin-gson/docs/Order.md new file mode 100644 index 000000000000..ef31dbf2f4f4 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/Order.md @@ -0,0 +1,22 @@ + +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**petId** | **kotlin.Long** | | [optional] +**quantity** | **kotlin.Int** | | [optional] +**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional] +**status** | [**inline**](#StatusEnum) | Order Status | [optional] +**complete** | **kotlin.Boolean** | | [optional] + + + +## Enum: status +Name | Value +---- | ----- +status | placed, approved, delivered + + + diff --git a/samples/client/petstore/kotlin-gson/docs/Pet.md b/samples/client/petstore/kotlin-gson/docs/Pet.md new file mode 100644 index 000000000000..ec7756007379 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/Pet.md @@ -0,0 +1,22 @@ + +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **kotlin.String** | | +**photoUrls** | **kotlin.Array<kotlin.String>** | | +**tags** | [**kotlin.Array<Tag>**](Tag.md) | | [optional] +**status** | [**inline**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: status +Name | Value +---- | ----- +status | available, pending, sold + + + diff --git a/samples/client/petstore/kotlin-gson/docs/PetApi.md b/samples/client/petstore/kotlin-gson/docs/PetApi.md new file mode 100644 index 000000000000..ea93e1745279 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/PetApi.md @@ -0,0 +1,405 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +# **addPet** +> addPet(body) + +Add a new pet to the store + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val body : Pet = // Pet | Pet object that needs to be added to the store +try { + apiInstance.addPet(body) +} catch (e: ClientException) { + println("4xx response calling PetApi#addPet") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#addPet") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +# **deletePet** +> deletePet(petId, apiKey) + +Deletes a pet + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete +val apiKey : kotlin.String = apiKey_example // kotlin.String | +try { + apiInstance.deletePet(petId, apiKey) +} catch (e: ClientException) { + println("4xx response calling PetApi#deletePet") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#deletePet") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| Pet id to delete | + **apiKey** | **kotlin.String**| | [optional] + +### Return type + +null (empty response body) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **findPetsByStatus** +> kotlin.Array<Pet> findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val status : kotlin.Array = // kotlin.Array | Status values that need to be considered for filter +try { + val result : kotlin.Array = apiInstance.findPetsByStatus(status) + println(result) +} catch (e: ClientException) { + println("4xx response calling PetApi#findPetsByStatus") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#findPetsByStatus") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] + +### Return type + +[**kotlin.Array<Pet>**](Pet.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByTags** +> kotlin.Array<Pet> findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val tags : kotlin.Array = // kotlin.Array | Tags to filter by +try { + val result : kotlin.Array = apiInstance.findPetsByTags(tags) + println(result) +} catch (e: ClientException) { + println("4xx response calling PetApi#findPetsByTags") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#findPetsByTags") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Tags to filter by | + +### Return type + +[**kotlin.Array<Pet>**](Pet.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return +try { + val result : Pet = apiInstance.getPetById(petId) + println(result) +} catch (e: ClientException) { + println("4xx response calling PetApi#getPetById") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#getPetById") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updatePet** +> updatePet(body) + +Update an existing pet + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val body : Pet = // Pet | Pet object that needs to be added to the store +try { + apiInstance.updatePet(body) +} catch (e: ClientException) { + println("4xx response calling PetApi#updatePet") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#updatePet") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +# **updatePetWithForm** +> updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated +val name : kotlin.String = name_example // kotlin.String | Updated name of the pet +val status : kotlin.String = status_example // kotlin.String | Updated status of the pet +try { + apiInstance.updatePetWithForm(petId, name, status) +} catch (e: ClientException) { + println("4xx response calling PetApi#updatePetWithForm") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#updatePetWithForm") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| ID of pet that needs to be updated | + **name** | **kotlin.String**| Updated name of the pet | [optional] + **status** | **kotlin.String**| Updated status of the pet | [optional] + +### Return type + +null (empty response body) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +# **uploadFile** +> ApiResponse uploadFile(petId, additionalMetadata, file) + +uploads an image + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update +val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server +val file : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload +try { + val result : ApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file) + println(result) +} catch (e: ClientException) { + println("4xx response calling PetApi#uploadFile") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#uploadFile") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| ID of pet to update | + **additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional] + **file** | **java.io.File**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/kotlin-gson/docs/StoreApi.md b/samples/client/petstore/kotlin-gson/docs/StoreApi.md new file mode 100644 index 000000000000..f4986041af8c --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/StoreApi.md @@ -0,0 +1,196 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = StoreApi() +val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted +try { + apiInstance.deleteOrder(orderId) +} catch (e: ClientException) { + println("4xx response calling StoreApi#deleteOrder") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling StoreApi#deleteOrder") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **kotlin.String**| ID of the order that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **getInventory** +> kotlin.collections.Map<kotlin.String, kotlin.Int> getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = StoreApi() +try { + val result : kotlin.collections.Map = apiInstance.getInventory() + println(result) +} catch (e: ClientException) { + println("4xx response calling StoreApi#getInventory") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling StoreApi#getInventory") + e.printStackTrace() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**kotlin.collections.Map<kotlin.String, kotlin.Int>** + +### Authorization + + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = StoreApi() +val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched +try { + val result : Order = apiInstance.getOrderById(orderId) + println(result) +} catch (e: ClientException) { + println("4xx response calling StoreApi#getOrderById") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling StoreApi#getOrderById") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **kotlin.Long**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **placeOrder** +> Order placeOrder(body) + +Place an order for a pet + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = StoreApi() +val body : Order = // Order | order placed for purchasing the pet +try { + val result : Order = apiInstance.placeOrder(body) + println(result) +} catch (e: ClientException) { + println("4xx response calling StoreApi#placeOrder") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling StoreApi#placeOrder") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/kotlin-gson/docs/Tag.md b/samples/client/petstore/kotlin-gson/docs/Tag.md new file mode 100644 index 000000000000..60ce1bcdbad3 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/Tag.md @@ -0,0 +1,11 @@ + +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-gson/docs/User.md b/samples/client/petstore/kotlin-gson/docs/User.md new file mode 100644 index 000000000000..e801729b5ed1 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/User.md @@ -0,0 +1,17 @@ + +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**username** | **kotlin.String** | | [optional] +**firstName** | **kotlin.String** | | [optional] +**lastName** | **kotlin.String** | | [optional] +**email** | **kotlin.String** | | [optional] +**password** | **kotlin.String** | | [optional] +**phone** | **kotlin.String** | | [optional] +**userStatus** | **kotlin.Int** | User Status | [optional] + + + diff --git a/samples/client/petstore/kotlin-gson/docs/UserApi.md b/samples/client/petstore/kotlin-gson/docs/UserApi.md new file mode 100644 index 000000000000..0f55f06bc629 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/docs/UserApi.md @@ -0,0 +1,376 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + + +# **createUser** +> createUser(body) + +Create user + +This can only be done by the logged in user. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +val body : User = // User | Created user object +try { + apiInstance.createUser(body) +} catch (e: ClientException) { + println("4xx response calling UserApi#createUser") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#createUser") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body) + +Creates list of users with given input array + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +val body : kotlin.Array = // kotlin.Array | List of user object +try { + apiInstance.createUsersWithArrayInput(body) +} catch (e: ClientException) { + println("4xx response calling UserApi#createUsersWithArrayInput") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#createUsersWithArrayInput") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**kotlin.Array<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **createUsersWithListInput** +> createUsersWithListInput(body) + +Creates list of users with given input array + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +val body : kotlin.Array = // kotlin.Array | List of user object +try { + apiInstance.createUsersWithListInput(body) +} catch (e: ClientException) { + println("4xx response calling UserApi#createUsersWithListInput") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#createUsersWithListInput") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**kotlin.Array<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted +try { + apiInstance.deleteUser(username) +} catch (e: ClientException) { + println("4xx response calling UserApi#deleteUser") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#deleteUser") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **kotlin.String**| The name that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing. +try { + val result : User = apiInstance.getUserByName(username) + println(result) +} catch (e: ClientException) { + println("4xx response calling UserApi#getUserByName") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#getUserByName") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **loginUser** +> kotlin.String loginUser(username, password) + +Logs user into the system + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +val username : kotlin.String = username_example // kotlin.String | The user name for login +val password : kotlin.String = password_example // kotlin.String | The password for login in clear text +try { + val result : kotlin.String = apiInstance.loginUser(username, password) + println(result) +} catch (e: ClientException) { + println("4xx response calling UserApi#loginUser") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#loginUser") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **kotlin.String**| The user name for login | + **password** | **kotlin.String**| The password for login in clear text | + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +try { + apiInstance.logoutUser() +} catch (e: ClientException) { + println("4xx response calling UserApi#logoutUser") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#logoutUser") + e.printStackTrace() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **updateUser** +> updateUser(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = UserApi() +val username : kotlin.String = username_example // kotlin.String | name that need to be deleted +val body : User = // User | Updated user object +try { + apiInstance.updateUser(username, body) +} catch (e: ClientException) { + println("4xx response calling UserApi#updateUser") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling UserApi#updateUser") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **kotlin.String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + diff --git a/samples/client/petstore/kotlin-gson/pom.xml b/samples/client/petstore/kotlin-gson/pom.xml new file mode 100644 index 000000000000..46e3845d39ba --- /dev/null +++ b/samples/client/petstore/kotlin-gson/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + io.swagger + KotlinGsonPetstoreClientTests + pom + 1.0-SNAPSHOT + Kotlin Gson Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + bundle-test + integration-test + + exec + + + gradle + + test + + + + + + + + diff --git a/samples/client/petstore/kotlin-gson/settings.gradle b/samples/client/petstore/kotlin-gson/settings.gradle new file mode 100644 index 000000000000..207bc66a067c --- /dev/null +++ b/samples/client/petstore/kotlin-gson/settings.gradle @@ -0,0 +1,2 @@ + +rootProject.name = 'kotlin-petstore-gson' \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/PetApi.kt new file mode 100644 index 000000000000..bc3e77dbf5f1 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -0,0 +1,318 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.apis + +import org.openapitools.client.models.ApiResponse +import org.openapitools.client.models.Pet + +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue + +class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiClient(basePath) { + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun addPet(body: Pet) : Unit { + val localVariableBody: kotlin.Any? = body + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/pet", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey (optional) + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf("api_key" to apiKey.toString()) + val localVariableConfig = RequestConfig( + RequestMethod.DELETE, + "/pet/{petId}".replace("{"+"petId"+"}", "$petId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * 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 + * @return kotlin.Array + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun findPetsByStatus(status: kotlin.Array) : kotlin.Array { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf>() + .apply { + put("status", toMultiValue(status.toList(), "csv")) + } + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/findByStatus", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request>( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as kotlin.Array + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * 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 + * @return kotlin.Array + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun findPetsByTags(tags: kotlin.Array) : kotlin.Array { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf>() + .apply { + put("tags", toMultiValue(tags.toList(), "csv")) + } + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/findByTags", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request>( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as kotlin.Array + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return + * @return Pet + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun getPetById(petId: kotlin.Long) : Pet { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/{petId}".replace("{"+"petId"+"}", "$petId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as Pet + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun updatePet(body: Pet) : Unit { + val localVariableBody: kotlin.Any? = body + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.PUT, + "/pet", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * 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 (optional) + * @param status Updated status of the pet (optional) + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit { + val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status") + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "") + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/pet/{petId}".replace("{"+"petId"+"}", "$petId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server (optional) + * @param file file to upload (optional) + * @return ApiResponse + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse { + val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file") + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "") + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/pet/{petId}/uploadImage".replace("{"+"petId"+"}", "$petId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as ApiResponse + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt new file mode 100644 index 000000000000..086f39cc5e79 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -0,0 +1,168 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.apis + +import org.openapitools.client.models.Order + +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue + +class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiClient(basePath) { + + /** + * 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 + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun deleteOrder(orderId: kotlin.String) : Unit { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.DELETE, + "/store/order/{orderId}".replace("{"+"orderId"+"}", "$orderId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return kotlin.collections.Map + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun getInventory() : kotlin.collections.Map { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/store/inventory", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request>( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * 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 + * @return Order + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun getOrderById(orderId: kotlin.Long) : Order { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/store/order/{orderId}".replace("{"+"orderId"+"}", "$orderId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as Order + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + * @return Order + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun placeOrder(body: Order) : Order { + val localVariableBody: kotlin.Any? = body + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/store/order", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as Order + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/UserApi.kt new file mode 100644 index 000000000000..0e22814d9de1 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -0,0 +1,309 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.apis + +import org.openapitools.client.models.User + +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue + +class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiClient(basePath) { + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun createUser(body: User) : Unit { + val localVariableBody: kotlin.Any? = body + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun createUsersWithArrayInput(body: kotlin.Array) : Unit { + val localVariableBody: kotlin.Any? = body + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user/createWithArray", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun createUsersWithListInput(body: kotlin.Array) : Unit { + val localVariableBody: kotlin.Any? = body + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user/createWithList", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun deleteUser(username: kotlin.String) : Unit { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.DELETE, + "/user/{username}".replace("{"+"username"+"}", "$username"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return User + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun getUserByName(username: kotlin.String) : User { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/user/{username}".replace("{"+"username"+"}", "$username"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as User + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + * @return kotlin.String + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Suppress("UNCHECKED_CAST") + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf>() + .apply { + put("username", listOf(username.toString())) + put("password", listOf(password.toString())) + } + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/user/login", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> (response as Success<*>).data as kotlin.String + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * Logs out current logged in user session + * + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun logoutUser() : Unit { + val localVariableBody: kotlin.Any? = null + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/user/logout", + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + + /** + * 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 + * @return void + * @throws UnsupportedOperationException If the API returns an informational or redirection response + * @throws ClientException If the API returns a client error response + * @throws ServerException If the API returns a server error response + */ + @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) + fun updateUser(username: kotlin.String, body: User) : Unit { + val localVariableBody: kotlin.Any? = body + val localVariableQuery: MultiValueMap = mutableMapOf() + val localVariableHeaders: MutableMap = mutableMapOf() + val localVariableConfig = RequestConfig( + RequestMethod.PUT, + "/user/{username}".replace("{"+"username"+"}", "$username"), + query = localVariableQuery, + headers = localVariableHeaders + ) + val response = request( + localVariableConfig, + localVariableBody + ) + + return when (response.responseType) { + ResponseType.Success -> Unit + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") + ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + } + } + +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt new file mode 100644 index 000000000000..ef7a8f1e1a62 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt @@ -0,0 +1,23 @@ +package org.openapitools.client.infrastructure + +typealias MultiValueMap = MutableMap> + +fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { + "csv" -> "," + "tsv" -> "\t" + "pipe" -> "|" + "space" -> " " + else -> "" +} + +val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } + +fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) + = toMultiValue(items.asIterable(), collectionFormat, map) + +fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List { + return when(collectionFormat) { + "multi" -> items.map(map) + else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map)) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt new file mode 100644 index 000000000000..ca294b411c8a --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -0,0 +1,172 @@ +package org.openapitools.client.infrastructure + +import okhttp3.OkHttpClient +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.asRequestBody +import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.FormBody +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull +import okhttp3.ResponseBody +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.Request +import java.io.File + +open class ApiClient(val baseUrl: String) { + companion object { + protected const val ContentType = "Content-Type" + protected const val Accept = "Accept" + protected const val Authorization = "Authorization" + protected const val JsonMediaType = "application/json" + protected const val FormDataMediaType = "multipart/form-data" + protected const val FormUrlEncMediaType = "application/x-www-form-urlencoded" + protected const val XmlMediaType = "application/xml" + + val apiKey: MutableMap = mutableMapOf() + val apiKeyPrefix: MutableMap = mutableMapOf() + var username: String? = null + var password: String? = null + var accessToken: String? = null + + @JvmStatic + val client: OkHttpClient by lazy { + builder.build() + } + + @JvmStatic + val builder: OkHttpClient.Builder = OkHttpClient.Builder() + } + + protected inline fun requestBody(content: T, mediaType: String = JsonMediaType): RequestBody = + when { + content is File -> content.asRequestBody( + mediaType.toMediaTypeOrNull() + ) + mediaType == FormDataMediaType || mediaType == FormUrlEncMediaType -> { + FormBody.Builder().apply { + // content's type *must* be Map + @Suppress("UNCHECKED_CAST") + (content as Map).forEach { (key, value) -> + add(key, value) + } + }.build() + } + mediaType == JsonMediaType -> Serializer.gson.toJson(content, T::class.java).toRequestBody( + mediaType.toMediaTypeOrNull() + ) + mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.") + // TODO: this should be extended with other serializers + else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.") + } + + protected inline fun responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? { + if(body == null) { + return null + } + val bodyContent = body.string() + if (bodyContent.isEmpty()) { + return null + } + return when(mediaType) { + JsonMediaType -> Serializer.gson.fromJson(bodyContent, T::class.java) + else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.") + } + } + + protected fun updateAuthParams(requestConfig: RequestConfig) { + if (requestConfig.headers["api_key"].isNullOrEmpty()) { + if (apiKey["api_key"] != null) { + if (apiKeyPrefix["api_key"] != null) { + requestConfig.headers["api_key"] = apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!! + } else { + requestConfig.headers["api_key"] = apiKey["api_key"]!! + } + } + } + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + accessToken?.let { accessToken -> + requestConfig.headers[Authorization] = "Bearer " + accessToken + } + } + } + + protected inline fun request(requestConfig: RequestConfig, body : Any? = null): ApiInfrastructureResponse { + val httpUrl = baseUrl.toHttpUrlOrNull() ?: throw IllegalStateException("baseUrl is invalid.") + + // take authMethod from operation + updateAuthParams(requestConfig) + + val url = httpUrl.newBuilder() + .addPathSegments(requestConfig.path.trimStart('/')) + .apply { + requestConfig.query.forEach { query -> + query.value.forEach { queryValue -> + addQueryParameter(query.key, queryValue) + } + } + }.build() + + // take content-type/accept from spec or set to default (application/json) if not defined + if (requestConfig.headers[ContentType].isNullOrEmpty()) { + requestConfig.headers[ContentType] = JsonMediaType + } + if (requestConfig.headers[Accept].isNullOrEmpty()) { + requestConfig.headers[Accept] = JsonMediaType + } + val headers = requestConfig.headers + + if(headers[ContentType] ?: "" == "") { + throw kotlin.IllegalStateException("Missing Content-Type header. This is required.") + } + + if(headers[Accept] ?: "" == "") { + throw kotlin.IllegalStateException("Missing Accept header. This is required.") + } + + // TODO: support multiple contentType options here. + val contentType = (headers[ContentType] as String).substringBefore(";").toLowerCase() + + val request = when (requestConfig.method) { + RequestMethod.DELETE -> Request.Builder().url(url).delete(requestBody(body, contentType)) + RequestMethod.GET -> Request.Builder().url(url) + RequestMethod.HEAD -> Request.Builder().url(url).head() + RequestMethod.PATCH -> Request.Builder().url(url).patch(requestBody(body, contentType)) + RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(body, contentType)) + RequestMethod.POST -> Request.Builder().url(url).post(requestBody(body, contentType)) + RequestMethod.OPTIONS -> Request.Builder().url(url).method("OPTIONS", null) + }.apply { + headers.forEach { header -> addHeader(header.key, header.value) } + }.build() + + val response = client.newCall(request).execute() + val accept = response.header(ContentType)?.substringBefore(";")?.toLowerCase() + + // TODO: handle specific mapping types. e.g. Map> + when { + response.isRedirect -> return Redirection( + response.code, + response.headers.toMultimap() + ) + response.isInformational -> return Informational( + response.message, + response.code, + response.headers.toMultimap() + ) + response.isSuccessful -> return Success( + responseBody(response.body, accept), + response.code, + response.headers.toMultimap() + ) + response.isClientError -> return ClientError( + response.body?.string(), + response.code, + response.headers.toMultimap() + ) + else -> return ServerError( + null, + response.body?.string(), + response.code, + response.headers.toMultimap() + ) + } + } +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiInfrastructureResponse.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiInfrastructureResponse.kt new file mode 100644 index 000000000000..f1a8aecc914b --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiInfrastructureResponse.kt @@ -0,0 +1,40 @@ +package org.openapitools.client.infrastructure + +enum class ResponseType { + Success, Informational, Redirection, ClientError, ServerError +} + +abstract class ApiInfrastructureResponse(val responseType: ResponseType) { + abstract val statusCode: Int + abstract val headers: Map> +} + +class Success( + val data: T, + override val statusCode: Int = -1, + override val headers: Map> = mapOf() +): ApiInfrastructureResponse(ResponseType.Success) + +class Informational( + val statusText: String, + override val statusCode: Int = -1, + override val headers: Map> = mapOf() +) : ApiInfrastructureResponse(ResponseType.Informational) + +class Redirection( + override val statusCode: Int = -1, + override val headers: Map> = mapOf() +) : ApiInfrastructureResponse(ResponseType.Redirection) + +class ClientError( + val body: Any? = null, + override val statusCode: Int = -1, + override val headers: Map> = mapOf() +) : ApiInfrastructureResponse(ResponseType.ClientError) + +class ServerError( + val message: String? = null, + val body: Any? = null, + override val statusCode: Int = -1, + override val headers: Map> +): ApiInfrastructureResponse(ResponseType.ServerError) \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.kt new file mode 100644 index 000000000000..dd34bd48b2c0 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.kt @@ -0,0 +1,29 @@ +package org.openapitools.client.infrastructure + +import kotlin.properties.ReadWriteProperty +import kotlin.reflect.KProperty + +object ApplicationDelegates { + /** + * Provides a property delegate, allowing the property to be set once and only once. + * + * If unset (no default value), a get on the property will throw [IllegalStateException]. + */ + fun setOnce(defaultValue: T? = null) : ReadWriteProperty = SetOnce(defaultValue) + + private class SetOnce(defaultValue: T? = null) : ReadWriteProperty { + private var isSet = false + private var value: T? = defaultValue + + override fun getValue(thisRef: Any?, property: KProperty<*>): T { + return value ?: throw IllegalStateException("${property.name} not initialized") + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) = synchronized(this) { + if (!isSet) { + this.value = value + isSet = true + } + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt new file mode 100644 index 000000000000..6120b081929d --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -0,0 +1,33 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException + +class ByteArrayAdapter : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: ByteArray?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(String(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): ByteArray? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return out.nextString().toByteArray() + } + } + } +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt new file mode 100644 index 000000000000..c5d330ac0757 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt @@ -0,0 +1,37 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.text.DateFormat +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale + +class DateAdapter(val formatter: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault())) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: Date?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): Date? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return formatter.parse(out.nextString()) + } + } + } +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt new file mode 100644 index 000000000000..2f3b0157ba70 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt @@ -0,0 +1,42 @@ +@file:Suppress("unused") +package org.openapitools.client.infrastructure + +import java.lang.RuntimeException + +open class ClientException : RuntimeException { + + /** + * Constructs an [ClientException] with no detail message. + */ + constructor() : super() + + /** + * Constructs an [ClientException] with the specified detail message. + + * @param message the detail message. + */ + constructor(message: kotlin.String) : super(message) + + companion object { + private const val serialVersionUID: Long = 123L + } +} + +open class ServerException : RuntimeException { + + /** + * Constructs an [ServerException] with no detail message. + */ + constructor() : super() + + /** + * Constructs an [ServerException] with the specified detail message. + + * @param message the detail message. + */ + constructor(message: kotlin.String) : super(message) + + companion object { + private const val serialVersionUID: Long = 456L + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt new file mode 100644 index 000000000000..30ef6697183a --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.LocalDate +import java.time.format.DateTimeFormatter + +class LocalDateAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDate?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDate? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDate.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt new file mode 100644 index 000000000000..3ad781c66ca1 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +class LocalDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDateTime?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDateTime? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDateTime.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt new file mode 100644 index 000000000000..9c22257e223a --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt @@ -0,0 +1,16 @@ +package org.openapitools.client.infrastructure + +/** + * Defines a config object for a given request. + * NOTE: This object doesn't include 'body' because it + * allows for caching of the constructed object + * for many request definitions. + * NOTE: Headers is a Map because rfc2616 defines + * multi-valued headers as csv-only. + */ +data class RequestConfig( + val method: RequestMethod, + val path: String, + val headers: MutableMap = mutableMapOf(), + val query: MutableMap> = mutableMapOf() +) \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt new file mode 100644 index 000000000000..931b12b8bd7a --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt @@ -0,0 +1,8 @@ +package org.openapitools.client.infrastructure + +/** + * Provides enumerated HTTP verbs + */ +enum class RequestMethod { + GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt new file mode 100644 index 000000000000..69b562becb07 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt @@ -0,0 +1,23 @@ +package org.openapitools.client.infrastructure + +import okhttp3.Response + +/** + * Provides an extension to evaluation whether the response is a 1xx code + */ +val Response.isInformational : Boolean get() = this.code in 100..199 + +/** + * Provides an extension to evaluation whether the response is a 3xx code + */ +val Response.isRedirect : Boolean get() = this.code in 300..399 + +/** + * Provides an extension to evaluation whether the response is a 4xx code + */ +val Response.isClientError : Boolean get() = this.code in 400..499 + +/** + * Provides an extension to evaluation whether the response is a 5xx (Standard) through 999 (non-standard) code + */ +val Response.isServerError : Boolean get() = this.code in 500..999 diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt new file mode 100644 index 000000000000..a81be094f417 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -0,0 +1,19 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import java.time.LocalDate +import java.time.LocalDateTime +import java.util.UUID +import java.util.Date + +object Serializer { + @JvmStatic + val gson: Gson = GsonBuilder() + .registerTypeAdapter(Date::class.java, DateAdapter()) + .registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter()) + .registerTypeAdapter(LocalDate::class.java, LocalDateAdapter()) + .registerTypeAdapter(UUID::class.java, UUIDAdapter()) + .registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter()) + .create() +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt new file mode 100644 index 000000000000..04dce98308e8 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt @@ -0,0 +1,34 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.util.UUID + +class UUIDAdapter : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: UUID?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(value.toString()) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): UUID? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return UUID.fromString(out.nextString()) + } + } + } +} diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt new file mode 100644 index 000000000000..96b24b0b2b28 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt @@ -0,0 +1,33 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName +/** + * Describes the result of uploading an image resource + * @param code + * @param type + * @param message + */ + +data class ApiResponse ( + @SerializedName("code") + val code: kotlin.Int? = null, + @SerializedName("type") + val type: kotlin.String? = null, + @SerializedName("message") + val message: kotlin.String? = null +) + + + diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Category.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Category.kt new file mode 100644 index 000000000000..d0af4fb050bb --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Category.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName +/** + * A category for a pet + * @param id + * @param name + */ + +data class Category ( + @SerializedName("id") + val id: kotlin.Long? = null, + @SerializedName("name") + val name: kotlin.String? = null +) + + + diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt new file mode 100644 index 000000000000..ac55ce97d53a --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt @@ -0,0 +1,55 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName +/** + * An order for a pets from the pet store + * @param id + * @param petId + * @param quantity + * @param shipDate + * @param status Order Status + * @param complete + */ + +data class Order ( + @SerializedName("id") + val id: kotlin.Long? = null, + @SerializedName("petId") + val petId: kotlin.Long? = null, + @SerializedName("quantity") + val quantity: kotlin.Int? = null, + @SerializedName("shipDate") + val shipDate: java.time.LocalDateTime? = null, + /* Order Status */ + @SerializedName("status") + val status: Order.Status? = null, + @SerializedName("complete") + val complete: kotlin.Boolean? = null +) + + +{ + /** + * Order Status + * Values: placed,approved,delivered + */ + + enum class Status(val value: kotlin.String){ + @SerializedName(value="placed") placed("placed"), + @SerializedName(value="approved") approved("approved"), + @SerializedName(value="delivered") delivered("delivered"); + } +} + diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Pet.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Pet.kt new file mode 100644 index 000000000000..c9c7e0d8f1ec --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Pet.kt @@ -0,0 +1,57 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + +import org.openapitools.client.models.Category +import org.openapitools.client.models.Tag + +import com.google.gson.annotations.SerializedName +/** + * A pet for sale in the pet store + * @param id + * @param category + * @param name + * @param photoUrls + * @param tags + * @param status pet status in the store + */ + +data class Pet ( + @SerializedName("name") + val name: kotlin.String, + @SerializedName("photoUrls") + val photoUrls: kotlin.Array, + @SerializedName("id") + val id: kotlin.Long? = null, + @SerializedName("category") + val category: Category? = null, + @SerializedName("tags") + val tags: kotlin.Array? = null, + /* pet status in the store */ + @SerializedName("status") + val status: Pet.Status? = null +) + + +{ + /** + * pet status in the store + * Values: available,pending,sold + */ + + enum class Status(val value: kotlin.String){ + @SerializedName(value="available") available("available"), + @SerializedName(value="pending") pending("pending"), + @SerializedName(value="sold") sold("sold"); + } +} + diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Tag.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Tag.kt new file mode 100644 index 000000000000..484f3db87cd6 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Tag.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName +/** + * A tag for a pet + * @param id + * @param name + */ + +data class Tag ( + @SerializedName("id") + val id: kotlin.Long? = null, + @SerializedName("name") + val name: kotlin.String? = null +) + + + diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/User.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/User.kt new file mode 100644 index 000000000000..4a660298d733 --- /dev/null +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/User.kt @@ -0,0 +1,49 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName +/** + * A User who is purchasing from the pet store + * @param id + * @param username + * @param firstName + * @param lastName + * @param email + * @param password + * @param phone + * @param userStatus User Status + */ + +data class User ( + @SerializedName("id") + val id: kotlin.Long? = null, + @SerializedName("username") + val username: kotlin.String? = null, + @SerializedName("firstName") + val firstName: kotlin.String? = null, + @SerializedName("lastName") + val lastName: kotlin.String? = null, + @SerializedName("email") + val email: kotlin.String? = null, + @SerializedName("password") + val password: kotlin.String? = null, + @SerializedName("phone") + val phone: kotlin.String? = null, + /* User Status */ + @SerializedName("userStatus") + val userStatus: kotlin.Int? = null +) + + + diff --git a/samples/client/petstore/kotlin-nonpublic/build.gradle b/samples/client/petstore/kotlin-nonpublic/build.gradle index 98ac4f243e6f..d2b39bf5e9fd 100644 --- a/samples/client/petstore/kotlin-nonpublic/build.gradle +++ b/samples/client/petstore/kotlin-nonpublic/build.gradle @@ -7,7 +7,7 @@ wrapper { } buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { mavenCentral() @@ -32,6 +32,6 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.8.0" compile "com.squareup.moshi:moshi-adapters:1.8.0" - compile "com.squareup.okhttp3:okhttp:4.2.0" - testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" + compile "com.squareup.okhttp3:okhttp:4.2.2" + testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin-nonpublic/pom.xml b/samples/client/petstore/kotlin-nonpublic/pom.xml new file mode 100644 index 000000000000..2b400e564b9a --- /dev/null +++ b/samples/client/petstore/kotlin-nonpublic/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + io.swagger + KotlinNonpublicPetstoreClientTests + pom + 1.0-SNAPSHOT + Kotlin Nonpublic Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + bundle-test + integration-test + + exec + + + gradle + + test + + + + + + + + diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index edce99a21281..ed683e3a093f 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -48,17 +48,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -83,17 +83,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -121,17 +121,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -159,17 +159,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -194,17 +194,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Pet + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Pet ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -228,17 +228,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -264,17 +264,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -301,17 +301,17 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as ApiResponse + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as ApiResponse ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 46b6b316d957..9c448c5bd185 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -47,17 +47,17 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2 query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2 query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -116,17 +116,17 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2 query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -151,17 +151,17 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2 query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 4b289be0dcd3..da7eda47fea5 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -47,17 +47,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -115,17 +115,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -149,17 +149,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -184,17 +184,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as User + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as User ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -224,17 +224,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.String + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.String ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -257,17 +257,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -292,17 +292,17 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2" query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt index 8e1cefd24852..86bcb51fba6f 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -9,4 +9,4 @@ internal class ByteArrayAdapter { @FromJson fun fromJson(data: String): ByteArray = data.toByteArray() -} \ No newline at end of file +} diff --git a/samples/client/petstore/kotlin-okhttp3/build.gradle b/samples/client/petstore/kotlin-okhttp3/build.gradle index c3a555eaaed5..7272e8785fe2 100644 --- a/samples/client/petstore/kotlin-okhttp3/build.gradle +++ b/samples/client/petstore/kotlin-okhttp3/build.gradle @@ -7,7 +7,7 @@ wrapper { } buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { mavenCentral() @@ -32,6 +32,6 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.8.0" compile "com.squareup.moshi:moshi-adapters:1.8.0" - compile "com.squareup.okhttp3:okhttp:3.12.4" - testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" + compile "com.squareup.okhttp3:okhttp:3.12.6" + testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index bc3e77dbf5f1..5eabd2dbcb4e 100644 --- a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -48,17 +48,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -83,17 +83,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -121,17 +121,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -159,17 +159,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -194,17 +194,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Pet + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Pet ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -228,17 +228,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -264,17 +264,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -301,17 +301,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as ApiResponse + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as ApiResponse ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 086f39cc5e79..8f24aeabaafe 100644 --- a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -47,17 +47,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -116,17 +116,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -151,17 +151,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 0e22814d9de1..db099377b839 100644 --- a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -47,17 +47,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -115,17 +115,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -149,17 +149,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -184,17 +184,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as User + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as User ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -224,17 +224,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.String + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.String ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -257,17 +257,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -292,17 +292,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt index 617ac3fe9069..ff5e2a81ee8c 100644 --- a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -9,4 +9,4 @@ class ByteArrayAdapter { @FromJson fun fromJson(data: String): ByteArray = data.toByteArray() -} \ No newline at end of file +} diff --git a/samples/client/petstore/kotlin-string/build.gradle b/samples/client/petstore/kotlin-string/build.gradle index 98ac4f243e6f..d2b39bf5e9fd 100644 --- a/samples/client/petstore/kotlin-string/build.gradle +++ b/samples/client/petstore/kotlin-string/build.gradle @@ -7,7 +7,7 @@ wrapper { } buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { mavenCentral() @@ -32,6 +32,6 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.8.0" compile "com.squareup.moshi:moshi-adapters:1.8.0" - compile "com.squareup.okhttp3:okhttp:4.2.0" - testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" + compile "com.squareup.okhttp3:okhttp:4.2.2" + testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index bc3e77dbf5f1..5eabd2dbcb4e 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -48,17 +48,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -83,17 +83,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -121,17 +121,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -159,17 +159,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -194,17 +194,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Pet + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Pet ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -228,17 +228,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -264,17 +264,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -301,17 +301,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as ApiResponse + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as ApiResponse ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 086f39cc5e79..8f24aeabaafe 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -47,17 +47,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -116,17 +116,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -151,17 +151,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 0e22814d9de1..db099377b839 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -47,17 +47,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -115,17 +115,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -149,17 +149,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -184,17 +184,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as User + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as User ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -224,17 +224,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.String + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.String ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -257,17 +257,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -292,17 +292,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt index 617ac3fe9069..ff5e2a81ee8c 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -9,4 +9,4 @@ class ByteArrayAdapter { @FromJson fun fromJson(data: String): ByteArray = data.toByteArray() -} \ No newline at end of file +} diff --git a/samples/client/petstore/kotlin-threetenbp/build.gradle b/samples/client/petstore/kotlin-threetenbp/build.gradle index 6ec6192162b3..613a199fea5f 100644 --- a/samples/client/petstore/kotlin-threetenbp/build.gradle +++ b/samples/client/petstore/kotlin-threetenbp/build.gradle @@ -7,7 +7,7 @@ wrapper { } buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { mavenCentral() @@ -32,7 +32,7 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.8.0" compile "com.squareup.moshi:moshi-adapters:1.8.0" - compile "com.squareup.okhttp3:okhttp:4.2.0" + compile "com.squareup.okhttp3:okhttp:4.2.2" compile "org.threeten:threetenbp:1.4.0" - testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" + testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index bc3e77dbf5f1..5eabd2dbcb4e 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -48,17 +48,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -83,17 +83,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -121,17 +121,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -159,17 +159,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -194,17 +194,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Pet + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Pet ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -228,17 +228,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -264,17 +264,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -301,17 +301,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as ApiResponse + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as ApiResponse ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 086f39cc5e79..8f24aeabaafe 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -47,17 +47,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -116,17 +116,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -151,17 +151,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 0e22814d9de1..db099377b839 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -47,17 +47,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -115,17 +115,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -149,17 +149,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -184,17 +184,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as User + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as User ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -224,17 +224,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.String + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.String ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -257,17 +257,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -292,17 +292,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt index 617ac3fe9069..ff5e2a81ee8c 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -9,4 +9,4 @@ class ByteArrayAdapter { @FromJson fun fromJson(data: String): ByteArray = data.toByteArray() -} \ No newline at end of file +} diff --git a/samples/client/petstore/kotlin/build.gradle b/samples/client/petstore/kotlin/build.gradle index 98ac4f243e6f..d2b39bf5e9fd 100644 --- a/samples/client/petstore/kotlin/build.gradle +++ b/samples/client/petstore/kotlin/build.gradle @@ -7,7 +7,7 @@ wrapper { } buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { mavenCentral() @@ -32,6 +32,6 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.8.0" compile "com.squareup.moshi:moshi-adapters:1.8.0" - compile "com.squareup.okhttp3:okhttp:4.2.0" - testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" + compile "com.squareup.okhttp3:okhttp:4.2.2" + testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index bc3e77dbf5f1..5eabd2dbcb4e 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -48,17 +48,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -83,17 +83,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -121,17 +121,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -159,17 +159,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -194,17 +194,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Pet + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Pet ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -228,17 +228,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -264,17 +264,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -301,17 +301,17 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as ApiResponse + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as ApiResponse ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 086f39cc5e79..8f24aeabaafe 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -47,17 +47,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val localVarResponse = request>( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -116,17 +116,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -151,17 +151,17 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as Order + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 0e22814d9de1..db099377b839 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -47,17 +47,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -81,17 +81,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -115,17 +115,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -149,17 +149,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -184,17 +184,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as User + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as User ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -224,17 +224,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.String + return when (localVarResponse.responseType) { + ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.String ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -257,17 +257,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } @@ -292,17 +292,17 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl query = localVariableQuery, headers = localVariableHeaders ) - val response = request( + val localVarResponse = request( localVariableConfig, localVariableBody ) - return when (response.responseType) { + return when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException((localVarResponse as ClientError<*>).body as? String ?: "Client error") + ResponseType.ServerError -> throw ServerException((localVarResponse as ServerError<*>).message ?: "Server error") } } diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt index 617ac3fe9069..ff5e2a81ee8c 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -9,4 +9,4 @@ class ByteArrayAdapter { @FromJson fun fromJson(data: String): ByteArray = data.toByteArray() -} \ No newline at end of file +} diff --git a/samples/client/petstore/python-asyncio/petstore_api/api_client.py b/samples/client/petstore/python-asyncio/petstore_api/api_client.py index 9ad41e84f6d1..24b99a2946f4 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api_client.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api_client.py @@ -622,11 +622,11 @@ def __deserialize_model(self, data, klass): return data kwargs = {} - if klass.openapi_types is not None: + if (data is not None and + klass.openapi_types is not None and + isinstance(data, (list, dict))): for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) diff --git a/samples/client/petstore/python-experimental/.openapi-generator/VERSION b/samples/client/petstore/python-experimental/.openapi-generator/VERSION index c3a2c7076fa8..d168f1d8bdaa 100644 --- a/samples/client/petstore/python-experimental/.openapi-generator/VERSION +++ b/samples/client/petstore/python-experimental/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +4.2.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python-experimental/petstore_api/api_client.py b/samples/client/petstore/python-experimental/petstore_api/api_client.py index 3cfe1c3ecc85..6673889b51f7 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api_client.py +++ b/samples/client/petstore/python-experimental/petstore_api/api_client.py @@ -339,18 +339,19 @@ def call_api(self, resource_path, method, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _check_type) - else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, _check_type)) - return thread + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _check_type)) def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, diff --git a/samples/client/petstore/python-tornado/petstore_api/api_client.py b/samples/client/petstore/python-tornado/petstore_api/api_client.py index bd360c4b05f2..0d1075ffe970 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api_client.py +++ b/samples/client/petstore/python-tornado/petstore_api/api_client.py @@ -624,11 +624,11 @@ def __deserialize_model(self, data, klass): return data kwargs = {} - if klass.openapi_types is not None: + if (data is not None and + klass.openapi_types is not None and + isinstance(data, (list, dict))): for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index 5e7a95a35f3b..46e568df26ab 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -622,11 +622,11 @@ def __deserialize_model(self, data, klass): return data kwargs = {} - if klass.openapi_types is not None: + if (data is not None and + klass.openapi_types is not None and + isinstance(data, (list, dict))): for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_any_type.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_any_type.rb index b7b7b216a532..dc63ea992146 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_any_type.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_any_type.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_array.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_array.rb index 302f3a0435b0..11fc4b70ec12 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_array.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_array.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_boolean.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_boolean.rb index 4de535b4d10b..a9f2ee1eb28d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_boolean.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_boolean.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb index d01c83cc62b2..bdf557c94a9c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb @@ -70,6 +70,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -275,7 +281,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_integer.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_integer.rb index ac1a28bcc8e6..2dc0bfc3136d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_integer.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_integer.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_number.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_number.rb index 02f2e756bd89..9736beb023e6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_number.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_number.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_object.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_object.rb index 6f87bf291355..cc08e89a1cd9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_object.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_object.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_string.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_string.rb index f3be808fa27a..d85c3e4b0237 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_string.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_string.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb index fb2487e99aa1..abc65e4d227c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # discriminator's property name in OpenAPI v3 def self.openapi_discriminator_name :'class_name' @@ -190,7 +196,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb index 1ec744fd6fc4..17835d6215bc 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb index 3d7b6966c5ab..5abad943b7ba 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb index 1717f521e714..16e11fbcd7a5 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb index 893302c2ef8f..3f2b0883805f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -193,7 +199,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb index 94bfa2273add..2fa82ea749e3 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb @@ -51,6 +51,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -215,7 +221,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb index 637b67a38b66..66983cbfd5e1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb index 6dc13cbd2b85..29514833eba1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb index d7e6a1fd9eb9..4e535ea49788 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -185,7 +191,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb index d24a651b6dfa..fd1c582de00f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb index 9457f2591e82..59cbd23b927d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb index 3d6bfce3f827..4b06d9e93e9d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb index 61a55de7ffaa..edbc2d01be84 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb index b3b26138785e..7bcce6fcbdb2 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb @@ -56,6 +56,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -214,7 +220,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb index bdd0b1008198..f9d30fffc798 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb @@ -68,6 +68,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -280,7 +286,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb index b71a8676b76e..76a98abaa7bf 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb @@ -32,6 +32,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb index dab73dc4bcbb..55ae9ed867b6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb index 3de19f7800b1..409ed2ea0f53 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb @@ -82,6 +82,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -496,7 +502,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb index 2c22b38453f3..56cf4f959626 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb index a6770da4d348..24d06293854f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb index 3974d29af515..2445ce5a3616 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb @@ -64,6 +64,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -226,7 +232,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 991773081e33..829b4c83c493 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -189,7 +195,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb index 6858f297eaef..2cc48793f574 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb @@ -35,6 +35,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -179,7 +185,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb index 8f5040f9f376..b2b054e82c98 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb index d3c3fe021c35..c2c0f728c680 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb @@ -43,6 +43,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -202,7 +208,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb index b7490b8a77f1..cb8739074c0a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb index e7280550f551..9d025ec60aa4 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -251,7 +257,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb index a7155714e13c..f17fd5ed9902 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb index 6aebd504d0a7..d2e84bb116c6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -263,7 +269,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb index 36c5476c27c1..a0c6236adf6a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb index 38a7ad79b181..d31b38e75709 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb index fe7741c5dae3..548cf6e660bb 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_default.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_default.rb index a2bb34e8710b..8588a5679afe 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_default.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_default.rb @@ -46,6 +46,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -236,7 +242,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_example.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_example.rb index cb0111bcd88b..9669dd9ee4b7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_example.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/type_holder_example.rb @@ -50,6 +50,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -246,7 +252,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb index 34c305b5500b..cc5b83b62b05 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb @@ -59,6 +59,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -233,7 +239,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/xml_item.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/xml_item.rb index eb268f50cf5a..3a5771b4bcaf 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/xml_item.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/xml_item.rb @@ -142,6 +142,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -439,7 +445,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_any_type.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_any_type.rb index b7b7b216a532..dc63ea992146 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_any_type.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_any_type.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_array.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_array.rb index 302f3a0435b0..11fc4b70ec12 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_array.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_array.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_boolean.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_boolean.rb index 4de535b4d10b..a9f2ee1eb28d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_boolean.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_boolean.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index d01c83cc62b2..bdf557c94a9c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -70,6 +70,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -275,7 +281,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_integer.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_integer.rb index ac1a28bcc8e6..2dc0bfc3136d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_integer.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_integer.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_number.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_number.rb index 02f2e756bd89..9736beb023e6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_number.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_number.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_object.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_object.rb index 6f87bf291355..cc08e89a1cd9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_object.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_object.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_string.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_string.rb index f3be808fa27a..d85c3e4b0237 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_string.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_string.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index fb2487e99aa1..abc65e4d227c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # discriminator's property name in OpenAPI v3 def self.openapi_discriminator_name :'class_name' @@ -190,7 +196,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index 1ec744fd6fc4..17835d6215bc 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb index 3d7b6966c5ab..5abad943b7ba 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb index 1717f521e714..16e11fbcd7a5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb index 893302c2ef8f..3f2b0883805f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -193,7 +199,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb index 94bfa2273add..2fa82ea749e3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -51,6 +51,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -215,7 +221,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 637b67a38b66..66983cbfd5e1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat_all_of.rb b/samples/client/petstore/ruby/lib/petstore/models/cat_all_of.rb index 6dc13cbd2b85..29514833eba1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat_all_of.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index d7e6a1fd9eb9..4e535ea49788 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -185,7 +191,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb index d24a651b6dfa..fd1c582de00f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index 9457f2591e82..59cbd23b927d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 3d6bfce3f827..4b06d9e93e9d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog_all_of.rb b/samples/client/petstore/ruby/lib/petstore/models/dog_all_of.rb index 61a55de7ffaa..edbc2d01be84 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog_all_of.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb index b3b26138785e..7bcce6fcbdb2 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -56,6 +56,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -214,7 +220,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb index bdd0b1008198..f9d30fffc798 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -68,6 +68,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -280,7 +286,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/file.rb b/samples/client/petstore/ruby/lib/petstore/models/file.rb index b71a8676b76e..76a98abaa7bf 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file.rb @@ -32,6 +32,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb index dab73dc4bcbb..55ae9ed867b6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash 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 3de19f7800b1..409ed2ea0f53 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -82,6 +82,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -496,7 +502,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb index 2c22b38453f3..56cf4f959626 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index a6770da4d348..24d06293854f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb index 3974d29af515..2445ce5a3616 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -64,6 +64,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -226,7 +232,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 991773081e33..829b4c83c493 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -189,7 +195,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb index 6858f297eaef..2cc48793f574 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -35,6 +35,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -179,7 +185,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 8f5040f9f376..b2b054e82c98 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index d3c3fe021c35..c2c0f728c680 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -43,6 +43,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -202,7 +208,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb index b7490b8a77f1..cb8739074c0a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index e7280550f551..9d025ec60aa4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -251,7 +257,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb index a7155714e13c..f17fd5ed9902 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 6aebd504d0a7..d2e84bb116c6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -263,7 +269,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb index 36c5476c27c1..a0c6236adf6a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 38a7ad79b181..d31b38e75709 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index fe7741c5dae3..548cf6e660bb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb b/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb index a2bb34e8710b..8588a5679afe 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb @@ -46,6 +46,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -236,7 +242,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb b/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb index cb0111bcd88b..9669dd9ee4b7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb @@ -50,6 +50,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -246,7 +252,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index 34c305b5500b..cc5b83b62b05 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -59,6 +59,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -233,7 +239,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb b/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb index eb268f50cf5a..3a5771b4bcaf 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb @@ -142,6 +142,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -439,7 +445,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts index cae61335b783..aae84ac329d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts @@ -70,7 +70,7 @@ export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ord 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], - 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), 'status': !exists(json, 'status') ? undefined : json['status'], 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; @@ -88,7 +88,7 @@ export function OrderToJSON(value?: Order | null): any { 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, - 'shipDate': value.shipDate == null ? undefined : value.shipDate.toISOString(), + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), 'status': value.status, 'complete': value.complete, }; diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts index ecd7e174a209..2a0ca231c74a 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts @@ -82,7 +82,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), 'status': !exists(json, 'status') ? undefined : json['status'], }; } @@ -100,7 +100,7 @@ export function PetToJSON(value?: Pet | null): any { 'category': CategoryToJSON(value.category), 'name': value.name, 'photoUrls': value.photoUrls, - 'tags': value.tags == null ? undefined : (value.tags as Array).map(TagToJSON), + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), 'status': value.status, }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts index cae61335b783..aae84ac329d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts @@ -70,7 +70,7 @@ export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ord 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], - 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), 'status': !exists(json, 'status') ? undefined : json['status'], 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; @@ -88,7 +88,7 @@ export function OrderToJSON(value?: Order | null): any { 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, - 'shipDate': value.shipDate == null ? undefined : value.shipDate.toISOString(), + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), 'status': value.status, 'complete': value.complete, }; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts index ecd7e174a209..2a0ca231c74a 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts @@ -82,7 +82,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), 'status': !exists(json, 'status') ? undefined : json['status'], }; } @@ -100,7 +100,7 @@ export function PetToJSON(value?: Pet | null): any { 'category': CategoryToJSON(value.category), 'name': value.name, 'photoUrls': value.photoUrls, - 'tags': value.tags == null ? undefined : (value.tags as Array).map(TagToJSON), + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), 'status': value.status, }; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts index cae61335b783..aae84ac329d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts @@ -70,7 +70,7 @@ export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ord 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], - 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), 'status': !exists(json, 'status') ? undefined : json['status'], 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; @@ -88,7 +88,7 @@ export function OrderToJSON(value?: Order | null): any { 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, - 'shipDate': value.shipDate == null ? undefined : value.shipDate.toISOString(), + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), 'status': value.status, 'complete': value.complete, }; diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts index ecd7e174a209..2a0ca231c74a 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts @@ -82,7 +82,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), 'status': !exists(json, 'status') ? undefined : json['status'], }; } @@ -100,7 +100,7 @@ export function PetToJSON(value?: Pet | null): any { 'category': CategoryToJSON(value.category), 'name': value.name, 'photoUrls': value.photoUrls, - 'tags': value.tags == null ? undefined : (value.tags as Array).map(TagToJSON), + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), 'status': value.status, }; } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts index cae61335b783..aae84ac329d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts @@ -70,7 +70,7 @@ export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ord 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], - 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), 'status': !exists(json, 'status') ? undefined : json['status'], 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; @@ -88,7 +88,7 @@ export function OrderToJSON(value?: Order | null): any { 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, - 'shipDate': value.shipDate == null ? undefined : value.shipDate.toISOString(), + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), 'status': value.status, 'complete': value.complete, }; diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts index ecd7e174a209..2a0ca231c74a 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts @@ -82,7 +82,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), 'status': !exists(json, 'status') ? undefined : json['status'], }; } @@ -100,7 +100,7 @@ export function PetToJSON(value?: Pet | null): any { 'category': CategoryToJSON(value.category), 'name': value.name, 'photoUrls': value.photoUrls, - 'tags': value.tags == null ? undefined : (value.tags as Array).map(TagToJSON), + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), 'status': value.status, }; } diff --git a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Order.ts index cae61335b783..aae84ac329d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Order.ts @@ -70,7 +70,7 @@ export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ord 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], - 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), 'status': !exists(json, 'status') ? undefined : json['status'], 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; @@ -88,7 +88,7 @@ export function OrderToJSON(value?: Order | null): any { 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, - 'shipDate': value.shipDate == null ? undefined : value.shipDate.toISOString(), + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), 'status': value.status, 'complete': value.complete, }; diff --git a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Pet.ts index ecd7e174a209..2a0ca231c74a 100644 --- a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/models/Pet.ts @@ -82,7 +82,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), 'status': !exists(json, 'status') ? undefined : json['status'], }; } @@ -100,7 +100,7 @@ export function PetToJSON(value?: Pet | null): any { 'category': CategoryToJSON(value.category), 'name': value.name, 'photoUrls': value.photoUrls, - 'tags': value.tags == null ? undefined : (value.tags as Array).map(TagToJSON), + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), 'status': value.status, }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts index cae61335b783..aae84ac329d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts @@ -70,7 +70,7 @@ export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ord 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], - 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), 'status': !exists(json, 'status') ? undefined : json['status'], 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; @@ -88,7 +88,7 @@ export function OrderToJSON(value?: Order | null): any { 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, - 'shipDate': value.shipDate == null ? undefined : value.shipDate.toISOString(), + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), 'status': value.status, 'complete': value.complete, }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts index ecd7e174a209..2a0ca231c74a 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts @@ -82,7 +82,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), 'status': !exists(json, 'status') ? undefined : json['status'], }; } @@ -100,7 +100,7 @@ export function PetToJSON(value?: Pet | null): any { 'category': CategoryToJSON(value.category), 'name': value.name, 'photoUrls': value.photoUrls, - 'tags': value.tags == null ? undefined : (value.tags as Array).map(TagToJSON), + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), 'status': value.status, }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts index cae61335b783..aae84ac329d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts @@ -70,7 +70,7 @@ export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ord 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], - 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), 'status': !exists(json, 'status') ? undefined : json['status'], 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; @@ -88,7 +88,7 @@ export function OrderToJSON(value?: Order | null): any { 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, - 'shipDate': value.shipDate == null ? undefined : value.shipDate.toISOString(), + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), 'status': value.status, 'complete': value.complete, }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts index ecd7e174a209..2a0ca231c74a 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts @@ -82,7 +82,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), 'status': !exists(json, 'status') ? undefined : json['status'], }; } @@ -100,7 +100,7 @@ export function PetToJSON(value?: Pet | null): any { 'category': CategoryToJSON(value.category), 'name': value.name, 'photoUrls': value.photoUrls, - 'tags': value.tags == null ? undefined : (value.tags as Array).map(TagToJSON), + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), 'status': value.status, }; } diff --git a/samples/meta-codegen-kotlin/.gitignore b/samples/meta-codegen-kotlin/.gitignore new file mode 100644 index 000000000000..eb30a7a3eb78 --- /dev/null +++ b/samples/meta-codegen-kotlin/.gitignore @@ -0,0 +1,23 @@ +# Created by https://www.gitignore.io/api/gradle +# Edit at https://www.gitignore.io/?templates=gradle + +### Gradle ### +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +#!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### Gradle Patch ### +**/build/ + +# End of https://www.gitignore.io/api/gradle diff --git a/samples/meta-codegen-kotlin/gradle/wrapper/gradle-wrapper.properties b/samples/meta-codegen-kotlin/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..7c4388a92162 --- /dev/null +++ b/samples/meta-codegen-kotlin/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/meta-codegen-kotlin/gradlew b/samples/meta-codegen-kotlin/gradlew new file mode 100755 index 000000000000..cccdd3d517fc --- /dev/null +++ b/samples/meta-codegen-kotlin/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/samples/meta-codegen-kotlin/gradlew.bat b/samples/meta-codegen-kotlin/gradlew.bat new file mode 100644 index 000000000000..e95643d6a2ca --- /dev/null +++ b/samples/meta-codegen-kotlin/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/meta-codegen-kotlin/lib/README.md b/samples/meta-codegen-kotlin/lib/README.md new file mode 100644 index 000000000000..ed9aa572f291 --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/README.md @@ -0,0 +1,60 @@ +# my-client-codegen-openapi-generator + +## Requirements + +* Gradle 5.x +* Java 8+ + +## Getting Started + +* Initialize the gradle wrapper: + ```bash + gradle wrapper --gradle-version 5.6.2 + ``` +* Modify the codegen class and associated templates +* Compile with `./gradlew standalone` +* Verify: + ```bash + java -jar build/libs/my-client-codegen-openapi-generator-standalone.jar config-help -g myClientCodegen + ``` + +## Building + +### Standalone + +As seen in "Getting Started", the generator may be built as a standalone customized version of OpenAPI Generator's CLI. This may be the simplest option for developers who are unfamiliar with working in the JVM. Please be aware of any licensing concerns before distributing this "uber-jar". + +To build as a standalone, run: + +```bash +./gradlew standalone +``` + +To list generators via OpenAPI Generator CLI: + +```bash +java -jar build/libs/my-client-codegen-openapi-generator-standalone.jar list --include all +``` + +### ShadowJar + +This generator supports building as a lightweight "fat-jar". This option includes Kotlin or any other `implementation` dependencies you'll add. This will simplify publishing if your generator has many dependencies. + +To build as a shadowJar, run: + +```bash +./gradlew shadowJar +``` + +To list generators via OpenAPI Generator CLI, you must refer to the CLI jar explicitly. We add a custom copy task which includes the CLI jar in the build output directory: + +```bash +java -cp build/libs/openapi-generator-cli-4.1.3.jar:build/libs/my-client-codegen-openapi-generator-1.0-SNAPSHOT-all.jar org.openapitools.codegen.OpenAPIGenerator list +``` + +Notice that this command _must_ pass classpath via `-cp` and include OpenAPI Generator CLI as well as the artifact built from this project. Also notice that the manifest class must be passed explicitly as `org.openapitools.codegen.OpenAPIGenerator`. + +## See Also + +* [Customization docs](https://openapi-generator.tech/docs/customization) +* [Templating docs](https://openapi-generator.tech/docs/templating) diff --git a/samples/meta-codegen-kotlin/lib/build.gradle.kts b/samples/meta-codegen-kotlin/lib/build.gradle.kts new file mode 100644 index 000000000000..d3368ff515eb --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/build.gradle.kts @@ -0,0 +1,62 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("jvm") version "1.3.41" + id("com.github.johnrengelman.shadow") version("5.0.0") +} + +group = "org.openapitools" +version = "1.0-SNAPSHOT" + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + val openapiGeneratorVersion = "4.1.3" + + implementation(kotlin("stdlib-jdk8")) + implementation("org.openapitools:openapi-generator:$openapiGeneratorVersion") + + runtime("org.openapitools:openapi-generator-cli:$openapiGeneratorVersion") + + testImplementation("org.junit.jupiter:junit-jupiter:5.5.2") +} + +tasks.test { + useJUnitPlatform() + testLogging { + events("passed", "skipped", "failed") + } +} + +tasks.register("copyToLib") { + from(project.configurations.runtime) + into(File(buildDir, "libs")) +} + +tasks.register("standalone") { + archiveFileName.set("myClientCodegen-openapi-generator-standalone.jar") + archiveClassifier.set("all") + + from(sourceSets["main"].output) + + configurations.add(project.configurations["runtimeClasspath"]) + configurations.add(project.configurations["runtime"]) + + mergeServiceFiles() + + manifest.attributes(mapOf("Main-Class" to "org.openapitools.codegen.OpenAPIGenerator")) +} + +tasks.withType { + kotlinOptions.jvmTarget = "1.8" +} + +tasks.wrapper { + this.distributionType = Wrapper.DistributionType.BIN +} + +tasks.named("shadowJar") { dependsOn("copyToLib") } diff --git a/samples/meta-codegen-kotlin/lib/gradle.properties b/samples/meta-codegen-kotlin/lib/gradle.properties new file mode 100644 index 000000000000..7fc6f1ff272e --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/gradle.properties @@ -0,0 +1 @@ +kotlin.code.style=official diff --git a/samples/meta-codegen-kotlin/lib/gradle/wrapper/gradle-wrapper.properties b/samples/meta-codegen-kotlin/lib/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..7c4388a92162 --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/meta-codegen-kotlin/lib/gradlew b/samples/meta-codegen-kotlin/lib/gradlew new file mode 100755 index 000000000000..cccdd3d517fc --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/samples/meta-codegen-kotlin/lib/settings.gradle b/samples/meta-codegen-kotlin/lib/settings.gradle new file mode 100644 index 000000000000..2faa1176a29b --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'my-client-codegen-openapi-generator' diff --git a/samples/meta-codegen-kotlin/lib/src/main/kotlin/com/my/company/codegen/MyclientcodegenGenerator.kt b/samples/meta-codegen-kotlin/lib/src/main/kotlin/com/my/company/codegen/MyclientcodegenGenerator.kt new file mode 100644 index 000000000000..3ca0a620f9d5 --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/src/main/kotlin/com/my/company/codegen/MyclientcodegenGenerator.kt @@ -0,0 +1,183 @@ +@file:JvmName("MyclientcodegenGenerator") +package com.my.company.codegen + +import org.openapitools.codegen.* + +import java.util.* +import java.io.File + +open class MyclientcodegenGenerator() : DefaultCodegen(), CodegenConfig { + + // source folder where files are written + private var sourceFolder = "src" + private var apiVersion = "1.0.0" + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see org.openapitools.codegen.CodegenType + */ + override fun getTag(): CodegenType { + return CodegenType.DOCUMENTATION + } + + /** + * Configures a friendly name for the generator. This will be used by the generator + * to select the library with the -g flag. + * + * @return the friendly name for the generator + */ + override fun getName(): String { + return "myClientCodegen" + } + + /** + * Provides an opportunity to inspect and modify operation data before the code is generated. + */ + @Suppress("UNCHECKED_CAST") + override fun postProcessOperationsWithModels(objs: Map, allModels: List?): Map { + val results = super.postProcessOperationsWithModels(objs, allModels) + + val ops = results["operations"] as Map + val opList = ops["operation"] as ArrayList + + // iterate over the operation and perhaps modify something + for (co: CodegenOperation in opList) { + // example: + // co.httpMethod = co.httpMethod.toLowerCase(); + } + + return results + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + override fun getHelp(): String { + return "Generates a myClientCodegen client library." + } + + init { + // set the output folder here + outputFolder = "generated-code/myClientCodegen" + + /** + * Models. You can write model files using the modelTemplateFiles map. + * if you want to create one template for file, you can do so here. + * for multiple files for model, just put another entry in the `modelTemplateFiles` with + * a different extension + */ + modelTemplateFiles["model.mustache"] = ".sample" // the extension for each file to write + + /** + * Api classes. You can write classes for each Api file with the apiTemplateFiles map. + * as with models, add multiple entries with different extensions for multiple files per + * class + */ + apiTemplateFiles["api.mustache"] = ".sample" // the extension for each file to write + + /** + * Template Location. This is the location which templates will be read from. The generator + * will use the resource stream to attempt to read the templates. + */ + templateDir = "myClientCodegen" + + /** + * Api Package. Optional, if needed, this can be used in templates + */ + apiPackage = "org.openapitools.api" + + /** + * Model Package. Optional, if needed, this can be used in templates + */ + modelPackage = "org.openapitools.model" + + /** + * Reserved words. Override this with reserved words specific to your language + */ + reservedWords = HashSet( + listOf("sample1", "sample2") + ) + + /** + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ + additionalProperties["apiVersion"] = apiVersion + + /** + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ + supportingFiles.add( + SupportingFile( + "myFile.mustache", // the input template or file + "", // the destination folder, relative `outputFolder` + "myFile.sample" + ) // the output file + ) + + /** + * Language Specific Primitives. These types will not trigger imports by + * the client generator + */ + languageSpecificPrimitives = HashSet( + listOf("Type1", "Type2") + ) + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping + * those terms here. This logic is only called if a variable matches the reserved words + * + * @return the escaped term + */ + override fun escapeReservedWord(name: String?): String { + // add an underscore to the name if it exists. + return if (name == null) "" else "_$name" + } + + /** + * Location to write model files. You can use the modelPackage() as defined when the class is + * instantiated + */ + override fun modelFileFolder(): String { + return """$outputFolder/$sourceFolder/${modelPackage().replace('.', File.separatorChar)}""" + } + + /** + * Location to write api files. You can use the apiPackage() as defined when the class is + * instantiated + */ + override fun apiFileFolder(): String { + return """$outputFolder/$sourceFolder/${apiPackage().replace('.', File.separatorChar)}""" + } + + /** + * override with any special text escaping logic to handle unsafe + * characters so as to avoid code injection + * + * @param input String to be cleaned up + * @return string with unsafe characters removed or escaped + */ + override fun escapeUnsafeCharacters(input: String): String { + //TODO: check that this logic is safe to escape unsafe characters to avoid code injection + return input + } + + /** + * Escape single and/or double quote to avoid code injection + * + * @param input String to be cleaned up + * @return string with quotation mark removed or escaped + */ + override fun escapeQuotationMark(input: String): String { + //TODO: check that this logic is safe to escape quotation mark to avoid code injection + return with(input) { replace("\"", "\\\"") } + } +} \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/lib/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/samples/meta-codegen-kotlin/lib/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig new file mode 100644 index 000000000000..c59c7d7efc48 --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -0,0 +1 @@ +com.my.company.codegen.MyclientcodegenGenerator \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/api.mustache b/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/api.mustache new file mode 100644 index 000000000000..62802f7f1e78 --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/api.mustache @@ -0,0 +1,28 @@ + +# This is a sample api mustache template. It is representing a ficticous +# language and won't be usable or compile to anything without lots of changes. +# Use it as an example. You can access the variables in the generator object +# like such: + +# use the package from the `apiPackage` variable +package: {{package}} + +# operations block +{{#operations}} +classname: {{classname}} + +# loop over each operation in the API: +{{#operation}} + +# each operation has an `operationId`: +operationId: {{operationId}} + +# and parameters: +{{#allParams}} +{{paramName}}: {{dataType}} +{{/allParams}} + +{{/operation}} + +# end of operations block +{{/operations}} \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/model.mustache b/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/model.mustache new file mode 100644 index 000000000000..143f30f5be0d --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/model.mustache @@ -0,0 +1 @@ +# This is a sample model mustache template. \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/myFile.mustache b/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/myFile.mustache new file mode 100644 index 000000000000..6421ab03f86c --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/src/main/resources/myClientCodegen/myFile.mustache @@ -0,0 +1 @@ +# This is a sample supporting file mustache template. \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/lib/src/test/kotlin/com/my/company/codegen/MyclientcodegenGeneratorTest.kt b/samples/meta-codegen-kotlin/lib/src/test/kotlin/com/my/company/codegen/MyclientcodegenGeneratorTest.kt new file mode 100644 index 000000000000..3ebf1576b252 --- /dev/null +++ b/samples/meta-codegen-kotlin/lib/src/test/kotlin/com/my/company/codegen/MyclientcodegenGeneratorTest.kt @@ -0,0 +1,26 @@ +package com.my.company.codegen + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.openapitools.codegen.ClientOptInput +import org.openapitools.codegen.DefaultGenerator +import org.openapitools.codegen.config.CodegenConfigurator + +internal class MyclientcodegenGeneratorTest { + + // use this test to launch you code generator in the debugger. + // this allows you to easily set break points in MyclientcodegenGenerator. + @Test + fun launchCodeGenerator() { + // to understand how the 'openapi-generator-cli' module is using 'CodegenConfigurator', have a look at the 'Generate' class: + // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java + val configurator: CodegenConfigurator = CodegenConfigurator() + .setGeneratorName("myClientCodegen") + .setInputSpec("https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // or from the server + .setOutputDir("out/myClientCodegen") + + val clientOptInput: ClientOptInput = configurator.toClientOptInput() + val generator = DefaultGenerator() + generator.opts(clientOptInput).generate() + } +} \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/usage/.openapi-generator-ignore b/samples/meta-codegen-kotlin/usage/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/meta-codegen-kotlin/usage/.openapi-generator/VERSION b/samples/meta-codegen-kotlin/usage/.openapi-generator/VERSION new file mode 100644 index 000000000000..717311e32e3c --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/.openapi-generator/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/usage/myFile.sample b/samples/meta-codegen-kotlin/usage/myFile.sample new file mode 100644 index 000000000000..6421ab03f86c --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/myFile.sample @@ -0,0 +1 @@ +# This is a sample supporting file mustache template. \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/PetApi.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/PetApi.sample new file mode 100644 index 000000000000..e75a6149341a --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/PetApi.sample @@ -0,0 +1,76 @@ + +# This is a sample api mustache template. It is representing a ficticous +# language and won't be usable or compile to anything without lots of changes. +# Use it as an example. You can access the variables in the generator object +# like such: + +# use the package from the `apiPackage` variable +package: org.openapitools.api + +# operations block +classname: PetApi + +# loop over each operation in the API: + +# each operation has an `operationId`: +operationId: addPet + +# and parameters: +body: Pet + + +# each operation has an `operationId`: +operationId: deletePet + +# and parameters: +petId: Long +apiKey: String + + +# each operation has an `operationId`: +operationId: findPetsByStatus + +# and parameters: +status: List + + +# each operation has an `operationId`: +operationId: findPetsByTags + +# and parameters: +tags: List + + +# each operation has an `operationId`: +operationId: getPetById + +# and parameters: +petId: Long + + +# each operation has an `operationId`: +operationId: updatePet + +# and parameters: +body: Pet + + +# each operation has an `operationId`: +operationId: updatePetWithForm + +# and parameters: +petId: String +name: String +status: String + + +# each operation has an `operationId`: +operationId: uploadFile + +# and parameters: +petId: Long +additionalMetadata: String +file: File + + +# end of operations block diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/StoreApi.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/StoreApi.sample new file mode 100644 index 000000000000..298e7edbb0fd --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/StoreApi.sample @@ -0,0 +1,42 @@ + +# This is a sample api mustache template. It is representing a ficticous +# language and won't be usable or compile to anything without lots of changes. +# Use it as an example. You can access the variables in the generator object +# like such: + +# use the package from the `apiPackage` variable +package: org.openapitools.api + +# operations block +classname: StoreApi + +# loop over each operation in the API: + +# each operation has an `operationId`: +operationId: deleteOrder + +# and parameters: +orderId: String + + +# each operation has an `operationId`: +operationId: getInventory + +# and parameters: + + +# each operation has an `operationId`: +operationId: getOrderById + +# and parameters: +orderId: String + + +# each operation has an `operationId`: +operationId: placeOrder + +# and parameters: +body: Order + + +# end of operations block diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/UserApi.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/UserApi.sample new file mode 100644 index 000000000000..ebc744ed975e --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/api/UserApi.sample @@ -0,0 +1,72 @@ + +# This is a sample api mustache template. It is representing a ficticous +# language and won't be usable or compile to anything without lots of changes. +# Use it as an example. You can access the variables in the generator object +# like such: + +# use the package from the `apiPackage` variable +package: org.openapitools.api + +# operations block +classname: UserApi + +# loop over each operation in the API: + +# each operation has an `operationId`: +operationId: createUser + +# and parameters: +body: User + + +# each operation has an `operationId`: +operationId: createUsersWithArrayInput + +# and parameters: +body: List + + +# each operation has an `operationId`: +operationId: createUsersWithListInput + +# and parameters: +body: List + + +# each operation has an `operationId`: +operationId: deleteUser + +# and parameters: +username: String + + +# each operation has an `operationId`: +operationId: getUserByName + +# and parameters: +username: String + + +# each operation has an `operationId`: +operationId: loginUser + +# and parameters: +username: String +password: String + + +# each operation has an `operationId`: +operationId: logoutUser + +# and parameters: + + +# each operation has an `operationId`: +operationId: updateUser + +# and parameters: +username: String +body: User + + +# end of operations block diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Category.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Category.sample new file mode 100644 index 000000000000..143f30f5be0d --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Category.sample @@ -0,0 +1 @@ +# This is a sample model mustache template. \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Order.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Order.sample new file mode 100644 index 000000000000..143f30f5be0d --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Order.sample @@ -0,0 +1 @@ +# This is a sample model mustache template. \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Pet.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Pet.sample new file mode 100644 index 000000000000..143f30f5be0d --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Pet.sample @@ -0,0 +1 @@ +# This is a sample model mustache template. \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Tag.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Tag.sample new file mode 100644 index 000000000000..143f30f5be0d --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/Tag.sample @@ -0,0 +1 @@ +# This is a sample model mustache template. \ No newline at end of file diff --git a/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/User.sample b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/User.sample new file mode 100644 index 000000000000..143f30f5be0d --- /dev/null +++ b/samples/meta-codegen-kotlin/usage/src/org/openapitools/model/User.sample @@ -0,0 +1 @@ +# This is a sample model mustache template. \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index 5e7a95a35f3b..46e568df26ab 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -622,11 +622,11 @@ def __deserialize_model(self, data, klass): return data kwargs = {} - if klass.openapi_types is not None: + if (data is not None and + klass.openapi_types is not None and + isinstance(data, (list, dict))): for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb index db0a19529b9d..bda9712d12af 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -182,7 +188,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/animal.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/animal.rb index fb2487e99aa1..abc65e4d227c 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/animal.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/animal.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # discriminator's property name in OpenAPI v3 def self.openapi_discriminator_name :'class_name' @@ -190,7 +196,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb index 1ec744fd6fc4..17835d6215bc 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb index 3d7b6966c5ab..5abad943b7ba 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb index 1717f521e714..16e11fbcd7a5 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb index 893302c2ef8f..3f2b0883805f 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -193,7 +199,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb index 94bfa2273add..2fa82ea749e3 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb @@ -51,6 +51,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -215,7 +221,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat.rb index 637b67a38b66..66983cbfd5e1 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb index 6dc13cbd2b85..29514833eba1 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/cat_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/category.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/category.rb index d7e6a1fd9eb9..4e535ea49788 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/category.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/category.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -185,7 +191,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb index d24a651b6dfa..fd1c582de00f 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/client.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/client.rb index 9457f2591e82..59cbd23b927d 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/client.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/client.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog.rb index 3d6bfce3f827..4b06d9e93e9d 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb index 61a55de7ffaa..edbc2d01be84 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/dog_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb index b3b26138785e..7bcce6fcbdb2 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb @@ -56,6 +56,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -214,7 +220,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb index 28adcff9fb6a..ec4d96613617 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb @@ -80,6 +80,13 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'outer_enum', + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -307,7 +314,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file.rb index b71a8676b76e..76a98abaa7bf 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file.rb @@ -32,6 +32,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb index dab73dc4bcbb..55ae9ed867b6 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/foo.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/foo.rb index 32b1a33570ef..6742735e38a5 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/foo.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/foo.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb index 9dc3296dfb52..b70408419487 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb @@ -88,6 +88,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -520,7 +526,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb index 2c22b38453f3..56cf4f959626 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb index ea946134b5d5..9366423e0b7c 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb @@ -31,6 +31,13 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'nullable_message' + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb index 3140ed41a420..a43f8f5664ab 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb index 27557505ca70..932e507dc15c 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb index 73e500af56eb..1f8d88c018dc 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb @@ -58,6 +58,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -218,7 +224,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb index 6ab144d8fd09..ae4cf54c66a4 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb @@ -96,6 +96,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -501,7 +507,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb index 255475c06f7e..32034cbef4fc 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -190,7 +196,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb index 2a213bb0c0cf..245c45e58d5d 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -185,7 +191,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_response_default.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_response_default.rb index 8b5c138c1595..81e29fe689f0 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_response_default.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/inline_response_default.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/list.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/list.rb index a6770da4d348..24d06293854f 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/list.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/list.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb index 3974d29af515..2445ce5a3616 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb @@ -64,6 +64,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -226,7 +232,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 991773081e33..829b4c83c493 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -189,7 +195,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb index 6858f297eaef..2cc48793f574 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb @@ -35,6 +35,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -179,7 +185,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb index 8f5040f9f376..b2b054e82c98 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/name.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/name.rb index d3c3fe021c35..c2c0f728c680 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/name.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/name.rb @@ -43,6 +43,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -202,7 +208,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb index 959f610a9590..fb7ad5cf332b 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb @@ -74,6 +74,22 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'integer_prop', + :'number_prop', + :'boolean_prop', + :'string_prop', + :'date_prop', + :'datetime_prop', + :'array_nullable_prop', + :'array_and_items_nullable_prop', + :'object_nullable_prop', + :'object_and_items_nullable_prop', + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -280,7 +296,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb index b7490b8a77f1..cb8739074c0a 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/order.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/order.rb index e7280550f551..9d025ec60aa4 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/order.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/order.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -251,7 +257,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb index a7155714e13c..f17fd5ed9902 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/pet.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/pet.rb index 6aebd504d0a7..d2e84bb116c6 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/pet.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/pet.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -263,7 +269,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb index 36c5476c27c1..a0c6236adf6a 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb index 38a7ad79b181..d31b38e75709 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/tag.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/tag.rb index fe7741c5dae3..548cf6e660bb 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/tag.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/tag.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/user.rb b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/user.rb index 34c305b5500b..cc5b83b62b05 100644 --- a/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/user.rb +++ b/samples/openapi3/client/petstore/ruby-faraday/lib/petstore/models/user.rb @@ -59,6 +59,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -233,7 +239,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index db0a19529b9d..bda9712d12af 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -182,7 +188,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb index fb2487e99aa1..abc65e4d227c 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # discriminator's property name in OpenAPI v3 def self.openapi_discriminator_name :'class_name' @@ -190,7 +196,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb index 1ec744fd6fc4..17835d6215bc 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb index 3d7b6966c5ab..5abad943b7ba 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb index 1717f521e714..16e11fbcd7a5 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb index 893302c2ef8f..3f2b0883805f 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -193,7 +199,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb index 94bfa2273add..2fa82ea749e3 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -51,6 +51,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -215,7 +221,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb index 637b67a38b66..66983cbfd5e1 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat_all_of.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat_all_of.rb index 6dc13cbd2b85..29514833eba1 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat_all_of.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb index d7e6a1fd9eb9..4e535ea49788 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -185,7 +191,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb index d24a651b6dfa..fd1c582de00f 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb index 9457f2591e82..59cbd23b927d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb index 3d6bfce3f827..4b06d9e93e9d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ @@ -181,7 +187,11 @@ def to_hash hash = super self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog_all_of.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog_all_of.rb index 61a55de7ffaa..edbc2d01be84 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog_all_of.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog_all_of.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb index b3b26138785e..7bcce6fcbdb2 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -56,6 +56,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -214,7 +220,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb index 28adcff9fb6a..ec4d96613617 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -80,6 +80,13 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'outer_enum', + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -307,7 +314,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb index b71a8676b76e..76a98abaa7bf 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb @@ -32,6 +32,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb index dab73dc4bcbb..55ae9ed867b6 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb index 32b1a33570ef..6742735e38a5 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -171,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb index 9dc3296dfb52..b70408419487 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -88,6 +88,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -520,7 +526,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb index 2c22b38453f3..56cf4f959626 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb index ea946134b5d5..9366423e0b7c 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb @@ -31,6 +31,13 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'nullable_message' + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +177,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object.rb index 3140ed41a420..a43f8f5664ab 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object1.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object1.rb index 27557505ca70..932e507dc15c 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object1.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object1.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -180,7 +186,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object2.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object2.rb index 73e500af56eb..1f8d88c018dc 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object2.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object2.rb @@ -58,6 +58,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -218,7 +224,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object3.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object3.rb index 6ab144d8fd09..ae4cf54c66a4 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object3.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object3.rb @@ -96,6 +96,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -501,7 +507,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object4.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object4.rb index 255475c06f7e..32034cbef4fc 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object4.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object4.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -190,7 +196,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object5.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object5.rb index 2a213bb0c0cf..245c45e58d5d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object5.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_object5.rb @@ -36,6 +36,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -185,7 +191,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb index 8b5c138c1595..81e29fe689f0 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb index a6770da4d348..24d06293854f 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb index 3974d29af515..2445ce5a3616 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -64,6 +64,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -226,7 +232,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 991773081e33..829b4c83c493 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -189,7 +195,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb index 6858f297eaef..2cc48793f574 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -35,6 +35,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -179,7 +185,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb index 8f5040f9f376..b2b054e82c98 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -31,6 +31,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -170,7 +176,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb index d3c3fe021c35..c2c0f728c680 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb @@ -43,6 +43,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -202,7 +208,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/nullable_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/nullable_class.rb index 959f610a9590..fb7ad5cf332b 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/nullable_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/nullable_class.rb @@ -74,6 +74,22 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'integer_prop', + :'number_prop', + :'boolean_prop', + :'string_prop', + :'date_prop', + :'datetime_prop', + :'array_nullable_prop', + :'array_and_items_nullable_prop', + :'object_nullable_prop', + :'object_and_items_nullable_prop', + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -280,7 +296,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb index b7490b8a77f1..cb8739074c0a 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb index e7280550f551..9d025ec60aa4 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -251,7 +257,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb index a7155714e13c..f17fd5ed9902 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -38,6 +38,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -187,7 +193,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb index 6aebd504d0a7..d2e84bb116c6 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb @@ -73,6 +73,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -263,7 +269,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb index 36c5476c27c1..a0c6236adf6a 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 38a7ad79b181..d31b38e75709 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -30,6 +30,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -169,7 +175,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb index fe7741c5dae3..548cf6e660bb 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb @@ -34,6 +34,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -178,7 +184,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb index 34c305b5500b..cc5b83b62b05 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb @@ -59,6 +59,12 @@ def self.openapi_types } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -233,7 +239,11 @@ def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + hash[param] = _to_hash(value) end hash diff --git a/samples/server/petstore/aspnetcore/.openapi-generator/VERSION b/samples/server/petstore/aspnetcore/.openapi-generator/VERSION index 2f81801b7943..0e97bd19efbf 100644 --- a/samples/server/petstore/aspnetcore/.openapi-generator/VERSION +++ b/samples/server/petstore/aspnetcore/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.1-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json index a0a4803cd077..ec994f8fca35 100644 --- a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -1,35 +1,32 @@ { "openapi" : "3.0.1", "info" : { - "title" : "OpenAPI Petstore", "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", "license" : { "name" : "Apache-2.0", "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" }, + "title" : "OpenAPI Petstore", "version" : "1.0.0" }, "servers" : [ { "url" : "http://petstore.swagger.io/v2" } ], "tags" : [ { - "name" : "pet", - "description" : "Everything about your Pets" + "description" : "Everything about your Pets", + "name" : "pet" }, { - "name" : "store", - "description" : "Access to Petstore orders" + "description" : "Access to Petstore orders", + "name" : "store" }, { - "name" : "user", - "description" : "Operations about user" + "description" : "Operations about user", + "name" : "user" } ], "paths" : { "/pet" : { - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "operationId" : "updatePet", + "post" : { + "operationId" : "addPet", "requestBody" : { - "description" : "Pet object that needs to be added to the store", "content" : { "application/json" : { "schema" : { @@ -42,33 +39,25 @@ } } }, + "description" : "Pet object that needs to be added to the store", "required" : true }, "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - }, "405" : { - "description" : "Validation exception", - "content" : { } + "content" : { }, + "description" : "Invalid input" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ], "x-codegen-request-body-name" : "body" }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "operationId" : "addPet", + "put" : { + "operationId" : "updatePet", "requestBody" : { - "description" : "Pet object that needs to be added to the store", "content" : { "application/json" : { "schema" : { @@ -81,146 +70,184 @@ } } }, + "description" : "Pet object that needs to be added to the store", "required" : true }, "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Pet not found" + }, "405" : { - "description" : "Invalid input", - "content" : { } + "content" : { }, + "description" : "Validation exception" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ], "x-codegen-request-body-name" : "body" } }, "/pet/findByStatus" : { "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", "description" : "Multiple status values can be provided with comma separated strings", "operationId" : "findPetsByStatus", "parameters" : [ { - "name" : "status", - "in" : "query", "description" : "Status values that need to be considered for filter", - "required" : true, - "style" : "form", "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, "schema" : { - "type" : "array", "items" : { - "type" : "string", "default" : "available", - "enum" : [ "available", "pending", "sold" ] - } - } + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } }, "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid status value", - "content" : { } + "content" : { }, + "description" : "Invalid status value" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] } }, "/pet/findByTags" : { "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", + "deprecated" : true, "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", "operationId" : "findPetsByTags", "parameters" : [ { - "name" : "tags", - "in" : "query", "description" : "Tags to filter by", - "required" : true, - "style" : "form", "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, "schema" : { - "type" : "array", "items" : { "type" : "string" - } - } + }, + "type" : "array" + }, + "style" : "form" } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } }, "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid tag value", - "content" : { } + "content" : { }, + "description" : "Invalid tag value" } }, - "deprecated" : true, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] } }, "/pet/{petId}" : { + "delete" : { + "operationId" : "deletePet", + "parameters" : [ { + "in" : "header", + "name" : "api_key", + "schema" : { + "type" : "string" + } + }, { + "description" : "Pet id to delete", + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", "description" : "Returns a single pet", "operationId" : "getPetById", "parameters" : [ { - "name" : "petId", - "in" : "path", "description" : "ID of pet to return", + "in" : "path", + "name" : "petId", "required" : true, "schema" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" } } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -232,33 +259,34 @@ "$ref" : "#/components/schemas/Pet" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid ID supplied", - "content" : { } + "content" : { }, + "description" : "Invalid ID supplied" }, "404" : { - "description" : "Pet not found", - "content" : { } + "content" : { }, + "description" : "Pet not found" } }, "security" : [ { "api_key" : [ ] - } ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] }, "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", "operationId" : "updatePetWithForm", "parameters" : [ { - "name" : "petId", - "in" : "path", "description" : "ID of pet that needs to be updated", + "in" : "path", + "name" : "petId", "required" : true, "schema" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" } } ], "requestBody" : { @@ -267,12 +295,12 @@ "schema" : { "properties" : { "name" : { - "type" : "string", - "description" : "Updated name of the pet" + "description" : "Updated name of the pet", + "type" : "string" }, "status" : { - "type" : "string", - "description" : "Updated status of the pet" + "description" : "Updated status of the pet", + "type" : "string" } } } @@ -281,58 +309,28 @@ }, "responses" : { "405" : { - "description" : "Invalid input", - "content" : { } + "content" : { }, + "description" : "Invalid input" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "operationId" : "deletePet", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "schema" : { - "type" : "string" - } - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } } ], - "responses" : { - "400" : { - "description" : "Invalid pet value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] } }, "/pet/{petId}/uploadImage" : { "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", "operationId" : "uploadFile", "parameters" : [ { - "name" : "petId", - "in" : "path", "description" : "ID of pet to update", + "in" : "path", + "name" : "petId", "required" : true, "schema" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" } } ], "requestBody" : { @@ -341,13 +339,13 @@ "schema" : { "properties" : { "additionalMetadata" : { - "type" : "string", - "description" : "Additional data to pass to server" + "description" : "Additional data to pass to server", + "type" : "string" }, "file" : { - "type" : "string", "description" : "file to upload", - "format" : "binary" + "format" : "binary", + "type" : "string" } } } @@ -356,55 +354,54 @@ }, "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/ApiResponse" } } - } + }, + "description" : "successful operation" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] } }, "/store/inventory" : { "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", "description" : "Returns a map of status codes to quantities", "operationId" : "getInventory", "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/json" : { "schema" : { - "type" : "object", "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } + "format" : "int32", + "type" : "integer" + }, + "type" : "object" } } - } + }, + "description" : "successful operation" } }, "security" : [ { "api_key" : [ ] - } ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] } }, "/store/order" : { "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", "operationId" : "placeOrder", "requestBody" : { - "description" : "order placed for purchasing the pet", "content" : { "*/*" : { "schema" : { @@ -412,11 +409,11 @@ } } }, + "description" : "order placed for purchasing the pet", "required" : true }, "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -428,37 +425,62 @@ "$ref" : "#/components/schemas/Order" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid Order", - "content" : { } + "content" : { }, + "description" : "Invalid Order" } }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ], "x-codegen-request-body-name" : "body" } }, "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", "operationId" : "getOrderById", "parameters" : [ { - "name" : "orderId", - "in" : "path", "description" : "ID of pet that needs to be fetched", + "in" : "path", + "name" : "orderId", "required" : true, "schema" : { + "format" : "int64", "maximum" : 5, "minimum" : 1, - "type" : "integer", - "format" : "int64" + "type" : "integer" } } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -470,52 +492,27 @@ "$ref" : "#/components/schemas/Order" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid ID supplied", - "content" : { } + "content" : { }, + "description" : "Invalid ID supplied" }, "404" : { - "description" : "Order not found", - "content" : { } - } - } - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" + "content" : { }, + "description" : "Order not found" } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] } }, "/user" : { "post" : { - "tags" : [ "user" ], - "summary" : "Create user", "description" : "This can only be done by the logged in user.", "operationId" : "createUser", "requestBody" : { - "description" : "Created user object", "content" : { "*/*" : { "schema" : { @@ -523,90 +520,91 @@ } } }, + "description" : "Created user object", "required" : true }, "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } }, + "summary" : "Create user", + "tags" : [ "user" ], "x-codegen-request-body-name" : "body" } }, "/user/createWithArray" : { "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", "operationId" : "createUsersWithArrayInput", "requestBody" : { - "description" : "List of user object", "content" : { "*/*" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/User" - } + }, + "type" : "array" } } }, + "description" : "List of user object", "required" : true }, "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } }, + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ], "x-codegen-request-body-name" : "body" } }, "/user/createWithList" : { "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", "operationId" : "createUsersWithListInput", "requestBody" : { - "description" : "List of user object", "content" : { "*/*" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/User" - } + }, + "type" : "array" } } }, + "description" : "List of user object", "required" : true }, "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } }, + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ], "x-codegen-request-body-name" : "body" } }, "/user/login" : { "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", "operationId" : "loginUser", "parameters" : [ { - "name" : "username", - "in" : "query", "description" : "The user name for login", + "in" : "query", + "name" : "username", "required" : true, "schema" : { "type" : "string" } }, { - "name" : "password", - "in" : "query", "description" : "The password for login in clear text", + "in" : "query", + "name" : "password", "required" : true, "schema" : { "type" : "string" @@ -614,65 +612,90 @@ } ], "responses" : { "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", + "content" : { + "application/xml" : { "schema" : { - "type" : "integer", - "format" : "int32" + "type" : "string" } }, - "X-Expires-After" : { - "description" : "date in UTC when toekn expires", + "application/json" : { "schema" : { - "type" : "string", - "format" : "date-time" + "type" : "string" } } }, - "content" : { - "application/xml" : { + "description" : "successful operation", + "headers" : { + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", "schema" : { - "type" : "string" + "format" : "int32", + "type" : "integer" } }, - "application/json" : { + "X-Expires-After" : { + "description" : "date in UTC when toekn expires", "schema" : { + "format" : "date-time", "type" : "string" } } } }, "400" : { - "description" : "Invalid username/password supplied", - "content" : { } + "content" : { }, + "description" : "Invalid username/password supplied" } - } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] } }, "/user/logout" : { "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", "operationId" : "logoutUser", "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } - } + }, + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] } }, "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid username supplied" + }, + "404" : { + "content" : { }, + "description" : "User not found" + } + }, + "summary" : "Delete user", + "tags" : [ "user" ] + }, "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", "operationId" : "getUserByName", "parameters" : [ { - "name" : "username", - "in" : "path", "description" : "The name that needs to be fetched. Use user1 for testing.", + "in" : "path", + "name" : "username", "required" : true, "schema" : { "type" : "string" @@ -680,7 +703,6 @@ } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -692,34 +714,34 @@ "$ref" : "#/components/schemas/User" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid username supplied", - "content" : { } + "content" : { }, + "description" : "Invalid username supplied" }, "404" : { - "description" : "User not found", - "content" : { } + "content" : { }, + "description" : "User not found" } - } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] }, "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", "description" : "This can only be done by the logged in user.", "operationId" : "updateUser", "parameters" : [ { - "name" : "username", - "in" : "path", "description" : "name that need to be deleted", + "in" : "path", + "name" : "username", "required" : true, "schema" : { "type" : "string" } } ], "requestBody" : { - "description" : "Updated user object", "content" : { "*/*" : { "schema" : { @@ -727,120 +749,107 @@ } } }, + "description" : "Updated user object", "required" : true }, "responses" : { "400" : { - "description" : "Invalid user supplied", - "content" : { } + "content" : { }, + "description" : "Invalid user supplied" }, "404" : { - "description" : "User not found", - "content" : { } + "content" : { }, + "description" : "User not found" } }, - "x-codegen-request-body-name" : "body" - }, - "delete" : { + "summary" : "Updated user", "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - } + "x-codegen-request-body-name" : "body" } } }, "components" : { "schemas" : { "Order" : { - "title" : "Pet Order", - "type" : "object", + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "petId" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "quantity" : { - "type" : "integer", - "format" : "int32" + "format" : "int32", + "type" : "integer" }, "shipDate" : { - "type" : "string", - "format" : "date-time" + "format" : "date-time", + "type" : "string" }, "status" : { - "type" : "string", "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" }, "complete" : { - "type" : "boolean", - "default" : false + "default" : false, + "type" : "boolean" } }, - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, + "title" : "Pet Order", + "type" : "object", "xml" : { "name" : "Order" } }, "Category" : { - "title" : "Pet category", - "type" : "object", + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "name" : { "type" : "string" } }, - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, + "title" : "Pet category", + "type" : "object", "xml" : { "name" : "Category" } }, "User" : { - "title" : "a User", - "type" : "object", + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "username" : { "type" : "string" @@ -861,118 +870,113 @@ "type" : "string" }, "userStatus" : { - "type" : "integer", "description" : "User Status", - "format" : "int32" + "format" : "int32", + "type" : "integer" } }, - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, + "title" : "a User", + "type" : "object", "xml" : { "name" : "User" } }, "Tag" : { - "title" : "Pet Tag", - "type" : "object", + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "name" : { "type" : "string" } }, - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, + "title" : "Pet Tag", + "type" : "object", "xml" : { "name" : "Tag" } }, "Pet" : { - "title" : "a Pet", - "required" : [ "name", "photoUrls" ], - "type" : "object", + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "category" : { "$ref" : "#/components/schemas/Category" }, "name" : { - "type" : "string", - "example" : "doggie" + "example" : "doggie", + "type" : "string" }, "photoUrls" : { + "items" : { + "type" : "string" + }, "type" : "array", "xml" : { "name" : "photoUrl", "wrapped" : true - }, - "items" : { - "type" : "string" } }, "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, "type" : "array", "xml" : { "name" : "tag", "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" } }, "status" : { - "type" : "string", "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] + "enum" : [ "available", "pending", "sold" ], + "type" : "string" } }, - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", "xml" : { "name" : "Pet" } }, "ApiResponse" : { - "title" : "An uploaded response", - "type" : "object", + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, "properties" : { "code" : { - "type" : "integer", - "format" : "int32" + "format" : "int32", + "type" : "integer" }, "type" : { "type" : "string" @@ -981,17 +985,12 @@ "type" : "string" } }, - "description" : "Describes the result of uploading an image resource", - "example" : { - "code" : 0, - "type" : "type", - "message" : "message" - } + "title" : "An uploaded response", + "type" : "object" } }, "securitySchemes" : { "petstore_auth" : { - "type" : "oauth2", "flows" : { "implicit" : { "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", @@ -1000,12 +999,13 @@ "read:pets" : "read your pets" } } - } + }, + "type" : "oauth2" }, "api_key" : { - "type" : "apiKey", + "in" : "header", "name" : "api_key", - "in" : "header" + "type" : "apiKey" } } } diff --git a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION index c3a2c7076fa8..d168f1d8bdaa 100644 --- a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION +++ b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +4.2.1-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/cpp-pistache/CMakeLists.txt b/samples/server/petstore/cpp-pistache/CMakeLists.txt index 0cd21eda2986..992a04bf681d 100644 --- a/samples/server/petstore/cpp-pistache/CMakeLists.txt +++ b/samples/server/petstore/cpp-pistache/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.2) project(api-server) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pg -g3" ) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pg -g3" ) include(ExternalProject) diff --git a/samples/server/petstore/go-api-server/go/api_pet.go b/samples/server/petstore/go-api-server/go/api_pet.go index 3f12afa82cdf..f5275ecbef31 100644 --- a/samples/server/petstore/go-api-server/go/api_pet.go +++ b/samples/server/petstore/go-api-server/go/api_pet.go @@ -95,7 +95,7 @@ func (c *PetApiController) AddPet(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // DeletePet - Deletes a pet @@ -114,7 +114,7 @@ func (c *PetApiController) DeletePet(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // FindPetsByStatus - Finds Pets by status @@ -127,7 +127,7 @@ func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Reque return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // FindPetsByTags - Finds Pets by tags @@ -140,7 +140,7 @@ func (c *PetApiController) FindPetsByTags(w http.ResponseWriter, r *http.Request return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // GetPetById - Find pet by ID @@ -158,7 +158,7 @@ func (c *PetApiController) GetPetById(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // UpdatePet - Update an existing pet @@ -175,7 +175,7 @@ func (c *PetApiController) UpdatePet(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // UpdatePetWithForm - Updates a pet in the store with form data @@ -201,7 +201,7 @@ func (c *PetApiController) UpdatePetWithForm(w http.ResponseWriter, r *http.Requ return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // UploadFile - uploads an image @@ -232,5 +232,5 @@ func (c *PetApiController) UploadFile(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } diff --git a/samples/server/petstore/go-api-server/go/api_store.go b/samples/server/petstore/go-api-server/go/api_store.go index c67296a24249..fc9da3c0ee54 100644 --- a/samples/server/petstore/go-api-server/go/api_store.go +++ b/samples/server/petstore/go-api-server/go/api_store.go @@ -67,7 +67,7 @@ func (c *StoreApiController) DeleteOrder(w http.ResponseWriter, r *http.Request) return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // GetInventory - Returns pet inventories by status @@ -78,7 +78,7 @@ func (c *StoreApiController) GetInventory(w http.ResponseWriter, r *http.Request return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // GetOrderById - Find purchase order by ID @@ -96,7 +96,7 @@ func (c *StoreApiController) GetOrderById(w http.ResponseWriter, r *http.Request return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // PlaceOrder - Place an order for a pet @@ -113,5 +113,5 @@ func (c *StoreApiController) PlaceOrder(w http.ResponseWriter, r *http.Request) return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } diff --git a/samples/server/petstore/go-api-server/go/api_user.go b/samples/server/petstore/go-api-server/go/api_user.go index f883fc9f886e..a6618b9d62db 100644 --- a/samples/server/petstore/go-api-server/go/api_user.go +++ b/samples/server/petstore/go-api-server/go/api_user.go @@ -95,7 +95,7 @@ func (c *UserApiController) CreateUser(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // CreateUsersWithArrayInput - Creates list of users with given input array @@ -112,7 +112,7 @@ func (c *UserApiController) CreateUsersWithArrayInput(w http.ResponseWriter, r * return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // CreateUsersWithListInput - Creates list of users with given input array @@ -129,7 +129,7 @@ func (c *UserApiController) CreateUsersWithListInput(w http.ResponseWriter, r *h return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // DeleteUser - Delete user @@ -142,7 +142,7 @@ func (c *UserApiController) DeleteUser(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // GetUserByName - Get user by user name @@ -155,7 +155,7 @@ func (c *UserApiController) GetUserByName(w http.ResponseWriter, r *http.Request return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // LoginUser - Logs user into the system @@ -169,7 +169,7 @@ func (c *UserApiController) LoginUser(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // LogoutUser - Logs out current logged in user session @@ -180,7 +180,7 @@ func (c *UserApiController) LogoutUser(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } // UpdateUser - Updated user @@ -199,5 +199,5 @@ func (c *UserApiController) UpdateUser(w http.ResponseWriter, r *http.Request) { return } - EncodeJSONResponse(result, nil, w) + EncodeJSONResponse(result, nil, w) } diff --git a/samples/server/petstore/go-api-server/go/routers.go b/samples/server/petstore/go-api-server/go/routers.go index 5663164f6e58..bffdd7ec3675 100644 --- a/samples/server/petstore/go-api-server/go/routers.go +++ b/samples/server/petstore/go-api-server/go/routers.go @@ -15,7 +15,6 @@ import ( "net/http" "os" "strconv" - "github.com/gorilla/mux" ) diff --git a/samples/server/petstore/ruby-on-rails/.openapi-generator/VERSION b/samples/server/petstore/ruby-on-rails/.openapi-generator/VERSION index 4395ff592326..d168f1d8bdaa 100644 --- a/samples/server/petstore/ruby-on-rails/.openapi-generator/VERSION +++ b/samples/server/petstore/ruby-on-rails/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +4.2.1-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/ruby-on-rails/app/controllers/pet_controller.rb b/samples/server/petstore/ruby-on-rails/app/controllers/pet_controller.rb index 8b0bdc79ca8f..dfff064d1451 100644 --- a/samples/server/petstore/ruby-on-rails/app/controllers/pet_controller.rb +++ b/samples/server/petstore/ruby-on-rails/app/controllers/pet_controller.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/controllers/store_controller.rb b/samples/server/petstore/ruby-on-rails/app/controllers/store_controller.rb index 2f9652e99def..ba2a41feeaa9 100644 --- a/samples/server/petstore/ruby-on-rails/app/controllers/store_controller.rb +++ b/samples/server/petstore/ruby-on-rails/app/controllers/store_controller.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/controllers/user_controller.rb b/samples/server/petstore/ruby-on-rails/app/controllers/user_controller.rb index 33e22a3b8da4..2fe71c35b172 100644 --- a/samples/server/petstore/ruby-on-rails/app/controllers/user_controller.rb +++ b/samples/server/petstore/ruby-on-rails/app/controllers/user_controller.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/models/api_response.rb b/samples/server/petstore/ruby-on-rails/app/models/api_response.rb index 310396b1d774..0c1e6d50b9a4 100644 --- a/samples/server/petstore/ruby-on-rails/app/models/api_response.rb +++ b/samples/server/petstore/ruby-on-rails/app/models/api_response.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/models/category.rb b/samples/server/petstore/ruby-on-rails/app/models/category.rb index 2063e8d9b43a..49063118caec 100644 --- a/samples/server/petstore/ruby-on-rails/app/models/category.rb +++ b/samples/server/petstore/ruby-on-rails/app/models/category.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/models/inline_object.rb b/samples/server/petstore/ruby-on-rails/app/models/inline_object.rb new file mode 100644 index 000000000000..0295f078e06b --- /dev/null +++ b/samples/server/petstore/ruby-on-rails/app/models/inline_object.rb @@ -0,0 +1,14 @@ +=begin +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://github.com/openapitools/openapi-generator.git + +=end + + +class InlineObject < ApplicationRecord + +end diff --git a/samples/server/petstore/ruby-on-rails/app/models/inline_object_1.rb b/samples/server/petstore/ruby-on-rails/app/models/inline_object_1.rb new file mode 100644 index 000000000000..b8a3bcb66cd0 --- /dev/null +++ b/samples/server/petstore/ruby-on-rails/app/models/inline_object_1.rb @@ -0,0 +1,14 @@ +=begin +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://github.com/openapitools/openapi-generator.git + +=end + + +class InlineObject1 < ApplicationRecord + +end diff --git a/samples/server/petstore/ruby-on-rails/app/models/order.rb b/samples/server/petstore/ruby-on-rails/app/models/order.rb index 8c08266bb8ba..5bf6bc33f560 100644 --- a/samples/server/petstore/ruby-on-rails/app/models/order.rb +++ b/samples/server/petstore/ruby-on-rails/app/models/order.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/models/pet.rb b/samples/server/petstore/ruby-on-rails/app/models/pet.rb index b749610040a8..be067cf6eca8 100644 --- a/samples/server/petstore/ruby-on-rails/app/models/pet.rb +++ b/samples/server/petstore/ruby-on-rails/app/models/pet.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/models/tag.rb b/samples/server/petstore/ruby-on-rails/app/models/tag.rb index 302ed77e3346..b949dfb574ba 100644 --- a/samples/server/petstore/ruby-on-rails/app/models/tag.rb +++ b/samples/server/petstore/ruby-on-rails/app/models/tag.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/app/models/user.rb b/samples/server/petstore/ruby-on-rails/app/models/user.rb index 8df3aa77ef36..53263747e9b4 100644 --- a/samples/server/petstore/ruby-on-rails/app/models/user.rb +++ b/samples/server/petstore/ruby-on-rails/app/models/user.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/config/routes.rb b/samples/server/petstore/ruby-on-rails/config/routes.rb index 98a423786e5c..6b591017a9eb 100644 --- a/samples/server/petstore/ruby-on-rails/config/routes.rb +++ b/samples/server/petstore/ruby-on-rails/config/routes.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end diff --git a/samples/server/petstore/ruby-on-rails/db/migrate/0_init_tables.rb b/samples/server/petstore/ruby-on-rails/db/migrate/0_init_tables.rb index ba2dfae7f042..fbf324f2d198 100644 --- a/samples/server/petstore/ruby-on-rails/db/migrate/0_init_tables.rb +++ b/samples/server/petstore/ruby-on-rails/db/migrate/0_init_tables.rb @@ -3,7 +3,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -OpenAPI spec version: 1.0.0 +The version of the OpenAPI document: 1.0.0 Generated by: https://github.com/openapitools/openapi-generator.git =end @@ -25,6 +25,20 @@ def change t.timestamps end + create_table "inline_object".pluralize.to_sym, id: false do |t| + t.string :name + t.string :status + + t.timestamps + end + + create_table "inline_object_1".pluralize.to_sym, id: false do |t| + t.string :additional_metadata + t.File :file + + t.timestamps + end + create_table "order".pluralize.to_sym, id: false do |t| t.integer :id t.integer :pet_id diff --git a/samples/server/petstore/ruby-sinatra/.openapi-generator/VERSION b/samples/server/petstore/ruby-sinatra/.openapi-generator/VERSION index dde25ef08e8c..d168f1d8bdaa 100644 --- a/samples/server/petstore/ruby-sinatra/.openapi-generator/VERSION +++ b/samples/server/petstore/ruby-sinatra/.openapi-generator/VERSION @@ -1 +1 @@ -3.1.1-SNAPSHOT \ No newline at end of file +4.2.1-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/ruby-sinatra/openapi.yaml b/samples/server/petstore/ruby-sinatra/openapi.yaml index c0b60f85ddeb..b8e8bf1ec35b 100644 --- a/samples/server/petstore/ruby-sinatra/openapi.yaml +++ b/samples/server/petstore/ruby-sinatra/openapi.yaml @@ -1,11 +1,15 @@ -openapi: 3.0.1 +openapi: 3.0.0 info: - description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + description: This is a sample server Petstore server. For this sample, you can use + the api key `special-key` to test the authorization filters. license: name: Apache-2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html title: OpenAPI Petstore version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io servers: - url: http://petstore.swagger.io/v2 tags: @@ -20,18 +24,9 @@ paths: post: operationId: addPet requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true + $ref: '#/components/requestBodies/Pet' responses: 405: - content: {} description: Invalid input security: - petstore_auth: @@ -43,24 +38,13 @@ paths: put: operationId: updatePet requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true + $ref: '#/components/requestBodies/Pet' responses: 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Pet not found 405: - content: {} description: Validation exception security: - petstore_auth: @@ -104,11 +88,9 @@ paths: type: array description: successful operation 400: - content: {} description: Invalid status value security: - petstore_auth: - - write:pets - read:pets summary: Finds Pets by status tags: @@ -116,7 +98,8 @@ paths: /pet/findByTags: get: deprecated: true - description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + description: Multiple tags can be provided with comma separated strings. Use + tag1, tag2, tag3 for testing. operationId: findPetsByTags parameters: - description: Tags to filter by @@ -144,11 +127,9 @@ paths: type: array description: successful operation 400: - content: {} description: Invalid tag value security: - petstore_auth: - - write:pets - read:pets summary: Finds Pets by tags tags: @@ -157,20 +138,24 @@ paths: delete: operationId: deletePet parameters: - - in: header + - explode: false + in: header name: api_key + required: false schema: type: string + style: simple - description: Pet id to delete + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple responses: 400: - content: {} description: Invalid pet value security: - petstore_auth: @@ -184,12 +169,14 @@ paths: operationId: getPetById parameters: - description: ID of pet to return + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple responses: 200: content: @@ -201,10 +188,8 @@ paths: $ref: '#/components/schemas/Pet' description: successful operation 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Pet not found security: - api_key: [] @@ -215,13 +200,16 @@ paths: operationId: updatePetWithForm parameters: - description: ID of pet that needs to be updated + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object' content: application/x-www-form-urlencoded: schema: @@ -232,9 +220,9 @@ paths: status: description: Updated status of the pet type: string + type: object responses: 405: - content: {} description: Invalid input security: - petstore_auth: @@ -248,13 +236,16 @@ paths: operationId: uploadFile parameters: - description: ID of pet to update + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object_1' content: multipart/form-data: schema: @@ -266,6 +257,7 @@ paths: description: file to upload format: binary type: string + type: object responses: 200: content: @@ -304,7 +296,7 @@ paths: operationId: placeOrder requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/Order' description: order placed for purchasing the pet @@ -320,37 +312,39 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: - content: {} description: Invalid Order summary: Place an order for a pet tags: - store /store/order/{orderId}: delete: - description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors operationId: deleteOrder parameters: - description: ID of the order that needs to be deleted + explode: false in: path name: orderId required: true schema: type: string + style: simple responses: 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Order not found summary: Delete purchase order by ID tags: - store get: - description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generated exceptions operationId: getOrderById parameters: - description: ID of pet that needs to be fetched + explode: false in: path name: orderId required: true @@ -359,6 +353,7 @@ paths: maximum: 5 minimum: 1 type: integer + style: simple responses: 200: content: @@ -370,10 +365,8 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Order not found summary: Find purchase order by ID tags: @@ -384,15 +377,16 @@ paths: operationId: createUser requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' description: Created user object required: true responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Create user tags: - user @@ -400,18 +394,12 @@ paths: post: operationId: createUsersWithArrayInput requestBody: - content: - '*/*': - schema: - items: - $ref: '#/components/schemas/User' - type: array - description: List of user object - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Creates list of users with given input array tags: - user @@ -419,18 +407,12 @@ paths: post: operationId: createUsersWithListInput requestBody: - content: - '*/*': - schema: - items: - $ref: '#/components/schemas/User' - type: array - description: List of user object - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Creates list of users with given input array tags: - user @@ -439,17 +421,22 @@ paths: operationId: loginUser parameters: - description: The user name for login + explode: true in: query name: username required: true schema: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ type: string + style: form - description: The password for login in clear text + explode: true in: query name: password required: true schema: type: string + style: form responses: 200: content: @@ -461,18 +448,29 @@ paths: type: string description: successful operation headers: + Set-Cookie: + description: Cookie authentication key for use with the `auth_cookie` + apiKey authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple X-Rate-Limit: description: calls per hour allowed by the user + explode: false schema: format: int32 type: integer + style: simple X-Expires-After: description: date in UTC when toekn expires + explode: false schema: format: date-time type: string + style: simple 400: - content: {} description: Invalid username/password supplied summary: Logs user into the system tags: @@ -482,8 +480,9 @@ paths: operationId: logoutUser responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Logs out current logged in user session tags: - user @@ -493,18 +492,20 @@ paths: operationId: deleteUser parameters: - description: The name that needs to be deleted + explode: false in: path name: username required: true schema: type: string + style: simple responses: 400: - content: {} description: Invalid username supplied 404: - content: {} description: User not found + security: + - auth_cookie: [] summary: Delete user tags: - user @@ -512,11 +513,13 @@ paths: operationId: getUserByName parameters: - description: The name that needs to be fetched. Use user1 for testing. + explode: false in: path name: username required: true schema: type: string + style: simple responses: 200: content: @@ -528,10 +531,8 @@ paths: $ref: '#/components/schemas/User' description: successful operation 400: - content: {} description: Invalid username supplied 404: - content: {} description: User not found summary: Get user by user name tags: @@ -541,29 +542,61 @@ paths: operationId: updateUser parameters: - description: name that need to be deleted + explode: false in: path name: username required: true schema: type: string + style: simple requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' description: Updated user object required: true responses: 400: - content: {} description: Invalid user supplied 404: - content: {} description: User not found + security: + - auth_cookie: [] summary: Updated user tags: - user components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + inline_object: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/inline_object' + inline_object_1: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/inline_object_1' schemas: Order: description: An order for a pets from the pet store @@ -611,6 +644,7 @@ components: format: int64 type: integer name: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ type: string title: Pet category type: object @@ -736,6 +770,25 @@ components: type: string title: An uploaded response type: object + inline_object: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + inline_object_1: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object securitySchemes: petstore_auth: flows: @@ -749,3 +802,7 @@ components: in: header name: api_key type: apiKey + auth_cookie: + in: cookie + name: AUTH_KEY + type: apiKey diff --git a/samples/server/petstore/rust-server/output/openapi-v3/README.md b/samples/server/petstore/rust-server/output/openapi-v3/README.md index 66109167f3b6..d51e1c48832c 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-server/output/openapi-v3/README.md @@ -61,6 +61,8 @@ cargo run --example server To run a client, follow one of the following simple steps: ``` +cargo run --example client MultipleAuthSchemeGet +cargo run --example client ReadonlyAuthSchemeGet cargo run --example client RequiredOctetStreamPut cargo run --example client ResponsesWithHeadersGet cargo run --example client UuidGet @@ -102,6 +104,8 @@ All URIs are relative to *http://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- +[****](docs/default_api.md#) | **GET** /multiple_auth_scheme | +[****](docs/default_api.md#) | **GET** /readonly_auth_scheme | [****](docs/default_api.md#) | **PUT** /required_octet_stream | [****](docs/default_api.md#) | **GET** /responses_with_headers | [****](docs/default_api.md#) | **GET** /uuid | @@ -125,8 +129,22 @@ Method | HTTP request | Description ## Documentation For Authorization - Endpoints do not require authorization. +## authScheme +- **Type**: OAuth +- **Flow**: accessCode +- **Authorization URL**: http://example.org +- **Scopes**: + - **test.read**: Allowed to read state. + - **test.write**: Allowed to change state. + +Example +``` +``` + +Or via OAuth2 module to automatically refresh tokens and perform user authentication. +``` +``` ## Author diff --git a/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml b/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml index 552e1394d149..e903c1c2fe52 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml +++ b/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml @@ -86,6 +86,23 @@ paths: responses: 200: description: OK + /readonly_auth_scheme: + get: + responses: + 200: + description: Check that limiting to a single required auth scheme works + security: + - authScheme: + - test.read + /multiple_auth_scheme: + get: + responses: + 200: + description: Check that limiting to multiple required auth schemes works + security: + - authScheme: + - test.read + - test.write /responses_with_headers: get: responses: @@ -176,4 +193,14 @@ components: xml: name: snake_another_xml_object namespace: http://foo.bar + securitySchemes: + authScheme: + flows: + authorizationCode: + authorizationUrl: http://example.org + scopes: + test.read: Allowed to read state. + test.write: Allowed to change state. + tokenUrl: http://example.org + type: oauth2 diff --git a/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md b/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md index d6115c696e8a..82b8c773ff40 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md +++ b/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md @@ -4,6 +4,8 @@ All URIs are relative to *http://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- +****](default_api.md#) | **GET** /multiple_auth_scheme | +****](default_api.md#) | **GET** /readonly_auth_scheme | ****](default_api.md#) | **PUT** /required_octet_stream | ****](default_api.md#) | **GET** /responses_with_headers | ****](default_api.md#) | **GET** /uuid | @@ -14,6 +16,50 @@ Method | HTTP request | Description ****](default_api.md#) | **PUT** /xml | +# **** +> (ctx, ) + + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + + (empty response body) + +### Authorization + +[authScheme](../README.md#authScheme) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **** +> (ctx, ) + + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + + (empty response body) + +### Authorization + +[authScheme](../README.md#authScheme) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **** > (body) diff --git a/samples/server/petstore/rust-server/output/openapi-v3/examples/client.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/client.rs index 6b4bbb646334..dcbe006993af 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/client.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/client.rs @@ -19,6 +19,8 @@ use tokio_core::reactor; #[allow(unused_imports)] use openapi_v3::{ApiNoContext, ContextWrapperExt, ApiError, + MultipleAuthSchemeGetResponse, + ReadonlyAuthSchemeGetResponse, RequiredOctetStreamPutResponse, ResponsesWithHeadersGetResponse, UuidGetResponse, @@ -35,6 +37,8 @@ fn main() { .arg(Arg::with_name("operation") .help("Sets the operation to run") .possible_values(&[ + "MultipleAuthSchemeGet", + "ReadonlyAuthSchemeGet", "RequiredOctetStreamPut", "ResponsesWithHeadersGet", "UuidGet", @@ -83,6 +87,16 @@ fn main() { match matches.value_of("operation") { + Some("MultipleAuthSchemeGet") => { + let result = core.run(client.multiple_auth_scheme_get()); + println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); + }, + + Some("ReadonlyAuthSchemeGet") => { + let result = core.run(client.readonly_auth_scheme_get()); + println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); + }, + Some("RequiredOctetStreamPut") => { let result = core.run(client.required_octet_stream_put(swagger::ByteArray(Vec::from("BYTE_ARRAY_DATA_HERE")))); println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); diff --git a/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/mod.rs index ad8904ca16bd..2139af63155f 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/mod.rs @@ -13,6 +13,7 @@ use std::marker::PhantomData; use hyper; use openapi_v3; use swagger::{Has, XSpanIdString}; +use swagger::auth::Authorization; pub struct NewService{ marker: PhantomData @@ -24,7 +25,7 @@ impl NewService{ } } -impl hyper::server::NewService for NewService where C: Has + Clone + 'static { +impl hyper::server::NewService for NewService where C: Has + Has> + Clone + 'static { type Request = (hyper::Request, C); type Response = hyper::Response; type Error = hyper::Error; diff --git a/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs index a66ac4e58d77..56c760181776 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs @@ -11,6 +11,8 @@ use swagger::{Has, XSpanIdString}; use uuid; use openapi_v3::{Api, ApiError, + MultipleAuthSchemeGetResponse, + ReadonlyAuthSchemeGetResponse, RequiredOctetStreamPutResponse, ResponsesWithHeadersGetResponse, UuidGetResponse, @@ -36,6 +38,20 @@ impl Server { impl Api for Server where C: Has{ + fn multiple_auth_scheme_get(&self, context: &C) -> Box> { + let context = context.clone(); + println!("multiple_auth_scheme_get() - X-Span-ID: {:?}", context.get().0.clone()); + Box::new(futures::failed("Generic failure".into())) + } + + + fn readonly_auth_scheme_get(&self, context: &C) -> Box> { + let context = context.clone(); + println!("readonly_auth_scheme_get() - X-Span-ID: {:?}", context.get().0.clone()); + Box::new(futures::failed("Generic failure".into())) + } + + fn required_octet_stream_put(&self, body: swagger::ByteArray, context: &C) -> Box> { let context = context.clone(); println!("required_octet_stream_put({:?}) - X-Span-ID: {:?}", body, context.get().0.clone()); diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs index 3537ffbd9085..b67f0353b297 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs @@ -37,6 +37,8 @@ use swagger; use swagger::{ApiError, XSpanId, XSpanIdString, Has, AuthData}; use {Api, + MultipleAuthSchemeGetResponse, + ReadonlyAuthSchemeGetResponse, RequiredOctetStreamPutResponse, ResponsesWithHeadersGetResponse, UuidGetResponse, @@ -248,7 +250,153 @@ impl Client where impl Api for Client where F: Future + 'static, - C: Has { + C: Has + Has>{ + + fn multiple_auth_scheme_get(&self, context: &C) -> Box> { + let mut uri = format!( + "{}/multiple_auth_scheme", + self.base_path + ); + + let mut query_string = self::url::form_urlencoded::Serializer::new("".to_owned()); + + + let query_string_str = query_string.finish(); + if !query_string_str.is_empty() { + uri += "?"; + uri += &query_string_str; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Box::new(futures::done(Err(ApiError(format!("Unable to build URI: {}", err))))), + }; + + let mut request = hyper::Request::new(hyper::Method::Get, uri); + + + request.headers_mut().set(XSpanId((context as &Has).get().0.clone())); + + (context as &Has>).get().as_ref().map(|auth_data| { + // Currently only authentication with Basic, API Key, and Bearer are supported + match auth_data { + &AuthData::Bearer(ref bearer_header) => { + request.headers_mut().set(hyper::header::Authorization( + bearer_header.clone(), + )) + }, + _ => {} + } + }); + Box::new(self.client_service.call(request) + .map_err(|e| ApiError(format!("No response received: {}", e))) + .and_then(|mut response| { + match response.status().as_u16() { + 200 => { + let body = response.body(); + Box::new( + + future::ok( + MultipleAuthSchemeGetResponse::CheckThatLimitingToMultipleRequiredAuthSchemesWorks + ) + ) as Box> + }, + code => { + let headers = response.headers().clone(); + Box::new(response.body() + .take(100) + .concat2() + .then(move |body| + future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(ref body) => match str::from_utf8(body) { + Ok(body) => Cow::from(body), + Err(e) => Cow::from(format!("", e)), + }, + Err(e) => Cow::from(format!("", e)), + }))) + ) + ) as Box> + } + } + })) + + } + + fn readonly_auth_scheme_get(&self, context: &C) -> Box> { + let mut uri = format!( + "{}/readonly_auth_scheme", + self.base_path + ); + + let mut query_string = self::url::form_urlencoded::Serializer::new("".to_owned()); + + + let query_string_str = query_string.finish(); + if !query_string_str.is_empty() { + uri += "?"; + uri += &query_string_str; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Box::new(futures::done(Err(ApiError(format!("Unable to build URI: {}", err))))), + }; + + let mut request = hyper::Request::new(hyper::Method::Get, uri); + + + request.headers_mut().set(XSpanId((context as &Has).get().0.clone())); + + (context as &Has>).get().as_ref().map(|auth_data| { + // Currently only authentication with Basic, API Key, and Bearer are supported + match auth_data { + &AuthData::Bearer(ref bearer_header) => { + request.headers_mut().set(hyper::header::Authorization( + bearer_header.clone(), + )) + }, + _ => {} + } + }); + Box::new(self.client_service.call(request) + .map_err(|e| ApiError(format!("No response received: {}", e))) + .and_then(|mut response| { + match response.status().as_u16() { + 200 => { + let body = response.body(); + Box::new( + + future::ok( + ReadonlyAuthSchemeGetResponse::CheckThatLimitingToASingleRequiredAuthSchemeWorks + ) + ) as Box> + }, + code => { + let headers = response.headers().clone(); + Box::new(response.body() + .take(100) + .concat2() + .then(move |body| + future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(ref body) => match str::from_utf8(body) { + Ok(body) => Cow::from(body), + Err(e) => Cow::from(format!("", e)), + }, + Err(e) => Cow::from(format!("", e)), + }))) + ) + ) as Box> + } + } + })) + + } fn required_octet_stream_put(&self, param_body: swagger::ByteArray, context: &C) -> Box> { let mut uri = format!( @@ -272,7 +420,6 @@ impl Api for Client where let mut request = hyper::Request::new(hyper::Method::Put, uri); - // Body parameter let body = param_body.0; request.set_body(body); diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs index 0ccacdce2fcd..255d779db328 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs @@ -51,6 +51,18 @@ pub const BASE_PATH: &'static str = ""; pub const API_VERSION: &'static str = "1.0.7"; +#[derive(Debug, PartialEq)] +pub enum MultipleAuthSchemeGetResponse { + /// Check that limiting to multiple required auth schemes works + CheckThatLimitingToMultipleRequiredAuthSchemesWorks +} + +#[derive(Debug, PartialEq)] +pub enum ReadonlyAuthSchemeGetResponse { + /// Check that limiting to a single required auth scheme works + CheckThatLimitingToASingleRequiredAuthSchemeWorks +} + #[derive(Debug, PartialEq)] pub enum RequiredOctetStreamPutResponse { /// OK @@ -131,6 +143,12 @@ pub enum XmlPutResponse { pub trait Api { + fn multiple_auth_scheme_get(&self, context: &C) -> Box>; + + + fn readonly_auth_scheme_get(&self, context: &C) -> Box>; + + fn required_octet_stream_put(&self, body: swagger::ByteArray, context: &C) -> Box>; @@ -160,6 +178,12 @@ pub trait Api { pub trait ApiNoContext { + fn multiple_auth_scheme_get(&self) -> Box>; + + + fn readonly_auth_scheme_get(&self) -> Box>; + + fn required_octet_stream_put(&self, body: swagger::ByteArray) -> Box>; @@ -200,6 +224,16 @@ impl<'a, T: Api + Sized, C> ContextWrapperExt<'a, C> for T { impl<'a, T: Api, C> ApiNoContext for ContextWrapper<'a, T, C> { + fn multiple_auth_scheme_get(&self) -> Box> { + self.api().multiple_auth_scheme_get(&self.context()) + } + + + fn readonly_auth_scheme_get(&self) -> Box> { + self.api().readonly_auth_scheme_get(&self.context()) + } + + fn required_octet_stream_put(&self, body: swagger::ByteArray) -> Box> { self.api().required_octet_stream_put(body, &self.context()) } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/context.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/context.rs index 6f2900b3d70c..a377b535b623 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/context.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/context.rs @@ -83,6 +83,16 @@ impl hyper::server::Service for AddContext fn call(&self, req: Self::Request) -> Self::Future { let context = A::default().push(XSpanIdString::get_or_generate(&req)); + { + use hyper::header::{Authorization as HyperAuth, Basic, Bearer}; + use std::ops::Deref; + if let Some(bearer) = req.headers().get::>().cloned() { + let auth_data = AuthData::Bearer(bearer.deref().clone()); + let context = context.push(Some(auth_data)); + let context = context.push(None::); + return self.inner.call((req, context)); + } + } let context = context.push(None::); let context = context.push(None::); diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs index 72923bf8ee8c..2298f08c7076 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs @@ -35,6 +35,8 @@ use swagger::{ApiError, XSpanId, XSpanIdString, Has, RequestParser}; use swagger::auth::Scopes; use {Api, + MultipleAuthSchemeGetResponse, + ReadonlyAuthSchemeGetResponse, RequiredOctetStreamPutResponse, ResponsesWithHeadersGetResponse, UuidGetResponse, @@ -56,6 +58,8 @@ mod paths { lazy_static! { pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ + r"^/multiple_auth_scheme$", + r"^/readonly_auth_scheme$", r"^/required_octet_stream$", r"^/responses_with_headers$", r"^/uuid$", @@ -64,12 +68,14 @@ mod paths { r"^/xml_other$" ]).unwrap(); } - pub static ID_REQUIRED_OCTET_STREAM: usize = 0; - pub static ID_RESPONSES_WITH_HEADERS: usize = 1; - pub static ID_UUID: usize = 2; - pub static ID_XML: usize = 3; - pub static ID_XML_EXTRA: usize = 4; - pub static ID_XML_OTHER: usize = 5; + pub static ID_MULTIPLE_AUTH_SCHEME: usize = 0; + pub static ID_READONLY_AUTH_SCHEME: usize = 1; + pub static ID_REQUIRED_OCTET_STREAM: usize = 2; + pub static ID_RESPONSES_WITH_HEADERS: usize = 3; + pub static ID_UUID: usize = 4; + pub static ID_XML: usize = 5; + pub static ID_XML_EXTRA: usize = 6; + pub static ID_XML_OTHER: usize = 7; } pub struct NewService { @@ -80,7 +86,7 @@ pub struct NewService { impl NewService where T: Api + Clone + 'static, - C: Has + 'static + C: Has + Has> + 'static { pub fn new>>(api_impl: U) -> NewService { NewService{api_impl: api_impl.into(), marker: PhantomData} @@ -90,7 +96,7 @@ where impl hyper::server::NewService for NewService where T: Api + Clone + 'static, - C: Has + 'static + C: Has + Has> + 'static { type Request = (Request, C); type Response = Response; @@ -110,7 +116,7 @@ pub struct Service { impl Service where T: Api + Clone + 'static, - C: Has + 'static { + C: Has + Has> + 'static { pub fn new>>(api_impl: U) -> Service { Service{api_impl: api_impl.into(), marker: PhantomData} } @@ -119,7 +125,7 @@ where impl hyper::server::Service for Service where T: Api + Clone + 'static, - C: Has + 'static + C: Has + Has> + 'static { type Request = (Request, C); type Response = Response; @@ -135,6 +141,127 @@ where // Please update both places if changing how this code is autogenerated. match &method { + // MultipleAuthSchemeGet - GET /multiple_auth_scheme + &hyper::Method::Get if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => { + { + let authorization = match (&context as &Has>).get() { + &Some(ref authorization) => authorization, + &None => return Box::new(future::ok(Response::new() + .with_status(StatusCode::Forbidden) + .with_body("Unauthenticated"))), + }; + + // Authorization + if let Scopes::Some(ref scopes) = authorization.scopes { + let required_scopes: BTreeSet = vec![ + "test.read".to_string(), // Allowed to read state. + "test.write".to_string(), // Allowed to change state. + ].into_iter().collect(); + + if !required_scopes.is_subset(scopes) { + let missing_scopes = required_scopes.difference(scopes); + return Box::new(future::ok(Response::new() + .with_status(StatusCode::Forbidden) + .with_body(missing_scopes.fold( + "Insufficient authorization, missing scopes".to_string(), + |s, scope| format!("{} {}", s, scope) + )) + )); + } + } + } + Box::new({ + {{ + Box::new(api_impl.multiple_auth_scheme_get(&context) + .then(move |result| { + let mut response = Response::new(); + response.headers_mut().set(XSpanId((&context as &Has).get().0.to_string())); + + match result { + Ok(rsp) => match rsp { + MultipleAuthSchemeGetResponse::CheckThatLimitingToMultipleRequiredAuthSchemesWorks + + + => { + response.set_status(StatusCode::try_from(200).unwrap()); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.set_status(StatusCode::InternalServerError); + response.set_body("An internal error occurred"); + }, + } + + future::ok(response) + } + )) + }} + }) as Box> + }, + + // ReadonlyAuthSchemeGet - GET /readonly_auth_scheme + &hyper::Method::Get if path.matched(paths::ID_READONLY_AUTH_SCHEME) => { + { + let authorization = match (&context as &Has>).get() { + &Some(ref authorization) => authorization, + &None => return Box::new(future::ok(Response::new() + .with_status(StatusCode::Forbidden) + .with_body("Unauthenticated"))), + }; + + // Authorization + if let Scopes::Some(ref scopes) = authorization.scopes { + let required_scopes: BTreeSet = vec![ + "test.read".to_string(), // Allowed to read state. + ].into_iter().collect(); + + if !required_scopes.is_subset(scopes) { + let missing_scopes = required_scopes.difference(scopes); + return Box::new(future::ok(Response::new() + .with_status(StatusCode::Forbidden) + .with_body(missing_scopes.fold( + "Insufficient authorization, missing scopes".to_string(), + |s, scope| format!("{} {}", s, scope) + )) + )); + } + } + } + Box::new({ + {{ + Box::new(api_impl.readonly_auth_scheme_get(&context) + .then(move |result| { + let mut response = Response::new(); + response.headers_mut().set(XSpanId((&context as &Has).get().0.to_string())); + + match result { + Ok(rsp) => match rsp { + ReadonlyAuthSchemeGetResponse::CheckThatLimitingToASingleRequiredAuthSchemeWorks + + + => { + response.set_status(StatusCode::try_from(200).unwrap()); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.set_status(StatusCode::InternalServerError); + response.set_body("An internal error occurred"); + }, + } + + future::ok(response) + } + )) + }} + }) as Box> + }, + // RequiredOctetStreamPut - PUT /required_octet_stream &hyper::Method::Put if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => { // Body parameters (note that non-required body parameters will ignore garbage @@ -644,6 +771,12 @@ impl RequestParser for ApiRequestParser { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); match request.method() { + // MultipleAuthSchemeGet - GET /multiple_auth_scheme + &hyper::Method::Get if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Ok("MultipleAuthSchemeGet"), + + // ReadonlyAuthSchemeGet - GET /readonly_auth_scheme + &hyper::Method::Get if path.matched(paths::ID_READONLY_AUTH_SCHEME) => Ok("ReadonlyAuthSchemeGet"), + // RequiredOctetStreamPut - PUT /required_octet_stream &hyper::Method::Put if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => Ok("RequiredOctetStreamPut"), diff --git a/website/dynamic/users.yml b/website/dynamic/users.yml index 457c2371db35..e366ab1d08bf 100644 --- a/website/dynamic/users.yml +++ b/website/dynamic/users.yml @@ -118,6 +118,11 @@ image: "img/companies/formapi.png" infoLink: "https://formapi.io/" pinned: false +- + caption: "FreshCells" + image: "img/companies/freshcells.png" + infoLink: "https://www.freshcells.de/" + pinned: false - caption: "Fuse" image: "img/companies/fuseno.png" @@ -158,6 +163,11 @@ image: "img/companies/klarna.svg" infoLink: "https://www.klarna.com/us/" pinned: false +- + caption: "Kronsoft Development" + image: "img/companies/kronsoft.svg" + infoLink: "https://www.kronsoft.ro/home/" + pinned: false - caption: "Médiavision" image: "img/companies/mediavision.jpeg" @@ -218,6 +228,11 @@ image: "img/companies/prometheus.png" infoLink: "https://github.com/prometheus/alertmanager" pinned: false +- + caption: "Qulix Systems" + image: "img/companies/qulix.png" + infoLink: "https://www.qulix.com" + pinned: false - caption: "Raiffeisen Schweiz Genossenschaft" image: "img/companies/raiffeisen.png" diff --git a/website/static/img/companies/freshcells.png b/website/static/img/companies/freshcells.png new file mode 100644 index 000000000000..e3780a4ff38f Binary files /dev/null and b/website/static/img/companies/freshcells.png differ diff --git a/website/static/img/companies/kronsoft.png b/website/static/img/companies/kronsoft.png new file mode 100644 index 000000000000..201de65655ac Binary files /dev/null and b/website/static/img/companies/kronsoft.png differ diff --git a/website/static/img/companies/qulix.png b/website/static/img/companies/qulix.png new file mode 100644 index 000000000000..57e6bc55a43d Binary files /dev/null and b/website/static/img/companies/qulix.png differ