diff --git a/.github/workflows/gradle-plugin-tests.yaml b/.github/workflows/gradle-plugin-tests.yaml
new file mode 100644
index 00000000000..a162019bf90
--- /dev/null
+++ b/.github/workflows/gradle-plugin-tests.yaml
@@ -0,0 +1,43 @@
+name: Gradle plugin tests
+
+on:
+ push:
+ paths:
+ - modules/openapi-generator-gradle-plugin/**
+ pull_request:
+ paths:
+ - modules/openapi-generator-gradle-plugin/**
+
+jobs:
+ test:
+ name: Gradle plugin tests
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: 11
+ distribution: 'temurin'
+ - name: Cache maven dependencies
+ uses: actions/cache@v3
+ env:
+ cache-name: cache-maven-repository
+ with:
+ path: |
+ ~/.m2/repository
+ ~/.gradle
+ !~/.gradle/caches/modules-2/modules-2.lock
+ !~/.gradle/caches/*/plugin-resolution/
+ !~/.m2/repository/org/openapitools/
+ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-test-gradle-plugin-${{ env.cache-name }}-
+ ${{ runner.os }}-test-gradle-plugin-
+ - name: Run tests
+ run: |
+ mvn --no-snapshot-updates --batch-mode --quiet install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=error
+ (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk) # using gradle-6.8.3 via wrapper
+ (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)
+ (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildDotnetSdk)
+ (cd modules/openapi-generator-gradle-plugin/samples/local-spec && gradle buildJavaResttemplateSdk) # not using gradle wrapper
diff --git a/.github/workflows/gradle-test.yaml b/.github/workflows/gradle-test.yaml
index 067377c11f1..e9b9dcf9c14 100644
--- a/.github/workflows/gradle-test.yaml
+++ b/.github/workflows/gradle-test.yaml
@@ -2,17 +2,12 @@ name: Gradle tests (Java samples)
on:
push:
- branches:
- - master
- - '[5-9]+.[0-9]+.x'
- - "java*"
paths:
- 'samples/client/petstore/java/**'
+ - 'samples/openapi3/client/petstore/java/**'
pull_request:
- branches:
- - master
- - '[5-9]+.[0-9]+.x'
paths:
+ - 'samples/client/petstore/java/**'
- 'samples/openapi3/client/petstore/java/**'
env:
GRADLE_VERSION: 7.2
@@ -26,11 +21,11 @@ jobs:
fail-fast: true
matrix:
sample:
- - samples/client/petstore/java/jersey2-java8-localdatetime
- - samples/client/petstore/java/jersey2-java8
- samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters
- samples/openapi3/client/petstore/java/jersey2-java8
+ - samples/client/petstore/java/jersey2-java8-localdatetime
+ - samples/client/petstore/java/jersey2-java8
- samples/client/petstore/java/okhttp-gson
- samples/client/petstore/java/okhttp-gson-group-parameter
steps:
diff --git a/.github/workflows/java-helidon-functional-tests.yaml b/.github/workflows/java-helidon-functional-tests.yaml
new file mode 100644
index 00000000000..b2404063d8f
--- /dev/null
+++ b/.github/workflows/java-helidon-functional-tests.yaml
@@ -0,0 +1,46 @@
+name: Java Helidon Functional tests
+
+on:
+ push:
+ paths:
+ - modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/**
+ pull_request:
+ paths:
+ - modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/**
+
+jobs:
+ build:
+ name: Java Helidon Functional tests
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ java-version: [11, 17]
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK
+ uses: actions/setup-java@v3
+ with:
+ java-version: ${{ matrix.java-version }}
+ distribution: 'temurin'
+ - name: Cache maven dependencies
+ uses: actions/cache@v3
+ env:
+ cache-name: cache-maven-repository
+ with:
+ path: |
+ ~/.m2/repository
+ ~/.gradle
+ !~/.gradle/caches/*/plugin-resolution/
+ !~/.m2/repository/org/openapitools/
+ key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-build-${{ env.cache-name }}-
+ ${{ runner.os }}-build-
+ - name: Run unit tests
+ run: cd modules/openapi-generator && mvn --no-snapshot-updates --batch-mode -Dtest="**/functional/*Test" test -Dorg.slf4j.simpleLogger.defaultLogLevel=error
+ - name: Publish unit test reports
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v3
+ with:
+ name: surefire-test-results
+ path: '**/surefire-reports/TEST-*.xml'
diff --git a/.github/workflows/maven-plugin-tests.yaml b/.github/workflows/maven-plugin-tests.yaml
new file mode 100644
index 00000000000..4f3fe58a2f1
--- /dev/null
+++ b/.github/workflows/maven-plugin-tests.yaml
@@ -0,0 +1,42 @@
+name: Maven plugin tests
+
+on:
+ push:
+ paths:
+ - modules/openapi-generator-maven-plugin/**
+ pull_request:
+ paths:
+ - modules/openapi-generator-maven-plugin/**
+
+jobs:
+ test:
+ name: Maven plugin tests
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: 11
+ distribution: 'temurin'
+ - name: Cache maven dependencies
+ uses: actions/cache@v3
+ env:
+ cache-name: cache-maven-repository
+ with:
+ path: |
+ ~/.m2/repository
+ ~/.gradle
+ !~/.gradle/caches/*/plugin-resolution/
+ !~/.m2/repository/org/openapitools/
+ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-test-maven-plugin-${{ env.cache-name }}-
+ ${{ runner.os }}-test-maven-plugin-
+ - name: Run tests
+ run: |
+ mvn clean install -DskipTests -Dmaven.javadoc.skip=true
+ mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
+ mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
+ mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
+ mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
diff --git a/.github/workflows/openapi-generator.yaml b/.github/workflows/openapi-generator.yaml
index 423cec99062..fcbf678e89c 100644
--- a/.github/workflows/openapi-generator.yaml
+++ b/.github/workflows/openapi-generator.yaml
@@ -80,44 +80,6 @@ jobs:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
- functional-test:
- name: Functional tests
- runs-on: ubuntu-latest
- needs:
- - build
- strategy:
- matrix:
- java-version: [11, 17]
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK
- uses: actions/setup-java@v3
- with:
- java-version: ${{ matrix.java-version }}
- distribution: 'temurin'
- - name: Cache maven dependencies
- uses: actions/cache@v3
- env:
- cache-name: cache-maven-repository
- with:
- path: |
- ~/.m2/repository
- ~/.gradle
- !~/.gradle/caches/*/plugin-resolution/
- !~/.m2/repository/org/openapitools/
- key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-build-${{ env.cache-name }}-
- ${{ runner.os }}-build-
- - name: Run unit tests
- run: cd modules/openapi-generator && mvn --no-snapshot-updates --batch-mode -Dtest="**/functional/*Test" test -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- - name: Publish unit test reports
- if: ${{ always() }}
- uses: actions/upload-artifact@v3
- with:
- name: surefire-test-results
- path: '**/surefire-reports/TEST-*.xml'
-
documentation:
name: Docs up-to-date
runs-on: ubuntu-latest
@@ -191,71 +153,3 @@ jobs:
echo "Please run 'bin/generate-samples.sh' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
exit 1
fi
-
- test-maven-plugin:
- name: Maven plugin tests
- runs-on: ubuntu-latest
- needs:
- - build
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK 11
- uses: actions/setup-java@v3
- with:
- java-version: 11
- distribution: 'temurin'
- - name: Cache maven dependencies
- uses: actions/cache@v3
- env:
- cache-name: cache-maven-repository
- with:
- path: |
- ~/.m2/repository
- ~/.gradle
- !~/.gradle/caches/*/plugin-resolution/
- !~/.m2/repository/org/openapitools/
- key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-test-maven-plugin-${{ env.cache-name }}-
- ${{ runner.os }}-test-maven-plugin-
- - name: Run tests
- run: |
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
-
- test-gradle-plugin:
- name: Gradle plugin tests
- runs-on: ubuntu-latest
- needs:
- - build
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK 11
- uses: actions/setup-java@v3
- with:
- java-version: 11
- distribution: 'temurin'
- - name: Cache maven dependencies
- uses: actions/cache@v3
- env:
- cache-name: cache-maven-repository
- with:
- path: |
- ~/.m2/repository
- ~/.gradle
- !~/.gradle/caches/modules-2/modules-2.lock
- !~/.gradle/caches/*/plugin-resolution/
- !~/.m2/repository/org/openapitools/
- key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-test-gradle-plugin-${{ env.cache-name }}-
- ${{ runner.os }}-test-gradle-plugin-
- - name: Run tests
- run: |
- mvn --no-snapshot-updates --batch-mode --quiet install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk) # using gradle-6.8.3 via wrapper
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildDotnetSdk)
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && gradle buildJavaResttemplateSdk) # not using gradle wrapper
diff --git a/.github/workflows/samples-dotnet.yaml b/.github/workflows/samples-dotnet.yaml
index b89b473d473..56a8ec2d4dd 100644
--- a/.github/workflows/samples-dotnet.yaml
+++ b/.github/workflows/samples-dotnet.yaml
@@ -27,7 +27,7 @@ jobs:
- samples/server/petstore/aspnetcore-6.0-project4Models
steps:
- uses: actions/checkout@v3
- - uses: actions/setup-dotnet@v3.0.2
+ - uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '6.0.x'
- name: Build
diff --git a/.github/workflows/samples-go.yaml b/.github/workflows/samples-go.yaml
new file mode 100644
index 00000000000..a46a7ea9c22
--- /dev/null
+++ b/.github/workflows/samples-go.yaml
@@ -0,0 +1,36 @@
+name: Samples Go
+
+on:
+ push:
+ paths:
+ - 'samples/server/petstore/go-echo-server/**'
+ - 'samples/server/petstore/go-api-server/**'
+ pull_request:
+ paths:
+ - 'samples/server/petstore/go-echo-server/**'
+ - 'samples/server/petstore/go-api-server/**'
+
+jobs:
+ build:
+ name: Build Go
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ sample:
+ - samples/server/petstore/go-echo-server/
+ - samples/server/petstore/go-api-server/
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-go@v3
+ with:
+ go-version: '>=1.17.0'
+ - run: go version
+ - name: Install
+ working-directory: ${{ matrix.sample }}
+ run: |
+ go get github.com/labstack/echo/v4/middleware@v4.9.0
+ go get github.com/labstack/echo/v4@v4.9.0
+ - name: Build
+ working-directory: ${{ matrix.sample }}
+ run: go test -v
diff --git a/.github/workflows/samples-kotlin-client.yaml b/.github/workflows/samples-kotlin-client.yaml
index c1f1bfa441f..9eaecf529b9 100644
--- a/.github/workflows/samples-kotlin-client.yaml
+++ b/.github/workflows/samples-kotlin-client.yaml
@@ -51,6 +51,11 @@ jobs:
- samples/client/petstore/kotlin-bigdecimal-default-okhttp4
- samples/client/petstore/kotlin-jvm-ktor-jackson
- samples/client/petstore/kotlin-jvm-ktor-gson
+ - samples/client/petstore/kotlin-jvm-ktor-gson
+ - samples/client/petstore/kotlin-jvm-vertx-gson
+ - samples/client/petstore/kotlin-jvm-vertx-jackson
+ - samples/client/petstore/kotlin-jvm-vertx-jackson-coroutines
+ - samples/client/petstore/kotlin-jvm-vertx-moshi
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
diff --git a/.github/workflows/samples-scala.yaml b/.github/workflows/samples-scala.yaml
index 81372fccdcb..0d71f743d67 100644
--- a/.github/workflows/samples-scala.yaml
+++ b/.github/workflows/samples-scala.yaml
@@ -1,23 +1,26 @@
-name: Samples Scala
+name: Samples Scala/sbt
on:
push:
paths:
- 'samples/client/petstore/scala**'
- 'samples/server/petstore/scala**'
+ - 'samples/client/petstore/java/okhttp-gson/**'
pull_request:
paths:
- 'samples/client/petstore/scala**'
- 'samples/server/petstore/scala**'
+ - 'samples/client/petstore/java/okhttp-gson/**'
jobs:
build:
- name: Build Scala client, servers
+ name: Build sbt/Scala client, servers
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
# clients
+ - 'samples/client/petstore/java/okhttp-gson'
- samples/client/petstore/scalaz
#- samples/client/petstore/scala-sttp # won't pass while the same tests in circleci pass
# servers
diff --git a/.gitignore b/.gitignore
index 850adb6fac6..c2192dfc5e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,9 @@ packages/
**/.vs
.factorypath
.metals/*
+nbproject/
+nbactions.xml
+nb-configuration.xml
.settings
diff --git a/README.md b/README.md
index ba0dc63d569..d8413571da4 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,8 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
[ ](https://www.onesignal.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[ ](https://www.virtualansoftware.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[ ](https://www.merge.dev/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
+[ ](https://www.burkert.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
+[ ](https://www.finbourne.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS and Checkly for sponsoring the API monitoring
@@ -70,8 +72,8 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| | Languages/Frameworks |
| -------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client), **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
-| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
+| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
+| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer**, **WSDL** |
@@ -682,6 +684,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [TribalScale](https://www.tribalscale.com)
- [Trifork](https://trifork.com)
- [TUI InfoTec GmbH](http://www.tui-infotec.com/)
+- [Twilio](https://www.twilio.com/)
- [Twitter](https://twitter.com)
- [unblu inc.](https://www.unblu.com/)
- [Veamly](https://www.veamly.com/)
@@ -872,6 +875,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2022-08-01 - [Tutorial: Etsy Open API v3 (ruby)](https://blog.tjoyal.dev/etsy-open-api-v3/) by [Thierry Joyal](https://github.com/tjoyal)
- 2022-09-03 - [OpenAPI Generator For Go Web Development](https://blog.kevinhu.me/2022/09/03/03-openapi-generator/) by [Kevin Hu](https://twitter.com/Oldgunix)
- 2022-10-01 - [OpenAPI Generatorをカスタマイズしたコードを生成する(Swagger Codegenとほぼ同じ)](https://nainaistar.hatenablog.com/entry/2022/10/03/120000) by [きり丸](https://twitter.com/nainaistar)
+- 2022-10-21 - [Kotlin(Spring Boot)の API を OpenAPI Generator で自動生成](https://zenn.dev/msksgm/articles/20221021-kotlin-spring-openapi-generator) by [msksgm](https://zenn.dev/msksgm)
+- 2022-10-26 - [Quarkus Insights #106: Quarkiverse Extension Spotlight: OpenApi Generator](https://www.youtube.com/watch?v=_s_if69t2iQ) by [Quarkusio](https://www.youtube.com/c/Quarkusio)
## [6 - About Us](#table-of-contents)
@@ -942,6 +947,7 @@ Here is a list of template creators:
* Java (Rest-assured): @viclovsky
* Java (Java 11 Native HTTP client): @bbdouglas
* Java (Apache HttpClient): @harrywhite4
+ * Java (Helidon): @spericas @tjquinno @tvallin
* Javascript/NodeJS: @jfiala
* JavaScript (Apollo DataSource): @erithmetic
* JavaScript (Closure-annotated Angular) @achew22
@@ -1009,6 +1015,7 @@ Here is a list of template creators:
* Java PKMST: @anshu2185 @sanshuman @rkumar-pk @ninodpillai
* Java Vert.x: @lwlee2608
* Java Micronaut: @andriy-dmytruk
+ * Java Helidon: @spericas @tjquinno @tvallin
* JAX-RS RestEasy: @chameleon82
* JAX-RS CXF: @hiveship
* JAX-RS CXF (CDI): @nickcmaynard
diff --git a/bin/configs/kotlin-jvm-vertx-gson.yaml b/bin/configs/kotlin-jvm-vertx-gson.yaml
new file mode 100644
index 00000000000..50bfafb94dc
--- /dev/null
+++ b/bin/configs/kotlin-jvm-vertx-gson.yaml
@@ -0,0 +1,8 @@
+generatorName: kotlin
+outputDir: samples/client/petstore/kotlin-jvm-vertx-gson
+library: jvm-vertx
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-client
+additionalProperties:
+ artifactId: kotlin-petstore-jvm-vertx
+ serializationLibrary: "gson"
\ No newline at end of file
diff --git a/bin/configs/kotlin-jvm-vertx-jackson-coroutines.yaml b/bin/configs/kotlin-jvm-vertx-jackson-coroutines.yaml
new file mode 100644
index 00000000000..64693cba0e7
--- /dev/null
+++ b/bin/configs/kotlin-jvm-vertx-jackson-coroutines.yaml
@@ -0,0 +1,9 @@
+generatorName: kotlin
+outputDir: samples/client/petstore/kotlin-jvm-vertx-jackson-coroutines
+library: jvm-vertx
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-client
+additionalProperties:
+ artifactId: kotlin-petstore-jvm-vertx
+ serializationLibrary: "jackson"
+ useCoroutines: "true"
diff --git a/bin/configs/kotlin-jvm-vertx-jackson.yaml b/bin/configs/kotlin-jvm-vertx-jackson.yaml
new file mode 100644
index 00000000000..f23e8f4237c
--- /dev/null
+++ b/bin/configs/kotlin-jvm-vertx-jackson.yaml
@@ -0,0 +1,8 @@
+generatorName: kotlin
+outputDir: samples/client/petstore/kotlin-jvm-vertx-jackson
+library: jvm-vertx
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-client
+additionalProperties:
+ artifactId: kotlin-petstore-jvm-vertx
+ serializationLibrary: "jackson"
\ No newline at end of file
diff --git a/bin/configs/kotlin-jvm-vertx-moshi.yaml b/bin/configs/kotlin-jvm-vertx-moshi.yaml
new file mode 100644
index 00000000000..e3d658c39f3
--- /dev/null
+++ b/bin/configs/kotlin-jvm-vertx-moshi.yaml
@@ -0,0 +1,8 @@
+generatorName: kotlin
+outputDir: samples/client/petstore/kotlin-jvm-vertx-moshi
+library: jvm-vertx
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-client
+additionalProperties:
+ artifactId: kotlin-petstore-jvm-vertx
+ serializationLibrary: "moshi"
\ No newline at end of file
diff --git a/bin/configs/spring-boot-oas3.yaml b/bin/configs/spring-boot-oas3.yaml
index 21994a14ad4..1c4c87f1940 100644
--- a/bin/configs/spring-boot-oas3.yaml
+++ b/bin/configs/spring-boot-oas3.yaml
@@ -8,3 +8,4 @@ additionalProperties:
artifactId: springboot
snapshotVersion: "true"
hideGenerationTimestamp: "true"
+ requestMappingMode: api_interface
diff --git a/bin/configs/spring-boot.yaml b/bin/configs/spring-boot.yaml
index fe2345e7126..c0d8268ae70 100644
--- a/bin/configs/spring-boot.yaml
+++ b/bin/configs/spring-boot.yaml
@@ -7,3 +7,4 @@ additionalProperties:
artifactId: springboot
snapshotVersion: "true"
hideGenerationTimestamp: "true"
+ camelCaseDollarSign: "true"
diff --git a/bin/configs/typescript-rxjs-allOf-composition.yaml b/bin/configs/typescript-rxjs-allOf-composition.yaml
new file mode 100644
index 00000000000..e9bca87aa19
--- /dev/null
+++ b/bin/configs/typescript-rxjs-allOf-composition.yaml
@@ -0,0 +1,4 @@
+generatorName: typescript-rxjs
+outputDir: samples/client/others/typescript-rxjs/allOf-composition
+inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf_composition.yaml
+templateDir: modules/openapi-generator/src/main/resources/typescript-rxjs
diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md
index 76ec86abae0..e60f802f17b 100644
--- a/docs/generators/groovy.md
+++ b/docs/generators/groovy.md
@@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|
**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md
index e8f88e8269e..348f689876b 100644
--- a/docs/generators/java-camel.md
+++ b/docs/generators/java-camel.md
@@ -32,6 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|camelDataformatProperties|list of dataformat properties separated by comma (propertyName1=propertyValue2,...| ||
|camelRestBindingMode|binding mode to be used by the REST consumer| |auto|
|camelRestClientRequestValidation|enable validation of the client request to check whether the Content-Type and Accept headers from the client is supported by the Rest-DSL configuration| |false|
@@ -73,6 +74,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|performBeanValidation|Use Bean Validation Impl. to perform BeanValidation| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
+|requestMappingMode|Where to generate the class level @RequestMapping annotation.|**api_interface** Generate the @RequestMapping annotation on the generated Api Interface. **controller** Generate the @RequestMapping annotation on the generated Api Controller Implementation. **none** Do not add a class level @RequestMapping annotation. |controller|
|responseWrapper|wrap the responses in given type (Future, Callable, CompletableFuture,ListenableFuture, DeferredResult, RxObservable, RxSingle or fully qualified type)| |null|
|returnSuccessCode|Generated server returns 2xx code| |false|
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
diff --git a/docs/generators/java-helidon-client.md b/docs/generators/java-helidon-client.md
index 13b1af6a314..a2c57ac695e 100644
--- a/docs/generators/java-helidon-client.md
+++ b/docs/generators/java-helidon-client.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configKey|Config key in @RegisterRestClient. Default to none.| |null|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|**false** The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications. **true** Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default. |true|
diff --git a/docs/generators/java-helidon-server.md b/docs/generators/java-helidon-server.md
index a33de1eb380..b96f1730758 100644
--- a/docs/generators/java-helidon-server.md
+++ b/docs/generators/java-helidon-server.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|**false** The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications. **true** Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default. |true|
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md
index 52008c192a2..8dfd8797cd7 100644
--- a/docs/generators/java-inflector.md
+++ b/docs/generators/java-inflector.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md
index 1adf78b70f9..b0368d3ef59 100644
--- a/docs/generators/java-micronaut-client.md
+++ b/docs/generators/java-micronaut-client.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|build|Specify for which build tool to generate files|**gradle** Gradle configuration is generated for the project **all** Both Gradle and Maven configurations are generated **maven** Maven configuration is generated for the project |all|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configureAuth|Configure all the authorization methods as specified in the file| |false|
|dateFormat|Specify the format pattern of date as a string| |null|
|dateLibrary|Option. Date library to use|**java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
diff --git a/docs/generators/java-micronaut-server.md b/docs/generators/java-micronaut-server.md
index 715d9022d92..85422ca8bbc 100644
--- a/docs/generators/java-micronaut-server.md
+++ b/docs/generators/java-micronaut-server.md
@@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|build|Specify for which build tool to generate files|**gradle** Gradle configuration is generated for the project **all** Both Gradle and Maven configurations are generated **maven** Maven configuration is generated for the project |all|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|controllerPackage|The package in which controllers will be generated| |org.openapitools.api|
|dateFormat|Specify the format pattern of date as a string| |null|
|dateLibrary|Option. Date library to use|**java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md
index b11022c8633..15ab35ba4eb 100644
--- a/docs/generators/java-msf4j.md
+++ b/docs/generators/java-msf4j.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md
index 32e83edba4c..efb3e265c27 100644
--- a/docs/generators/java-pkmst.md
+++ b/docs/generators/java-pkmst.md
@@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package for java source code| |null|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md
index 3f2318a8622..65ae38fc1ac 100644
--- a/docs/generators/java-play-framework.md
+++ b/docs/generators/java-play-framework.md
@@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package for generated code| |org.openapitools|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
|controllerOnly|Whether to generate only API interface stubs without the server files.| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md
index 5b579a5aa70..019efb9117a 100644
--- a/docs/generators/java-undertow-server.md
+++ b/docs/generators/java-undertow-server.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md
index 2d00e598ba0..3a721083c20 100644
--- a/docs/generators/java-vertx-web.md
+++ b/docs/generators/java-vertx-web.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0-SNAPSHOT|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md
index 987772f131a..d5e12fe3f3b 100644
--- a/docs/generators/java-vertx.md
+++ b/docs/generators/java-vertx.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0-SNAPSHOT|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java.md b/docs/generators/java.md
index 2427013b0e2..1cdeb245262 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|asyncNative|If true, async handlers will be used, instead of the sync version| |false|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|configKey|Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option.| |null|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md
index 8c6eb15e7c8..6cd328248a4 100644
--- a/docs/generators/jaxrs-cxf-cdi.md
+++ b/docs/generators/jaxrs-cxf-cdi.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md
index 5e8f593a1fa..72cb6f71bcb 100644
--- a/docs/generators/jaxrs-cxf-client.md
+++ b/docs/generators/jaxrs-cxf-client.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md
index b68220e9063..e1778d3101b 100644
--- a/docs/generators/jaxrs-cxf-extended.md
+++ b/docs/generators/jaxrs-cxf-extended.md
@@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md
index 6e77fb11f91..e54504b1ca2 100644
--- a/docs/generators/jaxrs-cxf.md
+++ b/docs/generators/jaxrs-cxf.md
@@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md
index 0797cda9618..73bf0d8f6b2 100644
--- a/docs/generators/jaxrs-jersey.md
+++ b/docs/generators/jaxrs-jersey.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md
index b0e66a64f86..726c44cd45c 100644
--- a/docs/generators/jaxrs-resteasy-eap.md
+++ b/docs/generators/jaxrs-resteasy-eap.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md
index ec6f9b3ae87..aa92d499db2 100644
--- a/docs/generators/jaxrs-resteasy.md
+++ b/docs/generators/jaxrs-resteasy.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md
index 90038fb4ecd..84aea15c97e 100644
--- a/docs/generators/jaxrs-spec.md
+++ b/docs/generators/jaxrs-spec.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/kotlin-server.md b/docs/generators/kotlin-server.md
index ee8399a2a4c..1b25cca82d3 100644
--- a/docs/generators/kotlin-server.md
+++ b/docs/generators/kotlin-server.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
+|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|artifactVersion|Generated artifact's package version.| |1.0.0|
diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md
index a7de5eea623..cf81038ed36 100644
--- a/docs/generators/kotlin-spring.md
+++ b/docs/generators/kotlin-spring.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
+|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|annotationLibrary|Select the complementary documentation annotation library.|**none** Do not annotate Model and Api with complementary annotations. **swagger1** Annotate Model and Api using the Swagger Annotations 1.x library. **swagger2** Annotate Model and Api using the Swagger Annotations 2.x library. |swagger2|
|apiPackage|api package for generated code| |org.openapitools.api|
|apiSuffix|suffix for api classes| |Api|
diff --git a/docs/generators/kotlin-vertx.md b/docs/generators/kotlin-vertx.md
index 7a25d890a72..4bd4958a90a 100644
--- a/docs/generators/kotlin-vertx.md
+++ b/docs/generators/kotlin-vertx.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
+|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |null|
|artifactVersion|Generated artifact's package version.| |1.0.0|
diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md
index 7f562302f28..4c6b25ad394 100644
--- a/docs/generators/kotlin.md
+++ b/docs/generators/kotlin.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
+|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
|artifactVersion|Generated artifact's package version.| |1.0.0|
@@ -27,7 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false|
-|library|Library template (sub-template) to use|**jvm-ktor** Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default). **jvm-okhttp4** [DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0. **jvm-okhttp3** Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0. **jvm-retrofit2** Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2. **multiplatform** Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1. **jvm-volley** Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9 |jvm-okhttp4|
+|library|Library template (sub-template) to use|**jvm-ktor** Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default). **jvm-okhttp4** [DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0. **jvm-okhttp3** Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0. **jvm-retrofit2** Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2. **multiplatform** Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1. **jvm-volley** Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9 **jvm-vertx** Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson. |jvm-okhttp4|
|modelMutable|Create mutable models| |false|
|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|omitGradlePluginVersions|Whether to declare Gradle plugin versions in build files.| |false|
diff --git a/docs/generators/ktorm-schema.md b/docs/generators/ktorm-schema.md
index b4b5b1b6162..f279a112e66 100644
--- a/docs/generators/ktorm-schema.md
+++ b/docs/generators/ktorm-schema.md
@@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|addSurrogateKey|Adds the surrogate key for all models that don't already have a primary key (named by the above convention)| |false|
+|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|artifactId|Generated artifact id (name of jar).| |ktorm|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|defaultDatabaseName|Default database name for all queries| |sqlite.db|
diff --git a/docs/generators/ruby.md b/docs/generators/ruby.md
index 7e88dbc2cf3..2200cadf241 100644
--- a/docs/generators/ruby.md
+++ b/docs/generators/ruby.md
@@ -33,7 +33,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|gemVersion|gem version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|**true** The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document. **false** The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing. |true|
-|library|HTTP library template (sub-template) to use|**faraday** Faraday (https://github.com/lostisland/faraday) (Beta support) **typhoeus** Typhoeus >= 1.0.1 (https://github.com/typhoeus/typhoeus) |typhoeus|
+|library|HTTP library template (sub-template) to use|**faraday** Faraday >= 1.0.1 (https://github.com/lostisland/faraday) **typhoeus** Typhoeus >= 1.0.1 (https://github.com/typhoeus/typhoeus) |typhoeus|
|moduleName|top module name (convention: CamelCase, usually corresponding to gem name).| |OpenAPIClient|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/spring.md b/docs/generators/spring.md
index 4abe7440838..9d28e7915e7 100644
--- a/docs/generators/spring.md
+++ b/docs/generators/spring.md
@@ -32,6 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
+|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
|dateLibrary|Option. Date library to use|**joda** Joda (for legacy app only) **legacy** Legacy java.util.Date **java8-localdatetime** Java 8 using LocalDateTime (for legacy app only) **java8** Java 8 native JSR310 (preferred for jdk 1.8+) |java8|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
@@ -66,6 +67,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|performBeanValidation|Use Bean Validation Impl. to perform BeanValidation| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
+|requestMappingMode|Where to generate the class level @RequestMapping annotation.|**api_interface** Generate the @RequestMapping annotation on the generated Api Interface. **controller** Generate the @RequestMapping annotation on the generated Api Controller Implementation. **none** Do not add a class level @RequestMapping annotation. |controller|
|responseWrapper|wrap the responses in given type (Future, Callable, CompletableFuture,ListenableFuture, DeferredResult, RxObservable, RxSingle or fully qualified type)| |null|
|returnSuccessCode|Generated server returns 2xx code| |false|
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md
index be714cbd096..2a0df3ca3ab 100644
--- a/docs/generators/typescript.md
+++ b/docs/generators/typescript.md
@@ -87,6 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
char
class
const
+constructor
continue
debugger
default
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
index 82fe7e761e8..a610baa80e6 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
@@ -21,6 +21,7 @@ import org.gradle.api.GradleException
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
@@ -98,7 +99,8 @@ open class GenerateTask : DefaultTask() {
* The template directory holding a custom template.
*/
@Optional
- @Input
+ @InputDirectory
+ @PathSensitive(PathSensitivity.RELATIVE)
val templateDir = project.objects.property()
/**
@@ -122,7 +124,8 @@ open class GenerateTask : DefaultTask() {
* Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options.
*/
@Optional
- @Input
+ @InputFile
+ @PathSensitive(PathSensitivity.RELATIVE)
val configFile = project.objects.property()
/**
@@ -320,7 +323,8 @@ open class GenerateTask : DefaultTask() {
* Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
*/
@Optional
- @Input
+ @InputFile
+ @PathSensitive(PathSensitivity.RELATIVE)
val ignoreFileOverride = project.objects.property()
/**
diff --git a/modules/openapi-generator-gradle-plugin/src/test/kotlin/GenerateTaskFromCacheTest.kt b/modules/openapi-generator-gradle-plugin/src/test/kotlin/GenerateTaskFromCacheTest.kt
new file mode 100644
index 00000000000..2f573c94a11
--- /dev/null
+++ b/modules/openapi-generator-gradle-plugin/src/test/kotlin/GenerateTaskFromCacheTest.kt
@@ -0,0 +1,200 @@
+package org.openapitools.generator.gradle.plugin
+
+import org.gradle.testkit.runner.TaskOutcome
+import org.testng.annotations.BeforeMethod
+import org.testng.annotations.DataProvider
+import org.testng.annotations.Test
+import java.io.File
+import kotlin.test.assertEquals
+
+class GenerateTaskFromCacheTest : TestBase() {
+
+ private lateinit var buildCacheDir: File
+ private lateinit var projectDir1: File
+ private lateinit var projectDir2: File
+
+ @BeforeMethod
+ override fun before() {
+ initialize()
+ buildCacheDir = temp.resolve("buildCacheDir").apply { mkdir() }
+ projectDir1 = temp.resolve("projectDir1").apply { mkdir() }
+ projectDir2 = temp.resolve("projectDir2").apply { mkdir() }
+ }
+
+ @DataProvider(name = "gradle_version_provider")
+ private fun gradleVersionProvider(): Array> = arrayOf(arrayOf("6.9.2"), arrayOf("7.5.1"))
+
+ // inputSpec tests
+
+ private val inputSpecExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ """.trimIndent()
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `inputSpec - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ runCacheabilityTestUsingSameDirectory(gradleVersion, inputSpecExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `inputSpec - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ runCacheabilityTestUsingDifferentDirectories(gradleVersion, inputSpecExtensionContents)
+ }
+
+ // templateDir tests
+
+ private val templateDirExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ templateDir = file("templateDir").absolutePath
+ """.trimIndent()
+
+ private fun initializeTemplateDirTest() {
+ projectDir1.resolve("templateDir").mkdir()
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `templateDir - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ initializeTemplateDirTest()
+ runCacheabilityTestUsingSameDirectory(gradleVersion, templateDirExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `templateDir - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ initializeTemplateDirTest()
+ runCacheabilityTestUsingDifferentDirectories(gradleVersion, templateDirExtensionContents)
+ }
+
+ // configFile tests
+
+ private val configFileExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ configFile = file("configFile").absolutePath
+ """.trimIndent()
+
+ private fun initializeConfigFileTest() {
+ val configFile = projectDir1.resolve("configFile")
+ configFile.createNewFile()
+ configFile.writeText("""{"foo":"bar"}""")
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `configFile - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ initializeConfigFileTest()
+ runCacheabilityTestUsingSameDirectory(gradleVersion, configFileExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `configFile - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ initializeConfigFileTest()
+ runCacheabilityTestUsingDifferentDirectories(gradleVersion, configFileExtensionContents)
+ }
+
+ // ignoreFileOverride tests
+
+ private val ignoreFileOverrideExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ ignoreFileOverride = file(".openapi-generator-ignore").absolutePath
+ """.trimIndent()
+
+ private fun initializeIgnoreFileTest() {
+ projectDir1.resolve(".openapi-generator-ignore").createNewFile()
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `ignoreFileOverride - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ initializeIgnoreFileTest()
+ runCacheabilityTestUsingSameDirectory(gradleVersion, ignoreFileOverrideExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `ignoreFileOverride - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
+ initializeIgnoreFileTest()
+ runCacheabilityTestUsingDifferentDirectories(gradleVersion, ignoreFileOverrideExtensionContents)
+ }
+
+ // Helper methods & test fixtures
+
+ private fun runCacheabilityTestUsingSameDirectory(gradleVersion: String, extensionContents: String) {
+ // Arrange
+ withProject(extensionContents)
+
+ // Act
+ val result1 = build {
+ withProjectDir(projectDir1)
+ withArguments("--build-cache", "clean", "openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ val expectedRelativeFilePathSet = projectDir1.toRelativeFilePathSet()
+
+ val result2 = build {
+ withProjectDir(projectDir1)
+ withArguments("--build-cache", "clean", "openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ // Assert
+ assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
+ assertEquals(TaskOutcome.FROM_CACHE, result2.task(":openApiGenerate")?.outcome)
+ assertEquals(expectedRelativeFilePathSet, projectDir1.toRelativeFilePathSet())
+ }
+
+ private fun runCacheabilityTestUsingDifferentDirectories(gradleVersion: String, extensionContents: String) {
+ // Arrange
+ withProject(extensionContents)
+ projectDir1.copyRecursively(projectDir2)
+
+ // Act
+ val result1 = build {
+ withProjectDir(projectDir1)
+ withArguments("--build-cache", "clean", "openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ val result2 = build {
+ withProjectDir(projectDir2)
+ withArguments("--build-cache", "clean", "openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ // Assert
+ assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
+ assertEquals(TaskOutcome.FROM_CACHE, result2.task(":openApiGenerate")?.outcome)
+ assertEquals(projectDir1.toRelativeFilePathSet(), projectDir2.toRelativeFilePathSet())
+ }
+
+ private fun File.toRelativeFilePathSet() =
+ resolve("build").walk().map { it.toRelativeString(resolve("build")) }.toSet()
+
+ private fun withProject(extensionContents: String) {
+ val settingsContents = """
+ buildCache {
+ local {
+ directory = file("${buildCacheDir.toURI()}")
+ }
+ }
+ rootProject.name = "openapi-generator"
+ """.trimIndent()
+ val buildContents = """
+ plugins {
+ id 'base'
+ id 'org.openapi.generator'
+ }
+ openApiGenerate {
+ $extensionContents
+ }
+ """.trimIndent()
+ val projectFiles = mapOf(
+ "spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")!!
+ )
+ withProject(
+ projectDir = projectDir1,
+ settingsContents = settingsContents,
+ buildContents = buildContents,
+ projectFiles = projectFiles
+ )
+ }
+}
diff --git a/modules/openapi-generator-gradle-plugin/src/test/kotlin/GenerateTaskUpToDateTest.kt b/modules/openapi-generator-gradle-plugin/src/test/kotlin/GenerateTaskUpToDateTest.kt
new file mode 100644
index 00000000000..8510135b0d1
--- /dev/null
+++ b/modules/openapi-generator-gradle-plugin/src/test/kotlin/GenerateTaskUpToDateTest.kt
@@ -0,0 +1,173 @@
+package org.openapitools.generator.gradle.plugin
+
+import org.gradle.testkit.runner.TaskOutcome
+import org.testng.annotations.DataProvider
+import org.testng.annotations.Test
+import java.io.File
+import kotlin.test.assertEquals
+
+class GenerateTaskUpToDateTest : TestBase() {
+
+ @DataProvider(name = "gradle_version_provider")
+ private fun gradleVersionProvider(): Array> = arrayOf(arrayOf("6.9.2"), arrayOf("7.5.1"))
+
+ // inputSpec tests
+
+ private val inputSpecExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ """.trimIndent()
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `inputSpec - no file changes - should be up-to-date`(gradleVersion: String) {
+ runShouldBeUpToDateTest(gradleVersion, inputSpecExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `inputSpec - has file changes - should execute`(gradleVersion: String) {
+ runShouldExecuteTest(gradleVersion, inputSpecExtensionContents) {
+ val inputSpec = File(temp, "spec.yaml")
+ val newContents = inputSpec.readText().replace("version: 1.0.0", "version: 1.0.1")
+ inputSpec.writeText(newContents)
+ }
+ }
+
+ // templateDir tests
+
+ private val templateDirExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ templateDir = file("templateDir").absolutePath
+ """.trimIndent()
+
+ private fun initializeTemplateDirTest(): File {
+ val templateDir = temp.resolve("templateDir")
+ templateDir.mkdir()
+ return templateDir.resolve("templateFile").apply { writeText("contents") }
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `templateDir - no file changes - should be up-to-date`(gradleVersion: String) {
+ initializeTemplateDirTest()
+ runShouldBeUpToDateTest(gradleVersion, templateDirExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `templateDir - has file changes - should execute`(gradleVersion: String) {
+ val templateFile = initializeTemplateDirTest()
+ runShouldExecuteTest(gradleVersion, templateDirExtensionContents) {
+ templateFile.writeText("new contents")
+ }
+ }
+
+ // configFile tests
+
+ private val configFileExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ configFile = file("configFile").absolutePath
+ """.trimIndent()
+
+ private fun initializeConfigFileTest(): File {
+ return temp.resolve("configFile").apply { writeText("""{"foo":"bar"}""") }
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `configFile - no file changes - should be up-to-date`(gradleVersion: String) {
+ initializeConfigFileTest()
+ runShouldBeUpToDateTest(gradleVersion, configFileExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `configFile - has file changes - should execute`(gradleVersion: String) {
+ val configFile = initializeConfigFileTest()
+ runShouldExecuteTest(gradleVersion, configFileExtensionContents) {
+ configFile.writeText("""{"foo":"baz"}""")
+ }
+ }
+
+ // ignoreFileOverride tests
+
+ private val ignoreFileOverrideExtensionContents = """
+ generatorName = "kotlin"
+ inputSpec = file("spec.yaml").absolutePath
+ ignoreFileOverride = file(".openapi-generator-ignore").absolutePath
+ """.trimIndent()
+
+ private fun initializeIgnoreFileTest(): File {
+ return temp.resolve(".openapi-generator-ignore").apply { writeText(".some_file_to_ignore") }
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `ignoreFileOverride - no file changes - should be up-to-date`(gradleVersion: String) {
+ initializeIgnoreFileTest()
+ runShouldBeUpToDateTest(gradleVersion, ignoreFileOverrideExtensionContents)
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `ignoreFileOverride - has file changes - should execute`(gradleVersion: String) {
+ val ignoreFileOverride = initializeIgnoreFileTest()
+ runShouldExecuteTest(gradleVersion, ignoreFileOverrideExtensionContents) {
+ ignoreFileOverride.writeText(".new_file_to_ignore")
+ }
+ }
+
+ // Helper methods & test fixtures
+
+ private fun runShouldBeUpToDateTest(gradleVersion: String, extensionContents: String) {
+ // Arrange
+ withProject(extensionContents)
+
+ // Act
+ val result1 = build {
+ withArguments("clean", "openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ val result2 = build {
+ withArguments("openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ // Assert
+ assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
+ assertEquals(TaskOutcome.UP_TO_DATE, result2.task(":openApiGenerate")?.outcome)
+ }
+
+ private fun runShouldExecuteTest(gradleVersion: String, extensionContents: String, action: () -> Unit) {
+ // Arrange
+ withProject(extensionContents)
+
+ // Act
+ val result1 = build {
+ withArguments("clean", "openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ action()
+
+ val result2 = build {
+ withArguments("openApiGenerate")
+ withGradleVersion(gradleVersion)
+ }
+
+ // Assert
+ assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
+ assertEquals(TaskOutcome.SUCCESS, result2.task(":openApiGenerate")?.outcome)
+ }
+
+ private fun withProject(extensionContents: String) {
+ val buildContents = """
+ plugins {
+ id 'base'
+ id 'org.openapi.generator'
+ }
+ openApiGenerate {
+ $extensionContents
+ }
+ """.trimIndent()
+ File(temp, "build.gradle").writeText(buildContents)
+ File(javaClass.classLoader.getResource("specs/petstore-v3.0.yaml")!!.toURI())
+ .copyTo(File(temp, "spec.yaml"))
+ }
+}
diff --git a/modules/openapi-generator-gradle-plugin/src/test/kotlin/TestBase.kt b/modules/openapi-generator-gradle-plugin/src/test/kotlin/TestBase.kt
index c676686db50..b7abfb5d718 100644
--- a/modules/openapi-generator-gradle-plugin/src/test/kotlin/TestBase.kt
+++ b/modules/openapi-generator-gradle-plugin/src/test/kotlin/TestBase.kt
@@ -1,5 +1,6 @@
package org.openapitools.generator.gradle.plugin
+import org.gradle.testkit.runner.GradleRunner
import org.testng.annotations.AfterMethod
import org.testng.annotations.BeforeMethod
import java.io.File
@@ -10,7 +11,11 @@ abstract class TestBase {
protected open lateinit var temp: File
@BeforeMethod
- protected fun before() {
+ protected open fun before() {
+ initialize()
+ }
+
+ protected fun initialize() {
temp = createTempDirectory(javaClass.simpleName).toFile()
temp.deleteOnExit()
}
@@ -20,12 +25,28 @@ abstract class TestBase {
temp.deleteRecursively()
}
- protected fun withProject(buildContents: String, projectFiles: Map = mapOf()) {
- File(temp, "build.gradle").writeText(buildContents)
+ protected fun withProject(
+ buildContents: String,
+ projectFiles: Map = mapOf(),
+ projectDir: File? = temp,
+ settingsContents: String? = null
+ ) {
+ File(projectDir, "build.gradle").writeText(buildContents)
+ if (!settingsContents.isNullOrEmpty()) {
+ File(projectDir, "settings.gradle").writeText(settingsContents)
+ }
projectFiles.forEach { entry ->
- val target = File(temp, entry.key)
+ val target = File(projectDir, entry.key)
entry.value.copyTo(target.outputStream())
}
}
+
+ protected fun build(configure: GradleRunner.() -> Unit = {}) =
+ GradleRunner.create()
+ .withProjectDir(temp)
+ .withPluginClasspath()
+ .forwardOutput()
+ .apply(configure)
+ .build()!!
}
\ No newline at end of file
diff --git a/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml b/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml
index da8dd1cc914..edea61cc879 100644
--- a/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml
+++ b/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml
@@ -147,7 +147,7 @@
com.github.scribejava
scribejava-apis
- 6.9.0
+ 8.3.1
org.tomitribe
diff --git a/modules/openapi-generator/pom.xml b/modules/openapi-generator/pom.xml
index f8d3fa08301..3d04d22fb6e 100644
--- a/modules/openapi-generator/pom.xml
+++ b/modules/openapi-generator/pom.xml
@@ -377,7 +377,7 @@
com.fasterxml.jackson.core
jackson-databind
- ${jackson.version}
+ ${jackson-databind.version}
com.fasterxml.jackson.datatype
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index d6eef2a4222..0159ca2c8da 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -90,7 +90,7 @@ public class DefaultCodegen implements CodegenConfig {
// A cache of sanitized words. The sanitizeName() method is invoked many times with the same
// arguments, this cache is used to optimized performance.
- private static Cache sanitizedNameCache;
+ private static final Cache sanitizedNameCache;
private static final String xSchemaTestExamplesKey = "x-schema-test-examples";
private static final String xSchemaTestExamplesRefPrefix = "#/components/x-schema-test-examples/";
protected static Schema falseSchema;
@@ -161,9 +161,9 @@ public class DefaultCodegen implements CodegenConfig {
protected Set reservedWords;
protected Set languageSpecificPrimitives = new HashSet<>();
protected Map importMapping = new HashMap<>();
- // a map to store the mappping between a schema and the new one
+ // a map to store the mapping between a schema and the new one
protected Map schemaMapping = new HashMap<>();
- // a map to store the mappping between inline schema and the name provided by the user
+ // a map to store the mapping between inline schema and the name provided by the user
protected Map inlineSchemaNameMapping = new HashMap<>();
// a map to store the inline schema naming conventions
protected Map inlineSchemaNameDefault = new HashMap<>();
@@ -3715,7 +3715,7 @@ public class DefaultCodegen implements CodegenConfig {
} else {
property.openApiType = p.getType();
}
- property.nameInCamelCase = camelize(property.name, false);
+ property.nameInCamelCase = camelize(property.name);
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
property.description = escapeText(p.getDescription());
property.unescapedDescription = p.getDescription();
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java
index ef684023d35..40ebf90595a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java
@@ -903,7 +903,7 @@ public class InlineModelResolver {
addGenerated(name, schema);
openAPI.getComponents().addSchemas(name, schema);
if (!name.equals(schema.getTitle()) && !inlineSchemaNameMappingValues.contains(name)) {
- LOGGER.info("Inline schema created as {}. To have complete control of the model name, set the `title` field or use the inlineSchemaNameMapping option (--inline-schema-name-mapping in CLI).", name);
+ LOGGER.info("Inline schema created as {}. To have complete control of the model name, set the `title` field or use the inlineSchemaNameMapping option (--inline-schema-name-mappings in CLI).", name);
}
uniqueNames.add(name);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
index 2965605fd3c..dd67f9f4b57 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
abstract public class AbstractAdaCodegen extends DefaultCodegen implements CodegenConfig {
@@ -826,7 +827,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
// method with only the scope that it requires. We have to create a new auth method
// instance because the original object must not be modified.
List opScopes = (scopes == null) ? null : scopes.get(authMethod.name);
- authMethod.name = camelize(sanitizeName(authMethod.name), true);
+ authMethod.name = camelize(sanitizeName(authMethod.name), LOWERCASE_FIRST_LETTER);
if (opScopes != null) {
CodegenSecurity opSecurity = new CodegenSecurity();
opSecurity.name = authMethod.name;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
index 8f96a4bd34e..d64a2d56714 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {
@@ -111,7 +112,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
// camelize (lower first character) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
@@ -422,11 +423,11 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
index 4281abea4fe..610322f0cf4 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
@@ -41,6 +41,7 @@ import java.io.IOException;
import java.io.Writer;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig {
@@ -521,6 +522,16 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
property.isMap = composedProperty.isMap;
property.isContainer = composedProperty.isContainer;
}
+
+ // fix incorrect data types for maps of maps
+ if (property.datatypeWithEnum.contains("List>") && property.items != null) {
+ property.datatypeWithEnum = property.datatypeWithEnum.replace("List>", property.items.datatypeWithEnum + ">");
+ property.dataType = property.datatypeWithEnum;
+ }
+ if (property.datatypeWithEnum.contains("Dictionary>") && property.items != null) {
+ property.datatypeWithEnum = property.datatypeWithEnum.replace("Dictionary>", property.items.datatypeWithEnum + ">");
+ property.dataType = property.datatypeWithEnum;
+ }
}
@Override
@@ -964,7 +975,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// camelize(lower) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
index 5559d7f3ebe..11495fd7672 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
@@ -28,6 +28,7 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractDartCodegen extends DefaultCodegen {
@@ -373,7 +374,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
// camelize (lower first character) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
if (name.matches("^\\d.*")) {
name = "n" + name;
@@ -721,18 +722,18 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
public String toOperationId(String operationId) {
operationId = super.toOperationId(operationId);
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
operationId = newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java
index 5e179068c5d..112861cbb8f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -343,7 +344,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- String sanitizedOperationId = camelize(sanitizeName(operationId), true);
+ String sanitizedOperationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
@@ -354,7 +355,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
- sanitizedOperationId = camelize("call_" + sanitizedOperationId, true);
+ sanitizedOperationId = camelize("call_" + sanitizedOperationId, LOWERCASE_FIRST_LETTER);
}
// method name from updateSomething to update_Something.
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java
index b8a44efe931..0b66281495b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java
@@ -38,6 +38,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -661,7 +662,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -707,7 +708,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
// camelize(lower) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
index e024a49f143..d436a01c42f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
@@ -34,6 +34,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -232,7 +233,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
// params should be lowerCamelCase. E.g. "person Person", instead of
// "Person Person".
//
- name = camelize(toVarName(name), true);
+ name = camelize(toVarName(name), LOWERCASE_FIRST_LETTER);
// REVISIT: Actually, for idiomatic go, the param name should
// really should just be a letter, e.g. "p Person"), but we'll get
@@ -626,11 +627,39 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
iterator.remove();
}
- boolean addedTimeImport = false;
- boolean addedOSImport = false;
for (ModelMap m : objs.getModels()) {
+ boolean addedTimeImport = false;
+ boolean addedOSImport = false;
CodegenModel model = m.getModel();
- for (CodegenProperty cp : model.vars) {
+
+ List inheritedProperties = new ArrayList<>();
+ if (model.getComposedSchemas() != null) {
+ if (model.getComposedSchemas().getAllOf() != null) {
+ inheritedProperties.addAll(model.getComposedSchemas().getAllOf());
+ }
+ if (model.getComposedSchemas().getAnyOf() != null) {
+ inheritedProperties.addAll(model.getComposedSchemas().getAnyOf());
+ }
+ if (model.getComposedSchemas().getOneOf() != null) {
+ inheritedProperties.addAll(model.getComposedSchemas().getOneOf());
+ }
+ }
+
+ List codegenProperties = new ArrayList<>();
+ if(model.getIsModel() || model.getComposedSchemas() == null) {
+ // If the model is a model, use model.vars as it only
+ // contains properties the generated struct will own itself.
+ // If model is no model and it has no composed schemas use
+ // model.vars.
+ codegenProperties.addAll(model.vars);
+ } else {
+ // If the model is no model, but is a
+ // allOf, anyOf or oneOf, add all first level options
+ // from allOf, anyOf or oneOf.
+ codegenProperties.addAll(inheritedProperties);
+ }
+
+ for (CodegenProperty cp : codegenProperties) {
if (!addedTimeImport && ("time.Time".equals(cp.dataType) ||
(cp.items != null && "time.Time".equals(cp.items.dataType)))) {
imports.add(createMapping("import", "time"));
@@ -647,6 +676,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
imports.add(createMapping("import", "fmt"));
}
+ // if oneOf contains "time.Time" type
+ if (!addedTimeImport && model.oneOf != null && model.oneOf.contains("time.Time")) {
+ imports.add(createMapping("import", "time"));
+ }
+
// if oneOf contains "null" type
if (model.oneOf != null && !model.oneOf.isEmpty() && model.oneOf.contains("nil")) {
model.isNullable = true;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java
index 1966b054827..b72b574e89a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -160,7 +161,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
if (name.matches("^[A-Z_]*$"))
return name;
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name))
@@ -326,7 +327,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
sanitizedOperationId = "call_" + sanitizedOperationId;
}
- return camelize(sanitizedOperationId, false);
+ return camelize(sanitizedOperationId);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
index ea6fa237fb0..572575e0882 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
@@ -40,6 +40,7 @@ import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
+import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,6 +56,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
+import static org.openapitools.codegen.utils.CamelizeOption.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig,
@@ -81,6 +83,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public static final String IMPLICIT_HEADERS = "implicitHeaders";
public static final String IMPLICIT_HEADERS_REGEX = "implicitHeadersRegex";
+ public static final String CAMEL_CASE_DOLLAR_SIGN = "camelCaseDollarSign";
+
public static final String DEFAULT_TEST_FOLDER = "${project.build.directory}/generated-test-sources/openapi";
protected String dateLibrary = "java8";
@@ -130,6 +134,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected boolean implicitHeaders = false;
protected String implicitHeadersRegex = null;
+ protected boolean camelCaseDollarSign = false;
+
private Map schemaKeyToModelNameCache = new HashMap<>();
public AbstractJavaCodegen() {
@@ -262,6 +268,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
cliOptions.add(CliOption.newBoolean(OPENAPI_NULLABLE, "Enable OpenAPI Jackson Nullable library", this.openApiNullable));
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Skip header parameters in the generated API methods using @ApiImplicitParams annotation.", implicitHeaders));
cliOptions.add(CliOption.newString(IMPLICIT_HEADERS_REGEX, "Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true"));
+ cliOptions.add(CliOption.newBoolean(CAMEL_CASE_DOLLAR_SIGN, "Fix camelCase when starting with $ sign. when true : $Value when false : $value"));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_GROUP_ID, CodegenConstants.PARENT_GROUP_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_ARTIFACT_ID, CodegenConstants.PARENT_ARTIFACT_ID_DESC));
@@ -549,6 +556,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.setImplicitHeadersRegex(additionalProperties.get(IMPLICIT_HEADERS_REGEX).toString());
}
+ if (additionalProperties.containsKey(CAMEL_CASE_DOLLAR_SIGN)) {
+ this.setCamelCaseDollarSign(Boolean.parseBoolean(additionalProperties.get(CAMEL_CASE_DOLLAR_SIGN).toString()));
+ }
+
if (!StringUtils.isEmpty(parentGroupId) && !StringUtils.isEmpty(parentArtifactId) && !StringUtils.isEmpty(parentVersion)) {
additionalProperties.put("parentOverridden", true);
}
@@ -795,7 +806,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// camelize (lower first character) the variable name
// pet_id => petId
- name = camelize(name, true);
+ if (camelCaseDollarSign) {
+ name = camelize(name, LOWERCASE_FIRST_CHAR);
+ } else {
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
+ }
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
@@ -1261,11 +1276,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -1273,7 +1288,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + operationId), true);
- operationId = camelize("call_" + operationId, true);
+ operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@@ -1902,6 +1917,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.implicitHeadersRegex = implicitHeadersRegex;
}
+ public void setCamelCaseDollarSign(boolean camelCaseDollarSign) {
+ this.camelCaseDollarSign = camelCaseDollarSign;
+ }
+
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
@@ -1984,7 +2003,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
*/
@Override
public String getterAndSetterCapitalize(String name) {
- boolean lowercaseFirstLetter = false;
+ CamelizeOption camelizeOption = UPPERCASE_FIRST_CHAR;
if (name == null || name.length() == 0) {
return name;
}
@@ -1996,9 +2015,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// http://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf)
//
if (name.length() > 1 && Character.isLowerCase(name.charAt(0)) && Character.isUpperCase(name.charAt(1))) {
- lowercaseFirstLetter = true;
+ camelizeOption = LOWERCASE_FIRST_LETTER;
}
- return camelize(name, lowercaseFirstLetter);
+ return camelize(name, camelizeOption);
}
@Override
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 bd3b2279d19..399e9f61f99 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
@@ -39,6 +39,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
@@ -49,6 +50,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
public static final String MODEL_MUTABLE = "modelMutable";
public static final String MODEL_MUTABLE_DESC = "Create mutable models";
+ public static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS = "additionalModelTypeAnnotations";
private final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
@@ -60,12 +62,12 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
protected String sourceFolder = "src/main/kotlin";
protected String testFolder = "src/test/kotlin";
+ protected String resourcesFolder = "src/main/resources";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected boolean parcelizeModels = false;
protected boolean serializableModel = false;
- protected boolean needsDataClassBody = false;
protected boolean nonPublicApi = false;
@@ -76,7 +78,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// ref: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-hash-map/
protected Set propertyAdditionalKeywords = new HashSet<>(Arrays.asList("entries", "keys", "size", "values"));
- private Map schemaKeyToModelNameCache = new HashMap<>();
+ private final Map schemaKeyToModelNameCache = new HashMap<>();
+ protected List additionalModelTypeAnnotations = new LinkedList<>();
public AbstractKotlinCodegen() {
super();
@@ -262,6 +265,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
cliOptions.add(new CliOption(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG_DESC));
cliOptions.add(CliOption.newBoolean(MODEL_MUTABLE, MODEL_MUTABLE_DESC, false));
+ cliOptions.add(CliOption.newString(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)"));
}
@Override
@@ -398,6 +402,21 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
}
+ @Override
+ public Map postProcessAllModels(Map objs) {
+ objs = super.postProcessAllModels(objs);
+ objs = super.updateAllModels(objs);
+
+ if (!additionalModelTypeAnnotations.isEmpty()) {
+ for (String modelName : objs.keySet()) {
+ Map models = (Map) objs.get(modelName);
+ models.put(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, additionalModelTypeAnnotations);
+ }
+ }
+
+ return objs;
+ }
+
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
objs = super.postProcessModelsEnum(objs);
@@ -506,6 +525,11 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi);
}
+ if (additionalProperties.containsKey(ADDITIONAL_MODEL_TYPE_ANNOTATIONS)) {
+ String additionalAnnotationsList = additionalProperties.get(ADDITIONAL_MODEL_TYPE_ANNOTATIONS).toString();
+ this.setAdditionalModelTypeAnnotations(Arrays.asList(additionalAnnotationsList.trim().split("\\s*(;|\\r?\\n)\\s*")));
+ }
+
additionalProperties.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, getSortParamsByRequiredFlag());
additionalProperties.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, getSortModelPropertiesByRequiredFlag());
@@ -578,14 +602,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
this.nonPublicApi = nonPublicApi;
}
- public boolean isNeedsDataClassBody() {
- return needsDataClassBody;
- }
-
- public void setNeedsDataClassBody(boolean needsDataClassBody) {
- this.needsDataClassBody = needsDataClassBody;
- }
-
/**
* Return the sanitized variable name for enum
*
@@ -610,7 +626,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
break;
case camelCase:
// NOTE: Removes hyphens and underscores
- modified = camelize(modified, true);
+ modified = camelize(modified, LOWERCASE_FIRST_LETTER);
break;
case PascalCase:
// NOTE: Removes hyphens and underscores
@@ -673,9 +689,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toModelName(final String name) {
// memoization
- String origName = name;
- if (schemaKeyToModelNameCache.containsKey(origName)) {
- return schemaKeyToModelNameCache.get(origName);
+ if (schemaKeyToModelNameCache.containsKey(name)) {
+ return schemaKeyToModelNameCache.get(name);
}
// Allow for explicitly configured kotlin.* and java.* types
@@ -695,9 +710,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
String modifiedName = name.replaceAll("\\.", "");
- String sanitizedName = sanitizeKotlinSpecificNames(modifiedName);
- String nameWithPrefixSuffix = sanitizedName;
+ String nameWithPrefixSuffix = sanitizeKotlinSpecificNames(modifiedName);
if (!StringUtils.isEmpty(modelNamePrefix)) {
// add '_' so that model name can be camelized correctly
nameWithPrefixSuffix = modelNamePrefix + "_" + nameWithPrefixSuffix;
@@ -726,8 +740,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return modelName;
}
- schemaKeyToModelNameCache.put(origName, titleCase(modifiedName));
- return schemaKeyToModelNameCache.get(origName);
+ schemaKeyToModelNameCache.put(name, titleCase(modifiedName));
+ return schemaKeyToModelNameCache.get(name);
}
/**
@@ -742,19 +756,19 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
if (StringUtils.isEmpty(operationId))
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
- operationId = camelize("call_" + operationId, true);
+ LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), LOWERCASE_FIRST_LETTER);
+ operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@@ -843,10 +857,9 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
protected boolean needToImport(String type) {
// provides extra protection against improperly trying to import language primitives and java types
- boolean imports = !type.startsWith("kotlin.") && !type.startsWith("java.") &&
+ return !type.startsWith("kotlin.") && !type.startsWith("java.") &&
!defaultIncludes.contains(type) && !languageSpecificPrimitives.contains(type) &&
!type.contains(".");
- return imports;
}
@Override
@@ -909,7 +922,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
public String toVarName(String name) {
name = toVariableName(name);
if (propertyAdditionalKeywords.contains(name)) {
- return camelize("property_" + name, true);
+ return camelize("property_" + name, LOWERCASE_FIRST_LETTER);
} else {
return name;
}
@@ -938,7 +951,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
// If name contains special chars -> replace them.
- if ((name.chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character))))) {
+ if ((name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character))))) {
List allowedCharacters = new ArrayList<>();
allowedCharacters.add("_");
allowedCharacters.add("$");
@@ -947,7 +960,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// camelize (lower first character) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number or containing dollar symbol, escape it
if (isReservedWord(name) || name.matches("(^\\d.*)|(.*[$].*)")) {
@@ -1017,15 +1030,17 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toDefaultValue(Schema schema) {
- Schema p = ModelUtils.getReferencedSchema(this.openAPI, schema);
+ Schema> p = ModelUtils.getReferencedSchema(this.openAPI, schema);
if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
} else if (ModelUtils.isDateSchema(p)) {
// TODO
+ return null;
} else if (ModelUtils.isDateTimeSchema(p)) {
// TODO
+ return null;
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {
return fixNumberValue(p.getDefault().toString(), p);
@@ -1071,7 +1086,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
return null;
}
-
return null;
}
@@ -1082,7 +1096,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
protected void updateModelForObject(CodegenModel m, Schema schema) {
- /**
+ /*
* we have a custom version of this function so we only set isMap to true if
* ModelUtils.isMapSchema
* In other generators, isMap is true for all type object schemas
@@ -1105,4 +1119,12 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// process 'additionalProperties'
setAddProps(schema, m);
}
+
+ public List getAdditionalModelTypeAnnotations() {
+ return additionalModelTypeAnnotations;
+ }
+
+ public void setAdditionalModelTypeAnnotations(final List additionalModelTypeAnnotations) {
+ this.additionalModelTypeAnnotations = additionalModelTypeAnnotations;
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
index 98fd8f92217..cdf154aefd8 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
@@ -35,6 +35,9 @@ import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
+import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -413,9 +416,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
if ("camelCase".equals(variableNamingConvention)) {
// return the name in camelCase style
// phone_number => phoneNumber
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
} else if ("PascalCase".equals(variableNamingConvention)) {
- name = camelize(name, false);
+ name = camelize(name, UPPERCASE_FIRST_CHAR);
} else { // default to snake case
// return the name in underscore style
// PhoneNumber => phone_number
@@ -542,17 +545,17 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER));
operationId = "call_" + operationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER));
operationId = "call_" + operationId;
}
- return camelize(sanitizeName(operationId), true);
+ return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
/**
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
index 5f0f932c8d9..88ae7be78fd 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
@@ -313,7 +313,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
if (name == null || name.length() == 0) {
return "DefaultController";
}
- return camelize(name, false) + "Controller";
+ return camelize(name) + "Controller";
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java
index 9d8541fc641..3fa7e4c9368 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java
@@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Escapers;
import com.samskivert.mustache.Mustache;
+import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
@@ -27,15 +28,20 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.model.ModelsMap;
+import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.*;
import static org.openapitools.codegen.languages.AbstractJavaCodegen.DATE_LIBRARY;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
+import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -293,7 +299,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -527,7 +533,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
if (specialCharReplacements.containsKey(name)) {
name = specialCharReplacements.get(name);
}
- String identifier = camelize(sanitizeName(name), true);
+ String identifier = camelize(sanitizeName(name), LOWERCASE_FIRST_LETTER);
if (capitalized) {
identifier = StringUtils.capitalize(identifier);
}
@@ -588,11 +594,11 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -600,7 +606,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
- operationId = camelize("call_" + operationId, true);
+ operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@@ -614,4 +620,32 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.SCALA;
}
+
+ protected static abstract class CustomLambda implements Mustache.Lambda {
+ @Override
+ public void execute(Template.Fragment frag, Writer out) throws IOException {
+ final StringWriter tempWriter = new StringWriter();
+ frag.execute(tempWriter);
+ out.write(formatFragment(tempWriter.toString()));
+ }
+
+ public abstract String formatFragment(String fragment);
+ }
+
+ protected static class CamelizeLambda extends CustomLambda {
+ private final CamelizeOption option;
+
+ public CamelizeLambda(boolean capitalizeFirst) {
+ if (capitalizeFirst) {
+ option = UPPERCASE_FIRST_CHAR;
+ } else {
+ option = LOWERCASE_FIRST_LETTER;
+ }
+ }
+
+ @Override
+ public String formatFragment(String fragment) {
+ return camelize(fragment, option);
+ }
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
index 91c7bb1accd..779a71ccf60 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
@@ -47,6 +47,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.ParameterExpander.ParamStyle.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -757,7 +758,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
throw new RuntimeException("Empty method name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
operationId = toSafeIdentifier(operationId);
return operationId;
@@ -802,7 +803,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -820,7 +821,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -911,7 +912,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
case original:
return name;
case camelCase:
- return camelize(underscore(name), true);
+ return camelize(underscore(name), LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(underscore(name));
case snake_case:
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java
index b0bbe14c92e..597e94fd510 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java
@@ -30,6 +30,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -267,7 +268,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
// camelize (lower first character) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
@@ -394,11 +395,11 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
throw new RuntimeException("Empty method name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java
index 65efb273c70..64980677c15 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -807,7 +808,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
public String toOperationId(String operationId) {
// rename to empty_method_name_1 (e.g.) if method name is empty
if (StringUtils.isEmpty(operationId)) {
- operationId = camelize("empty_method_name_" + emptyMethodNameCounter++, true);
+ operationId = camelize("empty_method_name_" + emptyMethodNameCounter++, LOWERCASE_FIRST_LETTER);
LOGGER.warn("Empty method name (operationId) found. Renamed to {}", operationId);
return operationId;
}
@@ -825,7 +826,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
operationId = "call_" + operationId;
}
- return camelize(sanitizeName(operationId), true);
+ return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
index c0c49772095..16436597ffc 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
@@ -32,6 +32,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -733,19 +734,19 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize(sanitizeName("call_" + operationId), true);
+ String newOperationId = camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- String newOperationId = camelize(sanitizeName("call_" + operationId), true);
+ String newOperationId = camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
- return camelize(sanitizeName(operationId), true);
+ return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
index 6700545a65f..153d9b4b471 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
@@ -31,6 +31,7 @@ import java.io.File;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.isEmpty;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -835,7 +836,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
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 82975676024..5275022545e 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
@@ -42,6 +42,7 @@ import java.util.Comparator;
import java.util.List;
import static org.apache.commons.lang3.StringUtils.isEmpty;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -84,10 +85,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
private static FrameworkStrategy defaultFramework = FrameworkStrategy.NETSTANDARD_2_0;
protected final Map frameworks;
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
- protected String clientPackage = "Org.OpenAPITools.Client";
+ protected String clientPackage = "Client";
protected String authFolder = "Auth";
- protected String apiDocPath = "docs/";
- protected String modelDocPath = "docs/";
+ protected String apiDocPath = "docs" + File.separator;
+ protected String modelDocPath = "docs" + File.separator;
// Defines TargetFrameworkVersion in csproj files
protected String targetFramework = defaultFramework.name;
@@ -490,7 +491,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -547,6 +548,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
postProcessPattern(property.pattern, property.vendorExtensions);
postProcessEmitDefaultValue(property.vendorExtensions);
+ // remove once https://github.com/OpenAPITools/openapi-generator/pull/13681 is merged
if (GENERICHOST.equals(getLibrary())) {
// all c# libraries should want this, but avoid breaking changes for now
// a class cannot contain a property with the same name
@@ -664,8 +666,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
setModelPackage("Model");
}
- clientPackage = "Client";
-
if (GENERICHOST.equals(getLibrary())) {
setLibrary(GENERICHOST);
additionalProperties.put("useGenericHost", true);
@@ -679,7 +679,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
additionalProperties.put("useHttpClient", true);
needsUriBuilder = true;
} else {
- throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only restsharp, httpclient are supported.");
+ throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only restsharp, httpclient, and generichost are supported.");
}
String inputFramework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
@@ -742,7 +742,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
final AtomicReference excludeTests = new AtomicReference<>();
syncBooleanProperty(additionalProperties, CodegenConstants.EXCLUDE_TESTS, excludeTests::set, false);
- syncStringProperty(additionalProperties, "clientPackage", (s) -> { }, clientPackage);
+ syncStringProperty(additionalProperties, "clientPackage", this::setClientPackage, clientPackage);
syncStringProperty(additionalProperties, CodegenConstants.API_PACKAGE, this::setApiPackage, apiPackage);
syncStringProperty(additionalProperties, CodegenConstants.MODEL_PACKAGE, this::setModelPackage, modelPackage);
@@ -809,6 +809,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
addTestInstructions();
}
+ public void setClientPackage(String clientPackage) {
+ this.clientPackage = clientPackage;
+ }
+
@Override
public CodegenOperation fromOperation(String path,
String httpMethod,
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java
index 4d4495fda4d..e9b09f0acb9 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java
@@ -37,6 +37,7 @@ import java.util.function.Consumer;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.isEmpty;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -415,7 +416,7 @@ public class CSharpNetCoreReducedClientCodegen extends AbstractCSharpCodegen {
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java
index a60e1cdb6be..5c6381a0884 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java
@@ -32,6 +32,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class CppTizenClientCodegen extends AbstractCppCodegen implements CodegenConfig {
@@ -311,7 +312,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
}
// add_pet_by_id => addPetById
- return camelize(operationId, true);
+ return camelize(operationId, LOWERCASE_FIRST_LETTER);
}
/**
* Output the Getter name for boolean property, e.g. getActive
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppUE4ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppUE4ClientCodegen.java
index 09f7808f119..cec3f30a402 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppUE4ClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppUE4ClientCodegen.java
@@ -485,7 +485,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
languageSpecificPrimitives.contains(type)) {
return type;
} else {
- return modelNamePrefix + camelize(sanitizeName(type), false);
+ return modelNamePrefix + camelize(sanitizeName(type));
}
}
@@ -500,7 +500,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
}
//Unreal variable names are CamelCase
- String camelCaseName = camelize(name, false);
+ String camelCaseName = camelize(name);
//Avoid empty variable name at all costs
if(!camelCaseName.isEmpty()) {
@@ -527,7 +527,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
@Override
public String toApiName(String type) {
- return modelNamePrefix + camelize(type, false) + "Api";
+ return modelNamePrefix + camelize(type) + "Api";
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java
index 2bad546e9bd..bef91d6e735 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java
@@ -84,27 +84,21 @@ public class CrystalClientCodegen extends DefaultCodegen {
SecurityFeature.BasicAuth,
SecurityFeature.BearerToken,
SecurityFeature.ApiKey,
- SecurityFeature.OAuth2_Implicit
- ))
+ SecurityFeature.OAuth2_Implicit))
.excludeGlobalFeatures(
GlobalFeature.XMLStructureDefinitions,
GlobalFeature.Callbacks,
GlobalFeature.LinkObjects,
GlobalFeature.ParameterStyling,
GlobalFeature.ParameterizedServer,
- GlobalFeature.MultiServer
- )
+ GlobalFeature.MultiServer)
.includeSchemaSupportFeatures(
- SchemaSupportFeature.Polymorphism
- )
+ SchemaSupportFeature.Polymorphism)
.excludeParameterFeatures(
- ParameterFeature.Cookie
- )
+ ParameterFeature.Cookie)
.includeClientModificationFeatures(
ClientModificationFeature.BasePath,
- ClientModificationFeature.UserAgent
- )
- );
+ ClientModificationFeature.UserAgent));
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
@@ -128,13 +122,14 @@ public class CrystalClientCodegen extends DefaultCodegen {
apiTestTemplateFiles.put("api_test.mustache", ".cr");
// TODO support auto-generated doc
- //modelDocTemplateFiles.put("model_doc.mustache", ".md");
- //apiDocTemplateFiles.put("api_doc.mustache", ".md");
+ // modelDocTemplateFiles.put("model_doc.mustache", ".md");
+ // apiDocTemplateFiles.put("api_doc.mustache", ".md");
// default HIDE_GENERATION_TIMESTAMP to true
hideGenerationTimestamp = Boolean.TRUE;
- // reserved word. Ref: https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#available-keywords
+ // reserved word. Ref:
+ // https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#available-keywords
reservedWords = new HashSet<>(
Arrays.asList(
"abstract", "annotation", "do", "if", "nil?", "select", "union",
@@ -146,8 +141,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
"break", "extend", "macro", "require", "true", "with",
"case", "false", "module", "rescue", "type", "yield",
"class", "for", "next", "responds_to?", "typeof",
- "def", "fun", "nil", "return", "uninitialized")
- );
+ "def", "fun", "nil", "return", "uninitialized"));
languageSpecificPrimitives.clear();
languageSpecificPrimitives.add("String");
@@ -180,6 +174,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
typeMapping.put("set", "Set");
typeMapping.put("map", "Hash");
typeMapping.put("object", "Object");
+ typeMapping.put("AnyType", "Object");
typeMapping.put("file", "::File");
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
@@ -194,29 +189,25 @@ public class CrystalClientCodegen extends DefaultCodegen {
cliOptions.removeIf(opt -> CodegenConstants.MODEL_PACKAGE.equals(opt.getOpt()) ||
CodegenConstants.API_PACKAGE.equals(opt.getOpt()));
- cliOptions.add(new CliOption(SHARD_NAME, "shard name (e.g. twitter_client").
- defaultValue("openapi_client"));
+ cliOptions.add(new CliOption(SHARD_NAME, "shard name (e.g. twitter_client").defaultValue("openapi_client"));
- cliOptions.add(new CliOption(MODULE_NAME, "module name (e.g. TwitterClient").
- defaultValue("OpenAPIClient"));
+ cliOptions.add(new CliOption(MODULE_NAME, "module name (e.g. TwitterClient").defaultValue("OpenAPIClient"));
cliOptions.add(new CliOption(SHARD_VERSION, "shard version.").defaultValue("1.0.0"));
- cliOptions.add(new CliOption(SHARD_LICENSE, "shard license.").
- defaultValue("unlicense"));
+ cliOptions.add(new CliOption(SHARD_LICENSE, "shard license.").defaultValue("unlicense"));
- cliOptions.add(new CliOption(SHARD_HOMEPAGE, "shard homepage.").
- defaultValue("http://org.openapitools"));
+ cliOptions.add(new CliOption(SHARD_HOMEPAGE, "shard homepage.").defaultValue("http://org.openapitools"));
- cliOptions.add(new CliOption(SHARD_DESCRIPTION, "shard description.").
- defaultValue("This shard maps to a REST API"));
+ cliOptions.add(
+ new CliOption(SHARD_DESCRIPTION, "shard description.").defaultValue("This shard maps to a REST API"));
cliOptions.add(new CliOption(SHARD_AUTHOR, "shard author (only one is supported)."));
cliOptions.add(new CliOption(SHARD_AUTHOR_EMAIL, "shard author email (only one is supported)."));
- cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).
- defaultValue(Boolean.TRUE.toString()));
+ cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
+ CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).defaultValue(Boolean.TRUE.toString()));
}
@Override
@@ -224,7 +215,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
super.processOpts();
if (StringUtils.isEmpty(System.getenv("CRYSTAL_POST_PROCESS_FILE"))) {
- LOGGER.info("Hint: Environment variable 'CRYSTAL_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export CRYSTAL_POST_PROCESS_FILE=\"/usr/local/bin/crystal tool format\"' (Linux/Mac)");
+ LOGGER.info(
+ "Hint: Environment variable 'CRYSTAL_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export CRYSTAL_POST_PROCESS_FILE=\"/usr/local/bin/crystal tool format\"' (Linux/Mac)");
}
if (additionalProperties.containsKey(SHARD_NAME)) {
@@ -313,12 +305,14 @@ public class CrystalClientCodegen extends DefaultCodegen {
@Override
public String apiFileFolder() {
- return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator + apiPackage.replace("/", File.separator);
+ return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator
+ + apiPackage.replace("/", File.separator);
}
@Override
public String modelFileFolder() {
- return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator + modelPackage.replace("/", File.separator);
+ return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator
+ + modelPackage.replace("/", File.separator);
}
@Override
@@ -364,7 +358,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
@Override
public String toModelName(final String name) {
String modelName;
- modelName = sanitizeName(name);
+ modelName = sanitizeModelName(name);
if (!StringUtils.isEmpty(modelNamePrefix)) {
modelName = modelNamePrefix + "_" + modelName;
@@ -393,6 +387,15 @@ public class CrystalClientCodegen extends DefaultCodegen {
return camelize(modelName);
}
+ public String sanitizeModelName(String modelName) {
+ String[] parts = modelName.split("::");
+ ArrayList new_parts = new ArrayList();
+ for (String part : parts) {
+ new_parts.add(sanitizeName(part));
+ }
+ return String.join("::", new_parts);
+ }
+
@Override
public String toModelFilename(String name) {
return underscore(toModelName(name));
@@ -510,7 +513,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId,
+ underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -609,7 +613,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
return objs;
}
- private String constructExampleCode(CodegenParameter codegenParameter, HashMap modelMaps, HashMap processedModelMap) {
+ private String constructExampleCode(CodegenParameter codegenParameter, HashMap modelMaps,
+ HashMap processedModelMap) {
if (codegenParameter.isArray) { // array
if (codegenParameter.items == null) {
return "[]";
@@ -669,13 +674,15 @@ public class CrystalClientCodegen extends DefaultCodegen {
if (modelMaps.containsKey(codegenParameter.dataType)) {
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
} else {
- //LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
+ // LOGGER.error("Error in constructing examples. Failed to look up the model " +
+ // codegenParameter.dataType);
return "TODO";
}
}
}
- private String constructExampleCode(CodegenProperty codegenProperty, HashMap modelMaps, HashMap processedModelMap) {
+ private String constructExampleCode(CodegenProperty codegenProperty, HashMap modelMaps,
+ HashMap processedModelMap) {
if (codegenProperty.isArray) { // array
return "[" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "]";
} else if (codegenProperty.isMap) {
@@ -735,14 +742,17 @@ public class CrystalClientCodegen extends DefaultCodegen {
if (modelMaps.containsKey(codegenProperty.dataType)) {
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
} else {
- //LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
+ // LOGGER.error("Error in constructing examples. Failed to look up the model " +
+ // codegenParameter.dataType);
return "TODO";
}
}
}
- private String constructExampleCode(CodegenModel codegenModel, HashMap modelMaps, HashMap processedModelMap) {
- // break infinite recursion. Return, in case a model is already processed in the current context.
+ private String constructExampleCode(CodegenModel codegenModel, HashMap modelMaps,
+ HashMap processedModelMap) {
+ // break infinite recursion. Return, in case a model is already processed in the
+ // current context.
String model = codegenModel.name;
if (processedModelMap.containsKey(model)) {
int count = processedModelMap.get(model);
@@ -754,7 +764,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
throw new RuntimeException("Invalid count when constructing example: " + count);
}
} else if (codegenModel.isEnum) {
- List> enumVars = (List>) codegenModel.allowableValues.get("enumVars");
+ List> enumVars = (List>) codegenModel.allowableValues
+ .get("enumVars");
return moduleName + "::" + codegenModel.classname + "::" + enumVars.get(0).get("name");
} else if (codegenModel.oneOf != null && !codegenModel.oneOf.isEmpty()) {
String subModel = (String) codegenModel.oneOf.toArray()[0];
@@ -766,7 +777,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
List propertyExamples = new ArrayList<>();
for (CodegenProperty codegenProperty : codegenModel.requiredVars) {
- propertyExamples.add(codegenProperty.name + ": " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));
+ propertyExamples.add(
+ codegenProperty.name + ": " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));
}
String example = moduleName + "::" + toModelName(model) + ".new";
if (!propertyExamples.isEmpty()) {
@@ -826,7 +838,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return "Date.parse(\"" + String.format(Locale.ROOT, localDate.toString(), "") + "\")";
} else if (p.getDefault() instanceof java.time.OffsetDateTime) {
- return "Time.parse(\"" + String.format(Locale.ROOT, ((java.time.OffsetDateTime) p.getDefault()).atZoneSameInstant(ZoneId.systemDefault()).toString(), "") + "\")";
+ return "Time.parse(\"" + String.format(Locale.ROOT, ((java.time.OffsetDateTime) p.getDefault())
+ .atZoneSameInstant(ZoneId.systemDefault()).toString(), "") + "\")";
} else {
return "\"" + escapeText((String.valueOf(p.getDefault()))) + "\"";
}
@@ -901,14 +914,16 @@ public class CrystalClientCodegen extends DefaultCodegen {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
- try (InputStreamReader inputStreamReader = new InputStreamReader(p.getErrorStream(), StandardCharsets.UTF_8);
- BufferedReader br = new BufferedReader(inputStreamReader)) {
+ try (InputStreamReader inputStreamReader = new InputStreamReader(p.getErrorStream(),
+ StandardCharsets.UTF_8);
+ BufferedReader br = new BufferedReader(inputStreamReader)) {
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
- LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb);
+ LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command,
+ exitValue, sb);
}
} else {
LOGGER.info("Successfully executed: {}", command);
@@ -922,5 +937,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
}
@Override
- public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.CRYSTAL; }
+ public GeneratorLanguage generatorLanguage() {
+ return GeneratorLanguage.CRYSTAL;
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
index 16f1a974895..89d2c4cbf04 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
@@ -43,6 +43,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -187,11 +188,11 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -199,7 +200,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
- operationId = camelize("call_" + operationId, true);
+ operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@@ -226,7 +227,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toVarName(String name) {
- final String varName = camelize(name.replaceAll("[^a-zA-Z0-9_]", ""), true);
+ final String varName = camelize(name.replaceAll("[^a-zA-Z0-9_]", ""), LOWERCASE_FIRST_LETTER);
return isReservedWord(varName) ? escapeReservedWord(name) : varName;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java
index 2b89404ce7d..05eae90beec 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java
@@ -33,6 +33,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -297,7 +298,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
// underscore the variable name
// petId => pet_id
- name = camelize(dropDots(name), true);
+ name = camelize(dropDots(name), LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java
index e145e4a3855..6f3dae4915c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java
@@ -41,6 +41,7 @@ import java.io.IOException;
import java.io.Writer;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class GoClientCodegen extends AbstractGoCodegen {
@@ -392,7 +393,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
@Override
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
CodegenProperty prop = super.fromProperty(name, p, required);
- String cc = camelize(prop.name, true);
+ String cc = camelize(prop.name, LOWERCASE_FIRST_LETTER);
if (isReservedWord(cc)) {
cc = escapeReservedWord(cc);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java
index f728c766517..407e05a09af 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java
@@ -43,6 +43,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
+import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -1171,9 +1173,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
}
public String toVarName(String prefix, String name) {
- Boolean hasPrefix = !StringUtils.isBlank(prefix);
+ boolean hasPrefix = !StringUtils.isBlank(prefix);
name = underscore(sanitizeName(name.replaceAll("-", "_")));
- name = camelize(name, !hasPrefix);
+ name = camelize(name, hasPrefix ? UPPERCASE_FIRST_CHAR : LOWERCASE_FIRST_LETTER);
+
if (hasPrefix) {
return prefix + name;
} else {
@@ -1227,7 +1230,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = escapeIdentifier("op", camelize(sanitizeName(operationId), true));
+ operationId = escapeIdentifier("op", camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER));
return operationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java
index 5bc339d774f..4296074ddd1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java
@@ -35,6 +35,7 @@ import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class HaskellServantCodegen extends DefaultCodegen implements CodegenConfig {
@@ -592,7 +593,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
op.vendorExtensions.put("x-client-type", joinStrings(" -> ", type));
op.vendorExtensions.put("x-form-name", "Form" + camelize(op.operationId));
for (CodegenParameter param : op.formParams) {
- param.vendorExtensions.put("x-form-prefix", camelize(op.operationId, true));
+ param.vendorExtensions.put("x-form-prefix", camelize(op.operationId, LOWERCASE_FIRST_LETTER));
}
return op;
}
@@ -658,7 +659,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
}
// From the model name, compute the prefix for the fields.
- String prefix = camelize(model.classname, true);
+ String prefix = camelize(model.classname, LOWERCASE_FIRST_LETTER);
for (CodegenProperty prop : model.vars) {
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java
index d30093ce7c9..8b8c49076fc 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java
@@ -37,6 +37,7 @@ import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.dashize;
@@ -571,7 +572,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
}
// From the model name, compute the prefix for the fields.
- String prefix = camelize(model.classname, true);
+ String prefix = camelize(model.classname, LOWERCASE_FIRST_LETTER);
for (CodegenProperty prop : model.vars) {
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index c2b5ad4863a..fe85946ba88 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -44,6 +44,7 @@ import java.util.regex.Pattern;
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
import static java.util.Collections.sort;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavaClientCodegen extends AbstractJavaCodegen
@@ -762,7 +763,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
for (int i = 0; i < items.length; ++i) {
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
// camelize path variable
- items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
+ items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), LOWERCASE_FIRST_LETTER) + "}";
}
}
op.path = StringUtils.join(items, "/");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPKMSTServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPKMSTServerCodegen.java
index 22bd809dde6..ac6ce1e43f7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPKMSTServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPKMSTServerCodegen.java
@@ -33,6 +33,7 @@ import java.io.File;
import java.net.URL;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
/**
@@ -512,7 +513,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
title = title.substring(0, title.length() - 3);
}
- this.title = camelize(sanitizeName(title), true);
+ this.title = camelize(sanitizeName(title), LOWERCASE_FIRST_LETTER);
}
additionalProperties.put(TITLE, this.title);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java
index 9de29a5ef90..04abfd95b93 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java
@@ -34,6 +34,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
@@ -330,7 +331,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
Matcher match = pathVariableMatcher.matcher(operation.path);
while (match.find()) {
String completeMatch = match.group();
- String replacement = ":" + camelize(match.group(1), true);
+ String replacement = ":" + camelize(match.group(1), LOWERCASE_FIRST_LETTER);
operation.path = operation.path.replace(completeMatch, replacement);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java
index 686542b7617..e979a72b2c1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java
@@ -40,6 +40,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class JavascriptApolloClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -507,7 +508,7 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -840,18 +841,18 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
index eac98040cc6..5d388308675 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
@@ -39,6 +39,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -492,7 +493,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -825,18 +826,18 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java
index f93d32affc2..b0649d5a8a1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -179,7 +180,7 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
// camelize the variable name
// pet_id => PetId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*"))
@@ -287,11 +288,11 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize("call_" + operationId, true);
+ String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java
index afc56451f1c..c0dfa1c2e03 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java
@@ -16,6 +16,7 @@
package org.openapitools.codegen.languages;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.dashize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -708,7 +709,7 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
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 6b9dd53321d..994b4b052cc 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
@@ -63,6 +63,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
protected static final String JVM_RETROFIT2 = "jvm-retrofit2";
protected static final String MULTIPLATFORM = "multiplatform";
protected static final String JVM_VOLLEY = "jvm-volley";
+ protected static final String JVM_VERTX = "jvm-vertx";
public static final String USE_RX_JAVA = "useRxJava";
public static final String USE_RX_JAVA2 = "useRxJava2";
@@ -215,6 +216,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportedLibraries.put(JVM_RETROFIT2, "Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.");
supportedLibraries.put(MULTIPLATFORM, "Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.");
supportedLibraries.put(JVM_VOLLEY, "Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9");
+ supportedLibraries.put(JVM_VERTX, "Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
@@ -441,6 +443,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
case MULTIPLATFORM:
processMultiplatformLibrary(infrastructureFolder);
break;
+ case JVM_VERTX:
+ processJVMVertXLibrary(infrastructureFolder);
+ break;
default:
break;
}
@@ -666,6 +671,22 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("auth/OAuth.kt.mustache", authFolder, "OAuth.kt"));
}
+ /**
+ * Process Vert.x client options
+ *
+ * @param infrastructureFolder infrastructure destination folder
+ */
+ private void processJVMVertXLibrary(final String infrastructureFolder) {
+ supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/ApiResponse.kt.mustache", infrastructureFolder, "ApiResponse.kt"));
+ addSupportingSerializerAdapters(infrastructureFolder);
+
+ additionalProperties.put(JVM, true);
+ additionalProperties.put(JVM_VERTX, true);
+ }
+
private void processJVMOkHttpLibrary(final String infrastructureFolder) {
commonJvmMultiplatformSupportingFiles(infrastructureFolder);
addSupportingSerializerAdapters(infrastructureFolder);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
index 67a042da6b4..ffaef1dc137 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
@@ -131,7 +131,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files. This option is currently supported only when using jaxrs-spec library.").defaultValue(String.valueOf(interfaceOnly)));
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations. This option is currently supported only when using jaxrs-spec library.", useBeanValidation));
- cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines. This option is currently supported only when using jaxrs-spec library."));
+ cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines. This option is currently supported only when using jaxrs-spec library.", useCoroutines));
cliOptions.add(CliOption.newBoolean(RETURN_RESPONSE, "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true. This option is currently supported only when using jaxrs-spec library.").defaultValue(String.valueOf(returnResponse)));
}
@@ -293,7 +293,6 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
boolean generateApis = additionalProperties.containsKey(CodegenConstants.GENERATE_APIS) && (Boolean) additionalProperties.get(CodegenConstants.GENERATE_APIS);
String packageFolder = (sourceFolder + File.separator + packageName).replace(".", File.separator);
- String resourcesFolder = "src/main/resources"; // not sure this can be user configurable.
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
index bbdf6064c02..d63faee75ac 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
@@ -214,7 +214,6 @@ public class KotlinServerDeprecatedCodegen extends AbstractKotlinCodegen {
boolean generateApis = additionalProperties.containsKey(CodegenConstants.GENERATE_APIS) && (Boolean) additionalProperties.get(CodegenConstants.GENERATE_APIS);
String packageFolder = (sourceFolder + File.separator + packageName).replace(".", File.separator);
- String resourcesFolder = "src/main/resources"; // not sure this can be user configurable.
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
index a7d445eb3c8..b2cf3774b87 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
@@ -42,6 +42,7 @@ import java.net.URL;
import java.util.*;
import java.util.regex.Matcher;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
@@ -75,7 +76,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
private String invokerPackage;
private String serverPort = "8080";
private String title = "OpenAPI Kotlin Spring";
- private String resourceFolder = "src/main/resources";
private boolean useBeanValidation = true;
private boolean exceptionHandler = true;
private boolean gradleBuildFile = true;
@@ -234,14 +234,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
getDocumentationProvider().equals(DocumentationProvider.SOURCE);
}
- public String getResourceFolder() {
- return this.resourceFolder;
- }
-
- public void setResourceFolder(String resourceFolder) {
- this.resourceFolder = resourceFolder;
- }
-
public String getBasePackage() {
return this.basePackage;
}
@@ -336,10 +328,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
this.reactive = reactive;
}
- public boolean isBeanQualifiers() {
- return beanQualifiers;
- }
-
public void setBeanQualifiers(boolean beanQualifiers) {
this.beanQualifiers = beanQualifiers;
}
@@ -569,16 +557,16 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),
"HomeController.kt"));
supportingFiles.add(new SupportingFile("openapi.mustache",
- ("src/main/resources").replace("/", java.io.File.separator), "openapi.yaml"));
+ resourcesFolder.replace("/", java.io.File.separator), "openapi.yaml"));
}
- supportingFiles.add(new SupportingFile("application.mustache", resourceFolder, "application.yaml"));
+ supportingFiles.add(new SupportingFile("application.mustache", resourcesFolder, "application.yaml"));
supportingFiles.add(new SupportingFile("springBootApplication.mustache",
sanitizeDirectory(sourceFolder + File.separator + basePackage), "Application.kt"));
if (useSwaggerUI && selectedDocumentationProviderRequiresSwaggerUiBootstrap()) {
supportingFiles.add(new SupportingFile("swagger-ui.mustache",
- "src/main/resources/static", "swagger-ui.html"));
+ resourcesFolder + "/static", "swagger-ui.html"));
}
}
}
@@ -656,7 +644,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
if (title.toUpperCase(Locale.ROOT).endsWith("API"))
title = title.substring(0, title.length() - 3);
- this.title = camelize(sanitizeName(title), true);
+ this.title = camelize(sanitizeName(title), LOWERCASE_FIRST_LETTER);
}
additionalProperties.put(TITLE, this.title);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
index c524436a051..af90ec386ad 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -253,10 +254,10 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
String sanitizedOperationId = sanitizeName(operationId);
if (isReservedWord(sanitizedOperationId)) {
- sanitizedOperationId = "call" + StringUtils.camelize(sanitizedOperationId, false);
+ sanitizedOperationId = "call" + StringUtils.camelize(sanitizedOperationId);
}
- return StringUtils.camelize(sanitizedOperationId, true);
+ return StringUtils.camelize(sanitizedOperationId, LOWERCASE_FIRST_LETTER);
}
@Override
@@ -320,7 +321,7 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
// camelize (lower first character) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name)) {
@@ -350,7 +351,7 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toEnumName(CodegenProperty property) {
- String name = StringUtils.camelize(property.name, false);
+ String name = StringUtils.camelize(property.name);
if (name.matches("\\d.*")) { // starts with number
return "`" + name + "`";
@@ -362,7 +363,7 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toEnumVarName(String name, String datatype) {
name = name.replace(" ", "_");
- name = StringUtils.camelize(name, false);
+ name = StringUtils.camelize(name);
if (name.matches("\\d.*")) { // starts with number
return "`" + name + "`";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java
index 5a2a3822477..0b7f640cba5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -573,7 +574,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
// camelize (lower first character) the variable name
// e.g. `pet_id` to `petId`
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, prepend `_`
if (isReservedWord(name) || name.matches("^\\d.*")) {
@@ -618,11 +619,12 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
- operationId = "call_" + operationId;
+ final String newName = "call_" + operationId;
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newName);
+ operationId = newName;
}
- return camelize(sanitizeName(operationId), true);
+ return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
public void setClassPrefix(String classPrefix) {
@@ -677,6 +679,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
/**
* Return the default value of the schema
+ *
* @param p OpenAPI schema object
* @return string presentation of the default value of the schema
*/
@@ -795,5 +798,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
}
@Override
- public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.OBJECTIVE_C; }
+ public GeneratorLanguage generatorLanguage() {
+ return GeneratorLanguage.OBJECTIVE_C;
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLaravelServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLaravelServerCodegen.java
index dadc17a6fff..16920f32fc9 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLaravelServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLaravelServerCodegen.java
@@ -276,7 +276,7 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
return "DefaultController";
}
- return camelize(name, false) + "Controller";
+ return camelize(name) + "Controller";
}
protected String controllerFileFolder() {
@@ -298,7 +298,7 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
return "DefaultController";
}
- return camelize(name, false) + "Controller";
+ return camelize(name) + "Controller";
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSilexServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSilexServerCodegen.java
index 373381eafed..a2388a6fc12 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSilexServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSilexServerCodegen.java
@@ -32,6 +32,7 @@ import org.openapitools.codegen.meta.Stability;
import java.io.File;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -273,7 +274,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
for (int i = 0; i < items.length; ++i) {
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
// camelize path variable
- items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
+ items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), LOWERCASE_FIRST_LETTER) + "}";
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java
index 4d1fb30fa29..85331d98613 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java
@@ -613,14 +613,14 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
if (name.isEmpty()) {
return "DefaultApiInterface";
}
- return camelize(name, false) + "ApiInterface";
+ return camelize(name) + "ApiInterface";
}
protected String toControllerName(String name) {
if (name.isEmpty()) {
return "DefaultController";
}
- return camelize(name, false) + "Controller";
+ return camelize(name) + "Controller";
}
protected String toSymfonyService(String name) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
index 1328efd8ec6..5401e682152 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
@@ -43,6 +43,7 @@ import java.io.Writer;
import java.util.*;
import java.util.regex.Pattern;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -566,7 +567,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
if ("PascalCase".equals(operationIdNaming)) {
return camelize(sanitizedOperationId);
} else if ("camelCase".equals(operationIdNaming)) {
- return camelize(sanitizedOperationId, true);
+ return camelize(sanitizedOperationId, LOWERCASE_FIRST_LETTER);
} else if ("snake_case".equals(operationIdNaming)) {
return underscore(sanitizedOperationId);
} else {
@@ -829,15 +830,19 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
public String toDefaultValue(Schema p) {
if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
- if (Boolean.valueOf(p.getDefault().toString()) == false)
+ if (!Boolean.valueOf(p.getDefault().toString()))
return "FALSE";
else
return "TRUE";
}
} else if (ModelUtils.isDateSchema(p)) {
- // TODO
+ if (p.getDefault() != null) {
+ return "\"" + ((String.valueOf(p.getDefault()))).replaceAll("\"", "\\\"") + "\"";
+ }
} else if (ModelUtils.isDateTimeSchema(p)) {
- // TODO
+ if (p.getDefault() != null) {
+ return "\"" + ((String.valueOf(p.getDefault()))).replaceAll("\"", "\\\"") + "\"";
+ }
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
@@ -922,9 +927,9 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
public String constructExampleCode(CodegenParameter codegenParameter, HashMap modelMaps) {
if (codegenParameter.isArray) { // array
- return "list(" + constructExampleCode(codegenParameter.items, modelMaps, 0) + ")";
+ return "c(" + constructExampleCode(codegenParameter.items, modelMaps, 0) + ")";
} else if (codegenParameter.isMap) { // map
- return "list(key = " + constructExampleCode(codegenParameter.items, modelMaps, 0) + ")";
+ return "c(key = " + constructExampleCode(codegenParameter.items, modelMaps, 0) + ")";
} else if (languageSpecificPrimitives.contains(codegenParameter.dataType)) { // primitive type
return codegenParameter.example;
} else { // model
@@ -943,9 +948,9 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
depth++;
if (codegenProperty.isArray) { // array
- return "list(" + constructExampleCode(codegenProperty.items, modelMaps, depth) + ")";
+ return "c(" + constructExampleCode(codegenProperty.items, modelMaps, depth) + ")";
} else if (codegenProperty.isMap) { // map
- return "list(key = " + constructExampleCode(codegenProperty.items, modelMaps, depth) + ")";
+ return "c(key = " + constructExampleCode(codegenProperty.items, modelMaps, depth) + ")";
} else if (languageSpecificPrimitives.contains(codegenProperty.dataType)) { // primitive type
if ("character".equals(codegenProperty.dataType)) {
if (StringUtils.isEmpty(codegenProperty.example)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java
index 103114282ae..f4bbb55076c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java
@@ -170,7 +170,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
cliOptions.add(CliOption.newBoolean(USE_AUTOLOAD, "Use autoload instead of require to load modules.").
defaultValue(Boolean.FALSE.toString()));
- supportedLibraries.put(FARADAY, "Faraday (https://github.com/lostisland/faraday) (Beta support)");
+ supportedLibraries.put(FARADAY, "Faraday >= 1.0.1 (https://github.com/lostisland/faraday)");
supportedLibraries.put(TYPHOEUS, "Typhoeus >= 1.0.1 (https://github.com/typhoeus/typhoeus)");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "HTTP library template (sub-template) to use");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
index 73559171943..bbfa8f6afbc 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
@@ -450,6 +450,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
String schemaType = super.getSchemaType(p);
String type = typeMapping.getOrDefault(schemaType, schemaType);
+ // Implement integer type fitting (when property is enabled)
if (Objects.equals(p.getType(), "integer")) {
boolean bestFit = convertPropertyToBoolean(BEST_FIT_INT);
boolean preferUnsigned = convertPropertyToBoolean(PREFER_UNSIGNED_INT);
@@ -483,6 +484,18 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
return type;
}
+ @Override
+ public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
+ super.postProcessModelProperty(model, property);
+
+ // If a property is both nullable and non-required then we represent this using a double Option
+ // which requires the `serde_with` extension crate for deserialization.
+ // See: https://docs.rs/serde_with/latest/serde_with/rust/double_option/index.html
+ if (property.isNullable && !property.required) {
+ additionalProperties.put("serdeWith", true);
+ }
+ }
+
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List allModels) {
OperationMap objectMap = objs.getOperations();
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
index 5d8d88d943e..60e977633c8 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
@@ -1275,7 +1275,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
int position = property.dataType.lastIndexOf(":");
property.dataType = property.dataType.substring(0, position) + camelize(property.dataType.substring(position));
} else {
- property.dataType = camelize(property.dataType, false);
+ property.dataType = camelize(property.dataType);
}
property.isPrimitiveType = property.isContainer && languageSpecificPrimitives.contains(typeMapping.get(property.complexType));
} else {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java
index a74eabfcfe8..9cb73a97b6e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java
@@ -302,16 +302,6 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
}
}
- private static abstract class CustomLambda implements Mustache.Lambda {
- @Override
- public void execute(Template.Fragment frag, Writer out) throws IOException {
- final StringWriter tempWriter = new StringWriter();
- frag.execute(tempWriter);
- out.write(formatFragment(tempWriter.toString()));
- }
-
- public abstract String formatFragment(String fragment);
- }
private static class JavadocLambda extends CustomLambda {
@Override
@@ -334,19 +324,6 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
}
}
- private static class CamelizeLambda extends CustomLambda {
- private final boolean capitalizeFirst;
-
- public CamelizeLambda(boolean capitalizeFirst) {
- this.capitalizeFirst = capitalizeFirst;
- }
-
- @Override
- public String formatFragment(String fragment) {
- return camelize(fragment, !capitalizeFirst);
- }
- }
-
private class EnumEntryLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java
index de887007308..f8bf338f652 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java
@@ -30,6 +30,7 @@ import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
/*
@@ -200,7 +201,7 @@ public class ScalaHttpClientCodegen extends AbstractScalaCodegen implements Code
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
}
- return camelize(operationId, true);
+ return camelize(operationId, LOWERCASE_FIRST_LETTER);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java
index c4d38de101c..fedb4d8a1a7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements CodegenConfig {
@@ -163,7 +164,7 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
}
- return camelize(operationId, true);
+ return camelize(operationId, LOWERCASE_FIRST_LETTER);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java
index eaa7dcf08a3..fe503eb1ed0 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java
@@ -41,6 +41,7 @@ import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.rightPad;
import static org.openapitools.codegen.languages.AbstractJavaCodegen.DATE_LIBRARY;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implements CodegenConfig {
@@ -243,7 +244,7 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
Matcher match = pathVariableMatcher.matcher(operation.path);
while (match.find()) {
String completeMatch = match.group();
- String replacement = ":" + camelize(match.group(1), true);
+ String replacement = ":" + camelize(match.group(1), LOWERCASE_FIRST_LETTER);
operation.path = operation.path.replace(completeMatch, replacement);
}
@@ -265,7 +266,7 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
for (ModelMap mo : outer.getModels()) {
CodegenModel cm = mo.getModel();
postProcessModelsEnum(outer);
- cm.classVarName = camelize(cm.classVarName, true);
+ cm.classVarName = camelize(cm.classVarName, LOWERCASE_FIRST_LETTER);
modelsByClassName.put(cm.classname, cm);
boolean hasFiles = cm.vars.stream().anyMatch(var -> var.isFile);
cm.vendorExtensions.put("x-has-files", hasFiles);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java
index a5ef96adc72..dc7aaf221f4 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java
@@ -32,6 +32,7 @@ import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
+import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,6 +45,8 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.openapitools.codegen.utils.CamelizeOption.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
@@ -560,17 +563,6 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
}
}
- private static abstract class CustomLambda implements Mustache.Lambda {
- @Override
- public void execute(Template.Fragment frag, Writer out) throws IOException {
- final StringWriter tempWriter = new StringWriter();
- frag.execute(tempWriter);
- out.write(formatFragment(tempWriter.toString()));
- }
-
- public abstract String formatFragment(String fragment);
- }
-
private static class JavadocLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
@@ -592,19 +584,6 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
}
}
- private static class CamelizeLambda extends CustomLambda {
- private final boolean capitalizeFirst;
-
- public CamelizeLambda(boolean capitalizeFirst) {
- this.capitalizeFirst = capitalizeFirst;
- }
-
- @Override
- public String formatFragment(String fragment) {
- return camelize(fragment, !capitalizeFirst);
- }
- }
-
private class EnumEntryLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java
index 8f3971bd739..fe714b2ee87 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java
@@ -36,6 +36,7 @@ import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -152,7 +153,7 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@@ -228,7 +229,7 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
}
- return camelize(operationId, true);
+ return camelize(operationId, LOWERCASE_FIRST_LETTER);
}
private static abstract class CustomLambda implements Mustache.Lambda {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
index 7820efb9426..b43a9aa1c78 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
@@ -18,14 +18,17 @@
package org.openapitools.codegen.languages;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import com.samskivert.mustache.Mustache;
+import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.servers.Server;
+
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
@@ -40,6 +43,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
+
import org.apache.commons.lang3.tuple.Pair;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
@@ -102,6 +106,25 @@ public class SpringCodegen extends AbstractJavaCodegen
public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
public static final String USE_JAKARTA_EE = "useJakartaEe";
+ public static final String REQUEST_MAPPING_OPTION = "requestMappingMode";
+ public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
+ public static final String USE_REQUEST_MAPPING_ON_INTERFACE = "useRequestMappingOnInterface";
+
+ public enum RequestMappingMode {
+ api_interface("Generate the @RequestMapping annotation on the generated Api Interface."),
+ controller("Generate the @RequestMapping annotation on the generated Api Controller Implementation."),
+ none("Do not add a class level @RequestMapping annotation.");
+
+ public String getDescription() {
+ return description;
+ }
+
+ private String description;
+
+ RequestMappingMode(String description) {
+ this.description = description;
+ }
+ }
public static final String OPEN_BRACE = "{";
public static final String CLOSE_BRACE = "}";
@@ -111,7 +134,6 @@ public class SpringCodegen extends AbstractJavaCodegen
protected String basePackage = "org.openapitools";
protected boolean interfaceOnly = false;
protected boolean useFeignClientUrl = true;
- protected boolean useFeignClient = false;
protected boolean delegatePattern = false;
protected boolean delegateMethod = false;
protected boolean singleContentTypes = false;
@@ -131,6 +153,7 @@ public class SpringCodegen extends AbstractJavaCodegen
protected boolean useSpringController = false;
protected boolean useSwaggerUI = true;
protected boolean useSpringBoot3 = false;
+ protected RequestMappingMode requestMappingMode = RequestMappingMode.controller;
public SpringCodegen() {
super();
@@ -203,6 +226,15 @@ public class SpringCodegen extends AbstractJavaCodegen
cliOptions
.add(CliOption.newBoolean(RETURN_SUCCESS_CODE, "Generated server returns 2xx code", returnSuccessCode));
cliOptions.add(CliOption.newBoolean(SPRING_CONTROLLER, "Annotate the generated API as a Spring Controller", useSpringController));
+
+ CliOption requestMappingOpt = new CliOption(REQUEST_MAPPING_OPTION,
+ "Where to generate the class level @RequestMapping annotation.")
+ .defaultValue(requestMappingMode.name());
+ for (RequestMappingMode mode: RequestMappingMode.values()) {
+ requestMappingOpt.addEnum(mode.name(), mode.getDescription());
+ }
+ cliOptions.add(requestMappingOpt);
+
cliOptions.add(CliOption.newBoolean(UNHANDLED_EXCEPTION_HANDLING,
"Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).",
unhandledException));
@@ -299,6 +331,13 @@ public class SpringCodegen extends AbstractJavaCodegen
LOGGER.info("Set base package to invoker package ({})", basePackage);
}
+ if (additionalProperties.containsKey(REQUEST_MAPPING_OPTION)) {
+ RequestMappingMode optValue = RequestMappingMode.valueOf(
+ String.valueOf(additionalProperties.get(REQUEST_MAPPING_OPTION)));
+ setRequestMappingMode(optValue);
+ additionalProperties.remove(REQUEST_MAPPING_OPTION);
+ }
+
useOneOfInterfaces = true;
legacyDiscriminatorBehavior = false;
@@ -493,10 +532,15 @@ public class SpringCodegen extends AbstractJavaCodegen
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
this.setSingleContentTypes(true);
}
+ // @RequestMapping not supported with spring cloud openfeign.
+ setRequestMappingMode(RequestMappingMode.none);
additionalProperties.put(USE_FEIGN_CLIENT, "true");
- this.setUseFeignClient(true);
} else {
apiTemplateFiles.put("apiController.mustache", "Controller.java");
+ if (containsEnums()) {
+ supportingFiles.add(new SupportingFile("converter.mustache",
+ (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "EnumConverterConfiguration.java"));
+ }
supportingFiles.add(new SupportingFile("application.mustache",
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
supportingFiles.add(new SupportingFile("homeController.mustache",
@@ -573,6 +617,19 @@ public class SpringCodegen extends AbstractJavaCodegen
}
}
+ switch (getRequestMappingMode()) {
+ case api_interface:
+ additionalProperties.put(USE_REQUEST_MAPPING_ON_INTERFACE, true);
+ break;
+ case controller:
+ additionalProperties.put(USE_REQUEST_MAPPING_ON_CONTROLLER, true);
+ break;
+ case none:
+ additionalProperties.put(USE_REQUEST_MAPPING_ON_INTERFACE, false);
+ additionalProperties.put(USE_REQUEST_MAPPING_ON_CONTROLLER, false);
+ break;
+ }
+
// add lambda for mustache templates
additionalProperties.put("lambdaRemoveDoubleQuote", (Mustache.Lambda) (fragment, writer) -> writer
.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement(""))));
@@ -594,6 +651,20 @@ public class SpringCodegen extends AbstractJavaCodegen
}
}
+ private boolean containsEnums() {
+ if (openAPI == null) {
+ return false;
+ }
+
+ Components components = this.openAPI.getComponents();
+ if (components == null || components.getSchemas() == null) {
+ return false;
+ }
+
+ return components.getSchemas().values().stream()
+ .anyMatch(it -> it.getEnum() != null && !it.getEnum().isEmpty());
+ }
+
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co,
Map> operations) {
@@ -639,7 +710,7 @@ public class SpringCodegen extends AbstractJavaCodegen
title = title.substring(0, title.length() - 3);
}
- this.title = camelize(sanitizeName(title), true);
+ this.title = camelize(sanitizeName(title), LOWERCASE_FIRST_LETTER);
}
additionalProperties.put(TITLE, this.title);
}
@@ -767,7 +838,7 @@ public class SpringCodegen extends AbstractJavaCodegen
final List authMethods = (List) objs.get("authMethods");
if (authMethods != null) {
for (final CodegenSecurity authMethod : authMethods) {
- authMethod.name = camelize(sanitizeName(authMethod.name), true);
+ authMethod.name = camelize(sanitizeName(authMethod.name), LOWERCASE_FIRST_LETTER);
}
}
}
@@ -850,10 +921,6 @@ public class SpringCodegen extends AbstractJavaCodegen
this.singleContentTypes = singleContentTypes;
}
- public void setUseFeignClient( boolean useFeignClient ) {
- this.useFeignClient = useFeignClient;
- }
-
public void setSkipDefaultInterface(boolean skipDefaultInterface) {
this.skipDefaultInterface = skipDefaultInterface;
}
@@ -1098,4 +1165,12 @@ public class SpringCodegen extends AbstractJavaCodegen
public void setUseSpringBoot3(boolean useSpringBoot3) {
this.useSpringBoot3 = useSpringBoot3;
}
+
+ public RequestMappingMode getRequestMappingMode() {
+ return requestMappingMode;
+ }
+
+ public void setRequestMappingMode(RequestMappingMode requestMappingMode) {
+ this.requestMappingMode = requestMappingMode;
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
index 4d430ac4ee5..a1d0dab0517 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
@@ -42,6 +42,7 @@ import java.time.Instant;
import java.time.temporal.ChronoField;
import java.util.concurrent.TimeUnit;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig {
@@ -827,7 +828,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public String toOperationId(String operationId) {
- operationId = camelize(sanitizeName(operationId), true);
+ operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// Throw exception if method name is empty.
// This should not happen but keep the check just in case
@@ -837,15 +838,15 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- String newOperationId = camelize(("call_" + operationId), true);
+ String newOperationId = camelize(("call_" + operationId), LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
- operationId = camelize(sanitizeName("call_" + operationId), true);
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER));
+ operationId = camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER);
}
@@ -864,7 +865,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
// camelize the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved words surround with `` or append _
if (isReservedWord(name)) {
@@ -894,7 +895,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
// camelize(lower) the variable name
// pet_id => petId
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved words surround with ``
if (isReservedWord(name)) {
@@ -1019,7 +1020,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
if (enumUnknownDefaultCase) {
if (name.equals(enumUnknownDefaultCaseName)) {
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
}
}
@@ -1031,18 +1032,18 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
// Prefix with underscore if name starts with number
if (name.matches("\\d.*")) {
- return "_" + replaceSpecialCharacters(camelize(name, true));
+ return "_" + replaceSpecialCharacters(camelize(name, LOWERCASE_FIRST_LETTER));
}
// for symbol, e.g. $, #
if (getSymbolName(name) != null) {
- return camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT)), true);
+ return camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT)), LOWERCASE_FIRST_LETTER);
}
// Camelize only when we have a structure defined below
- Boolean camelized = false;
+ boolean camelized = false;
if (name.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
camelized = true;
}
@@ -1062,7 +1063,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
char[] separators = {'-', '_', ' ', ':', '(', ')'};
return camelize(replaceSpecialCharacters(WordUtils.capitalizeFully(StringUtils.lowerCase(name), separators)
.replaceAll("[-_ :\\(\\)]", "")),
- true);
+ LOWERCASE_FIRST_LETTER);
}
private String replaceSpecialCharacters(String name) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
index 3457324b538..612b9502ad1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
@@ -36,6 +36,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.apache.commons.lang3.StringUtils.capitalize;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen {
@@ -731,7 +732,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
if ("kebab-case".equals(fileNaming)) {
name = dashize(underscore(name));
} else {
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
}
return name;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java
index 73448a4cbef..2b815369955 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java
@@ -17,6 +17,7 @@
package org.openapitools.codegen.languages;
+import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
@@ -287,4 +288,10 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
updatePropertyForMap(property, p);
}
}
+
+ @Override
+ protected void addImport(ComposedSchema composed, Schema childSchema, CodegenModel model, String modelName) {
+ // import everything (including child schema of a composed schema)
+ addImport(model, modelName);
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java
index 934fef92462..93ef3994ec4 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java
@@ -54,6 +54,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -125,7 +126,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
"varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
"requestOptions", "from",
// Typescript reserved words
- "abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
+ "abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "constructor", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
languageSpecificPrimitives = new HashSet<>(Arrays.asList(
"string",
@@ -588,10 +589,10 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
// method name cannot use reserved keyword, e.g. return
// append _ at the beginning, e.g. _return
if (isReservedWord(operationId)) {
- return escapeReservedWord(camelize(sanitizeName(operationId), true));
+ return escapeReservedWord(camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER));
}
- return camelize(sanitizeName(operationId), true);
+ return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
public void setModelPropertyNaming(String naming) {
@@ -614,7 +615,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
case original:
return name;
case camelCase:
- return camelize(name, true);
+ return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java
index 6fdb5f0d169..fb4c041cf93 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java
@@ -31,6 +31,7 @@ import org.openapitools.codegen.model.OperationsMap;
import java.io.File;
import java.util.*;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCodegen {
@@ -315,7 +316,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
if (name.length() == 0) {
return "default.service";
}
- return camelize(name, true) + ".service";
+ return camelize(name, LOWERCASE_FIRST_LETTER) + ".service";
}
@Override
@@ -325,7 +326,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
@Override
public String toModelFilename(String name) {
- return camelize(toModelName(name), true);
+ return camelize(toModelName(name), LOWERCASE_FIRST_LETTER);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java
index 19b9369bd80..bc74742e283 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java
@@ -33,6 +33,7 @@ import java.io.File;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.capitalize;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodegen {
@@ -543,7 +544,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
if ("kebab-case".equals(fileNaming)) {
name = dashize(underscore(name));
} else {
- name = camelize(name, true);
+ name = camelize(name, LOWERCASE_FIRST_LETTER);
}
return name;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java
index cd5cde237a2..953465863c3 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java
@@ -35,6 +35,7 @@ import java.io.File;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.capitalize;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen {
@@ -141,7 +142,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
if (importMapping.containsKey(name)) {
return importMapping.get(name);
}
- return camelize(name, true) + apiSuffix;
+ return camelize(name, LOWERCASE_FIRST_LETTER) + apiSuffix;
}
@Override
@@ -159,7 +160,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
return importMapping.get(name);
}
- return DEFAULT_MODEL_FILENAME_DIRECTORY_PREFIX + camelize(toModelName(name), true);
+ return DEFAULT_MODEL_FILENAME_DIRECTORY_PREFIX + camelize(toModelName(name), LOWERCASE_FIRST_LETTER);
}
@Override
@@ -168,7 +169,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
return importMapping.get(name);
}
- return DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX + modelPackage() + "/" + camelize(toModelName(name), true);
+ return DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX + modelPackage() + "/" + camelize(toModelName(name), LOWERCASE_FIRST_LETTER);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java
index e9091517b3b..aeaca5caf3c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java
@@ -18,6 +18,7 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
@@ -420,4 +421,10 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
this.hasOptionalQueryParams = false; // will be updated within addConditionalImportInformation
}
}
+
+ @Override
+ protected void addImport(ComposedSchema composed, Schema childSchema, CodegenModel model, String modelName) {
+ // import everything (including child schema of a composed schema)
+ addImport(model, modelName);
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java
index 034d0cee76d..d7b14546f19 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java
@@ -20,10 +20,13 @@ package org.openapitools.codegen.templating.mustache;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import org.openapitools.codegen.CodegenConfig;
+import org.openapitools.codegen.utils.CamelizeOption;
import java.io.IOException;
import java.io.Writer;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
+import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
/**
@@ -42,10 +45,14 @@ import static org.openapitools.codegen.utils.StringUtils.camelize;
public class CamelCaseLambda implements Mustache.Lambda {
private CodegenConfig generator = null;
private Boolean escapeParam = false;
- private Boolean lowercaseFirstLetter = true;
+ private CamelizeOption option = LOWERCASE_FIRST_LETTER;
public CamelCaseLambda(boolean lowercaseFirstLetter) {
- this.lowercaseFirstLetter = lowercaseFirstLetter;
+ if (lowercaseFirstLetter) {
+ option = LOWERCASE_FIRST_LETTER;
+ } else {
+ option = UPPERCASE_FIRST_CHAR;
+ }
}
public CamelCaseLambda() {}
@@ -62,7 +69,7 @@ public class CamelCaseLambda implements Mustache.Lambda {
@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
- String text = camelize(fragment.execute().replace(" ", "_"), lowercaseFirstLetter);
+ String text = camelize(fragment.execute().replace(" ", "_"), option);
if (generator != null) {
text = generator.sanitizeName(text);
if (generator.reservedWords().contains(text)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/TitlecaseLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/TitlecaseLambda.java
index 2d94a5ad7b8..913578f8c99 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/TitlecaseLambda.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/TitlecaseLambda.java
@@ -61,7 +61,15 @@ public class TitlecaseLambda implements Mustache.Lambda {
}
private String titleCase(final String input) {
- return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
+ if(input == null || "".equals(input)){
+ return "";
+ }
+
+ String firstLetter = input.substring(0, 1).toUpperCase(Locale.ROOT);
+ if (input.length() == 1) {
+ return firstLetter;
+ }
+ return firstLetter + input.substring(1);
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/CamelizeOption.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/CamelizeOption.java
new file mode 100644
index 00000000000..838b56b1f2f
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/CamelizeOption.java
@@ -0,0 +1,7 @@
+package org.openapitools.codegen.utils;
+
+public enum CamelizeOption {
+ UPPERCASE_FIRST_CHAR,
+ LOWERCASE_FIRST_LETTER,
+ LOWERCASE_FIRST_CHAR
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/StringUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/StringUtils.java
index afd23f24cd7..6f81ef9a327 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/StringUtils.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/StringUtils.java
@@ -17,6 +17,8 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
+
public class StringUtils {
/**
@@ -30,7 +32,7 @@ public class StringUtils {
// A cache of camelized words. The camelize() method is invoked many times with the same
// arguments, this cache is used to optimized performance.
- private static Cache, String> camelizedWordsCache;
+ private static Cache, String> camelizedWordsCache;
// A cache of underscored words, used to optimize the performance of the underscore() method.
private static Cache underscoreWordsCache;
@@ -111,7 +113,7 @@ public class StringUtils {
* @return camelized string
*/
public static String camelize(String word) {
- return camelize(word, false);
+ return camelize(word, UPPERCASE_FIRST_CHAR);
}
private static Pattern camelizeSlashPattern = Pattern.compile("\\/(.?)");
@@ -124,16 +126,16 @@ public class StringUtils {
/**
* Camelize name (parameter, property, method, etc)
*
- * @param inputWord string to be camelize
- * @param lowercaseFirstLetter lower case for first letter if set to true
+ * @param inputWord string to be camelize
+ * @param camelizeOption option for the camelize result
* @return camelized string
*/
- public static String camelize(final String inputWord, boolean lowercaseFirstLetter) {
- Pair key = new ImmutablePair<>(inputWord, lowercaseFirstLetter);
+ public static String camelize(final String inputWord, CamelizeOption camelizeOption) {
+ Pair key = new ImmutablePair<>(inputWord, camelizeOption);
return camelizedWordsCache.get(key, pair -> {
String word = pair.getKey();
- Boolean lowerFirstLetter = pair.getValue();
+ CamelizeOption option = pair.getValue();
// Replace all slashes with dots (package separator)
Matcher m = camelizeSlashPattern.matcher(word);
while (m.find()) {
@@ -185,15 +187,13 @@ public class StringUtils {
m = camelizeHyphenPattern.matcher(word);
}
- if (lowerFirstLetter && word.length() > 0) {
- int i = 0;
- char charAt = word.charAt(i);
- while (i + 1 < word.length() && !((charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z'))) {
- i = i + 1;
- charAt = word.charAt(i);
- }
- i = i + 1;
- word = word.substring(0, i).toLowerCase(Locale.ROOT) + word.substring(i);
+ switch (option) {
+ case LOWERCASE_FIRST_LETTER:
+ word = lowercaseFirstLetter(word);
+ break;
+ case LOWERCASE_FIRST_CHAR:
+ word = word.substring(0, 1).toLowerCase(Locale.ROOT) + word.substring(1);
+ break;
}
// remove all underscore
@@ -202,6 +202,20 @@ public class StringUtils {
});
}
+ private static String lowercaseFirstLetter(String word) {
+ if (word.length() > 0) {
+ int i = 0;
+ char charAt = word.charAt(i);
+ while (i + 1 < word.length() && !((charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z'))) {
+ i = i + 1;
+ charAt = word.charAt(i);
+ }
+ i = i + 1;
+ word = word.substring(0, i).toLowerCase(Locale.ROOT) + word.substring(i);
+ }
+ return word;
+ }
+
private static class EscapedNameOptions {
public EscapedNameOptions(String name, Set specialChars, List charactersToAllow, String appendToReplacement) {
this.name = name;
diff --git a/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
index 7f640ba7475..8b4cf59ff0a 100644
--- a/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
@@ -42,7 +42,7 @@ public class ServerConfiguration {
throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + ".");
}
}
- url = url.replaceAll("\\{" + name + "\\}", value);
+ url = url.replace("{" + name + "}", value);
}
return url;
}
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 d3760936834..39ef41c0339 100644
--- a/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
@@ -117,7 +117,7 @@ ext {
jackson_version = "2.12.6"
jackson_databind_version = "2.12.6.1"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
jersey_version = "1.19.4"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/build.gradle.mustache
index 84589d91afd..911979d76a4 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/build.gradle.mustache
@@ -114,10 +114,10 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
- jackson_version = "2.12.6"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
httpclient_version = "4.5.13"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/pom.mustache
index e7fef245346..638d2142af1 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/pom.mustache
@@ -327,8 +327,8 @@
UTF-8
1.5.21
4.5.13
- 2.12.6
- 2.12.6.1
+ 2.13.4
+ 2.13.4.2
1.3.5
{{#useBeanValidation}}
2.0.2
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
index 6d320edcc9a..bb35f8689f7 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
@@ -102,10 +102,10 @@ test {
ext {
swagger_annotations_version = "1.5.24"
- jackson_version = "2.12.6.1"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
feign_version = "10.11"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.sbt.mustache
index 065280d08d8..da07dcf61ae 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.sbt.mustache
@@ -16,9 +16,9 @@ lazy val root = (project in file(".")).
"io.github.openfeign" % "feign-slf4j" % "10.11" % "compile",
"io.github.openfeign.form" % "feign-form" % "3.8.0" % "compile",
"io.github.openfeign" % "feign-okhttp" % "10.11" % "compile",
- "com.fasterxml.jackson.core" % "jackson-core" % "2.12.6.1" % "compile",
- "com.fasterxml.jackson.core" % "jackson-annotations" % "2.12.6.1" % "compile",
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.12.6.1" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-core" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.2" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile",
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile",
"com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache
index 2e9e1be46a3..fb8a34aa42f 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache
@@ -354,11 +354,11 @@
1.5.24
10.11
3.8.0
- 2.12.5
+ 2.13.4
{{#openApiNullable}}
- 0.2.3
+ 0.2.4
{{/openApiNullable}}
- 2.12.6.1
+ 2.13.4.2
1.3.5
5.7.0
1.0.0
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 629facf2582..c14b05a571c 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
@@ -98,10 +98,10 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.6.3"
- jackson_version = "2.12.5"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
google_api_client_version = "1.32.2"
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 c08c686ca6b..78da21f2e81 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
@@ -12,9 +12,9 @@ lazy val root = (project in file(".")).
"io.swagger" % "swagger-annotations" % "1.5.22",
"com.google.api-client" % "google-api-client" % "1.23.0",
"org.glassfish.jersey.core" % "jersey-common" % "2.25.1",
- "com.fasterxml.jackson.core" % "jackson-core" % "2.12.6.1" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-core" % "2.13.4" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.1" % "compile",
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.12.6.1" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.2" % "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 e1d06d235e7..44cc6295a6e 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
@@ -297,10 +297,10 @@
1.5.22
1.32.2
2.25.1
- 2.12.5
- 2.12.6.1
+ 2.13.4
+ 2.13.4.2
{{#openApiNullable}}
- 0.2.3
+ 0.2.4
{{/openApiNullable}}
{{#joda}}
2.9.9
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
index bf9545f34f4..2a027220da7 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
@@ -524,6 +524,22 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
throw new RuntimeException("No OAuth2 authentication configured!");
}
+ /**
+ * Helper method to set the credentials of a public client for the first OAuth2 authentication.
+ *
+ * @param clientId the client ID
+ * @return a {@link org.openapitools.client.ApiClient} object.
+ */
+ public ApiClient setOauthCredentialsForPublicClient(String clientId) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof OAuth) {
+ ((OAuth) auth).setCredentialsForPublicClient(clientId, isDebugging());
+ return this;
+ }
+ }
+ throw new RuntimeException("No OAuth2 authentication configured!");
+ }
+
/**
* Helper method to set the password flow for the first OAuth2 authentication.
*
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/auth/OAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/auth/OAuth.mustache
index b7e28e55bfc..8908aa543dd 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/auth/OAuth.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/auth/OAuth.mustache
@@ -158,6 +158,19 @@ public class OAuth implements Authentication {
return this;
}
+ public OAuth setCredentialsForPublicClient(String clientId, Boolean debug) {
+ if (Boolean.TRUE.equals(debug)) {
+ service = new ServiceBuilder(clientId)
+ .apiSecretIsEmptyStringUnsafe().debug()
+ .build(authApi);
+ } else {
+ service = new ServiceBuilder(clientId)
+ .apiSecretIsEmptyStringUnsafe()
+ .build(authApi);
+ }
+ return this;
+ }
+
public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.PASSWORD;
this.username = username;
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 e12528af751..b11d0add3ca 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
@@ -99,10 +99,10 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.6.5"
- jackson_version = "2.13.2"
- jackson_databind_version = "2.13.2.2"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
jersey_version = "2.35"
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 5ff4b1b0285..dc65e1b496b 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
@@ -18,13 +18,13 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.connectors" % "jersey-apache-connector" % "2.35",
"com.fasterxml.jackson.core" % "jackson-core" % "2.13.2" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.2" % "compile",
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.2.2" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.1" % "compile",
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.13.2" % "compile",
{{/joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.13.2" % "compile",
{{#openApiNullable}}
- "org.openapitools" % "jackson-databind-nullable" % "0.2.3" % "compile",
+ "org.openapitools" % "jackson-databind-nullable" % "0.2.4" % "compile",
{{/openApiNullable}}
{{#hasOAuthMethods}}
"com.github.scribejava" % "scribejava-apis" % "8.3.1" % "compile",
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 dc5a3f4a71a..aceaa42112f 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
@@ -382,9 +382,9 @@
UTF-8
1.6.5
2.35
- 2.13.2
- 2.13.2.2
- 0.2.3
+ 2.13.4
+ 2.13.4.2
+ 0.2.4
1.3.5
{{#useBeanValidation}}
2.0.2
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache
index baaa6037fab..a89642a2758 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache
@@ -524,6 +524,22 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
throw new RuntimeException("No OAuth2 authentication configured!");
}
+ /**
+ * Helper method to set the credentials of a public client for the first OAuth2 authentication.
+ *
+ * @param clientId the client ID
+ * @return a {@link org.openapitools.client.ApiClient} object.
+ */
+ public ApiClient setOauthCredentialsForPublicClient(String clientId) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof OAuth) {
+ ((OAuth) auth).setCredentialsForPublicClient(clientId, isDebugging());
+ return this;
+ }
+ }
+ throw new RuntimeException("No OAuth2 authentication configured!");
+ }
+
/**
* Helper method to set the password flow for the first OAuth2 authentication.
*
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/auth/OAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/auth/OAuth.mustache
index 993bfdcd394..67f56597696 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/auth/OAuth.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/auth/OAuth.mustache
@@ -158,6 +158,19 @@ public class OAuth implements Authentication {
return this;
}
+ public OAuth setCredentialsForPublicClient(String clientId, Boolean debug) {
+ if (Boolean.TRUE.equals(debug)) {
+ service = new ServiceBuilder(clientId)
+ .apiSecretIsEmptyStringUnsafe().debug()
+ .build(authApi);
+ } else {
+ service = new ServiceBuilder(clientId)
+ .apiSecretIsEmptyStringUnsafe()
+ .build(authApi);
+ }
+ return this;
+ }
+
public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.PASSWORD;
this.username = username;
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.gradle.mustache
index 8c555046415..55c2dfd81af 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.gradle.mustache
@@ -99,10 +99,10 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.6.5"
- jackson_version = "2.13.2"
- jackson_databind_version = "2.13.2.2"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "2.1.0"
jersey_version = "3.0.4"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.sbt.mustache
index 1574b6e6df7..ee811eb8ce7 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/build.sbt.mustache
@@ -16,15 +16,15 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.media" % "jersey-media-multipart" % "3.0.4",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "3.0.4",
"org.glassfish.jersey.connectors" % "jersey-apache-connector" % "3.0.4",
- "com.fasterxml.jackson.core" % "jackson-core" % "2.13.2" % "compile",
- "com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.2" % "compile",
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.2.2" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-core" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.2" % "compile",
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.13.2" % "compile",
{{/joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.13.2" % "compile",
{{#openApiNullable}}
- "org.openapitools" % "jackson-databind-nullable" % "0.2.3" % "compile",
+ "org.openapitools" % "jackson-databind-nullable" % "0.2.4" % "compile",
{{/openApiNullable}}
{{#hasOAuthMethods}}
"com.github.scribejava" % "scribejava-apis" % "8.3.1" % "compile",
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pom.mustache
index 9427390e9e2..e546d4a1f7e 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pom.mustache
@@ -382,9 +382,9 @@
UTF-8
1.6.5
3.0.4
- 2.13.2
- 2.13.2.2
- 0.2.3
+ 2.13.4
+ 2.13.4.2
+ 0.2.4
2.1.0
{{#useBeanValidation}}
2.0.2
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache
index 3d15f663bf7..0255e20c1fc 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache
@@ -336,7 +336,12 @@ public class {{classname}} {
{{#isExplode}}
{{#hasVars}}
{{#vars}}
+ {{#isArray}}
+ localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "{{baseName}}", {{paramName}}.{{getter}}()));
+ {{/isArray}}
+ {{^isArray}}
localVarQueryParams.addAll(ApiClient.parameterToPairs("{{baseName}}", {{paramName}}.{{getter}}()));
+ {{/isArray}}
{{/vars}}
{{/hasVars}}
{{^hasVars}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
index af793714675..ef6404095a7 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
@@ -222,7 +222,7 @@
11
11
2.13.4
- 0.2.3
+ 0.2.4
1.3.5
4.13.2
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
index 67dcd41e643..c81b9643a10 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
@@ -179,7 +179,6 @@ public class ApiClient {
this.basePath = basePath;
}
-{{#hasOAuthMethods}}
String tokenUrl = "{{{tokenUrl}}}";
if (!"".equals(tokenUrl) && !URI.create(tokenUrl).isAbsolute()) {
URI uri = URI.create(getBasePath());
@@ -196,7 +195,6 @@ public class ApiClient {
retryingOAuth
);
initHttpClient(Collections.singletonList(retryingOAuth));
-{{/hasOAuthMethods}}
// Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
@@ -387,7 +385,7 @@ public class ApiClient {
* @return a {@link {{invokerPackage}}.ApiClient} object
*/
public ApiClient setDateFormat(DateFormat dateFormat) {
- this.json.setDateFormat(dateFormat);
+ JSON.setDateFormat(dateFormat);
return this;
}
@@ -398,18 +396,18 @@ public class ApiClient {
* @return a {@link {{invokerPackage}}.ApiClient} object
*/
public ApiClient setSqlDateFormat(DateFormat dateFormat) {
- this.json.setSqlDateFormat(dateFormat);
+ JSON.setSqlDateFormat(dateFormat);
return this;
}
{{#joda}}
public ApiClient setDateTimeFormat(DateTimeFormatter dateFormat) {
- this.json.setDateTimeFormat(dateFormat);
+ JSON.setDateTimeFormat(dateFormat);
return this;
}
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
- this.json.setLocalDateFormat(dateFormat);
+ JSON.setLocalDateFormat(dateFormat);
return this;
}
@@ -422,7 +420,7 @@ public class ApiClient {
* @return a {@link {{invokerPackage}}.ApiClient} object
*/
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
- this.json.setOffsetDateTimeFormat(dateFormat);
+ JSON.setOffsetDateTimeFormat(dateFormat);
return this;
}
@@ -433,7 +431,7 @@ public class ApiClient {
* @return a {@link {{invokerPackage}}.ApiClient} object
*/
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
- this.json.setLocalDateFormat(dateFormat);
+ JSON.setLocalDateFormat(dateFormat);
return this;
}
@@ -445,7 +443,7 @@ public class ApiClient {
* @return a {@link {{invokerPackage}}.ApiClient} object
*/
public ApiClient setLenientOnJson(boolean lenientOnJson) {
- this.json.setLenientOnJson(lenientOnJson);
+ JSON.setLenientOnJson(lenientOnJson);
return this;
}
@@ -745,7 +743,7 @@ public class ApiClient {
return "";
} else if (param instanceof Date {{#joda}}|| param instanceof DateTime || param instanceof LocalDate{{/joda}}{{#jsr310}}|| param instanceof OffsetDateTime || param instanceof LocalDate{{/jsr310}}) {
//Serialize to json string and remove the " enclosing characters
- String jsonStr = json.serialize(param);
+ String jsonStr = JSON.serialize(param);
return jsonStr.substring(1, jsonStr.length() - 1);
} else if (param instanceof Collection) {
StringBuilder b = new StringBuilder();
@@ -753,7 +751,7 @@ public class ApiClient {
if (b.length() > 0) {
b.append(",");
}
- b.append(String.valueOf(o));
+ b.append(o);
}
return b.toString();
} else {
@@ -1045,7 +1043,7 @@ public class ApiClient {
contentType = "application/json";
}
if (isJsonMime(contentType)) {
- return json.deserialize(respBody, returnType);
+ return JSON.deserialize(respBody, returnType);
} else if (returnType.equals(String.class)) {
// Expecting string, return the raw response body.
return (T) respBody;
@@ -1079,13 +1077,13 @@ public class ApiClient {
} else if (isJsonMime(contentType)) {
String content;
if (obj != null) {
- content = json.serialize(obj);
+ content = JSON.serialize(obj);
} else {
content = null;
}
return RequestBody.create(content, MediaType.parse(contentType));
} else if (obj instanceof String) {
- return RequestBody.create(MediaType.parse(contentType), (String) obj);
+ return RequestBody.create((String) obj, MediaType.parse(contentType));
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
@@ -1583,7 +1581,7 @@ public class ApiClient {
} else {
String content;
if (obj != null) {
- content = json.serialize(obj);
+ content = JSON.serialize(obj);
} else {
content = null;
}
@@ -1661,7 +1659,7 @@ public class ApiClient {
KeyStore caKeyStore = newEmptyKeyStore(password);
int index = 0;
for (Certificate certificate : certificates) {
- String certificateAlias = "ca" + Integer.toString(index++);
+ String certificateAlias = "ca" + (index++);
caKeyStore.setCertificateEntry(certificateAlias, certificate);
}
trustManagerFactory.init(caKeyStore);
@@ -1736,7 +1734,7 @@ public class ApiClient {
if (entry.getKey().equals(param.getName())) {
switch (param.getIn()) {
case "path":
- path = path.replaceAll("\\{" + param.getName() + "\\}", escapeString(value.toString()));
+ path = path.replace("{" + param.getName() + "}", escapeString(value.toString()));
break;
case "query":
if (value instanceof Collection>) {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/additional_properties.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/additional_properties.mustache
index 96c779fd24a..bca54f84d57 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/additional_properties.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/additional_properties.mustache
@@ -9,6 +9,10 @@
/**
* Set the additional (undeclared) property with the specified name and value.
* If the property does not already exist, create it otherwise replace it.
+ *
+ * @param key name of the property
+ * @param value value of the property
+ * @return the {{classname}} instance itself
*/
public {{classname}} putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
@@ -20,6 +24,8 @@
/**
* Return the additional (undeclared) property.
+ *
+ * @return a map of objects
*/
public Map getAdditionalProperties() {
return additionalProperties;
@@ -27,6 +33,9 @@
/**
* Return the additional (undeclared) property with the specified name.
+ *
+ * @param key name of the property
+ * @return an object
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache
index 52002f8c507..d39478decb6 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache
@@ -137,7 +137,7 @@ public class {{classname}} {
// create path and map variables
{{^dynamicOperations}}
String localVarPath = "{{{path}}}"{{#pathParams}}
- .replaceAll("\\{" + "{{baseName}}" + "\\}", localVarApiClient.escapeString({{#collectionFormat}}localVarApiClient.collectionPathParameterToString("{{{collectionFormat}}}", {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}.toString(){{/collectionFormat}})){{/pathParams}};
+ .replace("{" + "{{baseName}}" + "}", localVarApiClient.escapeString({{#collectionFormat}}localVarApiClient.collectionPathParameterToString("{{{collectionFormat}}}", {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}.toString(){{/collectionFormat}})){{/pathParams}};
{{/dynamicOperations}}
{{#dynamicOperations}}
ApiOperation apiOperation = localVarApiClient.getOperationLookupMap().get("{{{operationId}}}");
@@ -193,7 +193,9 @@ public class {{classname}} {
{{/dynamicOperations}}
final String[] localVarAccepts = {
- {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}
+ {{#produces}}
+ "{{{mediaType}}}"{{^-last}},{{/-last}}
+ {{/produces}}
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
@@ -201,7 +203,9 @@ public class {{classname}} {
}
final String[] localVarContentTypes = {
- {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}
+ {{#consumes}}
+ "{{{mediaType}}}"{{^-last}},{{/-last}}
+ {{/consumes}}
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
if (localVarContentType != null) {
@@ -218,15 +222,16 @@ public class {{classname}} {
@SuppressWarnings("rawtypes")
private okhttp3.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException {
{{^performBeanValidation}}
- {{#allParams}}{{#required}}
+ {{#allParams}}
+ {{#required}}
// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null) {
throw new ApiException("Missing the required parameter '{{paramName}}' when calling {{operationId}}(Async)");
}
- {{/required}}{{/allParams}}
- okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback);
- return localVarCall;
+ {{/required}}
+ {{/allParams}}
+ return {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback);
{{/performBeanValidation}}
{{#performBeanValidation}}
@@ -240,9 +245,7 @@ public class {{classname}} {
parameterValues);
if (violations.size() == 0) {
- okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback);
- return localVarCall;
-
+ return {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback);
} else {
throw new BeanValidationException((Set) violations);
}
@@ -253,7 +256,6 @@ public class {{classname}} {
e.printStackTrace();
throw new ApiException(e.getMessage());
}
-
{{/performBeanValidation}}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache
index cb0e8250550..f11b22c629d 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache
@@ -56,6 +56,7 @@ public class OAuthOkHttpClient implements HttpClient {
response.body().string(),
response.body().contentType().toString(),
response.code(),
+ response.headers().toMultimap(),
responseClass);
} catch (IOException e) {
throw new OAuthSystemException(e);
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache
index 53f1de15fee..8fea0d29264 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache
@@ -66,8 +66,8 @@ public class RetryingOAuth extends OAuth implements Interceptor {
.setClientSecret(clientSecret));
setFlow(flow);
if (parameters != null) {
- for (String paramName : parameters.keySet()) {
- tokenRequestBuilder.setParameter(paramName, parameters.get(paramName));
+ for (Map.Entry entry : parameters.entrySet()) {
+ tokenRequestBuilder.setParameter(entry.getKey(), entry.getValue());
}
}
}
@@ -130,8 +130,8 @@ public class RetryingOAuth extends OAuth implements Interceptor {
}
Map headers = oAuthRequest.getHeaders();
- for (String headerName : headers.keySet()) {
- requestBuilder.addHeader(headerName, headers.get(headerName));
+ for (Map.Entry entry : headers.entrySet()) {
+ requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
requestBuilder.url(oAuthRequest.getLocationUri());
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache
index 17258d13e7a..2183fa8d790 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache
@@ -15,7 +15,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
- classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.3.0'
+ classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0'
}
}
@@ -69,7 +69,7 @@ if(hasProperty('target') && target == 'android') {
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
- artifacts.add('archives', task);
+ artifacts.add('archives', task)
}
}
@@ -110,19 +110,19 @@ ext {
}
dependencies {
- implementation 'io.swagger:swagger-annotations:1.6.5'
+ implementation 'io.swagger:swagger-annotations:1.6.8'
implementation "com.google.code.findbugs:jsr305:3.0.2"
- implementation 'com.squareup.okhttp3:okhttp:4.9.3'
- implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
- implementation 'com.google.code.gson:gson:2.9.0'
+ implementation 'com.squareup.okhttp3:okhttp:4.10.0'
+ implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
+ implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.8.5'
implementation 'javax.ws.rs:jsr311-api:1.1.1'
implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1'
{{#openApiNullable}}
- implementation 'org.openapitools:jackson-databind-nullable:0.2.3'
+ implementation 'org.openapitools:jackson-databind-nullable:0.2.4'
{{/openApiNullable}}
{{#hasOAuthMethods}}
- implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.1'
+ implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.2'
{{/hasOAuthMethods}}
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
{{#joda}}
@@ -132,9 +132,9 @@ dependencies {
implementation 'io.swagger.parser.v3:swagger-parser-v3:2.0.30'
{{/dynamicOperations}}
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
- testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testImplementation 'org.mockito:mockito-core:3.12.4'
- testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
}
javadoc {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache
index e3612cb5d9f..77d6183a97a 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache
@@ -10,17 +10,17 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.6.5",
- "com.squareup.okhttp3" % "okhttp" % "4.9.3",
- "com.squareup.okhttp3" % "logging-interceptor" % "4.9.3",
- "com.google.code.gson" % "gson" % "2.9.0",
+ "com.squareup.okhttp3" % "okhttp" % "4.10.0",
+ "com.squareup.okhttp3" % "logging-interceptor" % "4.10.0",
+ "com.google.code.gson" % "gson" % "2.9.1",
"org.apache.commons" % "commons-lang3" % "3.12.0",
"javax.ws.rs" % "jsr311-api" % "1.1.1",
"javax.ws.rs" % "javax.ws.rs-api" % "2.1.1",
{{#openApiNullable}}
- "org.openapitools" % "jackson-databind-nullable" % "0.2.3",
+ "org.openapitools" % "jackson-databind-nullable" % "0.2.4",
{{/openApiNullable}}
{{#hasOAuthMethods}}
- "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1",
+ "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.2",
{{/hasOAuthMethods}}
{{#joda}}
"joda-time" % "joda-time" % "2.9.9" % "compile",
@@ -32,7 +32,8 @@ lazy val root = (project in file(".")).
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
- "org.junit.jupiter" % "junit-jupiter-api" % "5.8.2" % "test",
- "com.novocode" % "junit-interface" % "0.10" % "test"
+ "org.junit.jupiter" % "junit-jupiter-api" % "5.9.1" % "test",
+ "com.novocode" % "junit-interface" % "0.10" % "test",
+ "org.mockito" % "mockito-core" % "3.12.4" % "test"
)
)
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
index b2d6a194208..ff011f9a016 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
@@ -12,6 +12,7 @@ import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -497,10 +498,20 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/required}}
{{/items.isModel}}
{{^items.isModel}}
- // ensure the json data is an array
- if ({{#required}}(jsonObj.get("{{{baseName}}}") != null && !jsonObj.get("{{{baseName}}}").isJsonNull()) && {{/required}}!jsonObj.get("{{{baseName}}}").isJsonArray()) {
+ {{^required}}
+ // ensure the optional json data is an array if present
+ if (jsonObj.get("{{{baseName}}}") != null && !jsonObj.get("{{{baseName}}}").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `{{{baseName}}}` to be an array in the JSON string but got `%s`", jsonObj.get("{{{baseName}}}").toString()));
}
+ {{/required}}
+ {{#required}}
+ // ensure the required json array is present
+ if (jsonObj.get("{{{baseName}}}") == null) {
+ throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
+ } else if (!jsonObj.get("{{{baseName}}}").isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected the field `{{{baseName}}}` to be an array in the JSON string but got `%s`", jsonObj.get("{{{baseName}}}").toString()));
+ }
+ {{/required}}
{{/items.isModel}}
{{/isArray}}
{{^isContainer}}
@@ -597,8 +608,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
else
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
- } else { // non-primitive type
- instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
+ } else if (entry.getValue().isJsonArray()) {
+ instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
+ } else { // JSON object
+ instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
}
}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache
index 992436ede09..d2a7e2cce97 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache
@@ -57,7 +57,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.0.0
+ 3.1.0
enforce-maven
@@ -100,6 +100,7 @@
maven-dependency-plugin
+ 3.3.0
package
@@ -116,7 +117,7 @@
org.apache.maven.plugins
maven-jar-plugin
- 3.2.0
+ 3.3.0
@@ -130,7 +131,7 @@
org.codehaus.mojo
build-helper-maven-plugin
- 3.2.0
+ 3.3.0
add_sources
@@ -161,7 +162,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.3.2
+ 3.4.1
attach-javadocs
@@ -184,7 +185,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.2.0
+ 3.2.1
attach-sources
@@ -299,7 +300,7 @@
org.apache.oltu.oauth2
org.apache.oltu.oauth2.client
- 1.0.1
+ 1.0.2
{{/hasOAuthMethods}}
@@ -401,14 +402,14 @@
${java.version}
1.8.5
1.6.5
- 4.9.3
- 2.9.0
+ 4.10.0
+ 2.9.1
3.12.0
{{#openApiNullable}}
- 0.2.3
+ 0.2.4
{{/openApiNullable}}
{{#joda}}
- 2.10.13
+ 2.12.0
{{/joda}}
1.3.5
{{#performBeanValidation}}
@@ -417,12 +418,12 @@
{{#useBeanValidation}}
2.0.2
{{/useBeanValidation}}
- 5.8.2
- 1.6.2
+ 5.9.1
+ 1.9.1
3.12.4
2.1.1
1.1.1
UTF-8
- 2.21.0
+ 2.27.2
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
index 4c9801cfdc4..67a9e7191a4 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
@@ -101,10 +101,10 @@ ext {
rest_assured_version = "4.5.1"
junit_version = "4.13.2"
{{#jackson}}
- jackson_version = "2.12.5"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
{{/jackson}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache
index 47acb40b9c5..820edf8d661 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache
@@ -14,19 +14,19 @@ lazy val root = (project in file(".")).
"io.rest-assured" % "scala-support" % "4.5.1",
"com.google.code.findbugs" % "jsr305" % "3.0.2",
{{#jackson}}
- "com.fasterxml.jackson.core" % "jackson-core" % "2.12.5",
- "com.fasterxml.jackson.core" % "jackson-annotations" % "2.12.5",
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.12.6.1",
+ "com.fasterxml.jackson.core" % "jackson-core" % "2.13.4",
+ "com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.4",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.2",
{{#openApiNullable}}
- "org.openapitools" % "jackson-databind-nullable" % "0.2.3",
+ "org.openapitools" % "jackson-databind-nullable" % "0.2.4",
{{/openApiNullable}}
{{#withXml}}
- "com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.12.6.1",
+ "com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.13.4.1",
{{/withXml}}
{{#joda}}
- "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.12.6.1",
+ "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.13.4.1",
{{/joda}}
- "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.12.6.1",
+ "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.13.4.1",
{{/jackson}}
{{#gson}}
"com.google.code.gson" % "gson" % "2.8.9",
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
index b1d15a0dc80..21c5cf6d25d 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
@@ -338,9 +338,9 @@
2.10.5
{{/joda}}
{{#jackson}}
- 2.12.5
- 2.12.6.1
- 0.2.3
+ 2.13.4
+ 2.13.4.2
+ 0.2.4
{{/jackson}}
1.3.5
{{#useBeanValidation}}
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 1ab85d70556..93a8b84ffc8 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
@@ -98,10 +98,10 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.6.3"
- jackson_version = "2.10.5"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
threetenbp_version = "2.9.10"
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 97d330b7da0..3e1de7399e1 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
@@ -13,9 +13,9 @@ lazy val root = (project in file(".")).
"org.jboss.resteasy" % "resteasy-client" % "3.1.3.Final" % "compile",
"org.jboss.resteasy" % "resteasy-multipart-provider" % "4.5.11.Final" % "compile",
"org.jboss.resteasy" % "resteasy-jackson2-provider" % "4.5.11.Final" % "compile",
- "com.fasterxml.jackson.core" % "jackson-core" % "2.10.5" % "compile",
- "com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.5" % "compile",
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.12.6.1" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-core" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.2" % "compile",
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.9.10" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "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 12f66fe0852..51ad71c3d76 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
@@ -279,10 +279,10 @@
UTF-8
1.6.3
4.7.6.Final
- 2.10.5
- 2.12.6.1
+ 2.13.4
+ 2.13.4.2
{{#openApiNullable}}
- 0.2.3
+ 0.2.4
{{/openApiNullable}}
1.3.5
2.9.10
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 edf70a6237a..ba319ebc890 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
@@ -98,10 +98,10 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.22"
- jackson_version = "2.10.5"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
spring_web_version = "5.3.18"
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 223bc90517f..637ce128ca9 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
@@ -308,7 +308,7 @@
5.3.18
2.12.7
2.12.7
- 0.2.3
+ 0.2.4
1.3.5
{{#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 7f2b0569ae8..5deba46d401 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
@@ -100,10 +100,10 @@ ext {
oltu_version = "1.0.1"
retrofit_version = "2.3.0"
{{#usePlayWS}}
- jackson_version = "2.12.1"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
play_version = "2.6.7"
{{/usePlayWS}}
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 f19624661e5..0bc66fde845 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
@@ -18,9 +18,9 @@ lazy val root = (project in file(".")).
"com.typesafe.play" % "play-ahc-ws_2.12" % "2.6.7" % "compile",
"jakarta.validation" % "jakarta.validation-api" % "2.0.2" % "compile",
"com.squareup.retrofit2" % "converter-jackson" % "2.3.0" % "compile",
- "com.fasterxml.jackson.core" % "jackson-core" % "2.12.1" % "compile",
- "com.fasterxml.jackson.core" % "jackson-annotations" % "2.12.1" % "compile",
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.12.6.1" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-core" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.4" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.2" % "compile",
{{/usePlayWS}}
{{#useRxJava2}}
"com.squareup.retrofit2" % "adapter-rxjava2" % "2.3.0" % "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 ce5a737fd40..5ec0dd02534 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
@@ -363,11 +363,11 @@
1.8.3
1.6.3
{{#usePlayWS}}
- 2.12.1
- 2.12.6.1
+ 2.13.4
+ 2.13.4.2
2.6.7
{{#openApiNullable}}
- 0.2.3
+ 0.2.4
{{/openApiNullable}}
{{/usePlayWS}}
2.5.0
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 8e8a20e422d..6f9d9e6bb2c 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
@@ -30,12 +30,12 @@ task execute(type:JavaExec) {
ext {
swagger_annotations_version = "1.5.21"
- jackson_version = "2.10.5"
- jackson_databind_version = "2.12.6.1"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
vertx_version = "3.4.2"
junit_version = "4.13.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
}
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 c32d1152404..099abffe2bb 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
@@ -292,9 +292,9 @@
UTF-8
3.4.2
1.5.22
- 2.10.5
- 2.12.6.1
- 0.2.3
+ 2.13.4
+ 2.13.4.2
+ 0.2.4
1.3.5
4.13.2
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache
index aeed99cbc1e..c9950a00c6a 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache
@@ -517,7 +517,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @return boolean true if the MediaType represents JSON, false otherwise
*/
public boolean isJsonMime(MediaType mediaType) {
- return mediaType != null && (MediaType.APPLICATION_JSON.isCompatibleWith(mediaType) || mediaType.getSubtype().matches("^.*\\+json[;]?\\s*$"));
+ return mediaType != null && (MediaType.APPLICATION_JSON.isCompatibleWith(mediaType) || mediaType.getSubtype().matches("^.*(\\+json|ndjson)[;]?\\s*$"));
}
/**
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
index 27d2cd43e7f..5d97c7d0f1b 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
@@ -114,10 +114,10 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.6.3"
spring_boot_version = "2.6.6"
- jackson_version = "2.12.7"
- jackson_databind_version = "2.12.7"
+ jackson_version = "2.13.4"
+ jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
- jackson_databind_nullable_version = "0.2.3"
+ jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
reactor_version = "3.4.3"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
index 660e76a1d4c..22faa52f939 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
@@ -148,10 +148,10 @@
UTF-8
1.6.3
2.6.6
- 2.12.7
- 2.12.7
+ 2.13.4
+ 2.13.4.2
{{#openApiNullable}}
- 0.2.3
+ 0.2.4
{{/openApiNullable}}
1.3.5
4.13.2
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache
index 09893b8df21..c66a9702887 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache
@@ -1,6 +1,8 @@
package {{package}};
+{{#models.0}}
import {{modelPackage}}.*;
+{{/models.0}}
import {{package}}.{{classname}}Service;
import {{package}}.factories.{{classname}}ServiceFactory;
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/apiService.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/apiService.mustache
index d395bb8ee2b..0aa3241c26d 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/apiService.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/apiService.mustache
@@ -1,7 +1,9 @@
package {{package}};
import {{package}}.*;
+{{#models.0}}
import {{modelPackage}}.*;
+{{/models.0}}
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/apiServiceImpl.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/apiServiceImpl.mustache
index af96791e89b..ab4aff25991 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/apiServiceImpl.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/apiServiceImpl.mustache
@@ -1,8 +1,9 @@
package {{package}}.impl;
import {{package}}.*;
+{{#models.0}}
import {{modelPackage}}.*;
-
+{{/models.0}}
{{#imports}}import {{import}};
{{/imports}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache
index cf48c4834a1..d548a7be1fe 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache
@@ -96,11 +96,11 @@ import javax.annotation.Generated;
{{#virtualService}}
@VirtualService
{{/virtualService}}
-{{^useFeignClient}}
+{{#useRequestMappingOnInterface}}
{{=<% %>=}}
@RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}")
<%={{ }}=%>
-{{/useFeignClient}}
+{{/useRequestMappingOnInterface}}
public interface {{classname}} {
{{#jdk8-default-interface}}
{{^isDelegate}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache
index 85589bb7b67..d6be388587d 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache
@@ -58,6 +58,11 @@ import javax.annotation.Generated;
{{>generatedAnnotation}}
@Controller
+{{#useRequestMappingOnController}}
+{{=<% %>=}}
+@RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}")
+<%={{ }}=%>
+{{/useRequestMappingOnController}}
{{#operations}}
public class {{classname}}Controller implements {{classname}} {
{{#isDelegate}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/converter.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/converter.mustache
new file mode 100644
index 00000000000..a331ded633b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/converter.mustache
@@ -0,0 +1,34 @@
+package {{configPackage}};
+
+{{#models}}
+ {{#model}}
+ {{#isEnum}}
+import {{modelPackage}}.{{name}};
+ {{/isEnum}}
+ {{/model}}
+{{/models}}
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.convert.converter.Converter;
+
+@Configuration
+public class EnumConverterConfiguration {
+
+{{#models}}
+{{#model}}
+{{#isEnum}}
+ @Bean
+ Converter<{{{dataType}}}, {{name}}> {{classVarName}}Converter() {
+ return new Converter<{{{dataType}}}, {{name}}>() {
+ @Override
+ public {{name}} convert({{{dataType}}} source) {
+ return {{name}}.fromValue(source);
+ }
+ };
+ }
+{{/isEnum}}
+{{/model}}
+{{/models}}
+
+}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache
index f00a6c3b6f7..adc5145d080 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache
@@ -3,8 +3,6 @@ package {{package}};
import org.springframework.cloud.openfeign.FeignClient;
import {{configPackage}}.ClientConfiguration;
-{{=<% %>=}}
-@FeignClient(name="${<%classVarName%>.name:<%classVarName%>}", url="${<%classVarName%>.url:<%basePath%>}", configuration = ClientConfiguration.class)
-<%={{ }}=%>
+@FeignClient(name="${{openbrace}}{{classVarName}}.name:{{classVarName}}{{closebrace}}", {{#useFeignClientUrl}}url="${{openbrace}}{{classVarName}}.url:{{basePath}}{{closebrace}}", {{/useFeignClientUrl}}configuration = ClientConfiguration.class)
public interface {{classname}}Client extends {{classname}} {
}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache
index 28a6ea60ac0..23dfcf6759b 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache
@@ -43,5 +43,5 @@ Mono result = Mono.empty();
{{^examples}}
exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
{{/examples}}
- return result.then(Mono.empty());
+ return result{{#allParams}}{{#isBodyParam}}{{^isArray}}{{#paramName}}.then({{.}}){{/paramName}}{{/isArray}}{{#isArray}}{{#paramName}}.thenMany({{.}}){{/paramName}}{{/isArray}}{{/isBodyParam}}{{/allParams}}.then(Mono.empty());
{{/reactive}}
diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache
index 8de1caf4bfa..eeafa6e8843 100644
--- a/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache
@@ -5,6 +5,7 @@ using System.Collections;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
{{#useCompareNetObjects}}
@@ -112,6 +113,8 @@ namespace {{packageName}}.Client
return boolean ? "true" : "false";
if (obj is ICollection collection)
return string.Join(",", collection.Cast());
+ if (obj is Enum && HasEnumMemberAttrValue(obj))
+ return GetEnumMemberAttrValue(obj);
return Convert.ToString(obj, CultureInfo.InvariantCulture);
}
@@ -210,5 +213,40 @@ namespace {{packageName}}.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
+
+ ///
+ /// Is the Enum decorated with EnumMember Attribute
+ ///
+ ///
+ /// true if found
+ private static bool HasEnumMemberAttrValue(object enumVal)
+ {
+ if (enumVal == null)
+ throw new ArgumentNullException(nameof(enumVal));
+ var enumType = enumVal.GetType();
+ var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
+ var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType().FirstOrDefault();
+ if (attr != null) return true;
+ return false;
+ }
+
+ ///
+ /// Get the EnumMember value
+ ///
+ ///
+ /// EnumMember value as string otherwise null
+ private static string GetEnumMemberAttrValue(object enumVal)
+ {
+ if (enumVal == null)
+ throw new ArgumentNullException(nameof(enumVal));
+ var enumType = enumVal.GetType();
+ var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
+ var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType().FirstOrDefault();
+ if (attr != null)
+ {
+ return attr.Value;
+ }
+ return null;
+ }
}
}
diff --git a/modules/openapi-generator/src/main/resources/elm/Api.mustache b/modules/openapi-generator/src/main/resources/elm/Api.mustache
index 2890e9deac9..57b78a2620c 100644
--- a/modules/openapi-generator/src/main/resources/elm/Api.mustache
+++ b/modules/openapi-generator/src/main/resources/elm/Api.mustache
@@ -3,6 +3,7 @@ module Api exposing
, request
, send
, sendWithCustomError
+ , sendWithCustomExpect
, task
, map
, withBasePath
@@ -55,13 +56,18 @@ send toMsg req =
sendWithCustomError : (Http.Error -> e) -> (Result e a -> msg) -> Request a -> Cmd msg
-sendWithCustomError mapError toMsg (Request req) =
+sendWithCustomError mapError toMsg req =
+ sendWithCustomExpect (expectJson mapError toMsg) req
+
+
+sendWithCustomExpect : (Json.Decode.Decoder a -> Http.Expect msg) -> Request a -> Cmd msg
+sendWithCustomExpect expect (Request req) =
Http.request
{ method = req.method
, headers = req.headers
, url = Url.Builder.crossOrigin req.basePath req.pathParams req.queryParams
, body = req.body
- , expect = expectJson mapError toMsg req.decoder
+ , expect = expect req.decoder
, timeout = req.timeout
, tracker = req.tracker
}
diff --git a/modules/openapi-generator/src/main/resources/go-echo-server/go-mod.mustache b/modules/openapi-generator/src/main/resources/go-echo-server/go-mod.mustache
index 4b31aa41c83..c1a4ac15ece 100644
--- a/modules/openapi-generator/src/main/resources/go-echo-server/go-mod.mustache
+++ b/modules/openapi-generator/src/main/resources/go-echo-server/go-mod.mustache
@@ -2,4 +2,4 @@ module github.com/{{{gitUserId}}}/{{{gitRepoId}}}
go 1.16
-require github.com/labstack/echo/v4 v4.2.0
+require github.com/labstack/echo/v4 v4.9.0
diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache
index c2c977178bb..44fbbcf4f95 100644
--- a/modules/openapi-generator/src/main/resources/go/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api.mustache
@@ -385,7 +385,8 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
newErr.error = err.Error()
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
- newErr.model = v
+ newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
+ newErr.model = v
{{^-last}}
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
{{/-last}}
diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index 62f75508bae..d5e45dfb03c 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -127,7 +127,7 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
// Check the type is as expected.
if reflect.TypeOf(obj).String() != expected {
- return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String())
+ return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String())
}
return nil
}
@@ -514,7 +514,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
}
if bodyBuf.Len() == 0 {
- err = fmt.Errorf("Invalid body type %s\n", contentType)
+ err = fmt.Errorf("invalid body type %s\n", contentType)
return nil, err
}
return bodyBuf, nil
@@ -616,3 +616,23 @@ func (e GenericOpenAPIError) Body() []byte {
func (e GenericOpenAPIError) Model() interface{} {
return e.model
}
+
+// format error message using title and detail when model implements rfc7807
+func formatErrorMessage(status string, v interface{}) string {
+
+ str := ""
+ metaValue := reflect.ValueOf(v).Elem()
+
+ field := metaValue.FieldByName("Title")
+ if field != (reflect.Value{}) {
+ str = fmt.Sprintf("%s", field.Interface())
+ }
+
+ field = metaValue.FieldByName("Detail")
+ if field != (reflect.Value{}) {
+ str = fmt.Sprintf("%s (%s)", str, field.Interface())
+ }
+
+ // status title (detail)
+ return fmt.Sprintf("%s %s", status, str)
+}
diff --git a/modules/openapi-generator/src/main/resources/go/configuration.mustache b/modules/openapi-generator/src/main/resources/go/configuration.mustache
index 610f9edc5d2..088e9202cf8 100644
--- a/modules/openapi-generator/src/main/resources/go/configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/go/configuration.mustache
@@ -207,7 +207,7 @@ func (c *Configuration) AddDefaultHeader(key string, value string) {
// URL formats template on a index using given variables
func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
if index < 0 || len(sc) <= index {
- return "", fmt.Errorf("Index %v out of range %v", index, len(sc)-1)
+ return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1)
}
server := sc[index]
url := server.URL
@@ -222,7 +222,7 @@ func (sc ServerConfigurations) URL(index int, variables map[string]string) (stri
}
}
if !found {
- return "", fmt.Errorf("The variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
+ return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
}
url = strings.Replace(url, "{"+name+"}", value, -1)
} else {
diff --git a/modules/openapi-generator/src/main/resources/go/model_anyof.mustache b/modules/openapi-generator/src/main/resources/go/model_anyof.mustache
index f1d8c57c85f..3b221d80fb6 100644
--- a/modules/openapi-generator/src/main/resources/go/model_anyof.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_anyof.mustache
@@ -22,7 +22,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
var jsonDict map[string]interface{}
err = json.Unmarshal(data, &jsonDict)
if err != nil {
- return fmt.Errorf("Failed to unmarshal JSON into map for the discriminator lookup.")
+ return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
}
{{/-first}}
@@ -59,7 +59,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
}
{{/anyOf}}
- return fmt.Errorf("Data failed to match schemas in anyOf({{classname}})")
+ return fmt.Errorf("data failed to match schemas in anyOf({{classname}})")
}
// Marshal data from the first non-nil pointers in the struct to JSON
diff --git a/modules/openapi-generator/src/main/resources/go/model_oneof.mustache b/modules/openapi-generator/src/main/resources/go/model_oneof.mustache
index 14bc3ada757..3f70f611683 100644
--- a/modules/openapi-generator/src/main/resources/go/model_oneof.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_oneof.mustache
@@ -33,7 +33,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
var jsonDict map[string]interface{}
err = newStrictDecoder(data).Decode(&jsonDict)
if err != nil {
- return fmt.Errorf("Failed to unmarshal JSON into map for the discriminator lookup.")
+ return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
}
{{/-first}}
@@ -45,7 +45,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
return nil // data stored in dst.{{{modelName}}}, return on the first match
} else {
dst.{{{modelName}}} = nil
- return fmt.Errorf("Failed to unmarshal {{classname}} as {{{modelName}}}: %s", err.Error())
+ return fmt.Errorf("failed to unmarshal {{classname}} as {{{modelName}}}: %s", err.Error())
}
}
@@ -75,11 +75,11 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil
{{/oneOf}}
- return fmt.Errorf("Data matches more than one schema in oneOf({{classname}})")
+ return fmt.Errorf("data matches more than one schema in oneOf({{classname}})")
} else if match == 1 {
return nil // exactly one match
} else { // no match
- return fmt.Errorf("Data failed to match schemas in oneOf({{classname}})")
+ return fmt.Errorf("data failed to match schemas in oneOf({{classname}})")
}
{{/discriminator}}
{{/useOneOfDiscriminatorLookup}}
@@ -106,11 +106,11 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil
{{/oneOf}}
- return fmt.Errorf("Data matches more than one schema in oneOf({{classname}})")
+ return fmt.Errorf("data matches more than one schema in oneOf({{classname}})")
} else if match == 1 {
return nil // exactly one match
} else { // no match
- return fmt.Errorf("Data failed to match schemas in oneOf({{classname}})")
+ return fmt.Errorf("data failed to match schemas in oneOf({{classname}})")
}
{{/useOneOfDiscriminatorLookup}}
}
diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
index 7a9b2565444..1f41f195532 100644
--- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache
@@ -122,8 +122,13 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
// Deprecated
{{/deprecated}}
func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
- if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
- return nil, false
+ if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+{{^isFreeFormObject}}
+ return nil, false
+ {{/isFreeFormObject}}
+ {{#isFreeFormObject}}
+ return {{vendorExtensions.x-go-base-type}}{}, false
+ {{/isFreeFormObject}}
}
{{#isNullable}}
{{#vendorExtensions.x-golang-is-container}}
@@ -163,7 +168,7 @@ func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
// Deprecated
{{/deprecated}}
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
- if o == nil{{^isNullable}} || o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+ if o == nil{{^isNullable}} || isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
var ret {{vendorExtensions.x-go-base-type}}
return ret
}
@@ -189,8 +194,13 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
// Deprecated
{{/deprecated}}
func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
- if o == nil{{^isNullable}} || o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
- return nil, false
+ if o == nil{{^isNullable}} || isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+ {{^isFreeFormObject}}
+ return nil, false
+ {{/isFreeFormObject}}
+ {{#isFreeFormObject}}
+ return {{vendorExtensions.x-go-base-type}}{}, false
+ {{/isFreeFormObject}}
}
{{#isNullable}}
{{#vendorExtensions.x-golang-is-container}}
@@ -207,7 +217,7 @@ func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/is
// Has{{name}} returns a boolean if a field has been set.
func (o *{{classname}}) Has{{name}}() bool {
- if o != nil && {{^isNullable}}o.{{name}} != nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}o.{{name}} != nil{{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
+ if o != nil && {{^isNullable}}!isNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}isNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
return true
}
@@ -285,7 +295,7 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
{{/isNullable}}
{{! if argument is not nullable, don't set it if it is nil}}
{{^isNullable}}
- if {{#required}}true{{/required}}{{^required}}o.{{name}} != nil{{/required}} {
+ if {{#required}}true{{/required}}{{^required}}!isNil(o.{{name}}){{/required}} {
toSerialize["{{baseName}}"] = o.{{name}}
}
{{/isNullable}}
diff --git a/modules/openapi-generator/src/main/resources/go/signing.mustache b/modules/openapi-generator/src/main/resources/go/signing.mustache
index d8c5b376e9e..6400d0265ea 100644
--- a/modules/openapi-generator/src/main/resources/go/signing.mustache
+++ b/modules/openapi-generator/src/main/resources/go/signing.mustache
@@ -126,26 +126,26 @@ func (h *HttpSignatureAuth) SetPrivateKey(privateKey string) error {
// are invalid.
func (h *HttpSignatureAuth) ContextWithValue(ctx context.Context) (context.Context, error) {
if h.KeyId == "" {
- return nil, fmt.Errorf("Key ID must be specified")
+ return nil, fmt.Errorf("key ID must be specified")
}
if h.PrivateKeyPath == "" && h.privateKey == nil {
- return nil, fmt.Errorf("Private key path must be specified")
+ return nil, fmt.Errorf("private key path must be specified")
}
if _, ok := supportedSigningSchemes[h.SigningScheme]; !ok {
- return nil, fmt.Errorf("Invalid signing scheme: '%v'", h.SigningScheme)
+ return nil, fmt.Errorf("invalid signing scheme: '%v'", h.SigningScheme)
}
m := make(map[string]bool)
for _, h := range h.SignedHeaders {
if strings.EqualFold(h, HttpHeaderAuthorization) {
- return nil, fmt.Errorf("Signed headers cannot include the 'Authorization' header")
+ return nil, fmt.Errorf("signed headers cannot include the 'Authorization' header")
}
m[h] = true
}
if len(m) != len(h.SignedHeaders) {
- return nil, fmt.Errorf("List of signed headers cannot have duplicate names")
+ return nil, fmt.Errorf("list of signed headers cannot have duplicate names")
}
if h.SignatureMaxValidity < 0 {
- return nil, fmt.Errorf("Signature max validity must be a positive value")
+ return nil, fmt.Errorf("signature max validity must be a positive value")
}
if err := h.loadPrivateKey(); err != nil {
return nil, err
@@ -168,7 +168,7 @@ func (h *HttpSignatureAuth) GetPublicKey() (crypto.PublicKey, error) {
default:
// Do not change '%T' to anything else such as '%v'!
// The value of the private key must not be returned.
- return nil, fmt.Errorf("Unsupported key: %T", h.privateKey)
+ return nil, fmt.Errorf("unsupported key: %T", h.privateKey)
}
}
@@ -181,7 +181,7 @@ func (h *HttpSignatureAuth) loadPrivateKey() (err error) {
var file *os.File
file, err = os.Open(h.PrivateKeyPath)
if err != nil {
- return fmt.Errorf("Cannot load private key '%s'. Error: %v", h.PrivateKeyPath, err)
+ return fmt.Errorf("cannot load private key '%s'. Error: %v", h.PrivateKeyPath, err)
}
defer func() {
err = file.Close()
@@ -199,7 +199,7 @@ func (h *HttpSignatureAuth) parsePrivateKey(priv []byte) error {
pemBlock, _ := pem.Decode(priv)
if pemBlock == nil {
// No PEM data has been found.
- return fmt.Errorf("File '%s' does not contain PEM data", h.PrivateKeyPath)
+ return fmt.Errorf("file '%s' does not contain PEM data", h.PrivateKeyPath)
}
var privKey []byte
var err error
@@ -225,7 +225,7 @@ func (h *HttpSignatureAuth) parsePrivateKey(priv []byte) error {
return err
}
default:
- return fmt.Errorf("Key '%s' is not supported", pemBlock.Type)
+ return fmt.Errorf("key '%s' is not supported", pemBlock.Type)
}
return nil
}
@@ -248,7 +248,7 @@ func SignRequest(
auth HttpSignatureAuth) error {
if auth.privateKey == nil {
- return fmt.Errorf("Private key is not set")
+ return fmt.Errorf("private key is not set")
}
now := time.Now()
date := now.UTC().Format(http.TimeFormat)
@@ -262,7 +262,7 @@ func SignRequest(
var expiresUnix float64
if auth.SignatureMaxValidity < 0 {
- return fmt.Errorf("Signature validity must be a positive value")
+ return fmt.Errorf("signature validity must be a positive value")
}
if auth.SignatureMaxValidity > 0 {
e := now.Add(auth.SignatureMaxValidity)
@@ -278,10 +278,10 @@ func SignRequest(
h = crypto.SHA256
prefix = "SHA-256="
default:
- return fmt.Errorf("Unsupported signature scheme: %v", auth.SigningScheme)
+ return fmt.Errorf("unsupported signature scheme: %v", auth.SigningScheme)
}
if !h.Available() {
- return fmt.Errorf("Hash '%v' is not available", h)
+ return fmt.Errorf("hash '%v' is not available", h)
}
// Build the "(request-target)" signature header.
@@ -308,7 +308,7 @@ func SignRequest(
m[h] = true
}
if len(m) != len(signedHeaders) {
- return fmt.Errorf("List of signed headers must not have any duplicates")
+ return fmt.Errorf("list of signed headers must not have any duplicates")
}
hasCreatedParameter := false
hasExpiresParameter := false
@@ -317,7 +317,7 @@ func SignRequest(
var value string
switch header {
case strings.ToLower(HttpHeaderAuthorization):
- return fmt.Errorf("Cannot include the 'Authorization' header as a signed header.")
+ return fmt.Errorf("cannot include the 'Authorization' header as a signed header")
case HttpSignatureParameterRequestTarget:
value = requestTarget
case HttpSignatureParameterCreated:
@@ -325,7 +325,7 @@ func SignRequest(
hasCreatedParameter = true
case HttpSignatureParameterExpires:
if auth.SignatureMaxValidity.Nanoseconds() == 0 {
- return fmt.Errorf("Cannot set '(expires)' signature parameter. SignatureMaxValidity is not configured.")
+ return fmt.Errorf("cannot set '(expires)' signature parameter. SignatureMaxValidity is not configured")
}
value = fmt.Sprintf("%.3f", expiresUnix)
hasExpiresParameter = true
@@ -361,7 +361,7 @@ func SignRequest(
if v, ok = r.Header[canonicalHeader]; !ok {
// If a header specified in the headers parameter cannot be matched with
// a provided header in the message, the implementation MUST produce an error.
- return fmt.Errorf("Header '%s' does not exist in the request", canonicalHeader)
+ return fmt.Errorf("header '%s' does not exist in the request", canonicalHeader)
}
// If there are multiple instances of the same header field, all
// header field values associated with the header field MUST be
@@ -376,7 +376,7 @@ func SignRequest(
fmt.Fprintf(&sb, "%s: %s", header, value)
}
if expiresUnix != 0 && !hasExpiresParameter {
- return fmt.Errorf("SignatureMaxValidity is specified, but '(expired)' parameter is not present")
+ return fmt.Errorf("signatureMaxValidity is specified, but '(expired)' parameter is not present")
}
msg := []byte(sb.String())
msgHash := h.New()
@@ -394,14 +394,14 @@ func SignRequest(
case "", HttpSigningAlgorithmRsaPSS:
signature, err = rsa.SignPSS(rand.Reader, key, h, d, nil)
default:
- return fmt.Errorf("Unsupported signing algorithm: '%s'", auth.SigningAlgorithm)
+ return fmt.Errorf("unsupported signing algorithm: '%s'", auth.SigningAlgorithm)
}
case *ecdsa.PrivateKey:
signature, err = key.Sign(rand.Reader, d, h)
case ed25519.PrivateKey: // requires go 1.13
signature, err = key.Sign(rand.Reader, msg, crypto.Hash(0))
default:
- return fmt.Errorf("Unsupported private key")
+ return fmt.Errorf("unsupported private key")
}
if err != nil {
return err
diff --git a/modules/openapi-generator/src/main/resources/go/utils.mustache b/modules/openapi-generator/src/main/resources/go/utils.mustache
index 5ae789a996c..cc42e879c85 100644
--- a/modules/openapi-generator/src/main/resources/go/utils.mustache
+++ b/modules/openapi-generator/src/main/resources/go/utils.mustache
@@ -3,6 +3,7 @@ package {{packageName}}
import (
"encoding/json"
+ "reflect"
"time"
)
@@ -317,3 +318,17 @@ func (v *NullableTime) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
+
+// isNil checks if an input is nil
+func isNil(i interface{}) bool {
+ if i == nil {
+ return true
+ }
+ switch reflect.TypeOf(i).Kind() {
+ case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
+ return reflect.ValueOf(i).IsNil()
+ case reflect.Array:
+ return reflect.ValueOf(i).IsZero()
+ }
+ return false
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
index d6dca22f5fc..d805869f5ae 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
@@ -20,8 +20,8 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Requires
{{#jvm}}
-* Kotlin 1.4.30
-* Gradle 6.8.3
+* Kotlin 1.6.10
+* Gradle 7.5
{{/jvm}}
{{#multiplatform}}
* Kotlin 1.5.10
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/additionalModelTypeAnnotations.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/additionalModelTypeAnnotations.mustache
new file mode 100644
index 00000000000..f4871c02cc2
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/additionalModelTypeAnnotations.mustache
@@ -0,0 +1,2 @@
+{{#additionalModelTypeAnnotations}}{{{.}}}
+{{/additionalModelTypeAnnotations}}
\ No newline at end of file
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 5716f8656c3..b43ef7f39f6 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
@@ -11,7 +11,7 @@ wrapper {
buildscript {
ext.kotlin_version = '1.6.10'
{{#jvm-ktor}}
- ext.ktor_version = '2.0.3'
+ ext.ktor_version = '2.1.2'
{{/jvm-ktor}}
{{#jvm-retrofit2}}
ext.retrofitVersion = '2.9.0'
@@ -25,6 +25,9 @@ buildscript {
{{#useRxJava3}}
ext.rxJava3Version = '3.0.12'
{{/useRxJava3}}
+ {{#jvm-vertx}}
+ ext.vertx_version = "4.3.3"
+ {{/jvm-vertx}}
repositories {
maven { url "https://repo1.maven.org/maven2" }
@@ -149,6 +152,15 @@ dependencies {
implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
{{/jvm-retrofit2}}
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
+ {{#jvm-vertx}}
+ implementation "io.vertx:vertx-web-client:$vertx_version"
+ implementation "io.vertx:vertx-core:$vertx_version"
+ implementation "io.vertx:vertx-lang-kotlin:$vertx_version"
+ implementation "io.vertx:vertx-uri-template:$vertx_version"
+ {{#useCoroutines}}
+ implementation "io.vertx:vertx-lang-kotlin-coroutines:$vertx_version"
+ {{/useCoroutines}}
+ {{/jvm-vertx}}
}
{{#kotlinx_serialization}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
index 8d2c28acd4a..0ddf4793a44 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
@@ -61,6 +61,7 @@ import {{packageName}}.infrastructure.ITransformForStorage
{{#isDeprecated}}
@Deprecated(message = "This schema is deprecated.")
{{/isDeprecated}}
+{{>additionalModelTypeAnnotations}}
{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface{{/discriminator}}{{^discriminator}}data class{{/discriminator}} {{classname}}{{^discriminator}} (
{{#allVars}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache
index 51a0a5f504e..301af9194f8 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache
@@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
import io.ktor.client.request.request
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
+import io.ktor.http.contentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import io.ktor.http.Parameters
@@ -34,11 +35,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.core.util.DefaultIndenter
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
{{/jackson}}
-import org.openapitools.client.auth.ApiKeyAuth
-import org.openapitools.client.auth.Authentication
-import org.openapitools.client.auth.HttpBasicAuth
-import org.openapitools.client.auth.HttpBearerAuth
-import org.openapitools.client.auth.OAuth
import {{packageName}}.auth.*
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(
@@ -111,7 +107,7 @@ import {{packageName}}.auth.*
* @param username Username
*/
fun setUsername(username: String) {
- val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
+ val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
?: throw Exception("No HTTP basic authentication configured")
auth.username = username
}
@@ -122,7 +118,7 @@ import {{packageName}}.auth.*
* @param password Password
*/
fun setPassword(password: String) {
- val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
+ val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
?: throw Exception("No HTTP basic authentication configured")
auth.password = password
}
@@ -134,7 +130,7 @@ import {{packageName}}.auth.*
* @param paramName The name of the API key parameter, or null or set the first key.
*/
fun setApiKey(apiKey: String, paramName: String? = null) {
- val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
+ val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
?: throw Exception("No API key authentication configured")
auth.apiKey = apiKey
}
@@ -146,7 +142,7 @@ import {{packageName}}.auth.*
* @param paramName The name of the API key parameter, or null or set the first key.
*/
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
- val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
+ val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
?: throw Exception("No API key authentication configured")
auth.apiKeyPrefix = apiKeyPrefix
}
@@ -157,7 +153,7 @@ import {{packageName}}.auth.*
* @param accessToken Access token
*/
fun setAccessToken(accessToken: String) {
- val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
+ val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth?
?: throw Exception("No OAuth2 authentication configured")
auth.accessToken = accessToken
}
@@ -168,7 +164,7 @@ import {{packageName}}.auth.*
* @param bearerToken The bearer token.
*/
fun setBearerToken(bearerToken: String) {
- val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
+ val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
?: throw Exception("No Bearer authentication configured")
auth.bearerToken = bearerToken
}
@@ -199,8 +195,9 @@ import {{packageName}}.auth.*
}
this.method = requestConfig.method.httpMethod
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
- if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
+ if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
setBody(body)
+ }
}
}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/api.mustache
new file mode 100644
index 00000000000..04e6e387819
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/api.mustache
@@ -0,0 +1,232 @@
+{{>licenseInfo}}
+package {{apiPackage}}
+
+import java.io.IOException
+
+{{#imports}}import {{import}}
+{{/imports}}
+
+{{#jackson}}
+import com.fasterxml.jackson.annotation.JsonProperty
+import com.fasterxml.jackson.core.type.TypeReference
+{{/jackson}}
+{{#gson}}
+import com.google.gson.reflect.TypeToken
+import com.google.gson.annotations.SerializedName
+{{/gson}}
+{{#moshi}}
+import com.squareup.moshi.Json
+{{/moshi}}
+
+import io.vertx.core.Vertx
+import io.vertx.core.http.RequestOptions
+import io.vertx.core.http.HttpMethod
+import io.vertx.core.buffer.Buffer
+import io.vertx.core.Future
+import io.vertx.ext.web.client.WebClient
+import io.vertx.uritemplate.UriTemplate
+
+{{#useCoroutines}}
+import io.vertx.kotlin.coroutines.await
+import io.vertx.kotlin.coroutines.dispatcher
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+{{/useCoroutines}}
+
+import {{packageName}}.infrastructure.*
+
+@Suppress ("UNUSED")
+{{#operations}}
+{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}(basePath: kotlin.String = ApiClient.defaultBasePath, accessToken: String? = null, apiKey: MutableMap = mutableMapOf(), apiKeyPrefix: MutableMap = mutableMapOf(), username: String? = null, password: String? = null, vertx: Vertx): ApiClient(basePath, accessToken, apiKey, apiKeyPrefix, username, password, vertx) {
+ {{#operation}}
+ {{#allParams}}
+ {{#isEnum}}
+ /**
+ * enum for parameter {{paramName}}
+ */
+ {{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{enumName}}_{{operationId}}(val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}) {
+ {{^enumUnknownDefaultCase}}
+ {{#allowableValues}}
+ {{#enumVars}}
+ {{#moshi}}
+ @Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
+ {{/moshi}}
+ {{#gson}}
+ @SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
+ {{/gson}}
+ {{#jackson}}
+ @JsonProperty(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
+ {{/jackson}}
+ {{#kotlinx_serialization}}
+ @SerialName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
+ {{/kotlinx_serialization}}
+ {{/enumVars}}
+ {{/allowableValues}}
+ {{/enumUnknownDefaultCase}}
+ {{#enumUnknownDefaultCase}}
+ {{#allowableValues}}
+ {{#enumVars}}
+ {{^-last}}
+ {{#moshi}}
+ @Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
+ {{/moshi}}
+ {{#gson}}
+ @SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
+ {{/gson}}
+ {{#jackson}}
+ @JsonProperty(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
+ {{/jackson}}
+ {{#kotlinx_serialization}}
+ @SerialName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
+ {{/kotlinx_serialization}}
+ {{/-last}}
+ {{/enumVars}}
+ {{/allowableValues}}
+ {{/enumUnknownDefaultCase}}
+ }
+
+ {{/isEnum}}
+ {{/allParams}}
+ /**
+ * {{summary}}
+ * {{notes}}
+ {{#allParams}}* @param {{{paramName}}} {{description}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}{{/required}}
+ {{/allParams}}* @return {{#returnType}}{{{returnType}}}{{#nullableReturnType}}{{^isResponseOptional}} or null{{/isResponseOptional}}{{/nullableReturnType}}{{#isResponseOptional}} or null{{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}
+ * @throws IllegalStateException If the request is not correctly configured
+ * @throws IOException Rethrows the OkHttp execute method exception
+ * @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
+ */{{#returnType}}
+ @Suppress("UNCHECKED_CAST"){{/returnType}}
+ @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
+ {{#isDeprecated}}
+ @Deprecated(message = "This operation is deprecated.")
+ {{/isDeprecated}}
+ {{#useCoroutines}}suspend {{/useCoroutines}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{#isEnum}}{{#isContainer}}kotlin.collections.List<{{enumName}}_{{operationId}}>{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{/required}}{{^required}}?{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : {{^useCoroutines}}Future<{{/useCoroutines}}{{#returnType}}{{{returnType}}}{{#nullableReturnType}}{{^isResponseOptional}}?{{/isResponseOptional}}{{/nullableReturnType}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{^useCoroutines}}>{{/useCoroutines}} {
+ return {{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}} = {{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}).map { localVarResponse ->
+ when (localVarResponse.responseType) {
+ ResponseType.Success -> {{#returnType}}(localVarResponse as Success<*>).data as {{{returnType}}}{{#nullableReturnType}}{{^isResponseOptional}}?{{/isResponseOptional}}{{/nullableReturnType}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/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 -> {
+ val localVarError = localVarResponse as ClientError<*>
+ throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
+ }
+ ResponseType.ServerError -> {
+ val localVarError = localVarResponse as ServerError<*>
+ throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
+ }
+ }
+ }{{#useCoroutines}}.await(){{/useCoroutines}}
+ }
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ {{#allParams}}* @param {{{paramName}}} {{description}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}{{/required}}
+ {{/allParams}}* @return ApiResponse<{{#returnType}}{{{returnType}}}?{{/returnType}}{{^returnType}}Unit?{{/returnType}}>
+ * @throws IllegalStateException If the request is not correctly configured
+ * @throws IOException Rethrows the OkHttp execute method exception
+ */{{#returnType}}
+ @Suppress("UNCHECKED_CAST"){{/returnType}}
+ @Throws(IllegalStateException::class, IOException::class)
+ {{#isDeprecated}}
+ @Deprecated(message = "This operation is deprecated.")
+ {{/isDeprecated}}
+ fun {{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}}: {{#isEnum}}{{#isContainer}}kotlin.collections.List<{{enumName}}_{{operationId}}>{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : Future> {
+ val vertxClient = WebClient.create(vertx)
+ val request = vertxClient.requestAbs(HttpMethod.{{httpMethod}}, UriTemplate.of("$basePath{{path}}"{{#pathParams}}.replace("{"+"{{baseName}}"+"}", encodeURIComponent({{#isContainer}}{{paramName}}.joinToString(","){{/isContainer}}{{^isContainer}}{{{paramName}}}{{#isEnum}}.value{{/isEnum}}.toString(){{/isContainer}})){{/pathParams}}))
+
+ {{#hasFormParams}}request.putHeader("Content-Type", {{^consumes}}"multipart/form-data"{{/consumes}}{{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}){{/hasFormParams}}
+ {{#headerParams}}{{{paramName}}}{{^required}}?{{/required}}.apply { request.putHeader("{{baseName}}", {{#isContainer}}this.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}this.toString(){{/isContainer}})}{{/headerParams}}
+ {{^hasFormParams}}{{#hasConsumes}}
+ {{#consumes}}
+ request.putHeader("Content-Type", "{{{mediaType}}}")
+ {{/consumes}}
+ {{/hasConsumes}}{{/hasFormParams}}
+ {{#hasProduces}}request.putHeader("Accept", "{{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}"){{/hasProduces}}
+
+ {{#hasFormParams}}
+ val form = io.vertx.core.MultiMap.caseInsensitiveMultiMap();
+ {{#formParams}}
+ {{{paramName}}}{{^required}}?{{/required}}.let { form.add("{{{baseName}}}", {{{paramName}}}{{#isEnum}}.value{{/isEnum}}{{^isString}}.toString(){{/isString}}) }
+ {{/formParams}}
+ {{/hasFormParams}}
+
+ {{#hasQueryParams}}
+ {{#queryParams}}
+ {{{paramName}}}{{^required}}?{{/required}}.let { request.queryParams().add("{{baseName}}", {{#isContainer}}toMultiValue(it.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{#isDateTime}}parseDateToQueryString(it){{/isDateTime}}{{#isDate}}parseDateToQueryString(it){{/isDate}}{{^isDateTime}}{{^isDate}}it.toString(){{/isDate}}{{/isDateTime}}){{/isContainer}}) }
+ {{/queryParams}}
+ {{/hasQueryParams}}
+
+ {{#authMethods}}
+ {{#isApiKey}}
+ if (apiKey["{{keyParamName}}"] != null) {
+ if (apiKeyPrefix["{{keyParamName}}"] != null) {
+ {{#isKeyInHeader}}
+ request.putHeader("{{keyParamName}}", apiKeyPrefix["{{keyParamName}}"]!! + " " + apiKey["{{keyParamName}}"]!!)
+ {{/isKeyInHeader}}
+ {{#isKeyInQuery}}
+ request.queryParams().add("{{keyParamName}}", apiKeyPrefix["{{keyParamName}}"]!! + " " + apiKey["{{keyParamName}}"]!!)
+ {{/isKeyInQuery}}
+ } else {
+ {{#isKeyInHeader}}
+ request.putHeader("{{keyParamName}}", apiKey["{{keyParamName}}"]!!)
+ {{/isKeyInHeader}}
+ {{#isKeyInQuery}}
+ request.queryParams().add("{{keyParamName}}", apiKey["{{keyParamName}}"]!!)
+ {{/isKeyInQuery}}
+ }
+ }
+ {{/isApiKey}}
+ {{#isBasic}}
+ {{#isBasicBasic}}
+ username?.let { username ->
+ password?.let { password ->
+ request.basicAuthentication(username, password)
+ }
+ }
+ {{/isBasicBasic}}
+ {{#isBasicBearer}}
+ accessToken?.let { accessToken ->
+ request.bearerTokenAuthentication(accessToken)
+ }
+ {{/isBasicBearer}}
+ {{/isBasic}}
+ {{#isOAuth}}
+ accessToken?.let { accessToken ->
+ request.bearerTokenAuthentication(accessToken)
+ }
+ {{/isOAuth}}
+ {{/authMethods}}
+
+ return request
+ {{#hasBodyParam}}
+ .sendBuffer(responseBody({{#bodyParams}}{{{paramName}}}{{/bodyParams}}))
+ {{/hasBodyParam}}
+ {{^hasBodyParam}}
+ .send()
+ {{/hasBodyParam}}
+ .map {
+ val apiResponse: ApiResponse<{{#returnType}}{{{returnType}}}?{{/returnType}}{{^returnType}}Unit?{{/returnType}}> = handleResponse(it)
+ apiResponse
+ }
+ }
+
+ {{/operation}}
+
+ private inline fun responseBody(body: T): Buffer {
+ {{#moshi}}
+ return Buffer.buffer(Serializer.moshi.adapter(T::class.java).toJson(body))
+ {{/moshi}}
+ {{#gson}}
+ return Buffer.buffer(Serializer.gson.toJson(body, T::class.java))
+ {{/gson}}
+ {{#jackson}}
+ return Buffer.buffer(Serializer.jacksonObjectMapper.writeValueAsBytes(body))
+ {{/jackson}}
+ }
+
+}
+{{/operations}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/ApiClient.kt.mustache
new file mode 100644
index 00000000000..dacce6f4742
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/ApiClient.kt.mustache
@@ -0,0 +1,110 @@
+package {{packageName}}.infrastructure
+
+import io.vertx.core.Vertx
+import io.vertx.core.buffer.Buffer
+import java.nio.charset.StandardCharsets
+{{#jackson}}
+import com.fasterxml.jackson.core.type.TypeReference
+{{/jackson}}
+{{#gson}}
+import com.google.gson.reflect.TypeToken
+{{/gson}}
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val basePath: kotlin.String = defaultBasePath, val accessToken: String? = null, val apiKey: MutableMap = mutableMapOf(), val apiKeyPrefix: MutableMap = mutableMapOf(), var username: String? = null, var password: String? = null, val vertx: Vertx) {
+ companion object {
+ const val baseUrlKey = "{{packageName}}.baseUrl"
+
+ @JvmStatic
+ val defaultBasePath: String by lazy {
+ System.getProperties().getProperty(baseUrlKey, "{{{basePath}}}")
+ }
+ }
+
+ protected inline fun handleResponse(response: io.vertx.ext.web.client.HttpResponse): ApiResponse {
+ val code = response.statusCode()
+ val headers = response.headers().associate { it.key to listOf(it.value) }
+ val contentType = headers["Content-Type"]?.firstOrNull()?.substringBefore(";")?.lowercase(java.util.Locale.getDefault())
+
+ return when (code) {
+ in 100..199 -> Informational(
+ response.statusMessage(),
+ code,
+ headers
+ )
+ in 200 .. 299 -> Success(
+ responseBody(response.body(), contentType),
+ code,
+ headers
+ )
+ in 300..399 -> Redirection(
+ code,
+ headers
+ )
+ in 400..499 -> ClientError(
+ response.statusMessage(),
+ response.bodyAsString(),
+ code,
+ headers
+ )
+ else -> ServerError(
+ response.statusMessage(),
+ response.bodyAsString(),
+ code,
+ headers
+ )
+ }
+ }
+
+ protected inline fun responseBody(body: Buffer?, mediaType: String? = "application/json"): T? {
+ body ?: return null
+
+ val bodyContent = String(body.bytes, StandardCharsets.UTF_8)
+ if (bodyContent.isEmpty()) {
+ return null
+ }
+
+ return when {
+ mediaType==null || (mediaType.startsWith("application/") && mediaType.endsWith("json")) ->
+ {{#moshi}}Serializer.moshi.adapter(T::class.java).fromJson(bodyContent){{/moshi}}{{!
+ }}{{#gson}}Serializer.gson.fromJson(bodyContent, (object: TypeToken(){}).getType()){{/gson}}{{!
+ }}{{#jackson}}Serializer.jacksonObjectMapper.readValue(bodyContent, object: TypeReference() {}){{/jackson}}{{!
+ }}{{#kotlinx_serialization}}Serializer.kotlinxSerializationJson.decodeFromString(bodyContent){{/kotlinx_serialization}}
+ else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.")
+ }
+ }
+
+ protected fun encodeURIComponent(parameter: String): String {
+ return try {
+ java.net.URLEncoder.encode(parameter, java.nio.charset.StandardCharsets.UTF_8.name())
+ } catch (e: java.io.UnsupportedEncodingException) {
+ parameter
+ }
+ }
+
+ protected inline fun parseDateToQueryString(value : T): String {
+ {{#toJson}}
+ /*
+ .replace("\"", "") converts the json object string to an actual string for the query parameter.
+ The moshi or gson adapter allows a more generic solution instead of trying to use a native
+ formatter. It also easily allows to provide a simple way to define a custom date format pattern
+ inside a gson/moshi adapter.
+ */
+ {{#moshi}}
+ return Serializer.moshi.adapter(T::class.java).toJson(value).replace("\"", "")
+ {{/moshi}}
+ {{#gson}}
+ return Serializer.gson.toJson(value, T::class.java).replace("\"", "")
+ {{/gson}}
+ {{#jackson}}
+ return Serializer.jacksonObjectMapper.writeValueAsString(value).replace("\"", "")
+ {{/jackson}}
+ {{#kotlinx_serialization}}
+ return Serializer.kotlinxSerializationJson.encodeToString(value).replace("\"", "")
+ {{/kotlinx_serialization}}
+ {{/toJson}}
+ {{^toJson}}
+ return value.toString()
+ {{/toJson}}
+ }
+
+}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/ApiResponse.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/ApiResponse.kt.mustache
new file mode 100644
index 00000000000..d529ad5599f
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/ApiResponse.kt.mustache
@@ -0,0 +1,43 @@
+package {{packageName}}.infrastructure
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}enum class ResponseType {
+ Success, Informational, Redirection, ClientError, ServerError
+}
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}interface Response
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}abstract class ApiResponse(val responseType: ResponseType): Response {
+ abstract val statusCode: Int
+ abstract val headers: Map>
+}
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}class Success(
+ val data: T{{#nullableReturnType}}?{{/nullableReturnType}},
+ override val statusCode: Int = -1,
+ override val headers: Map> = mapOf()
+): ApiResponse(ResponseType.Success)
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}class Informational(
+ val statusText: String,
+ override val statusCode: Int = -1,
+ override val headers: Map> = mapOf()
+) : ApiResponse(ResponseType.Informational)
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}class Redirection(
+ override val statusCode: Int = -1,
+ override val headers: Map> = mapOf()
+) : ApiResponse(ResponseType.Redirection)
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}class ClientError(
+ val message: String? = null,
+ val body: Any? = null,
+ override val statusCode: Int = -1,
+ override val headers: Map> = mapOf()
+) : ApiResponse(ResponseType.ClientError)
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}class ServerError(
+ val message: String? = null,
+ val body: Any? = null,
+ override val statusCode: Int = -1,
+ override val headers: Map>
+): ApiResponse(ResponseType.ServerError)
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/Errors.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/Errors.kt.mustache
new file mode 100644
index 00000000000..7c428ad655f
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-vertx/infrastructure/Errors.kt.mustache
@@ -0,0 +1,18 @@
+@file:Suppress("unused")
+package {{packageName}}.infrastructure
+
+import java.lang.RuntimeException
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}open class ClientException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
+
+ {{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
+ private const val serialVersionUID: Long = 123L
+ }
+}
+
+{{#nonPublicApi}}internal {{/nonPublicApi}}open class ServerException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
+
+ {{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
+ private const val serialVersionUID: Long = 456L
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache
index bc5d9b19508..bbed97d77ae 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache
@@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
-import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.FormDataContent
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.statement.HttpResponse
+import io.ktor.serialization.kotlinx.json.json
import io.ktor.http.*
import io.ktor.http.content.PartData
import kotlin.Unit
@@ -153,9 +153,9 @@ import {{packageName}}.auth.*
}
this.method = requestConfig.method.httpMethod
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
- if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
+ if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
this.setBody(body)
-
+ }
}
}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-server/data_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-server/data_class.mustache
index 215a291253f..84e4637d60e 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-server/data_class.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-server/data_class.mustache
@@ -9,7 +9,7 @@ import java.io.Serializable
/**
* {{{description}}}
{{#vars}}
- * @param {{name}} {{{description}}}
+ * @param {{{name}}} {{{description}}}
{{/vars}}
*/
{{#parcelizeModels}}
@@ -37,7 +37,7 @@ data class {{classname}}(
* {{{description}}}
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
*/
- enum class {{nameInCamelCase}}(val value: {{dataType}}){
+ enum class {{{nameInCamelCase}}}(val value: {{{dataType}}}){
{{#allowableValues}}
{{#enumVars}}
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache
index df50e9867aa..b2e7cc3b409 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache
@@ -1,4 +1,4 @@
{{#description}}
/* {{{.}}} */
{{/description}}
- {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}
\ No newline at end of file
+ {{>modelMutable}} {{{name}}}: {{#isEnum}}{{{classname}}}.{{{nameInCamelCase}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-server/data_class_req_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-server/data_class_req_var.mustache
index 0da9cbfe3c8..d3732ebad05 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-server/data_class_req_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-server/data_class_req_var.mustache
@@ -1,4 +1,4 @@
{{#description}}
/* {{{.}}} */
{{/description}}
- {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}
\ No newline at end of file
+ {{>modelMutable}} {{{name}}}: {{#isEnum}}{{{classname}}}.{{{nameInCamelCase}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache b/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache
index 5d62a7b5b9d..1921b061015 100644
--- a/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache
+++ b/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache
@@ -1,6 +1,6 @@
selectContentTypeHeader($contentTypes);
+ if (!$isMultipart) {
+ if($contentType === '') {
+ $contentType = 'application/json';
+ }
+
+ $headers['Content-Type'] = $contentType;
+ }
+
return $headers;
}
/**
- * @param string[] $accept
- * @return array
- */
- public function selectHeadersForMultipart($accept)
- {
- $headers = $this->selectHeaders($accept, []);
-
- unset($headers['Content-Type']);
- return $headers;
- }
-
- /**
- * Return the header 'Accept' based on an array of Accept provided
+ * Return the header 'Accept' based on an array of Accept provided.
*
* @param string[] $accept Array of header
*
* @return null|string Accept (e.g. application/json)
*/
- private function selectAcceptHeader($accept)
+ private function selectAcceptHeader(array $accept): ?string
{
- if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) {
+ # filter out empty entries
+ $accept = array_filter($accept);
+
+ if (count($accept) === 0) {
return null;
- } elseif ($jsonAccept = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept)) {
- return implode(',', $jsonAccept);
- } else {
+ }
+
+ # If there's only one Accept header, just use it
+ if (count($accept) === 1) {
+ return reset($accept);
+ }
+
+ # If none of the available Accept headers is of type "json", then just use all them
+ $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept);
+ if (count($headersWithJson) === 0) {
return implode(',', $accept);
}
+
+ # If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1,
+ # to give the highest priority to json-like headers - recalculating the existing ones, if needed
+ return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson);
}
/**
- * Return the content type based on an array of content-type provided
- *
- * @param string[] $contentType Array fo content-type
- *
- * @return string Content-Type (e.g. application/json)
- */
- private function selectContentTypeHeader($contentType)
+ * Create an Accept header string from the given "Accept" headers array, recalculating all weights
+ *
+ * @param string[] $accept Array of Accept Headers
+ * @param string[] $headersWithJson Array of Accept Headers of type "json"
+ *
+ * @return string "Accept" Header (e.g. "application/json, text/html; q=0.9")
+ */
+ private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string
{
- if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) {
- return 'application/json';
- } elseif (preg_grep("/application\/json/i", $contentType)) {
- return 'application/json';
- } else {
- return implode(',', $contentType);
+ $processedHeaders = [
+ 'withApplicationJson' => [],
+ 'withJson' => [],
+ 'withoutJson' => [],
+ ];
+
+ foreach ($accept as $header) {
+
+ $headerData = $this->getHeaderAndWeight($header);
+
+ if (stripos($headerData['header'], 'application/json') === 0) {
+ $processedHeaders['withApplicationJson'][] = $headerData;
+ } elseif (in_array($header, $headersWithJson, true)) {
+ $processedHeaders['withJson'][] = $headerData;
+ } else {
+ $processedHeaders['withoutJson'][] = $headerData;
+ }
}
+
+ $acceptHeaders = [];
+ $currentWeight = 1000;
+
+ $hasMoreThan28Headers = count($accept) > 28;
+
+ foreach($processedHeaders as $headers) {
+ if (count($headers) > 0) {
+ $acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers);
+ }
+ }
+
+ $acceptHeaders = array_merge(...$acceptHeaders);
+
+ return implode(',', $acceptHeaders);
+ }
+
+ /**
+ * Given an Accept header, returns an associative array splitting the header and its weight
+ *
+ * @param string $header "Accept" Header
+ *
+ * @return array with the header and its weight
+ */
+ private function getHeaderAndWeight(string $header): array
+ {
+ # matches headers with weight, splitting the header and the weight in $outputArray
+ if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) {
+ $headerData = [
+ 'header' => $outputArray[1],
+ 'weight' => (int)($outputArray[2] * 1000),
+ ];
+ } else {
+ $headerData = [
+ 'header' => trim($header),
+ 'weight' => 1000,
+ ];
+ }
+
+ return $headerData;
+ }
+
+ /**
+ * @param array[] $headers
+ * @param float $currentWeight
+ * @param bool $hasMoreThan28Headers
+ * @return string[] array of adjusted "Accept" headers
+ */
+ private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array
+ {
+ usort($headers, function (array $a, array $b) {
+ return $b['weight'] - $a['weight'];
+ });
+
+ $acceptHeaders = [];
+ foreach ($headers as $index => $header) {
+ if($index > 0 && $headers[$index - 1]['weight'] > $header['weight'])
+ {
+ $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers);
+ }
+
+ $weight = $currentWeight;
+
+ $acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight);
+ }
+
+ $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers);
+
+ return $acceptHeaders;
+ }
+
+ /**
+ * @param string $header
+ * @param int $weight
+ * @return string
+ */
+ private function buildAcceptHeader(string $header, int $weight): string
+ {
+ if($weight === 1000) {
+ return $header;
+ }
+
+ return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0');
+ }
+
+ /**
+ * Calculate the next weight, based on the current one.
+ *
+ * If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the
+ * following formula:
+ *
+ * next weight = current weight - 10 ^ (floor(log(current weight - 1)))
+ *
+ * ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) )
+ *
+ * Starting from 1000, this generates the following series:
+ *
+ * 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
+ *
+ * The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works
+ * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1
+ * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc.
+ *
+ * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value)
+ * @param bool $hasMoreThan28Headers
+ * @return int
+ */
+ public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int
+ {
+ if ($currentWeight <= 1) {
+ return 1;
+ }
+
+ if ($hasMoreThan28Headers) {
+ return $currentWeight - 1;
+ }
+
+ return $currentWeight - 10 ** floor( log10($currentWeight - 1) );
}
}
diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache
index 41c22daee04..a9893bf9e3f 100644
--- a/modules/openapi-generator/src/main/resources/php/api.mustache
+++ b/modules/openapi-generator/src/main/resources/php/api.mustache
@@ -60,7 +60,16 @@ use {{invokerPackage}}\ObjectSerializer;
*/
protected $hostIndex;
- /**
+ /** @var string[] $contentTypes **/
+ public const contentTypes = [{{#operation}}
+ '{{{operationId}}}' => [{{#consumes}}
+ '{{{mediaType}}}',{{/consumes}}
+ {{^consumes}}
+ 'application/json',
+{{/consumes}} ],{{/operation}}
+ ];
+
+/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
@@ -151,6 +160,7 @@ use {{invokerPackage}}\ObjectSerializer;
* @param array $variables Associative array of variables to pass to the host. Defaults to empty array.
{{/-first}}
{{/servers}}
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation
*
* @throws \{{invokerPackage}}\ApiException on non-2xx response
* @throws \InvalidArgumentException
@@ -159,9 +169,9 @@ use {{invokerPackage}}\ObjectSerializer;
* @deprecated
{{/isDeprecated}}
*/
- public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
+ public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
{
- {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
+ {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
return $response;{{/returnType}}
}
@@ -209,6 +219,7 @@ use {{invokerPackage}}\ObjectSerializer;
* @param array $variables Associative array of variables to pass to the host. Defaults to empty array.
{{/-first}}
{{/servers}}
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation
*
* @throws \{{invokerPackage}}\ApiException on non-2xx response
* @throws \InvalidArgumentException
@@ -217,9 +228,9 @@ use {{invokerPackage}}\ObjectSerializer;
* @deprecated
{{/isDeprecated}}
*/
- public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
+ public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
{
- $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
+ $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
try {
$options = $this->createHttpClientOption();
@@ -261,8 +272,8 @@ use {{invokerPackage}}\ObjectSerializer;
switch($statusCode) {
{{/-first}}
- {{#dataType}}{{^isRange}}
- {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
+ {{#dataType}}
+ {{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
if ('{{{dataType}}}' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
@@ -276,8 +287,8 @@ use {{invokerPackage}}\ObjectSerializer;
ObjectSerializer::deserialize($content, '{{{dataType}}}', []),
$response->getStatusCode(),
$response->getHeaders()
- ];
- {{/isRange}}{{/dataType}}
+ ];{{/isRange}}
+ {{/dataType}}
{{#-last}}
}
{{/-last}}
@@ -307,16 +318,16 @@ use {{invokerPackage}}\ObjectSerializer;
} catch (ApiException $e) {
switch ($e->getCode()) {
{{#responses}}
- {{#dataType}}{{^isRange}}
- {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
+ {{#dataType}}
+ {{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'{{{dataType}}}',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
- break;
- {{/isRange}}{{/dataType}}
+ break;{{/isRange}}
+ {{/dataType}}
{{/responses}}
}
throw $e;
@@ -367,6 +378,7 @@ use {{invokerPackage}}\ObjectSerializer;
* @param array $variables Associative array of variables to pass to the host. Defaults to empty array.
{{/-first}}
{{/servers}}
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
@@ -374,9 +386,9 @@ use {{invokerPackage}}\ObjectSerializer;
* @deprecated
{{/isDeprecated}}
*/
- public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
+ public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
{
- return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
+ return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
->then(
function ($response) {
return $response[0];
@@ -428,6 +440,7 @@ use {{invokerPackage}}\ObjectSerializer;
* @param array $variables Associative array of variables to pass to the host. Defaults to empty array.
{{/-first}}
{{/servers}}
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
@@ -435,10 +448,10 @@ use {{invokerPackage}}\ObjectSerializer;
* @deprecated
{{/isDeprecated}}
*/
- public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
+ public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
{
$returnType = '{{{returnType}}}';
- $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
+ $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
return $this->client
->sendAsync($request, $this->createHttpClientOption())
@@ -517,6 +530,7 @@ use {{invokerPackage}}\ObjectSerializer;
* @param array $variables Associative array of variables to pass to the host. Defaults to empty array.
{{/-first}}
{{/servers}}
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
@@ -524,7 +538,7 @@ use {{invokerPackage}}\ObjectSerializer;
* @deprecated
{{/isDeprecated}}
*/
- public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
+ public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
{
{{#vendorExtensions.x-group-parameters}}
// unbox the parameters from the associative array
@@ -533,7 +547,9 @@ use {{invokerPackage}}\ObjectSerializer;
{{/allParams}}{{#servers.0}}
$hostIndex = $associative_array['hostIndex'];
$variables = array_key_exists('variables', $associative_array) ? $associative_array['variables'] : [];
-{{/servers.0}}{{/vendorExtensions.x-group-parameters}}{{#allParams}}
+{{/servers.0}}
+ $contentType = $associative_array['contentType'] ?? self::contentTypes['{{{operationId}}}'][0];
+ {{/vendorExtensions.x-group-parameters}}{{#allParams}}
{{#required}}
// verify the required parameter '{{paramName}}' is set
if (${{paramName}} === null || (is_array(${{paramName}}) && count(${{paramName}}) === 0)) {
@@ -578,9 +594,7 @@ use {{invokerPackage}}\ObjectSerializer;
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.');
}
{{/minItems}}
-
- {{/hasValidation}}
- {{/allParams}}
+ {{/hasValidation}}{{/allParams}}
$resourcePath = '{{{path}}}';
$formParams = [];
@@ -649,21 +663,17 @@ use {{invokerPackage}}\ObjectSerializer;
}
{{/formParams}}
- if ($multipart) {
- $headers = $this->headerSelector->selectHeadersForMultipart(
- [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}]
- );
- } else {
- $headers = $this->headerSelector->selectHeaders(
- [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}],
- [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]
- );
- }
+ $headers = $this->headerSelector->selectHeaders(
+ [{{#produces}}'{{{mediaType}}}', {{/produces}}],
+ $contentType,
+ $multipart
+ );
// for model (json/xml)
{{#bodyParams}}
if (isset(${{paramName}})) {
- if ($headers['Content-Type'] === 'application/json') {
+ if (stripos($headers['Content-Type'], 'application/json') !== false) {
+ # if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}}));
} else {
$httpBody = ${{paramName}};
@@ -687,9 +697,9 @@ use {{invokerPackage}}\ObjectSerializer;
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
- } elseif ($headers['Content-Type'] === 'application/json') {
+ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+ # if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
-
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
diff --git a/modules/openapi-generator/src/main/resources/python-flask/model.mustache b/modules/openapi-generator/src/main/resources/python-flask/model.mustache
index 300938389a1..9be98da6f3f 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/model.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/model.mustache
@@ -58,7 +58,7 @@ class {{classname}}(Model):
}
{{#vars}}{{#-first}}
{{/-first}}
- self.{{name}} = {{name}}
+ self._{{name}} = {{name}}
{{/vars}}
@classmethod
diff --git a/modules/openapi-generator/src/main/resources/python/api_client.handlebars b/modules/openapi-generator/src/main/resources/python/api_client.handlebars
index bdcd4519ff4..81426853056 100644
--- a/modules/openapi-generator/src/main/resources/python/api_client.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/api_client.handlebars
@@ -293,7 +293,7 @@ class StyleFormSerializer(ParameterSerializerBase):
prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None
) -> str:
if prefix_separator_iterator is None:
- prefix_separator_iterator = PrefixSeparatorIterator('?', '&')
+ prefix_separator_iterator = PrefixSeparatorIterator('', '&')
return self._ref6570_expansion(
variable_name=name,
in_data=in_data,
@@ -1472,7 +1472,7 @@ class RequestBody(StyleFormSerializer, JSONDetector):
raise ValueError(
f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data')
cast_in_data = self.__json_encoder.default(in_data)
- value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=False)
+ value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=True)
return dict(body=value)
def serialize(
diff --git a/modules/openapi-generator/src/main/resources/python/endpoint_args.handlebars b/modules/openapi-generator/src/main/resources/python/endpoint_args.handlebars
index bff216a72fb..1eceaf34ad3 100644
--- a/modules/openapi-generator/src/main/resources/python/endpoint_args.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/endpoint_args.handlebars
@@ -73,6 +73,12 @@
{{/eq}}
{{/with}}
{{/if}}
+{{else}}
+ {{#if isOverload}}
+ {{#eq skipDeserialization "True"}}
+ skip_deserialization: typing_extensions.Literal[True],
+ {{/eq}}
+ {{/if}}
{{/if}}
{{#if queryParams}}
query_params: RequestQueryParams = frozendict.frozendict(),
diff --git a/modules/openapi-generator/src/main/resources/python/model_templates/new.handlebars b/modules/openapi-generator/src/main/resources/python/model_templates/new.handlebars
index eb47a54a035..fbf25512bad 100644
--- a/modules/openapi-generator/src/main/resources/python/model_templates/new.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/model_templates/new.handlebars
@@ -17,7 +17,15 @@ def __new__(
{{#if complexType}}
{{baseName}}: '{{complexType}}',
{{else}}
+ {{#if getSchemaIsFromAdditionalProperties}}
+ {{#if addPropsUnset}}
+ {{baseName}}: typing.Union[schemas.AnyTypeSchema, {{> model_templates/schema_python_types }}],
+ {{else}}
+ {{baseName}}: typing.Union[MetaOapg.additional_properties, {{> model_templates/schema_python_types }}],
+ {{/if}}
+ {{else}}
{{baseName}}: typing.Union[MetaOapg.properties.{{baseName}}, {{> model_templates/schema_python_types }}],
+ {{/if}}
{{/if}}
{{/unless}}
{{/with}}
diff --git a/modules/openapi-generator/src/main/resources/python/model_templates/schema_composed_or_anytype.handlebars b/modules/openapi-generator/src/main/resources/python/model_templates/schema_composed_or_anytype.handlebars
index 8c7b667493f..7f97830dcf7 100644
--- a/modules/openapi-generator/src/main/resources/python/model_templates/schema_composed_or_anytype.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/model_templates/schema_composed_or_anytype.handlebars
@@ -68,4 +68,8 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}
{{> model_templates/property_type_hints }}
+{{#if additionalProperties}}
{{> model_templates/new }}
+{{else}}
+ {{> model_templates/new addPropsUnset=true }}
+{{/if}}
diff --git a/modules/openapi-generator/src/main/resources/python/model_templates/schema_dict.handlebars b/modules/openapi-generator/src/main/resources/python/model_templates/schema_dict.handlebars
index 1bee51b3067..284590644f7 100644
--- a/modules/openapi-generator/src/main/resources/python/model_templates/schema_dict.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/model_templates/schema_dict.handlebars
@@ -32,4 +32,8 @@ class {{> model_templates/classname }}(
{{/if}}
{{> model_templates/property_type_hints }}
+{{#if additionalProperties}}
{{> model_templates/new }}
+{{else}}
+ {{> model_templates/new addPropsUnset=true }}
+{{/if}}
diff --git a/modules/openapi-generator/src/main/resources/python/rest.handlebars b/modules/openapi-generator/src/main/resources/python/rest.handlebars
index b1811396168..2ca16e1639e 100644
--- a/modules/openapi-generator/src/main/resources/python/rest.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/rest.handlebars
@@ -139,6 +139,7 @@ class RESTClientObject(object):
elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
r = self.pool_manager.request(
method, url,
+ body=body,
fields=fields,
encode_multipart=False,
preload_content=not stream,
diff --git a/modules/openapi-generator/src/main/resources/r/api.mustache b/modules/openapi-generator/src/main/resources/r/api.mustache
index db49260916b..a49694f8a07 100644
--- a/modules/openapi-generator/src/main/resources/r/api.mustache
+++ b/modules/openapi-generator/src/main/resources/r/api.mustache
@@ -86,7 +86,7 @@
#'
#' library({{{packageName}}})
{{#allParams}}
-#' var_{{{paramName}}} <- {{{example}}} # {{{dataType}}} | {{{description}}}
+#' var_{{{paramName}}} <- {{{vendorExtensions.x-r-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (Optional){{/required}}
{{/allParams}}
#'
{{#summary}}
diff --git a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache
index d67e502b01f..451f41a5b42 100644
--- a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache
+++ b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache
@@ -60,33 +60,49 @@
}
{{/isEnum}}
{{#isInteger}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`))
+ }
{{/isInteger}}
{{#isLong}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`))
+ }
{{/isLong}}
{{#isFloat}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`))
+ }
{{/isFloat}}
{{#isDouble}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`))
+ }
{{/isDouble}}
{{#isString}}
- stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`))
+ }
{{/isString}}
{{#isBoolean}}
- stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.logical(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a boolean:", `{{name}}`))
+ }
{{/isBoolean}}
{{#isDate}}
- stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`))
+ }
{{/isDate}}
{{#isDateTime}}
- stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`))
+ }
{{/isDateTime}}
{{#isUri}}
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", `{{name}}`))
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", `{{name}}`))
}
{{/isUri}}
{{^isPrimitiveType}}
@@ -116,33 +132,49 @@
}
{{/isEnum}}
{{#isInteger}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`))
+ }
{{/isInteger}}
{{#isLong}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`))
+ }
{{/isLong}}
{{#isFloat}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`))
+ }
{{/isFloat}}
{{#isDouble}}
- stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`))
+ }
{{/isDouble}}
{{#isString}}
- stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`))
+ }
{{/isString}}
{{#isBoolean}}
- stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1)
+ if (!(is.logical(`{{name}}`) && length(`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a boolean:", `{{name}}`))
+ }
{{/isBoolean}}
{{#isDate}}
- stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
+ if (!is.character(`{{name}}`)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`))
+ }
{{/isDate}}
{{#isDateTime}}
- stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
+ if (!is.character(`{{name}}`)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`))
+ }
{{/isDateTime}}
{{#isUri}}
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", `{{name}}`))
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", `{{name}}`))
}
{{/isUri}}
{{^isPrimitiveType}}
@@ -251,7 +283,7 @@
{{#isUri}}
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`{{baseName}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`{{baseName}}`))
+ stop(paste("Error! Invalid data for `{{baseName}}`. Must be a URL:", this_object$`{{baseName}}`))
}
{{/isUri}}
self$`{{name}}` <- this_object$`{{baseName}}`
@@ -383,7 +415,7 @@
{{#isUri}}
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`{{name}}`))
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", this_object$`{{name}}`))
}
{{/isUri}}
self$`{{name}}` <- this_object$`{{name}}`
@@ -418,33 +450,49 @@
if (!is.null(input_json$`{{name}}`)) {
{{^isContainer}}
{{#isInteger}}
- stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", input_json$`{{name}}`))
+ }
{{/isInteger}}
{{#isLong}}
- stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", input_json$`{{name}}`))
+ }
{{/isLong}}
{{#isFloat}}
- stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", input_json$`{{name}}`))
+ }
{{/isFloat}}
{{#isDouble}}
- stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", input_json$`{{name}}`))
+ }
{{/isDouble}}
{{#isString}}
- stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.character(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", input_json$`{{name}}`))
+ }
{{/isString}}
{{#isBoolean}}
- stopifnot(is.logical(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.logical(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a boolean:", input_json$`{{name}}`))
+ }
{{/isBoolean}}
{{#isDate}}
- stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.character(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", input_json$`{{name}}`))
+ }
{{/isDate}}
{{#isDateTime}}
- stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
+ if (!(is.character(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) {
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", input_json$`{{name}}`))
+ }
{{/isDateTime}}
{{#isUri}}
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(input_json$`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", input_json$`{{name}}`))
+ stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", input_json$`{{name}}`))
}
{{/isUri}}
{{^isPrimitiveType}}
diff --git a/modules/openapi-generator/src/main/resources/rust-server/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust-server/Cargo.mustache
index fba4aeda686..57486b46486 100644
--- a/modules/openapi-generator/src/main/resources/rust-server/Cargo.mustache
+++ b/modules/openapi-generator/src/main/resources/rust-server/Cargo.mustache
@@ -1,11 +1,22 @@
[package]
name = "{{{packageName}}}"
version = "{{{packageVersion}}}"
-authors = [{{#infoEmail}}"{{{.}}}"{{/infoEmail}}]
+{{#infoEmail}}
+authors = ["{{{.}}}"]
+{{/infoEmail}}
+{{^infoEmail}}
+authors = ["OpenAPI Generator team and contributors"]
+{{/infoEmail}}
{{#appDescription}}
description = "{{{.}}}"
{{/appDescription}}
+{{#licenseInfo}}
+license = "{{.}}"
+{{/licenseInfo}}
+{{^licenseInfo}}
+# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
+{{/licenseInfo}}
edition = "2018"
{{#publishRustRegistry}}
publish = ["{{.}}"]
@@ -83,7 +94,7 @@ serde_json = "1.0"
{{#usesXml}}
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
-serde-xml-rs = {git = "git://github.com/Metaswitch/serde-xml-rs.git" , branch = "master"}
+serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
{{/usesXml}}
{{#apiUsesMultipart}}
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
index 9ca82500e3a..98b1024cc0a 100644
--- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
@@ -1,12 +1,42 @@
[package]
name = "{{{packageName}}}"
version = "{{#lambdaVersion}}{{{packageVersion}}}{{/lambdaVersion}}"
+{{#infoEmail}}
+authors = ["{{{.}}}"]
+{{/infoEmail}}
+{{^infoEmail}}
authors = ["OpenAPI Generator team and contributors"]
+{{/infoEmail}}
+{{#appDescription}}
+description = "{{{.}}}"
+{{/appDescription}}
+{{#licenseInfo}}
+license = "{{.}}"
+{{/licenseInfo}}
+{{^licenseInfo}}
+# Override this license by providing a License Object in the OpenAPI.
+license = "Unlicense"
+{{/licenseInfo}}
edition = "2018"
+{{#publishRustRegistry}}
+publish = ["{{.}}"]
+{{/publishRustRegistry}}
+{{#repositoryUrl}}
+repository = "{{.}}"
+{{/repositoryUrl}}
+{{#documentationUrl}}
+documentation = "{{.}}"
+{{/documentationUrl}}
+{{#homePageUrl}}
+homepage = "{{.}}
+{{/homePageUrl}}
[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
+{{#serdeWith}}
+serde_with = "^2.0"
+{{/serdeWith}}
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde"] }
@@ -14,7 +44,6 @@ uuid = { version = "^1.0", features = ["serde"] }
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
http = "~0.2"
-serde_yaml = "0.7"
base64 = "~0.7.0"
futures = "^0.3"
{{/hyper}}
@@ -33,8 +62,3 @@ version = "^0.11"
features = ["json", "multipart"]
{{/supportAsync}}
{{/reqwest}}
-
-[dev-dependencies]
-{{#hyper}}
-tokio-core = "*"
-{{/hyper}}
diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache
index 8e4dac90ce8..2fcad1fbf36 100644
--- a/modules/openapi-generator/src/main/resources/rust/model.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/model.mustache
@@ -70,8 +70,8 @@ pub struct {{{classname}}} {
{{#description}}
/// {{{.}}}
{{/description}}
- #[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})]
- pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isModel}}Box<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
+ #[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default, with = "::serde_with::rust::double_option"{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})]
+ pub {{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isModel}}Box<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}},
{{/vars}}
}
diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
index d47d980814f..45e2a56434e 100644
--- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
@@ -141,7 +141,7 @@ export class BaseAPI {
init: initParams,
context,
}))
- }
+ };
const init: RequestInit = {
...overridedInit,
@@ -215,11 +215,11 @@ export class BaseAPI {
};
function isBlob(value: any): value is Blob {
- return typeof Blob !== 'undefined' && value instanceof Blob
+ return typeof Blob !== 'undefined' && value instanceof Blob;
}
function isFormData(value: any): value is FormData {
- return typeof FormData !== "undefined" && value instanceof FormData
+ return typeof FormData !== "undefined" && value instanceof FormData;
}
export class ResponseError extends Error {
@@ -257,7 +257,7 @@ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'
export type HTTPHeaders = { [key: string]: string };
export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery };
export type HTTPBody = Json | FormData | URLSearchParams;
-export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }
+export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody };
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise
@@ -328,7 +328,7 @@ export function canConsumeForm(consumes: Consume[]): boolean {
}
export interface Consume {
- contentType: string
+ contentType: string;
}
export interface RequestContext {
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/crystal/CrystalClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/crystal/CrystalClientCodegenTest.java
new file mode 100644
index 00000000000..98f2385d5c5
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/crystal/CrystalClientCodegenTest.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ * Copyright 2018 SmartBear Software
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.crystal;
+
+import io.swagger.v3.oas.models.OpenAPI;
+import org.apache.commons.io.FileUtils;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.languages.CrystalClientCodegen;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.*;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+/**
+ * Tests for CrystalClientCodegen-generated templates
+ */
+public class CrystalClientCodegenTest {
+
+ @Test
+ public void testGenerateCrystalClientWithHtmlEntity() throws Exception {
+ final File output = Files.createTempDirectory("test").toFile();
+ output.mkdirs();
+ output.deleteOnExit();
+
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/pathWithHtmlEntity.yaml");
+ CodegenConfig codegenConfig = new CrystalClientCodegen();
+ codegenConfig.setOutputDir(output.getAbsolutePath());
+
+ ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(codegenConfig);
+
+ DefaultGenerator generator = new DefaultGenerator();
+ List files = generator.opts(clientOptInput).generate();
+ boolean apiFileGenerated = false;
+ for (File file : files) {
+ if (file.getName().equals("default_api.cr")) {
+ apiFileGenerated = true;
+ // Crystal client should set the path unescaped in the api file
+ assertTrue(FileUtils.readFileToString(file, StandardCharsets.UTF_8)
+ .contains("local_var_path = \"/foo=bar\""));
+ }
+ }
+ if (!apiFileGenerated) {
+ fail("Default api file is not generated!");
+ }
+ }
+
+ @Test
+ public void testInitialConfigValues() throws Exception {
+ final CrystalClientCodegen codegen = new CrystalClientCodegen();
+ codegen.processOpts();
+
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP),
+ Boolean.TRUE);
+ Assert.assertEquals(codegen.isHideGenerationTimestamp(), true);
+ Assert.assertEquals(codegen.modelPackage(), "models");
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), null);
+ Assert.assertEquals(codegen.apiPackage(), "api");
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), null);
+ }
+
+ @Test
+ public void testSettersForConfigValues() throws Exception {
+ final CrystalClientCodegen codegen = new CrystalClientCodegen();
+ codegen.setHideGenerationTimestamp(false);
+ codegen.processOpts();
+
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP),
+ Boolean.FALSE);
+ Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
+ }
+
+ @Test
+ public void testAdditionalPropertiesPutForConfigValues() throws Exception {
+ final CrystalClientCodegen codegen = new CrystalClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
+ codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "crystal-models");
+ codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "crystal-api");
+ codegen.processOpts();
+
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP),
+ Boolean.FALSE);
+ Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "crystal-models");
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "crystal-api");
+ }
+
+ @Test
+ public void testBooleanDefaultValue() throws Exception {
+ final File output = Files.createTempDirectory("test").toFile();
+ output.mkdirs();
+ output.deleteOnExit();
+
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/npe1.yaml");
+ CodegenConfig codegenConfig = new CrystalClientCodegen();
+ codegenConfig.setOutputDir(output.getAbsolutePath());
+
+ ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(codegenConfig);
+
+ DefaultGenerator generator = new DefaultGenerator();
+ List files = generator.opts(clientOptInput).generate();
+ boolean apiFileGenerated = false;
+ for (File file : files) {
+ if (file.getName().equals("default_api.cr")) {
+ apiFileGenerated = true;
+ // Crystal client should set the path unescaped in the api file
+ assertTrue(FileUtils.readFileToString(file, StandardCharsets.UTF_8)
+ .contains("local_var_path = \"/default/Resources/{id}\""));
+ }
+ }
+ if (!apiFileGenerated) {
+ fail("Default api file is not generated!");
+ }
+ }
+
+ @Test
+ public void testSanitizeModelName() throws Exception {
+ final CrystalClientCodegen codegen = new CrystalClientCodegen();
+ codegen.setHideGenerationTimestamp(false);
+ codegen.processOpts();
+
+ Assert.assertEquals(codegen.sanitizeModelName("JSON::Any"), "JSON::Any");
+ // Disallows single colons
+ Assert.assertEquals(codegen.sanitizeModelName("JSON:Any"), "JSONAny");
+ }
+}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java
index 894a105fb45..b55967fdaf9 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java
@@ -222,4 +222,22 @@ public class GoClientCodegenTest {
"func Test_openapi_PetApiService(t *testing.T) {");
}
+ @Test
+ public void verifyFormatErrorMessageInUse() throws IOException {
+ File output = Files.createTempDirectory("test").toFile();
+ output.deleteOnExit();
+
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName("go")
+ .setInputSpec("src/test/resources/3_0/go/petstore-with-problem-details.yaml")
+ .setOutputDir(output.getAbsolutePath().replace("\\", "/"));
+
+ DefaultGenerator generator = new DefaultGenerator();
+ List files = generator.opts(configurator.toClientOptInput()).generate();
+ files.forEach(File::deleteOnExit);
+
+ TestUtils.assertFileExists(Paths.get(output + "/api_pet.go"));
+ TestUtils.assertFileContains(Paths.get(output + "/api_pet.go"),
+ "newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)");
+ }
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java
index 11956bdec17..a63f5be4276 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java
@@ -103,7 +103,7 @@ public class AbstractJavaCodegenTest {
}
@Test
- public void convertVarName() throws Exception {
+ public void convertVarName() {
Assert.assertEquals(fakeJavaCodegen.toVarName("name"), "name");
Assert.assertEquals(fakeJavaCodegen.toVarName("$name"), "$name");
Assert.assertEquals(fakeJavaCodegen.toVarName("nam$$e"), "nam$$e");
@@ -119,10 +119,15 @@ public class AbstractJavaCodegenTest {
Assert.assertEquals(fakeJavaCodegen.toVarName("1A"), "_1A");
Assert.assertEquals(fakeJavaCodegen.toVarName("1AAAA"), "_1AAAA");
Assert.assertEquals(fakeJavaCodegen.toVarName("1AAaa"), "_1aAaa");
+
+ AbstractJavaCodegen withCaml = new P_AbstractJavaCodegen();
+ withCaml.setCamelCaseDollarSign(true);
+ Assert.assertEquals(withCaml.toVarName("$name"), "$Name");
+ Assert.assertEquals(withCaml.toVarName("1AAaa"), "_1AAaa");
}
@Test
- public void convertModelName() throws Exception {
+ public void convertModelName() {
Assert.assertEquals(fakeJavaCodegen.toModelName("name"), "Name");
Assert.assertEquals(fakeJavaCodegen.toModelName("$name"), "Name");
Assert.assertEquals(fakeJavaCodegen.toModelName("nam#e"), "Name");
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
index e4b4fc94da6..81bdccd09a6 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
@@ -17,10 +17,41 @@
package org.openapitools.codegen.java;
-import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+import com.google.common.collect.ImmutableMap;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.Operation;
+import io.swagger.v3.oas.models.media.ArraySchema;
+import io.swagger.v3.oas.models.media.ComposedSchema;
+import io.swagger.v3.oas.models.media.Content;
+import io.swagger.v3.oas.models.media.IntegerSchema;
+import io.swagger.v3.oas.models.media.MediaType;
+import io.swagger.v3.oas.models.media.ObjectSchema;
+import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.media.StringSchema;
+import io.swagger.v3.oas.models.parameters.RequestBody;
+import io.swagger.v3.oas.models.responses.ApiResponse;
+import io.swagger.v3.parser.util.SchemaTypeUtil;
+import org.openapitools.codegen.ClientOptInput;
+import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.CodegenModel;
+import org.openapitools.codegen.CodegenOperation;
+import org.openapitools.codegen.CodegenParameter;
+import org.openapitools.codegen.CodegenProperty;
+import org.openapitools.codegen.CodegenResponse;
+import org.openapitools.codegen.CodegenSecurity;
+import org.openapitools.codegen.DefaultGenerator;
+import org.openapitools.codegen.TestUtils;
+import org.openapitools.codegen.config.CodegenConfigurator;
+import org.openapitools.codegen.java.assertions.JavaFileAssert;
+import org.openapitools.codegen.languages.AbstractJavaCodegen;
+import org.openapitools.codegen.languages.JavaClientCodegen;
+import org.openapitools.codegen.languages.features.BeanValidationFeatures;
+import org.openapitools.codegen.languages.features.CXFServerFeatures;
+import org.openapitools.codegen.model.OperationMap;
+import org.openapitools.codegen.model.OperationsMap;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
@@ -44,42 +75,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import org.openapitools.codegen.ClientOptInput;
-import org.openapitools.codegen.CodegenConstants;
-import org.openapitools.codegen.CodegenModel;
-import org.openapitools.codegen.CodegenOperation;
-import org.openapitools.codegen.CodegenParameter;
-import org.openapitools.codegen.CodegenProperty;
-import org.openapitools.codegen.CodegenResponse;
-import org.openapitools.codegen.CodegenSecurity;
-import org.openapitools.codegen.DefaultGenerator;
-import org.openapitools.codegen.TestUtils;
-import org.openapitools.codegen.config.CodegenConfigurator;
-import org.openapitools.codegen.java.assertions.JavaFileAssert;
-import org.openapitools.codegen.languages.AbstractJavaCodegen;
-import org.openapitools.codegen.languages.JavaClientCodegen;
-import org.openapitools.codegen.languages.features.BeanValidationFeatures;
-import org.openapitools.codegen.languages.features.CXFServerFeatures;
-import org.openapitools.codegen.model.OperationMap;
-import org.openapitools.codegen.model.OperationsMap;
-import org.testng.Assert;
-import org.testng.annotations.Ignore;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.Operation;
-import io.swagger.v3.oas.models.media.ArraySchema;
-import io.swagger.v3.oas.models.media.ComposedSchema;
-import io.swagger.v3.oas.models.media.Content;
-import io.swagger.v3.oas.models.media.IntegerSchema;
-import io.swagger.v3.oas.models.media.MediaType;
-import io.swagger.v3.oas.models.media.ObjectSchema;
-import io.swagger.v3.oas.models.media.Schema;
-import io.swagger.v3.oas.models.media.StringSchema;
-import io.swagger.v3.oas.models.parameters.RequestBody;
-import io.swagger.v3.oas.models.responses.ApiResponse;
-import io.swagger.v3.parser.util.SchemaTypeUtil;
+import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
public class JavaClientCodegenTest {
@@ -951,7 +950,7 @@ public class JavaClientCodegenTest {
*
* UPDATE: the following test has been ignored due to https://github.com/OpenAPITools/openapi-generator/pull/11081/
* We will contact the contributor of the following test to see if the fix will break their use cases and
- * how we can fix it accordingly.
+ * how we can fix it accordingly.
*/
@Test
@Ignore
@@ -1231,7 +1230,7 @@ public class JavaClientCodegenTest {
final Path defaultApi = Paths.get(output + "/src/main/java/xyz/abcdef/ApiClient.java");
TestUtils.assertFileContains(defaultApi, "value instanceof Map");
}
-
+
/**
* See https://github.com/OpenAPITools/openapi-generator/issues/8352
*/
@@ -1665,4 +1664,28 @@ public class JavaClientCodegenTest {
.assertParameterAnnotations()
.containsWithName("NotNull");
}
+
+ @Test
+ public void testNativeClientExplodedQueryParamWithArrayProperty() throws IOException {
+ Map properties = new HashMap<>();
+ properties.put(CodegenConstants.API_PACKAGE, "xyz.abcdef.api");
+
+ File output = Files.createTempDirectory("test").toFile();
+ output.deleteOnExit();
+
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName("java")
+ .setLibrary(JavaClientCodegen.NATIVE)
+ .setAdditionalProperties(properties)
+ .setInputSpec("src/test/resources/3_0/exploded-query-param-array.yaml")
+ .setOutputDir(output.getAbsolutePath().replace("\\", "/"));
+
+ final ClientOptInput clientOptInput = configurator.toClientOptInput();
+ DefaultGenerator generator = new DefaultGenerator();
+ generator.opts(clientOptInput).generate();
+
+ TestUtils.assertFileContains(Paths.get(output + "/src/main/java/xyz/abcdef/api/DefaultApi.java"),
+ "localVarQueryParams.addAll(ApiClient.parameterToPairs(\"multi\", \"values\", queryObject.getValues()));"
+ );
+ }
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/JavaHelidonCommonCodegenPackagePrefixTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/JavaHelidonCommonCodegenPackagePrefixTest.java
index d55c062f7e7..f3cc4a4c490 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/JavaHelidonCommonCodegenPackagePrefixTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/JavaHelidonCommonCodegenPackagePrefixTest.java
@@ -205,3 +205,6 @@ public class JavaHelidonCommonCodegenPackagePrefixTest {
}
}
+
+
+
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/functional/FunctionalHelidonClientBase.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/functional/FunctionalHelidonClientBase.java
index 967e77bcbaf..ca7bf989b1b 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/functional/FunctionalHelidonClientBase.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/functional/FunctionalHelidonClientBase.java
@@ -16,6 +16,7 @@
*/
package org.openapitools.codegen.java.helidon.functional;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.nio.file.Files;
@@ -26,6 +27,12 @@ import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
public class FunctionalHelidonClientBase extends FunctionalBase {
+
+ @BeforeClass
+ public void setup() {
+ generatorName("java-helidon-client");
+ }
+
@Test
void buildPetstore() {
generate("src/test/resources/3_0/petstore.yaml");
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
index ac1f12a3eb0..bec4ee24ce1 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
@@ -18,8 +18,11 @@
package org.openapitools.codegen.java.spring;
import static java.util.stream.Collectors.groupingBy;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.openapitools.codegen.TestUtils.assertFileContains;
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
+import static org.openapitools.codegen.languages.SpringCodegen.INTERFACE_ONLY;
+import static org.openapitools.codegen.languages.SpringCodegen.REQUEST_MAPPING_OPTION;
import static org.openapitools.codegen.languages.SpringCodegen.RESPONSE_WRAPPER;
import static org.openapitools.codegen.languages.SpringCodegen.SPRING_BOOT;
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER;
@@ -43,7 +46,6 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
-import org.assertj.core.api.Assertions;
import org.openapitools.codegen.java.assertions.JavaFileAssert;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.ClientOptInput;
@@ -106,10 +108,9 @@ public class SpringCodegenTest {
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"))
.assertTypeAnnotations()
- .hasSize(4)
+ .hasSize(3)
.containsWithName("Validated")
.containsWithName("Generated")
- .containsWithName("RequestMapping")
.containsWithNameAndAttributes("Generated", ImmutableMap.of(
"value", "\"org.openapitools.codegen.languages.SpringCodegen\""
))
@@ -660,6 +661,7 @@ public class SpringCodegenTest {
public void testRequestMappingAnnotation() throws IOException {
final SpringCodegen codegen = new SpringCodegen();
codegen.setLibrary("spring-boot");
+ codegen.additionalProperties().put(REQUEST_MAPPING_OPTION, SpringCodegen.RequestMappingMode.api_interface);
final Map files = generateFiles(codegen, "src/test/resources/2_0/petstore.yaml");
@@ -673,7 +675,7 @@ public class SpringCodegenTest {
}
@Test
- public void testNoRequestMappingAnnotation() throws IOException {
+ public void testNoRequestMappingAnnotation_spring_cloud_default() throws IOException {
final SpringCodegen codegen = new SpringCodegen();
codegen.setLibrary( "spring-cloud" );
@@ -686,6 +688,21 @@ public class SpringCodegenTest {
}
+ @Test
+ public void testNoRequestMappingAnnotation() throws IOException {
+ final SpringCodegen codegen = new SpringCodegen();
+ codegen.setLibrary( "spring-cloud" );
+ codegen.additionalProperties().put(INTERFACE_ONLY, "true");
+ codegen.additionalProperties().put(REQUEST_MAPPING_OPTION, SpringCodegen.RequestMappingMode.none);
+
+ final Map files = generateFiles( codegen, "src/test/resources/2_0/petstore.yaml" );
+
+ // Check that the @RequestMapping annotation is not generated in the Api file
+ final File petApiFile = files.get( "PetApi.java" );
+ JavaFileAssert.assertThat( petApiFile ).assertTypeAnnotations().hasSize( 3 ).containsWithName( "Validated" )
+ .containsWithName( "Generated" ).containsWithName( "Tag" );
+ }
+
@Test
public void testSettersForConfigValues() throws Exception {
final SpringCodegen codegen = new SpringCodegen();
@@ -1214,7 +1231,7 @@ public class SpringCodegenTest {
generator.opts(input).generate();
File[] generatedModels = new File(outputPath + "/src/main/java/org/openapitools/model").listFiles();
- Assertions.assertThat(generatedModels).isNotEmpty();
+ assertThat(generatedModels).isNotEmpty();
for (File modelPath : generatedModels) {
JavaFileAssert.assertThat(modelPath)
@@ -1227,22 +1244,9 @@ public class SpringCodegenTest {
@Test
public void testHandleDefaultValue_issue8535() throws Exception {
- File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
- output.deleteOnExit();
-
- OpenAPI openAPI = new OpenAPIParser()
- .readLocation("src/test/resources/3_0/issue_8535.yaml", null, new ParseOptions()).getOpenAPI();
- SpringCodegen codegen = new SpringCodegen();
- codegen.setOutputDir(output.getAbsolutePath());
- codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
-
- ClientOptInput input = new ClientOptInput()
- .openAPI(openAPI)
- .config(codegen);
-
- DefaultGenerator generator = new DefaultGenerator();
- Map files = generator.opts(input).generate().stream()
- .collect(Collectors.toMap(File::getName, Function.identity()));
+ Map additionalProperties = new HashMap<>();
+ additionalProperties.put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
+ Map files = generateFromContract("src/test/resources/3_0/issue_8535.yaml", SPRING_BOOT, additionalProperties);
JavaFileAssert.assertThat(files.get("TestHeadersApi.java"))
.assertMethod("headersTest")
@@ -1329,29 +1333,15 @@ public class SpringCodegenTest {
@Test
public void testResponseWithArray_issue11897() throws Exception {
- File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
- output.deleteOnExit();
-
- OpenAPI openAPI = new OpenAPIParser()
- .readLocation("src/test/resources/bugs/issue_11897.yaml", null, new ParseOptions()).getOpenAPI();
- SpringCodegen codegen = new SpringCodegen();
- codegen.setLibrary(SPRING_BOOT);
- codegen.setOutputDir(output.getAbsolutePath());
- codegen.additionalProperties().put(AbstractJavaCodegen.FULL_JAVA_UTIL, "true");
- codegen.additionalProperties().put(SpringCodegen.USE_TAGS, "true");
- codegen.additionalProperties().put(SpringCodegen.INTERFACE_ONLY, "true");
- codegen.additionalProperties().put(SpringCodegen.SKIP_DEFAULT_INTERFACE, "true");
- codegen.additionalProperties().put(SpringCodegen.PERFORM_BEANVALIDATION, "true");
- codegen.additionalProperties().put(SpringCodegen.SPRING_CONTROLLER, "true");
- codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, "jackson");
-
- ClientOptInput input = new ClientOptInput()
- .openAPI(openAPI)
- .config(codegen);
-
- DefaultGenerator generator = new DefaultGenerator();
- Map files = generator.opts(input).generate().stream()
- .collect(Collectors.toMap(File::getName, Function.identity()));
+ Map additionalProperties = new HashMap<>();
+ additionalProperties.put(AbstractJavaCodegen.FULL_JAVA_UTIL, "true");
+ additionalProperties.put(SpringCodegen.USE_TAGS, "true");
+ additionalProperties.put(SpringCodegen.INTERFACE_ONLY, "true");
+ additionalProperties.put(SpringCodegen.SKIP_DEFAULT_INTERFACE, "true");
+ additionalProperties.put(SpringCodegen.PERFORM_BEANVALIDATION, "true");
+ additionalProperties.put(SpringCodegen.SPRING_CONTROLLER, "true");
+ additionalProperties.put(CodegenConstants.SERIALIZATION_LIBRARY, "jackson");
+ Map files = generateFromContract("src/test/resources/bugs/issue_11897.yaml", SPRING_BOOT, additionalProperties);
JavaFileAssert.assertThat(files.get("MetadataApi.java"))
.assertMethod("getWithArrayOfObjects").hasReturnType("ResponseEntity>")
@@ -1369,29 +1359,16 @@ public class SpringCodegenTest {
@Test
public void shouldSetDefaultValueForMultipleArrayItems() throws IOException {
- File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
- output.deleteOnExit();
+ Map additionalProperties = new HashMap<>();
+ additionalProperties.put(AbstractJavaCodegen.FULL_JAVA_UTIL, "true");
+ additionalProperties.put(SpringCodegen.USE_TAGS, "true");
+ additionalProperties.put(SpringCodegen.INTERFACE_ONLY, "true");
+ additionalProperties.put(SpringCodegen.SKIP_DEFAULT_INTERFACE, "true");
+ additionalProperties.put(SpringCodegen.PERFORM_BEANVALIDATION, "true");
+ additionalProperties.put(SpringCodegen.SPRING_CONTROLLER, "true");
+ additionalProperties.put(CodegenConstants.SERIALIZATION_LIBRARY, "jackson");
- OpenAPI openAPI = new OpenAPIParser()
- .readLocation("src/test/resources/bugs/issue_11957.yaml", null, new ParseOptions()).getOpenAPI();
- SpringCodegen codegen = new SpringCodegen();
- codegen.setLibrary(SPRING_BOOT);
- codegen.setOutputDir(output.getAbsolutePath());
- codegen.additionalProperties().put(AbstractJavaCodegen.FULL_JAVA_UTIL, "true");
- codegen.additionalProperties().put(SpringCodegen.USE_TAGS, "true");
- codegen.additionalProperties().put(SpringCodegen.INTERFACE_ONLY, "true");
- codegen.additionalProperties().put(SpringCodegen.SKIP_DEFAULT_INTERFACE, "true");
- codegen.additionalProperties().put(SpringCodegen.PERFORM_BEANVALIDATION, "true");
- codegen.additionalProperties().put(SpringCodegen.SPRING_CONTROLLER, "true");
- codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, "jackson");
-
- ClientOptInput input = new ClientOptInput()
- .openAPI(openAPI)
- .config(codegen);
-
- DefaultGenerator generator = new DefaultGenerator();
- Map files = generator.opts(input).generate().stream()
- .collect(Collectors.toMap(File::getName, Function.identity()));
+ Map files = generateFromContract("src/test/resources/bugs/issue_11957.yaml", SPRING_BOOT, additionalProperties);
JavaFileAssert.assertThat(files.get("SearchApi.java"))
.assertMethod("defaultList")
@@ -1417,21 +1394,7 @@ public class SpringCodegenTest {
@Test
public void testPutItemsMethodContainsKeyInSuperClassMethodCall_issue12494() throws IOException {
- File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
- output.deleteOnExit();
-
- OpenAPI openAPI = new OpenAPIParser()
- .readLocation("src/test/resources/bugs/issue_12494.yaml", null, new ParseOptions()).getOpenAPI();
- SpringCodegen codegen = new SpringCodegen();
- codegen.setOutputDir(output.getAbsolutePath());
-
- ClientOptInput input = new ClientOptInput()
- .openAPI(openAPI)
- .config(codegen);
-
- DefaultGenerator generator = new DefaultGenerator();
- Map files = generator.opts(input).generate().stream()
- .collect(Collectors.toMap(File::getName, Function.identity()));
+ Map files = generateFromContract("src/test/resources/bugs/issue_12494.yaml", null);
JavaFileAssert.assertThat(files.get("ChildClass.java"))
.assertMethod("putSomeMapItem")
@@ -1440,22 +1403,7 @@ public class SpringCodegenTest {
@Test
public void shouldHandleCustomResponseType_issue11731() throws IOException {
- File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
- output.deleteOnExit();
-
- OpenAPI openAPI = new OpenAPIParser()
- .readLocation("src/test/resources/bugs/issue_11731.yaml", null, new ParseOptions()).getOpenAPI();
- SpringCodegen codegen = new SpringCodegen();
- codegen.setLibrary(SPRING_BOOT);
- codegen.setOutputDir(output.getAbsolutePath());
-
- ClientOptInput input = new ClientOptInput()
- .openAPI(openAPI)
- .config(codegen);
-
- DefaultGenerator generator = new DefaultGenerator();
- Map files = generator.opts(input).generate().stream()
- .collect(Collectors.toMap(File::getName, Function.identity()));
+ Map files = generateFromContract("src/test/resources/bugs/issue_11731.yaml", SPRING_BOOT);
JavaFileAssert.assertThat(files.get("CustomersApi.java"))
.assertMethod("getAllUsingGET1")
@@ -1464,23 +1412,9 @@ public class SpringCodegenTest {
@Test
public void shouldHandleContentTypeWithSecondWildcardSubtype_issue12457() throws IOException {
- File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
- output.deleteOnExit();
-
- OpenAPI openAPI = new OpenAPIParser()
- .readLocation("src/test/resources/bugs/issue_12457.yaml", null, new ParseOptions()).getOpenAPI();
- SpringCodegen codegen = new SpringCodegen();
- codegen.setLibrary(SPRING_BOOT);
- codegen.setOutputDir(output.getAbsolutePath());
- codegen.additionalProperties().put(SpringCodegen.USE_TAGS, "true");
-
- ClientOptInput input = new ClientOptInput()
- .openAPI(openAPI)
- .config(codegen);
-
- DefaultGenerator generator = new DefaultGenerator();
- Map files = generator.opts(input).generate().stream()
- .collect(Collectors.toMap(File::getName, Function.identity()));
+ Map additionalProperties = new HashMap<>();
+ additionalProperties.put(SpringCodegen.USE_TAGS, "true");
+ Map files = generateFromContract("src/test/resources/bugs/issue_12457.yaml", SPRING_BOOT, additionalProperties);
JavaFileAssert.assertThat(files.get("UsersApi.java"))
.assertMethod("wildcardSubTypeForContentType")
@@ -1493,28 +1427,15 @@ public class SpringCodegenTest {
@Test
public void shouldGenerateDiscriminatorFromAllOfWhenUsingLegacyDiscriminatorBehaviour_issue12692() throws IOException {
- File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
- output.deleteOnExit();
-
- OpenAPI openAPI = new OpenAPIParser()
- .readLocation("src/test/resources/bugs/issue_12692.yml", null, new ParseOptions()).getOpenAPI();
- SpringCodegen codegen = new SpringCodegen();
- codegen.setLibrary(SPRING_BOOT);
- codegen.setOutputDir(output.getAbsolutePath());
- codegen.additionalProperties().put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true");
-
- ClientOptInput input = new ClientOptInput()
- .openAPI(openAPI)
- .config(codegen);
-
- DefaultGenerator generator = new DefaultGenerator();
- generator.opts(input).generate();
+ Map additionalProperties = new HashMap<>();
+ additionalProperties.put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true");
+ Map output = generateFromContract("src/test/resources/bugs/issue_12692.yml", SPRING_BOOT, additionalProperties);
String jsonTypeInfo = "@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = \"type\", visible = true)";
String jsonSubType = "@JsonSubTypes({\n" +
" @JsonSubTypes.Type(value = Cat.class, name = \"cat\")" +
"})";
- assertFileContains(Paths.get(output.getAbsolutePath() + "/src/main/java/org/openapitools/model/Pet.java"), jsonTypeInfo, jsonSubType);
+ assertFileContains(output.get("Pet.java").toPath(), jsonTypeInfo, jsonSubType);
}
@Test
@@ -1696,4 +1617,46 @@ public class SpringCodegenTest {
.assertMethod("equals")
.bodyContainsLines("return Arrays.equals(this.picture, testObject.picture);");
}
+
+ @Test
+ public void contractWithoutEnumDoesNotContainsEnumConverter() throws IOException {
+ Map output = generateFromContract("src/test/resources/3_0/generic.yaml", SPRING_BOOT);
+
+ assertThat(output).doesNotContainKey("EnumConverterConfiguration.java");
+ }
+
+ @Test
+ public void contractWithEnumContainsEnumConverter() throws IOException {
+ Map output = generateFromContract("src/test/resources/3_0/enum.yaml", SPRING_BOOT);
+
+ JavaFileAssert.assertThat(output.get("EnumConverterConfiguration.java"))
+ .assertMethod("typeConverter");
+ }
+
+ private Map generateFromContract(String url, String library) throws IOException {
+ return generateFromContract(url, library, new HashMap<>());
+ }
+ private Map generateFromContract(String url, String library, Map additionalProperties) throws IOException {
+ File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
+ output.deleteOnExit();
+
+ OpenAPI openAPI = new OpenAPIParser()
+ .readLocation(url, null, new ParseOptions()).getOpenAPI();
+
+ SpringCodegen codegen = new SpringCodegen();
+ if (null != library) {
+ codegen.setLibrary(library);
+ }
+ codegen.setOutputDir(output.getAbsolutePath());
+ codegen.additionalProperties().putAll(additionalProperties);
+
+ ClientOptInput input = new ClientOptInput()
+ .openAPI(openAPI)
+ .config(codegen);
+
+ DefaultGenerator generator = new DefaultGenerator();
+
+ return generator.opts(input).generate().stream()
+ .collect(Collectors.toMap(File::getName, Function.identity()));
+ }
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinReservedWordsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinReservedWordsTest.java
index bd06fde5f2a..0d12b103ea4 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinReservedWordsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinReservedWordsTest.java
@@ -66,7 +66,7 @@ public class KotlinReservedWordsTest {
final DefaultCodegen codegen = new KotlinClientCodegen();
final Schema schema = new Schema();
final String escaped = "`" + reservedWord + "`";
- final String titleCased = StringUtils.camelize(reservedWord, false);
+ final String titleCased = StringUtils.camelize(reservedWord);
codegen.setOpenAPI(openAPI);
CodegenModel model = codegen.fromModel(reservedWord, schema);
@@ -106,7 +106,7 @@ public class KotlinReservedWordsTest {
final DefaultCodegen codegen = new KotlinClientCodegen();
final String escaped = "`" + reservedWord + "`";
- final String titleCased = StringUtils.camelize(reservedWord, false);
+ final String titleCased = StringUtils.camelize(reservedWord);
Schema linked = openAPI.getComponents().getSchemas().get("Linked");
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/templating/mustache/TitlecaseLambdaTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/templating/mustache/TitlecaseLambdaTest.java
index 2b3f632e9dd..d4c94d47026 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/templating/mustache/TitlecaseLambdaTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/templating/mustache/TitlecaseLambdaTest.java
@@ -15,6 +15,24 @@ public class TitlecaseLambdaTest extends LambdaTest {
test("Once Upon A Time", "{{#titlecase}}once upon a time{{/titlecase}}", ctx);
}
+ @Test
+ public void titlecaseSingleLetterTest() {
+ // Given
+ Map ctx = context("titlecase", new TitlecaseLambda());
+
+ // When & Then
+ test("O", "{{#titlecase}}o{{/titlecase}}", ctx);
+ }
+
+ @Test
+ public void titlecaseEmptyStringTest() {
+ // Given
+ Map ctx = context("titlecase", new TitlecaseLambda());
+
+ // When & Then
+ test("", "{{#titlecase}}{{/titlecase}}", ctx);
+ }
+
@Test
public void titlecaseWithDelimiterTest() {
// Given
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/StringUtilsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/StringUtilsTest.java
index 2001a9844c5..f8a0d6ddf99 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/StringUtilsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/StringUtilsTest.java
@@ -3,6 +3,8 @@ package org.openapitools.codegen.utils;
import org.testng.Assert;
import org.testng.annotations.Test;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_CHAR;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class StringUtilsTest {
@@ -21,14 +23,18 @@ public class StringUtilsTest {
Assert.assertEquals(camelize("some_value"), "SomeValue");
Assert.assertEquals(camelize("$type"), "$Type");
- Assert.assertEquals(camelize("abcd", true), "abcd");
- Assert.assertEquals(camelize("some-value", true), "someValue");
- Assert.assertEquals(camelize("some_value", true), "someValue");
- Assert.assertEquals(camelize("Abcd", true), "abcd");
- Assert.assertEquals(camelize("$type", true), "$type");
+ Assert.assertEquals(camelize("abcd", LOWERCASE_FIRST_LETTER), "abcd");
+ Assert.assertEquals(camelize("some-value", LOWERCASE_FIRST_LETTER), "someValue");
+ Assert.assertEquals(camelize("some_value", LOWERCASE_FIRST_LETTER), "someValue");
+ Assert.assertEquals(camelize("Abcd", LOWERCASE_FIRST_LETTER), "abcd");
+ Assert.assertEquals(camelize("$type", LOWERCASE_FIRST_LETTER), "$type");
- Assert.assertEquals(camelize("123", true), "123");
- Assert.assertEquals(camelize("$123", true), "$123");
+ Assert.assertEquals(camelize("123", LOWERCASE_FIRST_LETTER), "123");
+ Assert.assertEquals(camelize("$123", LOWERCASE_FIRST_LETTER), "$123");
+
+
+ Assert.assertEquals(camelize("some-value", LOWERCASE_FIRST_CHAR), "someValue");
+ Assert.assertEquals(camelize("$type", LOWERCASE_FIRST_CHAR), "$Type");
}
@Test
diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp-netcore/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp-netcore/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
new file mode 100644
index 00000000000..afd5a8a62b7
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/csharp-netcore/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -0,0 +1,2188 @@
+openapi: 3.0.0
+info:
+ description: >-
+ This spec is mainly for testing Petstore server and contains fake endpoints,
+ models. Please do not use this for any other purpose. Special characters: "
+ \
+ version: 1.0.0
+ title: OpenAPI Petstore
+ license:
+ name: Apache-2.0
+ url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
+tags:
+ - name: pet
+ description: Everything about your Pets
+ - name: store
+ description: Access to Petstore orders
+ - name: user
+ description: Operations about user
+paths:
+ /foo:
+ get:
+ responses:
+ default:
+ description: response
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ string:
+ $ref: '#/components/schemas/Foo'
+ /pet:
+ servers:
+ - url: 'http://petstore.swagger.io/v2'
+ - url: 'http://path-server-test.petstore.local/v2'
+ post:
+ tags:
+ - pet
+ summary: Add a new pet to the store
+ description: ''
+ operationId: addPet
+ responses:
+ '405':
+ description: Invalid input
+ security:
+ - http_signature_test: []
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ requestBody:
+ $ref: '#/components/requestBodies/Pet'
+ put:
+ tags:
+ - pet
+ summary: Update an existing pet
+ description: ''
+ operationId: updatePet
+ responses:
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Pet not found
+ '405':
+ description: Validation exception
+ security:
+ - http_signature_test: []
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ requestBody:
+ $ref: '#/components/requestBodies/Pet'
+ /pet/findByStatusWithFilter:
+ get:
+ tags:
+ - pet
+ summary: Finds Pets by status
+ description: Multiple status values can be provided with comma separated strings
+ operationId: findPetsByStatusWithFilter
+ parameters:
+ - name: status
+ in: query
+ description: Status values that need to be considered for filter
+ required: true
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/PetStatusFilter'
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pet'
+ '400':
+ description: Invalid status value
+ security:
+ - http_signature_test: []
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ /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
+ deprecated: true
+ schema:
+ type: array
+ items:
+ type: string
+ enum:
+ - available
+ - pending
+ - sold
+ default: available
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pet'
+ '400':
+ description: Invalid status value
+ security:
+ - http_signature_test: []
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ /pet/findByTags:
+ get:
+ tags:
+ - pet
+ summary: Finds Pets by tags
+ 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
+ schema:
+ type: array
+ items:
+ type: string
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pet'
+ '400':
+ description: Invalid tag value
+ security:
+ - http_signature_test: []
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ deprecated: true
+ '/pet/{petId}':
+ 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
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Pet not found
+ security:
+ - api_key: []
+ post:
+ tags:
+ - pet
+ summary: Updates a pet in the store with form data
+ description: ''
+ operationId: updatePetWithForm
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet that needs to be updated
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '405':
+ description: Invalid input
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ requestBody:
+ content:
+ application/x-www-form-urlencoded:
+ schema:
+ type: object
+ properties:
+ name:
+ description: Updated name of the pet
+ type: string
+ status:
+ description: Updated status of the pet
+ type: string
+ delete:
+ tags:
+ - pet
+ summary: Deletes a pet
+ description: ''
+ operationId: deletePet
+ parameters:
+ - name: api_key
+ in: header
+ required: false
+ 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
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ '/pet/{petId}/uploadImage':
+ post:
+ tags:
+ - pet
+ summary: uploads an image
+ description: ''
+ operationId: uploadFile
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to update
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ApiResponse'
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ requestBody:
+ content:
+ multipart/form-data:
+ schema:
+ type: object
+ properties:
+ additionalMetadata:
+ description: Additional data to pass to server
+ type: string
+ file:
+ description: file to upload
+ type: string
+ format: binary
+ /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
+ security:
+ - api_key: []
+ /store/order:
+ post:
+ tags:
+ - store
+ summary: Place an order for a pet
+ description: ''
+ operationId: placeOrder
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/Order'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Order'
+ '400':
+ description: Invalid Order
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Order'
+ description: order placed for purchasing the pet
+ required: true
+ '/store/order/{order_id}':
+ 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: order_id
+ in: path
+ description: ID of pet that needs to be fetched
+ required: true
+ schema:
+ type: integer
+ format: int64
+ minimum: 1
+ maximum: 5
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/Order'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Order'
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Order not found
+ 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: order_id
+ in: path
+ description: ID of the order that needs to be deleted
+ required: true
+ schema:
+ type: string
+ responses:
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Order not found
+ /user:
+ post:
+ tags:
+ - user
+ summary: Create user
+ description: This can only be done by the logged in user.
+ operationId: createUser
+ responses:
+ default:
+ description: successful operation
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/User'
+ description: Created user object
+ required: true
+ /user/createWithArray:
+ post:
+ tags:
+ - user
+ summary: Creates list of users with given input array
+ description: ''
+ operationId: createUsersWithArrayInput
+ responses:
+ default:
+ description: successful operation
+ requestBody:
+ $ref: '#/components/requestBodies/UserArray'
+ /user/createWithList:
+ post:
+ tags:
+ - user
+ summary: Creates list of users with given input array
+ description: ''
+ operationId: createUsersWithListInput
+ responses:
+ default:
+ description: successful operation
+ requestBody:
+ $ref: '#/components/requestBodies/UserArray'
+ /user/login:
+ get:
+ tags:
+ - user
+ summary: Logs user into the system
+ description: ''
+ operationId: loginUser
+ parameters:
+ - name: username
+ in: query
+ description: The user name for login
+ required: true
+ schema:
+ type: string
+ - name: password
+ in: query
+ description: The password for login in clear text
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: successful operation
+ headers:
+ X-Rate-Limit:
+ description: calls per hour allowed by the user
+ schema:
+ type: integer
+ format: int32
+ X-Expires-After:
+ description: date in UTC when token expires
+ schema:
+ type: string
+ format: date-time
+ content:
+ application/xml:
+ schema:
+ type: string
+ application/json:
+ schema:
+ type: string
+ '400':
+ description: Invalid username/password supplied
+ /user/logout:
+ get:
+ tags:
+ - user
+ summary: Logs out current logged in user session
+ description: ''
+ operationId: logoutUser
+ responses:
+ default:
+ description: successful operation
+ '/user/{username}':
+ get:
+ tags:
+ - user
+ summary: Get user by user name
+ description: ''
+ operationId: getUserByName
+ parameters:
+ - name: username
+ in: path
+ description: The name that needs to be fetched. Use user1 for testing.
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/User'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/User'
+ '400':
+ description: Invalid username supplied
+ '404':
+ description: User not found
+ 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
+ required: true
+ schema:
+ type: string
+ responses:
+ '400':
+ description: Invalid user supplied
+ '404':
+ description: User not found
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/User'
+ description: Updated user object
+ required: true
+ delete:
+ 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
+ '404':
+ description: User not found
+ /fake_classname_test:
+ patch:
+ tags:
+ - 'fake_classname_tags 123#$%^'
+ summary: To test class name in snake case
+ description: To test class name in snake case
+ operationId: testClassname
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Client'
+ security:
+ - api_key_query: []
+ requestBody:
+ $ref: '#/components/requestBodies/Client'
+ /fake:
+ patch:
+ tags:
+ - fake
+ summary: To test "client" model
+ description: To test "client" model
+ operationId: testClientModel
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Client'
+ requestBody:
+ $ref: '#/components/requestBodies/Client'
+ get:
+ tags:
+ - fake
+ summary: To test enum parameters
+ description: To test enum parameters
+ operationId: testEnumParameters
+ parameters:
+ - name: enum_header_string_array
+ in: header
+ description: Header parameter enum test (string array)
+ schema:
+ type: array
+ items:
+ type: string
+ default: $
+ enum:
+ - '>'
+ - $
+ - name: enum_header_string
+ in: header
+ description: Header parameter enum test (string)
+ schema:
+ type: string
+ enum:
+ - _abc
+ - '-efg'
+ - (xyz)
+ default: '-efg'
+ - name: enum_query_string_array
+ in: query
+ description: Query parameter enum test (string array)
+ schema:
+ type: array
+ items:
+ type: string
+ default: $
+ enum:
+ - '>'
+ - $
+ - name: enum_query_string
+ in: query
+ description: Query parameter enum test (string)
+ schema:
+ type: string
+ enum:
+ - _abc
+ - '-efg'
+ - (xyz)
+ default: '-efg'
+ - name: enum_query_integer
+ in: query
+ description: Query parameter enum test (double)
+ schema:
+ type: integer
+ format: int32
+ enum:
+ - 1
+ - -2
+ - name: enum_query_double
+ in: query
+ description: Query parameter enum test (double)
+ schema:
+ type: number
+ format: double
+ enum:
+ - 1.1
+ - -1.2
+ responses:
+ '400':
+ description: Invalid request
+ '404':
+ description: Not found
+ requestBody:
+ content:
+ application/x-www-form-urlencoded:
+ schema:
+ type: object
+ properties:
+ enum_form_string_array:
+ description: Form parameter enum test (string array)
+ type: array
+ items:
+ type: string
+ default: $
+ enum:
+ - '>'
+ - $
+ enum_form_string:
+ description: Form parameter enum test (string)
+ type: string
+ enum:
+ - _abc
+ - '-efg'
+ - (xyz)
+ default: '-efg'
+ post:
+ tags:
+ - fake
+ summary: |
+ Fake endpoint for testing various parameters
+ 假端點
+ 偽のエンドポイント
+ 가짜 엔드 포인트
+ description: |
+ Fake endpoint for testing various parameters
+ 假端點
+ 偽のエンドポイント
+ 가짜 엔드 포인트
+ operationId: testEndpointParameters
+ responses:
+ '400':
+ description: Invalid username supplied
+ '404':
+ description: User not found
+ security:
+ - http_basic_test: []
+ requestBody:
+ content:
+ application/x-www-form-urlencoded:
+ schema:
+ type: object
+ properties:
+ integer:
+ description: None
+ type: integer
+ minimum: 10
+ maximum: 100
+ int32:
+ description: None
+ type: integer
+ format: int32
+ minimum: 20
+ maximum: 200
+ int64:
+ description: None
+ type: integer
+ format: int64
+ number:
+ description: None
+ type: number
+ minimum: 32.1
+ maximum: 543.2
+ float:
+ description: None
+ type: number
+ format: float
+ maximum: 987.6
+ double:
+ description: None
+ type: number
+ format: double
+ minimum: 67.8
+ maximum: 123.4
+ string:
+ description: None
+ type: string
+ pattern: '/[a-z]/i'
+ pattern_without_delimiter:
+ description: None
+ type: string
+ pattern: '^[A-Z].*'
+ byte:
+ description: None
+ type: string
+ format: byte
+ binary:
+ description: None
+ type: string
+ format: binary
+ date:
+ description: None
+ type: string
+ format: date
+ dateTime:
+ description: None
+ type: string
+ format: date-time
+ default: '2010-02-01T10:20:10.11111+01:00'
+ example: '2020-02-02T20:20:20.22222Z'
+ password:
+ description: None
+ type: string
+ format: password
+ minLength: 10
+ maxLength: 64
+ callback:
+ description: None
+ type: string
+ required:
+ - number
+ - double
+ - pattern_without_delimiter
+ - byte
+ delete:
+ tags:
+ - fake
+ security:
+ - bearer_test: []
+ summary: Fake endpoint to test group parameters (optional)
+ description: Fake endpoint to test group parameters (optional)
+ operationId: testGroupParameters
+ x-group-parameters: true
+ parameters:
+ - name: required_string_group
+ in: query
+ description: Required String in group parameters
+ required: true
+ schema:
+ type: integer
+ - name: required_boolean_group
+ in: header
+ description: Required Boolean in group parameters
+ required: true
+ schema:
+ type: boolean
+ - name: required_int64_group
+ in: query
+ description: Required Integer in group parameters
+ required: true
+ schema:
+ type: integer
+ format: int64
+ - name: string_group
+ in: query
+ description: String in group parameters
+ schema:
+ type: integer
+ - name: boolean_group
+ in: header
+ description: Boolean in group parameters
+ schema:
+ type: boolean
+ - name: int64_group
+ in: query
+ description: Integer in group parameters
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '400':
+ description: Someting wrong
+ /fake/outer/number:
+ post:
+ tags:
+ - fake
+ description: Test serialization of outer number types
+ operationId: fakeOuterNumberSerialize
+ responses:
+ '200':
+ description: Output number
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/OuterNumber'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/OuterNumber'
+ description: Input number as post body
+ /fake/outer/string:
+ post:
+ tags:
+ - fake
+ description: Test serialization of outer string types
+ operationId: fakeOuterStringSerialize
+ responses:
+ '200':
+ description: Output string
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/OuterString'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/OuterString'
+ description: Input string as post body
+ /fake/outer/boolean:
+ post:
+ tags:
+ - fake
+ description: Test serialization of outer boolean types
+ operationId: fakeOuterBooleanSerialize
+ responses:
+ '200':
+ description: Output boolean
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/OuterBoolean'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/OuterBoolean'
+ description: Input boolean as post body
+ /fake/outer/composite:
+ post:
+ tags:
+ - fake
+ description: Test serialization of object with outer number type
+ operationId: fakeOuterCompositeSerialize
+ responses:
+ '200':
+ description: Output composite
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/OuterComposite'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/OuterComposite'
+ description: Input composite as post body
+ /fake/jsonFormData:
+ get:
+ tags:
+ - fake
+ summary: test json serialization of form data
+ description: ''
+ operationId: testJsonFormData
+ responses:
+ '200':
+ description: successful operation
+ requestBody:
+ content:
+ application/x-www-form-urlencoded:
+ schema:
+ type: object
+ properties:
+ param:
+ description: field1
+ type: string
+ param2:
+ description: field2
+ type: string
+ required:
+ - param
+ - param2
+ /fake/inline-additionalProperties:
+ post:
+ tags:
+ - fake
+ summary: test inline additionalProperties
+ description: ''
+ operationId: testInlineAdditionalProperties
+ responses:
+ '200':
+ description: successful operation
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ additionalProperties:
+ type: string
+ description: request body
+ required: true
+ /fake/body-with-query-params:
+ put:
+ tags:
+ - fake
+ operationId: testBodyWithQueryParams
+ parameters:
+ - name: query
+ in: query
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: Success
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/User'
+ required: true
+ /another-fake/dummy:
+ patch:
+ tags:
+ - $another-fake?
+ summary: To test special tags
+ description: To test special tags and operation ID starting with number
+ operationId: '123_test_@#$%_special_tags'
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Client'
+ requestBody:
+ $ref: '#/components/requestBodies/Client'
+ /fake/body-with-file-schema:
+ put:
+ tags:
+ - fake
+ description: >-
+ For this test, the body for this request much reference a schema named
+ `File`.
+ operationId: testBodyWithFileSchema
+ responses:
+ '200':
+ description: Success
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/FileSchemaTestClass'
+ required: true
+ /fake/test-query-parameters:
+ put:
+ tags:
+ - fake
+ description: To test the collection format in query parameters
+ operationId: testQueryParameterCollectionFormat
+ parameters:
+ - name: pipe
+ in: query
+ required: true
+ schema:
+ type: array
+ items:
+ type: string
+ - name: ioutil
+ in: query
+ required: true
+ style: form
+ explode: false
+ schema:
+ type: array
+ items:
+ type: string
+ - name: http
+ in: query
+ required: true
+ style: spaceDelimited
+ schema:
+ type: array
+ items:
+ type: string
+ - name: url
+ in: query
+ required: true
+ style: form
+ explode: false
+ schema:
+ type: array
+ items:
+ type: string
+ - name: context
+ in: query
+ required: true
+ explode: true
+ schema:
+ type: array
+ items:
+ type: string
+ responses:
+ "200":
+ description: Success
+ '/fake/{petId}/uploadImageWithRequiredFile':
+ post:
+ tags:
+ - pet
+ summary: uploads an image (required)
+ description: ''
+ operationId: uploadFileWithRequiredFile
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to update
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ApiResponse'
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ requestBody:
+ content:
+ multipart/form-data:
+ schema:
+ type: object
+ properties:
+ additionalMetadata:
+ description: Additional data to pass to server
+ type: string
+ requiredFile:
+ description: file to upload
+ type: string
+ format: binary
+ required:
+ - requiredFile
+ /fake/health:
+ get:
+ tags:
+ - fake
+ summary: Health check endpoint
+ responses:
+ 200:
+ description: The instance started successfully
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/HealthCheckResult'
+ /fake/array-of-enums:
+ get:
+ tags:
+ - fake
+ summary: Array of Enums
+ operationId: getArrayOfEnums
+ responses:
+ 200:
+ description: Got named array of enums
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ArrayOfEnums'
+servers:
+ - url: 'http://{server}.swagger.io:{port}/v2'
+ description: petstore server
+ variables:
+ server:
+ enum:
+ - 'petstore'
+ - 'qa-petstore'
+ - 'dev-petstore'
+ default: 'petstore'
+ port:
+ enum:
+ - 80
+ - 8080
+ default: 80
+ - url: https://localhost:8080/{version}
+ description: The local server
+ variables:
+ version:
+ enum:
+ - 'v1'
+ - 'v2'
+ default: 'v2'
+ - url: https://127.0.0.1/no_variable
+ description: The local server without variables
+components:
+ requestBodies:
+ UserArray:
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/User'
+ examples:
+ simple-list:
+ summary: Simple list example
+ description: Should not get into code examples
+ value:
+ - username: foo
+ - username: bar
+ description: List of user object
+ required: true
+ Client:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Client'
+ description: client model
+ 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
+ securitySchemes:
+ petstore_auth:
+ type: oauth2
+ flows:
+ implicit:
+ authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
+ scopes:
+ 'write:pets': modify pets in your account
+ 'read:pets': read your pets
+ api_key:
+ type: apiKey
+ name: api_key
+ in: header
+ api_key_query:
+ type: apiKey
+ name: api_key_query
+ in: query
+ http_basic_test:
+ type: http
+ scheme: basic
+ bearer_test:
+ type: http
+ scheme: bearer
+ bearerFormat: JWT
+ http_signature_test:
+ # Test the 'HTTP signature' security scheme.
+ # Each HTTP request is cryptographically signed as specified
+ # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/
+ type: http
+ scheme: signature
+ schemas:
+ Foo:
+ type: object
+ properties:
+ bar:
+ $ref: '#/components/schemas/Bar'
+ Bar:
+ type: string
+ default: bar
+ Order:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ petId:
+ type: integer
+ format: int64
+ quantity:
+ type: integer
+ format: int32
+ shipDate:
+ type: string
+ format: date-time
+ example: '2020-02-02T20:20:20.000222Z'
+ status:
+ type: string
+ description: Order Status
+ enum:
+ - placed
+ - approved
+ - delivered
+ complete:
+ type: boolean
+ default: false
+ xml:
+ name: Order
+ Category:
+ type: object
+ required:
+ - name
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ default: default-name
+ xml:
+ name: Category
+ User:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ x-is-unique: true
+ username:
+ type: string
+ firstName:
+ type: string
+ lastName:
+ type: string
+ email:
+ type: string
+ password:
+ type: string
+ phone:
+ type: string
+ userStatus:
+ type: integer
+ format: int32
+ description: User Status
+ objectWithNoDeclaredProps:
+ type: object
+ # Note: the 'additionalProperties' keyword is not specified, which is
+ # equivalent to allowing undeclared properties of any type.
+ description: test code generation for objects
+ Value must be a map of strings to values. It cannot be the 'null' value.
+ objectWithNoDeclaredPropsNullable:
+ type: object
+ # Note: the 'additionalProperties' keyword is not specified, which is
+ # equivalent to allowing undeclared properties of any type.
+ description: test code generation for nullable objects.
+ Value must be a map of strings to values or the 'null' value.
+ nullable: true
+ anyTypeProp:
+ description: test code generation for any type
+ Here the 'type' attribute is not specified, which means the value can be anything,
+ including the null value, string, number, boolean, array or object.
+ See https://github.com/OAI/OpenAPI-Specification/issues/1389
+ # TODO: this should be supported, currently there are some issues in the code generation.
+ #anyTypeExceptNullProp:
+ # description: any type except 'null'
+ # Here the 'type' attribute is not specified, which means the value can be anything,
+ # including the null value, string, number, boolean, array or object.
+ # not:
+ # type: 'null'
+ anyTypePropNullable:
+ description: test code generation for any type
+ Here the 'type' attribute is not specified, which means the value can be anything,
+ including the null value, string, number, boolean, array or object.
+ The 'nullable' attribute does not change the allowed values.
+ nullable: true
+ xml:
+ name: User
+ Tag:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ xml:
+ name: Tag
+ Pet:
+ type: object
+ required:
+ - name
+ - photoUrls
+ properties:
+ id:
+ type: integer
+ format: int64
+ x-is-unique: true
+ category:
+ $ref: '#/components/schemas/Category'
+ name:
+ type: string
+ example: doggie
+ photoUrls:
+ type: array
+ xml:
+ name: photoUrl
+ wrapped: true
+ items:
+ type: string
+ tags:
+ 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
+ xml:
+ name: Pet
+ ApiResponse:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ type:
+ type: string
+ message:
+ type: string
+ Return:
+ description: Model for testing reserved words
+ properties:
+ return:
+ type: integer
+ format: int32
+ xml:
+ name: Return
+ Name:
+ description: Model for testing model name same as property name
+ required:
+ - name
+ properties:
+ name:
+ type: integer
+ format: int32
+ snake_case:
+ readOnly: true
+ type: integer
+ format: int32
+ property:
+ type: string
+ 123Number:
+ type: integer
+ readOnly: true
+ xml:
+ name: Name
+ 200_response:
+ description: Model for testing model name starting with number
+ properties:
+ name:
+ type: integer
+ format: int32
+ class:
+ type: string
+ xml:
+ name: Name
+ ClassModel:
+ description: Model for testing model with "_class" property
+ properties:
+ _class:
+ type: string
+ Dog:
+ allOf:
+ - $ref: '#/components/schemas/Animal'
+ - type: object
+ properties:
+ breed:
+ type: string
+ Cat:
+ allOf:
+ - $ref: '#/components/schemas/Animal'
+ - $ref: '#/components/schemas/Address'
+ - type: object
+ properties:
+ declawed:
+ type: boolean
+ Address:
+ type: object
+ additionalProperties:
+ type: integer
+ Animal:
+ type: object
+ discriminator:
+ propertyName: className
+ required:
+ - className
+ properties:
+ className:
+ type: string
+ color:
+ type: string
+ default: red
+ AnimalFarm:
+ type: array
+ items:
+ $ref: '#/components/schemas/Animal'
+ format_test:
+ type: object
+ required:
+ - number
+ - byte
+ - date
+ - password
+ properties:
+ integer:
+ type: integer
+ maximum: 100
+ minimum: 10
+ multipleOf: 2
+ int32:
+ type: integer
+ format: int32
+ maximum: 200
+ minimum: 20
+ int64:
+ type: integer
+ format: int64
+ number:
+ maximum: 543.2
+ minimum: 32.1
+ type: number
+ multipleOf: 32.5
+ float:
+ type: number
+ format: float
+ maximum: 987.6
+ minimum: 54.3
+ double:
+ type: number
+ format: double
+ maximum: 123.4
+ minimum: 67.8
+ decimal:
+ type: string
+ format: number
+ string:
+ type: string
+ pattern: '/[a-z]/i'
+ byte:
+ type: string
+ format: byte
+ binary:
+ type: string
+ format: binary
+ date:
+ type: string
+ format: date
+ example: '2020-02-02'
+ dateTime:
+ type: string
+ format: date-time
+ example: '2007-12-03T10:15:30+01:00'
+ uuid:
+ type: string
+ format: uuid
+ example: 72f98069-206d-4f12-9f12-3d1e525a8e84
+ password:
+ type: string
+ format: password
+ maxLength: 64
+ minLength: 10
+ pattern_with_digits:
+ description: A string that is a 10 digit number. Can have leading zeros.
+ type: string
+ pattern: '^\d{10}$'
+ pattern_with_digits_and_delimiter:
+ description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+ type: string
+ pattern: '/^image_\d{1,3}$/i'
+ EnumClass:
+ type: string
+ default: '-efg'
+ enum:
+ - _abc
+ - '-efg'
+ - (xyz)
+ Enum_Test:
+ type: object
+ required:
+ - enum_string_required
+ properties:
+ enum_string:
+ type: string
+ enum:
+ - UPPER
+ - lower
+ - ''
+ enum_string_required:
+ type: string
+ enum:
+ - UPPER
+ - lower
+ - ''
+ enum_integer:
+ type: integer
+ format: int32
+ enum:
+ - 1
+ - -1
+ enum_integer_only:
+ type: integer
+ enum:
+ - 2
+ - -2
+ enum_number:
+ type: number
+ format: double
+ enum:
+ - 1.1
+ - -1.2
+ outerEnum:
+ $ref: '#/components/schemas/OuterEnum'
+ outerEnumInteger:
+ $ref: '#/components/schemas/OuterEnumInteger'
+ outerEnumDefaultValue:
+ $ref: '#/components/schemas/OuterEnumDefaultValue'
+ outerEnumIntegerDefaultValue:
+ $ref: '#/components/schemas/OuterEnumIntegerDefaultValue'
+ AdditionalPropertiesClass:
+ type: object
+ properties:
+ map_property:
+ type: object
+ additionalProperties:
+ type: string
+ map_of_map_property:
+ type: object
+ additionalProperties:
+ type: object
+ additionalProperties:
+ type: string
+ anytype_1: {}
+ map_with_undeclared_properties_anytype_1:
+ type: object
+ map_with_undeclared_properties_anytype_2:
+ type: object
+ properties: {}
+ map_with_undeclared_properties_anytype_3:
+ type: object
+ additionalProperties: true
+ empty_map:
+ type: object
+ description: an object with no declared properties and no undeclared
+ properties, hence it's an empty map.
+ additionalProperties: false
+ map_with_undeclared_properties_string:
+ type: object
+ additionalProperties:
+ type: string
+ MixedPropertiesAndAdditionalPropertiesClass:
+ type: object
+ properties:
+ uuid:
+ type: string
+ format: uuid
+ dateTime:
+ type: string
+ format: date-time
+ map:
+ type: object
+ additionalProperties:
+ $ref: '#/components/schemas/Animal'
+ List:
+ type: object
+ properties:
+ 123-list:
+ type: string
+ Client:
+ type: object
+ properties:
+ client:
+ type: string
+ ReadOnlyFirst:
+ type: object
+ properties:
+ bar:
+ type: string
+ readOnly: true
+ baz:
+ type: string
+ hasOnlyReadOnly:
+ type: object
+ properties:
+ bar:
+ type: string
+ readOnly: true
+ foo:
+ type: string
+ readOnly: true
+ Capitalization:
+ type: object
+ properties:
+ smallCamel:
+ type: string
+ CapitalCamel:
+ type: string
+ small_Snake:
+ type: string
+ Capital_Snake:
+ type: string
+ SCA_ETH_Flow_Points:
+ type: string
+ ATT_NAME:
+ description: |
+ Name of the pet
+ type: string
+ MapTest:
+ type: object
+ properties:
+ map_map_of_string:
+ type: object
+ additionalProperties:
+ type: object
+ additionalProperties:
+ type: string
+ map_of_enum_string:
+ type: object
+ additionalProperties:
+ type: string
+ enum:
+ - UPPER
+ - lower
+ direct_map:
+ type: object
+ additionalProperties:
+ type: boolean
+ indirect_map:
+ $ref: '#/components/schemas/StringBooleanMap'
+ ArrayTest:
+ type: object
+ properties:
+ array_of_string:
+ type: array
+ items:
+ type: string
+ array_array_of_integer:
+ type: array
+ items:
+ type: array
+ items:
+ type: integer
+ format: int64
+ array_array_of_model:
+ type: array
+ items:
+ type: array
+ items:
+ $ref: '#/components/schemas/ReadOnlyFirst'
+ NumberOnly:
+ type: object
+ properties:
+ JustNumber:
+ type: number
+ ArrayOfNumberOnly:
+ type: object
+ properties:
+ ArrayNumber:
+ type: array
+ items:
+ type: number
+ ArrayOfArrayOfNumberOnly:
+ type: object
+ properties:
+ ArrayArrayNumber:
+ type: array
+ items:
+ type: array
+ items:
+ type: number
+ EnumArrays:
+ type: object
+ properties:
+ just_symbol:
+ type: string
+ enum:
+ - '>='
+ - $
+ array_enum:
+ type: array
+ items:
+ type: string
+ enum:
+ - fish
+ - crab
+ OuterEnum:
+ nullable: true
+ type: string
+ enum:
+ - placed
+ - approved
+ - delivered
+ OuterEnumInteger:
+ type: integer
+ enum:
+ - 0
+ - 1
+ - 2
+ OuterEnumDefaultValue:
+ type: string
+ enum:
+ - placed
+ - approved
+ - delivered
+ default: placed
+ OuterEnumIntegerDefaultValue:
+ type: integer
+ enum:
+ - 0
+ - 1
+ - 2
+ default: 0
+ OuterComposite:
+ type: object
+ properties:
+ my_number:
+ $ref: '#/components/schemas/OuterNumber'
+ my_string:
+ $ref: '#/components/schemas/OuterString'
+ my_boolean:
+ $ref: '#/components/schemas/OuterBoolean'
+ OuterNumber:
+ type: number
+ OuterString:
+ type: string
+ OuterBoolean:
+ type: boolean
+ x-codegen-body-parameter-name: boolean_post_body
+ StringBooleanMap:
+ additionalProperties:
+ type: boolean
+ FileSchemaTestClass:
+ type: object
+ properties:
+ file:
+ $ref: '#/components/schemas/File'
+ files:
+ type: array
+ items:
+ $ref: '#/components/schemas/File'
+ File:
+ type: object
+ description: Must be named `File` for test.
+ properties:
+ sourceURI:
+ description: Test capitalization
+ type: string
+ _special_model.name_:
+ properties:
+ '$special[property.name]':
+ type: integer
+ format: int64
+ '_special_model.name_':
+ type: string
+ xml:
+ name: '$special[model.name]'
+ HealthCheckResult:
+ type: object
+ properties:
+ NullableMessage:
+ nullable: true
+ type: string
+ description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
+ NullableClass:
+ type: object
+ properties:
+ integer_prop:
+ type: integer
+ nullable: true
+ number_prop:
+ type: number
+ nullable: true
+ boolean_prop:
+ type: boolean
+ nullable: true
+ string_prop:
+ type: string
+ nullable: true
+ date_prop:
+ type: string
+ format: date
+ nullable: true
+ datetime_prop:
+ type: string
+ format: date-time
+ nullable: true
+ array_nullable_prop:
+ type: array
+ nullable: true
+ items:
+ type: object
+ array_and_items_nullable_prop:
+ type: array
+ nullable: true
+ items:
+ type: object
+ nullable: true
+ array_items_nullable:
+ type: array
+ items:
+ type: object
+ nullable: true
+ object_nullable_prop:
+ type: object
+ nullable: true
+ additionalProperties:
+ type: object
+ object_and_items_nullable_prop:
+ type: object
+ nullable: true
+ additionalProperties:
+ type: object
+ nullable: true
+ object_items_nullable:
+ type: object
+ additionalProperties:
+ type: object
+ nullable: true
+ additionalProperties:
+ type: object
+ nullable: true
+ fruit:
+ properties:
+ color:
+ type: string
+ oneOf:
+ - $ref: '#/components/schemas/apple'
+ - $ref: '#/components/schemas/banana'
+ # Below additionalProperties is set to false to validate the use
+ # case when a composed schema has additionalProperties set to false.
+ additionalProperties: false
+ apple:
+ type: object
+ properties:
+ cultivar:
+ type: string
+ pattern: ^[a-zA-Z\s]*$
+ origin:
+ type: string
+ pattern: /^[A-Z\s]*$/i
+ nullable: true
+ banana:
+ type: object
+ properties:
+ lengthCm:
+ type: number
+ mammal:
+ oneOf:
+ - $ref: '#/components/schemas/whale'
+ - $ref: '#/components/schemas/zebra'
+ - $ref: '#/components/schemas/Pig'
+ discriminator:
+ propertyName: className
+ whale:
+ type: object
+ properties:
+ hasBaleen:
+ type: boolean
+ hasTeeth:
+ type: boolean
+ className:
+ type: string
+ required:
+ - className
+ zebra:
+ type: object
+ properties:
+ type:
+ type: string
+ enum:
+ - plains
+ - mountain
+ - grevys
+ className:
+ type: string
+ required:
+ - className
+ additionalProperties: true
+ Pig:
+ oneOf:
+ - $ref: '#/components/schemas/BasquePig'
+ - $ref: '#/components/schemas/DanishPig'
+ discriminator:
+ propertyName: className
+ BasquePig:
+ type: object
+ properties:
+ className:
+ type: string
+ required:
+ - className
+ DanishPig:
+ type: object
+ properties:
+ className:
+ type: string
+ required:
+ - className
+ gmFruit:
+ properties:
+ color:
+ type: string
+ anyOf:
+ - $ref: '#/components/schemas/apple'
+ - $ref: '#/components/schemas/banana'
+ additionalProperties: false
+ fruitReq:
+ oneOf:
+ - type: 'null'
+ - $ref: '#/components/schemas/appleReq'
+ - $ref: '#/components/schemas/bananaReq'
+ additionalProperties: false
+ appleReq:
+ type: object
+ properties:
+ cultivar:
+ type: string
+ mealy:
+ type: boolean
+ required:
+ - cultivar
+ additionalProperties: false
+ bananaReq:
+ type: object
+ properties:
+ lengthCm:
+ type: number
+ sweet:
+ type: boolean
+ required:
+ - lengthCm
+ additionalProperties: false
+ # go-experimental is unable to make Triangle and Quadrilateral models
+ # correctly https://github.com/OpenAPITools/openapi-generator/issues/6149
+ Drawing:
+ type: object
+ properties:
+ mainShape:
+ # A property whose value is a 'oneOf' type, and the type is referenced instead
+ # of being defined inline. The value cannot be null.
+ $ref: '#/components/schemas/Shape'
+ shapeOrNull:
+ # A property whose value is a 'oneOf' type, and the type is referenced instead
+ # of being defined inline. The value may be null because ShapeOrNull has 'null'
+ # type as a child schema of 'oneOf'.
+ $ref: '#/components/schemas/ShapeOrNull'
+ nullableShape:
+ # A property whose value is a 'oneOf' type, and the type is referenced instead
+ # of being defined inline. The value may be null because NullableShape has the
+ # 'nullable: true' attribute. For this specific scenario this is exactly the
+ # same thing as 'shapeOrNull'.
+ $ref: '#/components/schemas/NullableShape'
+ shapes:
+ type: array
+ items:
+ $ref: '#/components/schemas/Shape'
+ additionalProperties:
+ # Here the additional properties are specified using a referenced schema.
+ # This is just to validate the generated code works when using $ref
+ # under 'additionalProperties'.
+ $ref: '#/components/schemas/fruit'
+ Shape:
+ oneOf:
+ - $ref: '#/components/schemas/Triangle'
+ - $ref: '#/components/schemas/Quadrilateral'
+ discriminator:
+ propertyName: shapeType
+ ShapeOrNull:
+ description: The value may be a shape or the 'null' value.
+ This is introduced in OAS schema >= 3.1.
+ oneOf:
+ - type: 'null'
+ - $ref: '#/components/schemas/Triangle'
+ - $ref: '#/components/schemas/Quadrilateral'
+ discriminator:
+ propertyName: shapeType
+ NullableShape:
+ description: The value may be a shape or the 'null' value.
+ The 'nullable' attribute was introduced in OAS schema >= 3.0
+ and has been deprecated in OAS schema >= 3.1.
+ oneOf:
+ - $ref: '#/components/schemas/Triangle'
+ - $ref: '#/components/schemas/Quadrilateral'
+ discriminator:
+ propertyName: shapeType
+ nullable: true
+ ShapeInterface:
+ properties:
+ shapeType:
+ type: string
+ required:
+ - shapeType
+ TriangleInterface:
+ properties:
+ triangleType:
+ type: string
+ required:
+ - triangleType
+ Triangle:
+ oneOf:
+ - $ref: '#/components/schemas/EquilateralTriangle'
+ - $ref: '#/components/schemas/IsoscelesTriangle'
+ - $ref: '#/components/schemas/ScaleneTriangle'
+ discriminator:
+ propertyName: triangleType
+ # Note: the 'additionalProperties' keyword is not specified, which is
+ # equivalent to allowing undeclared properties of any type.
+ EquilateralTriangle:
+ allOf:
+ - $ref: '#/components/schemas/ShapeInterface'
+ - $ref: '#/components/schemas/TriangleInterface'
+ IsoscelesTriangle:
+ allOf:
+ - $ref: '#/components/schemas/ShapeInterface'
+ - $ref: '#/components/schemas/TriangleInterface'
+ additionalProperties: false
+ ScaleneTriangle:
+ allOf:
+ - $ref: '#/components/schemas/ShapeInterface'
+ - $ref: '#/components/schemas/TriangleInterface'
+ QuadrilateralInterface:
+ properties:
+ quadrilateralType:
+ type: string
+ required:
+ - quadrilateralType
+ Quadrilateral:
+ oneOf:
+ - $ref: '#/components/schemas/SimpleQuadrilateral'
+ - $ref: '#/components/schemas/ComplexQuadrilateral'
+ discriminator:
+ propertyName: quadrilateralType
+ SimpleQuadrilateral:
+ allOf:
+ - $ref: '#/components/schemas/ShapeInterface'
+ - $ref: '#/components/schemas/QuadrilateralInterface'
+ ComplexQuadrilateral:
+ allOf:
+ - $ref: '#/components/schemas/ShapeInterface'
+ - $ref: '#/components/schemas/QuadrilateralInterface'
+ GrandparentAnimal:
+ type: object
+ required:
+ - pet_type
+ properties:
+ pet_type:
+ type: string
+ discriminator:
+ propertyName: pet_type
+ ParentPet:
+ type: object
+ allOf:
+ - $ref: '#/components/schemas/GrandparentAnimal'
+ ChildCat:
+ allOf:
+ - $ref: '#/components/schemas/ParentPet'
+ - type: object
+ properties:
+ name:
+ type: string
+ pet_type:
+ x-enum-as-string: true
+ type: string
+ enum:
+ - ChildCat
+ default: ChildCat
+ ArrayOfEnums:
+ type: array
+ items:
+ $ref: '#/components/schemas/OuterEnum'
+ DateTimeTest:
+ type: string
+ default: '2010-01-01T10:10:10.000111+01:00'
+ example: '2010-01-01T10:10:10.000111+01:00'
+ format: date-time
+ DeprecatedObject:
+ type: object
+ deprecated: true
+ properties:
+ name:
+ type: string
+ ObjectWithDeprecatedFields:
+ type: object
+ properties:
+ uuid:
+ type: string
+ id:
+ type: number
+ deprecated: true
+ deprecatedRef:
+ $ref: '#/components/schemas/DeprecatedObject'
+ bars:
+ type: array
+ deprecated: true
+ items:
+ $ref: '#/components/schemas/Bar'
+ PetStatusFilter:
+ type: string
+ enum:
+ - available
+ - pending
+ - sold
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index b9e2888f551..7695348b208 100644
--- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -2160,3 +2160,22 @@ components:
StringArrayItem:
type: string
format: string
+ Activity:
+ description: "test map of maps"
+ type: object
+ properties:
+ activity_outputs:
+ type: object
+ additionalProperties:
+ $ref: '#/components/schemas/ActivityOutputRepresentation'
+ ActivityOutputRepresentation:
+ type: array
+ items:
+ $ref: '#/components/schemas/ActivityOutputElementRepresentation'
+ ActivityOutputElementRepresentation:
+ type: object
+ properties:
+ prop1:
+ type: string
+ prop2:
+ type: object
diff --git a/modules/openapi-generator/src/test/resources/3_0/enum.yaml b/modules/openapi-generator/src/test/resources/3_0/enum.yaml
new file mode 100644
index 00000000000..e0cb0f881a8
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/enum.yaml
@@ -0,0 +1,32 @@
+openapi: 3.0.0
+info:
+ title: Sample API
+ description: API description in Markdown.
+ version: 1.0.0
+paths:
+ /ponies:
+ get:
+ summary: Returns all animals.
+ description: Optional extended description in Markdown.
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pony'
+components:
+ schemas:
+ Pony:
+ type: object
+ properties:
+ type:
+ $ref: '#/components/schemas/Type'
+ Type:
+ type: string
+ enum:
+ - Earth
+ - Pegasi
+ - Unicorn
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/3_0/exploded-query-param-array.yaml b/modules/openapi-generator/src/test/resources/3_0/exploded-query-param-array.yaml
new file mode 100644
index 00000000000..a46d6b753e0
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/exploded-query-param-array.yaml
@@ -0,0 +1,41 @@
+openapi: 3.0.3
+info:
+ title: Exploded query param array
+ description: "Exploded query params"
+ version: "1.0.0"
+servers:
+ - url: localhost:8080
+paths:
+ /api:
+ get:
+ operationId: GetSomeValue
+ parameters:
+ - in: query
+ name: QueryObject
+ explode: true
+ style: form
+ schema:
+ type: object
+ properties:
+ values:
+ type: array
+ items:
+ type: string
+ responses:
+ '200':
+ description: Some return value
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/SomeReturnValue'
+ example:
+ someValue: value
+components:
+ schemas:
+ SomeReturnValue:
+ type: object
+ required:
+ - someValue
+ properties:
+ someValue:
+ type: string
diff --git a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index 7b11b81e32a..4c7ed5960e1 100644
--- a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -2023,3 +2023,8 @@ components:
additionalProperties:
type: string
format: binary
+ OneOfPrimitiveTypes:
+ oneOf:
+ - type: string
+ - format: date-time
+ type: string
diff --git a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-problem-details.yaml b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-problem-details.yaml
new file mode 100644
index 00000000000..c4385355570
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-problem-details.yaml
@@ -0,0 +1,61 @@
+openapi: 3.0.0
+info:
+ description: >-
+ This spec is mainly for testing Petstore server and contains fake endpoints,
+ models. Please do not use this for any other purpose. Special characters: "
+ \
+ version: 1.0.0
+ title: OpenAPI Petstore
+ license:
+ name: Apache-2.0
+ url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
+tags:
+ - name: pet
+ description: Everything about your Pets
+paths:
+ /foo:
+ get:
+ tags:
+ - pet
+ responses:
+ "200":
+ description: response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Foo'
+ "404":
+ description: not found
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RestServiceError'
+ "422":
+ description: validation error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RestServiceError'
+components:
+ schemas:
+ Foo:
+ type: string
+ default: foo
+ # RFC7807 Problem Detail
+ RestServiceError:
+ properties:
+ type:
+ description: " A URI reference that identifies the problem type"
+ type: string
+ title:
+ description: "A short, human-readable summary of the problem type."
+ type: string
+ status:
+ description: "The HTTP Status Code"
+ type: integer
+ detail:
+ description: "A human-readable explanation specific to this occurrence of the problem."
+ type: string
+ instance:
+ description: "A unique URI that identifies the specific occurrence of the problem."
+ type: string
diff --git a/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-for-testing.yaml
index 7384758e953..4219f4004a2 100644
--- a/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-for-testing.yaml
@@ -72,7 +72,10 @@ paths:
- 'write:pets'
- 'read:pets'
requestBody:
- $ref: '#/components/schemas/Pet'
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
/pet/findByStatus:
get:
tags:
diff --git a/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-no-multipart-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-no-multipart-for-testing.yaml
index bcf99067930..3a10351b615 100644
--- a/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-no-multipart-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/helidon/petstore-no-multipart-for-testing.yaml
@@ -72,7 +72,10 @@ paths:
- 'write:pets'
- 'read:pets'
requestBody:
- $ref: '#/components/schemas/Pet'
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
/pet/findByStatus:
get:
tags:
diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-complex-headers.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-complex-headers.yaml
index a21b6b4e0d0..daf9e82cf1d 100644
--- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-complex-headers.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-complex-headers.yaml
@@ -36,13 +36,13 @@ paths:
- name: header1
in: header
schema:
- $ref: '#/components/requestBodies/Pet'
+ $ref: '#/components/schemas/Pet'
- name: header2
in: header
schema:
type: array
items:
- $ref: '#/components/requestBodies/Pet'
+ $ref: '#/components/schemas/Pet'
- name: Accept
in: header
schema:
diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index deef554542d..f6c3f327b18 100644
--- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -2978,4 +2978,17 @@ components:
$ref: "#/components/schemas/ArrayWithValidationsInItems"
required:
- from
- - "!reference"
\ No newline at end of file
+ - "!reference"
+ ObjectWithOptionalTestProp:
+ type: object
+ properties:
+ test:
+ type: string
+ ObjectWithAllOfWithReqTestPropFromUnsetAddProp:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalTestProp'
+ - type: object
+ required: [ test ]
+ properties:
+ name:
+ type: string
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml
index 55bedd6d474..86ef6839356 100644
--- a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml
@@ -1121,3 +1121,71 @@ components:
required:
- className
- url_property
+ format_test:
+ type: object
+ required:
+ - number
+ - byte
+ - date
+ - password
+ properties:
+ integer:
+ type: integer
+ maximum: 100
+ minimum: 10
+ int32:
+ type: integer
+ format: int32
+ maximum: 200
+ minimum: 20
+ int64:
+ type: integer
+ format: int64
+ number:
+ maximum: 543.2
+ minimum: 32.1
+ type: number
+ float:
+ type: number
+ format: float
+ maximum: 987.6
+ minimum: 54.3
+ double:
+ type: number
+ format: double
+ maximum: 123.4
+ minimum: 67.8
+ string:
+ type: string
+ pattern: '/[a-z]/i'
+ byte:
+ type: string
+ format: byte
+ binary:
+ type: string
+ format: binary
+ date:
+ type: string
+ format: date
+ default: 2019-07-19
+ dateTime:
+ type: string
+ format: date-time
+ default: 2015-10-28T14:38:02Z
+ uuid:
+ type: string
+ format: uuid
+ example: 72f98069-206d-4f12-9f12-3d1e525a8e84
+ password:
+ type: string
+ format: password
+ maxLength: 64
+ minLength: 10
+ pattern_with_digits:
+ description: A string that is a 10 digit number. Can have leading zeros.
+ type: string
+ pattern: '^\d{10}$'
+ pattern_with_digits_and_delimiter:
+ description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+ type: string
+ pattern: '/^image_\d{1,3}$/i'
diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
index deaf6dd0860..0c09dee9414 100644
--- a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
@@ -858,4 +858,23 @@ components:
async:
type: boolean
super:
- type: boolean
\ No newline at end of file
+ type: boolean
+ OptionalTesting:
+ description: Test handling of optional and nullable fields
+ type: object
+ required:
+ - required_nonnull
+ - required_nullable
+ properties:
+ optional_nonnull:
+ type: string
+ nullable: false
+ required_nonnull:
+ type: string
+ nullable: false
+ optional_nullable:
+ type: string
+ nullable: true
+ required_nullable:
+ type: string
+ nullable: true
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-separate-models-and-api-inheritance.yaml b/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-separate-models-and-api-inheritance.yaml
index d784ef25ba5..55262b783a3 100644
--- a/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-separate-models-and-api-inheritance.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-separate-models-and-api-inheritance.yaml
@@ -33,3 +33,63 @@ components:
type: object
allOf:
- "$ref": "#/components/schemas/AbstractUserDto"
+ AbstractFlatStockPickOrderBaseDto:
+ required:
+ - externalDmsCustomerOrderId
+ - id
+ - partInformation
+ - pickedQuantity
+ - quantity
+ - type
+ - warehouseId
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ created:
+ type: string
+ format: date-time
+ lastModified:
+ type: string
+ format: date-time
+ warehouseId:
+ type: integer
+ format: int64
+ quantity:
+ type: number
+ stockLocation:
+ maxLength: 31
+ minLength: 0
+ type: string
+ barcode:
+ maxLength: 31
+ minLength: 1
+ type: string
+ pickedQuantity:
+ type: number
+ type:
+ type: string
+ discriminator:
+ propertyName: type
+ mapping:
+ STOCK_PICK_ORDER: '#/components/schemas/FlatStockPickOrderDto'
+ FlatStockPickOrderDto:
+ required:
+ - externalDmsCustomerOrderId
+ - id
+ - partInformation
+ - pickedQuantity
+ - quantity
+ - warehouseId
+ type: object
+ allOf:
+ - $ref: '#/components/schemas/AbstractFlatStockPickOrderBaseDto'
+ - type: object
+ properties:
+ blockedUntil:
+ type: string
+ format: date-time
+ blockedById:
+ type: integer
+ format: int64
diff --git a/pom.xml b/pom.xml
index 9990cddbc7a..09f7a3db8c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1333,10 +1333,8 @@
samples/client/petstore/go
samples/openapi3/client/petstore/go
- samples/server/petstore/go-api-server
- samples/server/petstore/go-echo-server
@@ -1490,7 +1488,7 @@
1.4
2.11.0
3.12.0
- 1.9
+ 1.10.0
1.3.0
1.0.2
4.9.10
@@ -1498,6 +1496,7 @@
30.1.1-jre
4.2.1
2.10.0
+ 2.13.4.2
2.13.4
0.8.7
1.14
@@ -1519,7 +1518,7 @@
3.0.0-M6
7.22.0
io.swagger.parser.v3
- 2.1.1
+ 2.1.6
7.5
1.34
3.4.3
diff --git a/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs
index 3760fe4455b..29a02766057 100644
--- a/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -13,6 +13,7 @@ using System.Collections;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
@@ -116,6 +117,8 @@ namespace Org.OpenAPITools.Client
return boolean ? "true" : "false";
if (obj is ICollection collection)
return string.Join(",", collection.Cast());
+ if (obj is Enum && HasEnumMemberAttrValue(obj))
+ return GetEnumMemberAttrValue(obj);
return Convert.ToString(obj, CultureInfo.InvariantCulture);
}
@@ -214,5 +217,40 @@ namespace Org.OpenAPITools.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
+
+ ///
+ /// Is the Enum decorated with EnumMember Attribute
+ ///
+ ///
+ /// true if found
+ private static bool HasEnumMemberAttrValue(object enumVal)
+ {
+ if (enumVal == null)
+ throw new ArgumentNullException(nameof(enumVal));
+ var enumType = enumVal.GetType();
+ var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
+ var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType().FirstOrDefault();
+ if (attr != null) return true;
+ return false;
+ }
+
+ ///
+ /// Get the EnumMember value
+ ///
+ ///
+ /// EnumMember value as string otherwise null
+ private static string GetEnumMemberAttrValue(object enumVal)
+ {
+ if (enumVal == null)
+ throw new ArgumentNullException(nameof(enumVal));
+ var enumType = enumVal.GetType();
+ var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
+ var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType().FirstOrDefault();
+ if (attr != null)
+ {
+ return attr.Value;
+ }
+ return null;
+ }
}
}
diff --git a/samples/client/others/java/okhttp-gson-streaming/build.gradle b/samples/client/others/java/okhttp-gson-streaming/build.gradle
index 16f1394bf96..ad54274be84 100644
--- a/samples/client/others/java/okhttp-gson-streaming/build.gradle
+++ b/samples/client/others/java/okhttp-gson-streaming/build.gradle
@@ -13,7 +13,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
- classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.3.0'
+ classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0'
}
}
@@ -65,7 +65,7 @@ if(hasProperty('target') && target == 'android') {
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
- artifacts.add('archives', task);
+ artifacts.add('archives', task)
}
}
@@ -106,20 +106,20 @@ ext {
}
dependencies {
- implementation 'io.swagger:swagger-annotations:1.6.5'
+ implementation 'io.swagger:swagger-annotations:1.6.8'
implementation "com.google.code.findbugs:jsr305:3.0.2"
- implementation 'com.squareup.okhttp3:okhttp:4.9.3'
- implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
- implementation 'com.google.code.gson:gson:2.9.0'
+ implementation 'com.squareup.okhttp3:okhttp:4.10.0'
+ implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
+ implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.8.5'
implementation 'javax.ws.rs:jsr311-api:1.1.1'
implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1'
- implementation 'org.openapitools:jackson-databind-nullable:0.2.3'
+ implementation 'org.openapitools:jackson-databind-nullable:0.2.4'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
- testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testImplementation 'org.mockito:mockito-core:3.12.4'
- testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
}
javadoc {
diff --git a/samples/client/others/java/okhttp-gson-streaming/build.sbt b/samples/client/others/java/okhttp-gson-streaming/build.sbt
index 141ae383b38..544922ffed0 100644
--- a/samples/client/others/java/okhttp-gson-streaming/build.sbt
+++ b/samples/client/others/java/okhttp-gson-streaming/build.sbt
@@ -10,18 +10,19 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.6.5",
- "com.squareup.okhttp3" % "okhttp" % "4.9.3",
- "com.squareup.okhttp3" % "logging-interceptor" % "4.9.3",
- "com.google.code.gson" % "gson" % "2.9.0",
+ "com.squareup.okhttp3" % "okhttp" % "4.10.0",
+ "com.squareup.okhttp3" % "logging-interceptor" % "4.10.0",
+ "com.google.code.gson" % "gson" % "2.9.1",
"org.apache.commons" % "commons-lang3" % "3.12.0",
"javax.ws.rs" % "jsr311-api" % "1.1.1",
"javax.ws.rs" % "javax.ws.rs-api" % "2.1.1",
- "org.openapitools" % "jackson-databind-nullable" % "0.2.3",
+ "org.openapitools" % "jackson-databind-nullable" % "0.2.4",
"io.gsonfire" % "gson-fire" % "1.8.5" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
- "org.junit.jupiter" % "junit-jupiter-api" % "5.8.2" % "test",
- "com.novocode" % "junit-interface" % "0.10" % "test"
+ "org.junit.jupiter" % "junit-jupiter-api" % "5.9.1" % "test",
+ "com.novocode" % "junit-interface" % "0.10" % "test",
+ "org.mockito" % "mockito-core" % "3.12.4" % "test"
)
)
diff --git a/samples/client/others/java/okhttp-gson-streaming/pom.xml b/samples/client/others/java/okhttp-gson-streaming/pom.xml
index a9fb0ce7a3a..bdfd7504024 100644
--- a/samples/client/others/java/okhttp-gson-streaming/pom.xml
+++ b/samples/client/others/java/okhttp-gson-streaming/pom.xml
@@ -50,7 +50,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.0.0
+ 3.1.0
enforce-maven
@@ -93,6 +93,7 @@
maven-dependency-plugin
+ 3.3.0
package
@@ -109,7 +110,7 @@
org.apache.maven.plugins
maven-jar-plugin
- 3.2.0
+ 3.3.0
@@ -123,7 +124,7 @@
org.codehaus.mojo
build-helper-maven-plugin
- 3.2.0
+ 3.3.0
add_sources
@@ -154,7 +155,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.3.2
+ 3.4.1
attach-javadocs
@@ -177,7 +178,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.2.0
+ 3.2.1
attach-sources
@@ -340,17 +341,17 @@
${java.version}
1.8.5
1.6.5
- 4.9.3
- 2.9.0
+ 4.10.0
+ 2.9.1
3.12.0
- 0.2.3
+ 0.2.4
1.3.5
- 5.8.2
- 1.6.2
+ 5.9.1
+ 1.9.1
3.12.4
2.1.1
1.1.1
UTF-8
- 2.21.0
+ 2.27.2
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java
index 3e8b94b1584..a21641307c5 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java
@@ -278,7 +278,7 @@ public class ApiClient {
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setDateFormat(DateFormat dateFormat) {
- this.json.setDateFormat(dateFormat);
+ JSON.setDateFormat(dateFormat);
return this;
}
@@ -289,7 +289,7 @@ public class ApiClient {
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setSqlDateFormat(DateFormat dateFormat) {
- this.json.setSqlDateFormat(dateFormat);
+ JSON.setSqlDateFormat(dateFormat);
return this;
}
@@ -300,7 +300,7 @@ public class ApiClient {
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
- this.json.setOffsetDateTimeFormat(dateFormat);
+ JSON.setOffsetDateTimeFormat(dateFormat);
return this;
}
@@ -311,7 +311,7 @@ public class ApiClient {
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
- this.json.setLocalDateFormat(dateFormat);
+ JSON.setLocalDateFormat(dateFormat);
return this;
}
@@ -322,7 +322,7 @@ public class ApiClient {
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setLenientOnJson(boolean lenientOnJson) {
- this.json.setLenientOnJson(lenientOnJson);
+ JSON.setLenientOnJson(lenientOnJson);
return this;
}
@@ -583,7 +583,7 @@ public class ApiClient {
return "";
} else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) {
//Serialize to json string and remove the " enclosing characters
- String jsonStr = json.serialize(param);
+ String jsonStr = JSON.serialize(param);
return jsonStr.substring(1, jsonStr.length() - 1);
} else if (param instanceof Collection) {
StringBuilder b = new StringBuilder();
@@ -591,7 +591,7 @@ public class ApiClient {
if (b.length() > 0) {
b.append(",");
}
- b.append(String.valueOf(o));
+ b.append(o);
}
return b.toString();
} else {
@@ -842,7 +842,7 @@ public class ApiClient {
contentType = "application/json";
}
if (isJsonMime(contentType)) {
- return json.deserialize(respBody, returnType);
+ return JSON.deserialize(respBody, returnType);
} else if (returnType.equals(String.class)) {
// Expecting string, return the raw response body.
return (T) respBody;
@@ -876,13 +876,13 @@ public class ApiClient {
} else if (isJsonMime(contentType)) {
String content;
if (obj != null) {
- content = json.serialize(obj);
+ content = JSON.serialize(obj);
} else {
content = null;
}
return RequestBody.create(content, MediaType.parse(contentType));
} else if (obj instanceof String) {
- return RequestBody.create(MediaType.parse(contentType), (String) obj);
+ return RequestBody.create((String) obj, MediaType.parse(contentType));
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
@@ -1378,7 +1378,7 @@ public class ApiClient {
} else {
String content;
if (obj != null) {
- content = json.serialize(obj);
+ content = JSON.serialize(obj);
} else {
content = null;
}
@@ -1456,7 +1456,7 @@ public class ApiClient {
KeyStore caKeyStore = newEmptyKeyStore(password);
int index = 0;
for (Certificate certificate : certificates) {
- String certificateAlias = "ca" + Integer.toString(index++);
+ String certificateAlias = "ca" + (index++);
caKeyStore.setCertificateEntry(certificateAlias, certificate);
}
trustManagerFactory.init(caKeyStore);
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ServerConfiguration.java
index ca5c1187edf..59edc528a44 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -42,7 +42,7 @@ public class ServerConfiguration {
throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + ".");
}
}
- url = url.replaceAll("\\{" + name + "\\}", value);
+ url = url.replace("{" + name + "}", value);
}
return url;
}
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java
index 807f4f240ad..72a4e7910c9 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java
@@ -133,15 +133,12 @@ public class PingApi {
@SuppressWarnings("rawtypes")
private okhttp3.Call getPingValidateBeforeCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException {
-
// verify the required parameter 'petId' is set
if (petId == null) {
throw new ApiException("Missing the required parameter 'petId' when calling getPing(Async)");
}
-
- okhttp3.Call localVarCall = getPingCall(petId, name, status, _callback);
- return localVarCall;
+ return getPingCall(petId, name, status, _callback);
}
@@ -321,10 +318,7 @@ public class PingApi {
@SuppressWarnings("rawtypes")
private okhttp3.Call postPingValidateBeforeCall(SomeObj someObj, final ApiCallback _callback) throws ApiException {
-
-
- okhttp3.Call localVarCall = postPingCall(someObj, _callback);
- return localVarCall;
+ return postPingCall(someObj, _callback);
}
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java
index 52b25858f94..dee22d566b0 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java
@@ -38,6 +38,7 @@ import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
diff --git a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/.openapi-generator/FILES b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/.openapi-generator/FILES
index 54773e481d6..d848128b34b 100644
--- a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/.openapi-generator/FILES
+++ b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/.openapi-generator/FILES
@@ -6,8 +6,11 @@ common.ts
configuration.ts
git_push.sh
index.ts
+model/abstract-flat-stock-pick-order-base-dto.ts
model/abstract-user-dto.ts
model/branch-dto.ts
+model/flat-stock-pick-order-dto-all-of.ts
+model/flat-stock-pick-order-dto.ts
model/index.ts
model/internal-authenticated-user-dto.ts
model/remote-authenticated-user-dto.ts
diff --git a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/abstract-flat-stock-pick-order-base-dto.ts b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/abstract-flat-stock-pick-order-base-dto.ts
new file mode 100644
index 00000000000..9604cf4c300
--- /dev/null
+++ b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/abstract-flat-stock-pick-order-base-dto.ts
@@ -0,0 +1,78 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+
+/**
+ *
+ * @export
+ * @interface AbstractFlatStockPickOrderBaseDto
+ */
+export interface AbstractFlatStockPickOrderBaseDto {
+ /**
+ *
+ * @type {number}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'id': number;
+ /**
+ *
+ * @type {string}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'created'?: string;
+ /**
+ *
+ * @type {string}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'lastModified'?: string;
+ /**
+ *
+ * @type {number}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'warehouseId': number;
+ /**
+ *
+ * @type {number}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'quantity': number;
+ /**
+ *
+ * @type {string}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'stockLocation'?: string;
+ /**
+ *
+ * @type {string}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'barcode'?: string;
+ /**
+ *
+ * @type {number}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'pickedQuantity': number;
+ /**
+ *
+ * @type {string}
+ * @memberof AbstractFlatStockPickOrderBaseDto
+ */
+ 'type': string;
+}
+
diff --git a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/flat-stock-pick-order-dto-all-of.ts b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/flat-stock-pick-order-dto-all-of.ts
new file mode 100644
index 00000000000..217dff00486
--- /dev/null
+++ b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/flat-stock-pick-order-dto-all-of.ts
@@ -0,0 +1,36 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+
+/**
+ *
+ * @export
+ * @interface FlatStockPickOrderDtoAllOf
+ */
+export interface FlatStockPickOrderDtoAllOf {
+ /**
+ *
+ * @type {string}
+ * @memberof FlatStockPickOrderDtoAllOf
+ */
+ 'blockedUntil'?: string;
+ /**
+ *
+ * @type {number}
+ * @memberof FlatStockPickOrderDtoAllOf
+ */
+ 'blockedById'?: number;
+}
+
diff --git a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/flat-stock-pick-order-dto.ts b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/flat-stock-pick-order-dto.ts
new file mode 100644
index 00000000000..f473a8d58b2
--- /dev/null
+++ b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/flat-stock-pick-order-dto.ts
@@ -0,0 +1,29 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+// May contain unused imports in some cases
+// @ts-ignore
+import { AbstractFlatStockPickOrderBaseDto } from './abstract-flat-stock-pick-order-base-dto';
+// May contain unused imports in some cases
+// @ts-ignore
+import { FlatStockPickOrderDtoAllOf } from './flat-stock-pick-order-dto-all-of';
+
+/**
+ * @type FlatStockPickOrderDto
+ * @export
+ */
+export type FlatStockPickOrderDto = AbstractFlatStockPickOrderBaseDto & FlatStockPickOrderDtoAllOf;
+
+
diff --git a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/index.ts b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/index.ts
index f92a1d9cadf..3642df8da68 100644
--- a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/index.ts
+++ b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/index.ts
@@ -1,4 +1,7 @@
+export * from './abstract-flat-stock-pick-order-base-dto';
export * from './abstract-user-dto';
export * from './branch-dto';
+export * from './flat-stock-pick-order-dto';
+export * from './flat-stock-pick-order-dto-all-of';
export * from './internal-authenticated-user-dto';
export * from './remote-authenticated-user-dto';
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/.gitignore b/samples/client/others/typescript-rxjs/allOf-composition/.gitignore
new file mode 100644
index 00000000000..149b5765472
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/.gitignore
@@ -0,0 +1,4 @@
+wwwroot/*.js
+node_modules
+typings
+dist
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/.openapi-generator-ignore b/samples/client/others/typescript-rxjs/allOf-composition/.openapi-generator-ignore
new file mode 100644
index 00000000000..7484ee590a3
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/.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/others/typescript-rxjs/allOf-composition/.openapi-generator/FILES b/samples/client/others/typescript-rxjs/allOf-composition/.openapi-generator/FILES
new file mode 100644
index 00000000000..89276d499a4
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/.openapi-generator/FILES
@@ -0,0 +1,15 @@
+.gitignore
+apis/DefaultApi.ts
+apis/index.ts
+index.ts
+models/Hero.ts
+models/Human.ts
+models/SuperBaby.ts
+models/SuperBabyAllOf.ts
+models/SuperBoy.ts
+models/SuperBoyAllOf.ts
+models/SuperMan.ts
+models/index.ts
+runtime.ts
+servers.ts
+tsconfig.json
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/.openapi-generator/VERSION b/samples/client/others/typescript-rxjs/allOf-composition/.openapi-generator/VERSION
new file mode 100644
index 00000000000..d6b4ec4aa78
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/.openapi-generator/VERSION
@@ -0,0 +1 @@
+6.3.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/apis/DefaultApi.ts b/samples/client/others/typescript-rxjs/allOf-composition/apis/DefaultApi.ts
new file mode 100644
index 00000000000..50216e7be70
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/apis/DefaultApi.ts
@@ -0,0 +1,44 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+import type { Observable } from 'rxjs';
+import type { AjaxResponse } from 'rxjs/ajax';
+import { BaseAPI, throwIfNullOrUndefined, encodeURI } from '../runtime';
+import type { OperationOpts } from '../runtime';
+import type {
+ SuperMan,
+} from '../models';
+
+export interface ListRequest {
+ personId: string;
+}
+
+/**
+ * no description
+ */
+export class DefaultApi extends BaseAPI {
+
+ /**
+ */
+ list({ personId }: ListRequest): Observable
+ list({ personId }: ListRequest, opts?: OperationOpts): Observable>
+ list({ personId }: ListRequest, opts?: OperationOpts): Observable> {
+ throwIfNullOrUndefined(personId, 'personId', 'list');
+
+ return this.request({
+ url: '/person/display/{personId}'.replace('{personId}', encodeURI(personId)),
+ method: 'GET',
+ }, opts?.responseOpts);
+ };
+
+}
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/apis/index.ts b/samples/client/others/typescript-rxjs/allOf-composition/apis/index.ts
new file mode 100644
index 00000000000..a1aa4698ff2
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/apis/index.ts
@@ -0,0 +1 @@
+export * from './DefaultApi';
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/index.ts b/samples/client/others/typescript-rxjs/allOf-composition/index.ts
new file mode 100644
index 00000000000..b9e2f3ca3b7
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/index.ts
@@ -0,0 +1,4 @@
+export * from './runtime';
+export * from './servers';
+export * from './apis';
+export * from './models';
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/Hero.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/Hero.ts
new file mode 100644
index 00000000000..98c39a6ecd6
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/Hero.ts
@@ -0,0 +1,30 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+/**
+ * Hero
+ * @export
+ * @interface Hero
+ */
+export interface Hero {
+ /**
+ * @type {number}
+ * @memberof Hero
+ */
+ reward?: number;
+ /**
+ * @type {string}
+ * @memberof Hero
+ */
+ origin: string;
+}
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts
new file mode 100644
index 00000000000..2122f4c7a13
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts
@@ -0,0 +1,30 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+/**
+ * Human
+ * @export
+ * @interface Human
+ */
+export interface Human {
+ /**
+ * @type {number}
+ * @memberof Human
+ */
+ id: number;
+ /**
+ * @type {string}
+ * @memberof Human
+ */
+ name?: string;
+}
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBaby.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBaby.ts
new file mode 100644
index 00000000000..1647f9aa201
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBaby.ts
@@ -0,0 +1,23 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+import type {
+ Human,
+ SuperBabyAllOf,
+} from './';
+
+/**
+ * @type SuperBaby
+ * @export
+ */
+export type SuperBaby = Human & SuperBabyAllOf;
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBabyAllOf.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBabyAllOf.ts
new file mode 100644
index 00000000000..459c28d0f4e
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBabyAllOf.ts
@@ -0,0 +1,29 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+/**
+ * @export
+ * @interface SuperBabyAllOf
+ */
+export interface SuperBabyAllOf {
+ /**
+ * @type {string}
+ * @memberof SuperBabyAllOf
+ */
+ gender?: string;
+ /**
+ * @type {number}
+ * @memberof SuperBabyAllOf
+ */
+ age?: number;
+}
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBoy.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBoy.ts
new file mode 100644
index 00000000000..668faac8d17
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBoy.ts
@@ -0,0 +1,23 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+import type {
+ Human,
+ SuperBoyAllOf,
+} from './';
+
+/**
+ * @type SuperBoy
+ * @export
+ */
+export type SuperBoy = Human & SuperBoyAllOf;
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBoyAllOf.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBoyAllOf.ts
new file mode 100644
index 00000000000..26003b90c7d
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperBoyAllOf.ts
@@ -0,0 +1,29 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+/**
+ * @export
+ * @interface SuperBoyAllOf
+ */
+export interface SuperBoyAllOf {
+ /**
+ * @type {string}
+ * @memberof SuperBoyAllOf
+ */
+ category?: string;
+ /**
+ * @type {number}
+ * @memberof SuperBoyAllOf
+ */
+ level: number;
+}
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/SuperMan.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperMan.ts
new file mode 100644
index 00000000000..8548fb03519
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/SuperMan.ts
@@ -0,0 +1,24 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+import type {
+ Hero,
+ Human,
+ SuperBoyAllOf,
+} from './';
+
+/**
+ * @type SuperMan
+ * @export
+ */
+export type SuperMan = Hero & Human & SuperBoyAllOf;
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/index.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/index.ts
new file mode 100644
index 00000000000..d57bd6be7b9
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/models/index.ts
@@ -0,0 +1,7 @@
+export * from './Hero';
+export * from './Human';
+export * from './SuperBaby';
+export * from './SuperBabyAllOf';
+export * from './SuperBoy';
+export * from './SuperBoyAllOf';
+export * from './SuperMan';
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/runtime.ts b/samples/client/others/typescript-rxjs/allOf-composition/runtime.ts
new file mode 100644
index 00000000000..64b0b2b4ad4
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/runtime.ts
@@ -0,0 +1,193 @@
+// tslint:disable
+/**
+ * Example
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * 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.
+ */
+
+import { of } from 'rxjs';
+import type { Observable } from 'rxjs';
+import { ajax } from 'rxjs/ajax';
+import type { AjaxConfig, AjaxResponse } from 'rxjs/ajax';
+import { map, concatMap } from 'rxjs/operators';
+import { servers } from './servers';
+
+export const BASE_PATH = servers[0].getUrl();
+
+export interface ConfigurationParameters {
+ basePath?: string; // override base path
+ middleware?: Middleware[]; // middleware to apply before/after rxjs requests
+ username?: string; // parameter for basic security
+ password?: string; // parameter for basic security
+ apiKey?: string | ((name: string) => string); // parameter for apiKey security
+ accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
+}
+
+export class Configuration {
+ constructor(private configuration: ConfigurationParameters = {}) {}
+
+ get basePath(): string {
+ return this.configuration.basePath ?? BASE_PATH;
+ }
+
+ get middleware(): Middleware[] {
+ return this.configuration.middleware ?? [];
+ }
+
+ get username(): string | undefined {
+ return this.configuration.username;
+ }
+
+ get password(): string | undefined {
+ return this.configuration.password;
+ }
+
+ get apiKey(): ((name: string) => string) | undefined {
+ const { apiKey } = this.configuration;
+ return apiKey ? (typeof apiKey === 'string' ? () => apiKey : apiKey) : undefined;
+ }
+
+ get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
+ const { accessToken } = this.configuration;
+ return accessToken ? (typeof accessToken === 'string' ? () => accessToken : accessToken) : undefined;
+ }
+}
+
+/**
+ * This is the base class for all generated API classes.
+ */
+export class BaseAPI {
+ private middleware: Middleware[] = [];
+
+ constructor(protected configuration = new Configuration()) {
+ this.middleware = configuration.middleware;
+ }
+
+ withMiddleware = (middlewares: Middleware[]): this => {
+ const next = this.clone();
+ next.middleware = next.middleware.concat(middlewares);
+ return next;
+ };
+
+ withPreMiddleware = (preMiddlewares: Array) =>
+ this.withMiddleware(preMiddlewares.map((pre) => ({ pre })));
+
+ withPostMiddleware = (postMiddlewares: Array) =>
+ this.withMiddleware(postMiddlewares.map((post) => ({ post })));
+
+ protected request(requestOpts: RequestOpts): Observable
+ protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable>
+ protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable> {
+ return this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe(
+ map((res) => {
+ const { status, response } = res;
+ if (status >= 200 && status < 300) {
+ return responseOpts?.response === 'raw' ? res : response;
+ }
+ throw res;
+ })
+ );
+ }
+
+ private createRequestArgs = ({ url: baseUrl, query, method, headers, body, responseType }: RequestOpts): AjaxConfig => {
+ // only add the queryString to the URL if there are query parameters.
+ // this is done to avoid urls ending with a '?' character which buggy webservers
+ // do not handle correctly sometimes.
+ const url = `${this.configuration.basePath}${baseUrl}${query && Object.keys(query).length ? `?${queryString(query)}`: ''}`;
+
+ return {
+ url,
+ method,
+ headers,
+ body: body instanceof FormData ? body : JSON.stringify(body),
+ responseType: responseType ?? 'json',
+ };
+ }
+
+ private rxjsRequest = (params: AjaxConfig): Observable> =>
+ of(params).pipe(
+ map((request) => {
+ this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request)));
+ return request;
+ }),
+ concatMap((args) =>
+ ajax(args).pipe(
+ map((response) => {
+ this.middleware.filter((item) => item.post).forEach((mw) => (response = mw.post!(response)));
+ return response;
+ })
+ )
+ )
+ );
+
+ /**
+ * Create a shallow clone of `this` by constructing a new instance
+ * and then shallow cloning data members.
+ */
+ private clone = (): this =>
+ Object.assign(Object.create(Object.getPrototypeOf(this)), this);
+}
+
+/**
+ * @deprecated
+ * export for not being a breaking change
+ */
+export class RequiredError extends Error {
+ override name: 'RequiredError' = 'RequiredError';
+}
+
+export const COLLECTION_FORMATS = {
+ csv: ',',
+ ssv: ' ',
+ tsv: '\t',
+ pipes: '|',
+};
+
+export type Json = any;
+export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
+export type HttpHeaders = { [key: string]: string };
+export type HttpQuery = Partial<{ [key: string]: string | number | null | boolean | Array }>; // partial is needed for strict mode
+export type HttpBody = Json | FormData;
+
+export interface RequestOpts extends AjaxConfig {
+ // TODO: replace custom 'query' prop with 'queryParams'
+ query?: HttpQuery; // additional prop
+ // the following props have improved types over AjaxRequest
+ method: HttpMethod;
+ headers?: HttpHeaders;
+ body?: HttpBody;
+}
+
+export interface ResponseOpts {
+ response?: 'raw';
+}
+
+export interface OperationOpts {
+ responseOpts?: ResponseOpts;
+}
+
+export const encodeURI = (value: any) => encodeURIComponent(`${value}`);
+
+const queryString = (params: HttpQuery): string => Object.entries(params)
+ .map(([key, value]) => value instanceof Array
+ ? value.map((val) => `${encodeURI(key)}=${encodeURI(val)}`).join('&')
+ : `${encodeURI(key)}=${encodeURI(value)}`
+ )
+ .join('&');
+
+export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => {
+ if (value == null) {
+ throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
+ }
+};
+
+export interface Middleware {
+ pre?(request: AjaxConfig): AjaxConfig;
+ post?(response: AjaxResponse): AjaxResponse;
+}
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/servers.ts b/samples/client/others/typescript-rxjs/allOf-composition/servers.ts
new file mode 100644
index 00000000000..3d22265d43f
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/servers.ts
@@ -0,0 +1,43 @@
+/**
+ *
+ * Represents the configuration of a server including its
+ * url template and variable configuration based on the url.
+ *
+ */
+export class ServerConfiguration {
+ public constructor(private url: string, private variableConfiguration: T, private description: string) {}
+
+ /**
+ * Sets the value of the variables of this server.
+ *
+ * @param variableConfiguration a partial variable configuration for the variables contained in the url
+ */
+ public setVariables(variableConfiguration: Partial) {
+ Object.assign(this.variableConfiguration, variableConfiguration);
+ }
+
+ public getConfiguration(): T {
+ return this.variableConfiguration;
+ }
+
+ public getDescription(): string {
+ return this.description;
+ }
+
+ /**
+ * Constructions the URL this server using the url with variables
+ * replaced with their respective values
+ */
+ public getUrl(): string {
+ let replacedUrl = this.url;
+ for (const key in this.variableConfiguration) {
+ var re = new RegExp("{" + key + "}","g");
+ replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]);
+ }
+ return replacedUrl;
+ }
+}
+
+const server1 = new ServerConfiguration<{ }>("http://api.example.xyz/v1", { }, "");
+
+export const servers = [server1];
diff --git a/samples/client/others/typescript-rxjs/allOf-composition/tsconfig.json b/samples/client/others/typescript-rxjs/allOf-composition/tsconfig.json
new file mode 100644
index 00000000000..59a60838a05
--- /dev/null
+++ b/samples/client/others/typescript-rxjs/allOf-composition/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "compilerOptions": {
+ "declaration": true,
+ "target": "es5",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "outDir": "dist",
+ "rootDir": ".",
+ "lib": [
+ "es6",
+ "dom",
+ "es2017"
+ ],
+ "typeRoots": [
+ "node_modules/@types"
+ ]
+ },
+ "exclude": [
+ "dist",
+ "node_modules"
+ ]
+}
diff --git a/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES b/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES
index c1007a68c4d..d272f748838 100644
--- a/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES
+++ b/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES
@@ -21,6 +21,7 @@ R/date.R
R/dog.R
R/dog_all_of.R
R/fake_api.R
+R/format_test.R
R/mammal.R
R/model_api_response.R
R/nested_one_of.R
@@ -52,6 +53,7 @@ docs/Date.md
docs/Dog.md
docs/DogAllOf.md
docs/FakeApi.md
+docs/FormatTest.md
docs/Mammal.md
docs/ModelApiResponse.md
docs/NestedOneOf.md
diff --git a/samples/client/petstore/R-httr2-wrapper/NAMESPACE b/samples/client/petstore/R-httr2-wrapper/NAMESPACE
index fe9db16d34b..9abd239e110 100644
--- a/samples/client/petstore/R-httr2-wrapper/NAMESPACE
+++ b/samples/client/petstore/R-httr2-wrapper/NAMESPACE
@@ -28,6 +28,7 @@ export(DanishPig)
export(Date)
export(Dog)
export(DogAllOf)
+export(FormatTest)
export(Mammal)
export(ModelApiResponse)
export(NestedOneOf)
diff --git a/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R b/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R
index e485c15e4ca..220d89ee503 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R
@@ -42,23 +42,33 @@ AllofTagApiResponse <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!is.null(`code`)) {
- stopifnot(is.numeric(`code`), length(`code`) == 1)
+ if (!(is.numeric(`code`) && length(`code`) == 1)) {
+ stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`))
+ }
self$`code` <- `code`
}
if (!is.null(`type`)) {
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(`message`)) {
- stopifnot(is.character(`message`), length(`message`) == 1)
+ if (!(is.character(`message`) && length(`message`) == 1)) {
+ stop(paste("Error! Invalid data for `message`. Must be a string:", `message`))
+ }
self$`message` <- `message`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/animal.R b/samples/client/petstore/R-httr2-wrapper/R/animal.R
index 632b160087d..b506bced42f 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/animal.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/animal.R
@@ -35,11 +35,15 @@ Animal <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(additional_properties)) {
@@ -162,7 +166,9 @@ Animal <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R b/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R
index 2335bbe37c0..ac83042c8cf 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R
@@ -33,11 +33,15 @@ BasquePig <- R6::R6Class(
#' @export
initialize = function(`className`, `color`, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(additional_properties)) {
@@ -160,13 +164,17 @@ BasquePig <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `className` is missing."))
}
# check the required field `color`
if (!is.null(input_json$`color`)) {
- stopifnot(is.character(input_json$`color`), length(input_json$`color`) == 1)
+ if (!(is.character(input_json$`color`) && length(input_json$`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", input_json$`color`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/R/cat.R b/samples/client/petstore/R-httr2-wrapper/R/cat.R
index 60d417950b1..f74e2d887dd 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/cat.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/cat.R
@@ -37,15 +37,21 @@ Cat <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", `declawed` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(`declawed`)) {
- stopifnot(is.logical(`declawed`), length(`declawed`) == 1)
+ if (!(is.logical(`declawed`) && length(`declawed`) == 1)) {
+ stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`))
+ }
self$`declawed` <- `declawed`
}
if (!is.null(additional_properties)) {
@@ -184,7 +190,9 @@ Cat <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R b/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R
index c3969fc0550..197e1a46e3a 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R
@@ -30,7 +30,9 @@ CatAllOf <- R6::R6Class(
#' @export
initialize = function(`declawed` = NULL, additional_properties = NULL, ...) {
if (!is.null(`declawed`)) {
- stopifnot(is.logical(`declawed`), length(`declawed`) == 1)
+ if (!(is.logical(`declawed`) && length(`declawed`) == 1)) {
+ stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`))
+ }
self$`declawed` <- `declawed`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/category.R b/samples/client/petstore/R-httr2-wrapper/R/category.R
index 2de263a5682..2646d01bd72 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/category.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/category.R
@@ -33,11 +33,15 @@ Category <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R b/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R
index 737bfad4b97..06cf5096a88 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R
@@ -33,11 +33,15 @@ DanishPig <- R6::R6Class(
#' @export
initialize = function(`className`, `size`, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`size`)) {
- stopifnot(is.numeric(`size`), length(`size`) == 1)
+ if (!(is.numeric(`size`) && length(`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`))
+ }
self$`size` <- `size`
}
if (!is.null(additional_properties)) {
@@ -160,13 +164,17 @@ DanishPig <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `className` is missing."))
}
# check the required field `size`
if (!is.null(input_json$`size`)) {
- stopifnot(is.numeric(input_json$`size`), length(input_json$`size`) == 1)
+ if (!(is.numeric(input_json$`size`) && length(input_json$`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", input_json$`size`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/R/date.R b/samples/client/petstore/R-httr2-wrapper/R/date.R
index a26b7977d4f..79945bc8cfc 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/date.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/date.R
@@ -36,19 +36,25 @@ Date <- R6::R6Class(
#' @export
initialize = function(`className`, `url_property`, `percent_description` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`url_property`)) {
- stopifnot(is.character(`url_property`), length(`url_property`) == 1)
+ if (!(is.character(`url_property`) && length(`url_property`) == 1)) {
+ stop(paste("Error! Invalid data for `url_property`. Must be a string:", `url_property`))
+ }
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", `url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", `url_property`))
}
self$`url_property` <- `url_property`
}
if (!is.null(`percent_description`)) {
- stopifnot(is.character(`percent_description`), length(`percent_description`) == 1)
+ if (!(is.character(`percent_description`) && length(`percent_description`) == 1)) {
+ stop(paste("Error! Invalid data for `percent_description`. Must be a string:", `percent_description`))
+ }
self$`percent_description` <- `percent_description`
}
if (!is.null(additional_properties)) {
@@ -103,7 +109,7 @@ Date <- R6::R6Class(
if (!is.null(this_object$`url_property`)) {
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`))
}
self$`url_property` <- this_object$`url_property`
}
@@ -172,7 +178,7 @@ Date <- R6::R6Class(
self$`percent_description` <- this_object$`percent_description`
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`))
}
self$`url_property` <- this_object$`url_property`
# process additional properties/fields in the payload
@@ -195,16 +201,20 @@ Date <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing."))
}
# check the required field `url_property`
if (!is.null(input_json$`url_property`)) {
- stopifnot(is.character(input_json$`url_property`), length(input_json$`url_property`) == 1)
+ if (!(is.character(input_json$`url_property`) && length(input_json$`url_property`) == 1)) {
+ stop(paste("Error! Invalid data for `url_property`. Must be a string:", input_json$`url_property`))
+ }
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(input_json$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", input_json$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", input_json$`url_property`))
}
} else {
stop(paste("The JSON input `", input, "` is invalid for Date: the required field `url_property` is missing."))
diff --git a/samples/client/petstore/R-httr2-wrapper/R/dog.R b/samples/client/petstore/R-httr2-wrapper/R/dog.R
index 67fb8a315e2..a814c57d586 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/dog.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/dog.R
@@ -37,15 +37,21 @@ Dog <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", `breed` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(`breed`)) {
- stopifnot(is.character(`breed`), length(`breed`) == 1)
+ if (!(is.character(`breed`) && length(`breed`) == 1)) {
+ stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`))
+ }
self$`breed` <- `breed`
}
if (!is.null(additional_properties)) {
@@ -184,7 +190,9 @@ Dog <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R b/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R
index ea44d583d74..17608478eed 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R
@@ -30,7 +30,9 @@ DogAllOf <- R6::R6Class(
#' @export
initialize = function(`breed` = NULL, additional_properties = NULL, ...) {
if (!is.null(`breed`)) {
- stopifnot(is.character(`breed`), length(`breed`) == 1)
+ if (!(is.character(`breed`) && length(`breed`) == 1)) {
+ stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`))
+ }
self$`breed` <- `breed`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/fake_api.R b/samples/client/petstore/R-httr2-wrapper/R/fake_api.R
index 73cf0e8c54e..3a3ccd3d7a1 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/fake_api.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/fake_api.R
@@ -117,7 +117,7 @@
#' #################### add_pet_optional ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
#'
#' #Add a new pet to the store (optional body)
#' api_instance <- petstore_api$new()
@@ -155,7 +155,7 @@
#'
#' library(petstore)
#' var_dummy <- "dummy_example" # character | dummy required parameter
-#' var_var_data_file <- "var_data_file_example" # character | header data file
+#' var_var_data_file <- "var_data_file_example" # character | header data file (Optional)
#'
#' #test data_file to ensure it's escaped correctly
#' api_instance <- petstore_api$new()
@@ -188,7 +188,7 @@
#' #################### fake_path_array ####################
#'
#' library(petstore)
-#' var_path_array <- ["path_array_example"] # array[character] | dummy path parameter
+#' var_path_array <- c("inner_example") # array[character] | dummy path parameter
#'
#' #test array parameter in path
#' api_instance <- petstore_api$new()
@@ -238,8 +238,8 @@
#' #################### fake_set_query ####################
#'
#' library(petstore)
-#' var_set_dummy <- ["set_dummy_example"] # set[character] | set query
-#' var_array_dummy <- ["array_dummy_example"] # array[character] | array query
+#' var_set_dummy <- c("inner_example") # set[character] | set query
+#' var_array_dummy <- c("inner_example") # array[character] | array query
#'
#' #test set query parameter
#' api_instance <- petstore_api$new()
diff --git a/samples/client/petstore/R-httr2-wrapper/R/format_test.R b/samples/client/petstore/R-httr2-wrapper/R/format_test.R
new file mode 100644
index 00000000000..4bd74e3a727
--- /dev/null
+++ b/samples/client/petstore/R-httr2-wrapper/R/format_test.R
@@ -0,0 +1,711 @@
+#' Create a new FormatTest
+#'
+#' @description
+#' FormatTest Class
+#'
+#' @docType class
+#' @title FormatTest
+#' @description FormatTest Class
+#' @format An \code{R6Class} generator object
+#' @field integer integer [optional]
+#' @field int32 integer [optional]
+#' @field int64 integer [optional]
+#' @field number numeric
+#' @field float numeric [optional]
+#' @field double numeric [optional]
+#' @field string character [optional]
+#' @field byte character
+#' @field binary data.frame [optional]
+#' @field date character
+#' @field dateTime character [optional]
+#' @field uuid character [optional]
+#' @field password character
+#' @field pattern_with_digits A string that is a 10 digit number. Can have leading zeros. character [optional]
+#' @field pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. character [optional]
+#' @field _field_list a list of fields list(character)
+#' @field additional_properties additional properties list(character) [optional]
+#' @importFrom R6 R6Class
+#' @importFrom jsonlite fromJSON toJSON
+#' @export
+FormatTest <- R6::R6Class(
+ "FormatTest",
+ public = list(
+ `integer` = NULL,
+ `int32` = NULL,
+ `int64` = NULL,
+ `number` = NULL,
+ `float` = NULL,
+ `double` = NULL,
+ `string` = NULL,
+ `byte` = NULL,
+ `binary` = NULL,
+ `date` = NULL,
+ `dateTime` = NULL,
+ `uuid` = NULL,
+ `password` = NULL,
+ `pattern_with_digits` = NULL,
+ `pattern_with_digits_and_delimiter` = NULL,
+ `_field_list` = c("integer", "int32", "int64", "number", "float", "double", "string", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"),
+ `additional_properties` = list(),
+ #' Initialize a new FormatTest class.
+ #'
+ #' @description
+ #' Initialize a new FormatTest class.
+ #'
+ #' @param number number
+ #' @param byte byte
+ #' @param date date
+ #' @param password password
+ #' @param integer integer
+ #' @param int32 int32
+ #' @param int64 int64
+ #' @param float float
+ #' @param double double
+ #' @param string string
+ #' @param binary binary
+ #' @param dateTime dateTime. Default to "2015-10-28T14:38:02Z".
+ #' @param uuid uuid
+ #' @param pattern_with_digits A string that is a 10 digit number. Can have leading zeros.
+ #' @param pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+ #' @param additional_properties additonal properties (optional)
+ #' @param ... Other optional arguments.
+ #' @export
+ initialize = function(`number`, `byte`, `date`, `password`, `integer` = NULL, `int32` = NULL, `int64` = NULL, `float` = NULL, `double` = NULL, `string` = NULL, `binary` = NULL, `dateTime` = "2015-10-28T14:38:02Z", `uuid` = NULL, `pattern_with_digits` = NULL, `pattern_with_digits_and_delimiter` = NULL, additional_properties = NULL, ...) {
+ if (!missing(`number`)) {
+ self$`number` <- `number`
+ }
+ if (!missing(`byte`)) {
+ self$`byte` <- `byte`
+ }
+ if (!missing(`date`)) {
+ if (!(is.character(`date`) && length(`date`) == 1)) {
+ stop(paste("Error! Invalid data for `date`. Must be a string:", `date`))
+ }
+ self$`date` <- `date`
+ }
+ if (!missing(`password`)) {
+ if (!(is.character(`password`) && length(`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", `password`))
+ }
+ self$`password` <- `password`
+ }
+ if (!is.null(`integer`)) {
+ if (!(is.numeric(`integer`) && length(`integer`) == 1)) {
+ stop(paste("Error! Invalid data for `integer`. Must be an integer:", `integer`))
+ }
+ self$`integer` <- `integer`
+ }
+ if (!is.null(`int32`)) {
+ if (!(is.numeric(`int32`) && length(`int32`) == 1)) {
+ stop(paste("Error! Invalid data for `int32`. Must be an integer:", `int32`))
+ }
+ self$`int32` <- `int32`
+ }
+ if (!is.null(`int64`)) {
+ if (!(is.numeric(`int64`) && length(`int64`) == 1)) {
+ stop(paste("Error! Invalid data for `int64`. Must be an integer:", `int64`))
+ }
+ self$`int64` <- `int64`
+ }
+ if (!is.null(`float`)) {
+ if (!(is.numeric(`float`) && length(`float`) == 1)) {
+ stop(paste("Error! Invalid data for `float`. Must be a number:", `float`))
+ }
+ self$`float` <- `float`
+ }
+ if (!is.null(`double`)) {
+ if (!(is.numeric(`double`) && length(`double`) == 1)) {
+ stop(paste("Error! Invalid data for `double`. Must be a number:", `double`))
+ }
+ self$`double` <- `double`
+ }
+ if (!is.null(`string`)) {
+ if (!(is.character(`string`) && length(`string`) == 1)) {
+ stop(paste("Error! Invalid data for `string`. Must be a string:", `string`))
+ }
+ self$`string` <- `string`
+ }
+ if (!is.null(`binary`)) {
+ self$`binary` <- `binary`
+ }
+ if (!is.null(`dateTime`)) {
+ if (!is.character(`dateTime`)) {
+ stop(paste("Error! Invalid data for `dateTime`. Must be a string:", `dateTime`))
+ }
+ self$`dateTime` <- `dateTime`
+ }
+ if (!is.null(`uuid`)) {
+ if (!(is.character(`uuid`) && length(`uuid`) == 1)) {
+ stop(paste("Error! Invalid data for `uuid`. Must be a string:", `uuid`))
+ }
+ self$`uuid` <- `uuid`
+ }
+ if (!is.null(`pattern_with_digits`)) {
+ if (!(is.character(`pattern_with_digits`) && length(`pattern_with_digits`) == 1)) {
+ stop(paste("Error! Invalid data for `pattern_with_digits`. Must be a string:", `pattern_with_digits`))
+ }
+ self$`pattern_with_digits` <- `pattern_with_digits`
+ }
+ if (!is.null(`pattern_with_digits_and_delimiter`)) {
+ if (!(is.character(`pattern_with_digits_and_delimiter`) && length(`pattern_with_digits_and_delimiter`) == 1)) {
+ stop(paste("Error! Invalid data for `pattern_with_digits_and_delimiter`. Must be a string:", `pattern_with_digits_and_delimiter`))
+ }
+ self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter`
+ }
+ if (!is.null(additional_properties)) {
+ for (key in names(additional_properties)) {
+ self$additional_properties[[key]] <- additional_properties[[key]]
+ }
+ }
+ },
+ #' To JSON string
+ #'
+ #' @description
+ #' To JSON String
+ #'
+ #' @return FormatTest in JSON format
+ #' @export
+ toJSON = function() {
+ FormatTestObject <- list()
+ if (!is.null(self$`integer`)) {
+ FormatTestObject[["integer"]] <-
+ self$`integer`
+ }
+ if (!is.null(self$`int32`)) {
+ FormatTestObject[["int32"]] <-
+ self$`int32`
+ }
+ if (!is.null(self$`int64`)) {
+ FormatTestObject[["int64"]] <-
+ self$`int64`
+ }
+ if (!is.null(self$`number`)) {
+ FormatTestObject[["number"]] <-
+ self$`number`
+ }
+ if (!is.null(self$`float`)) {
+ FormatTestObject[["float"]] <-
+ self$`float`
+ }
+ if (!is.null(self$`double`)) {
+ FormatTestObject[["double"]] <-
+ self$`double`
+ }
+ if (!is.null(self$`string`)) {
+ FormatTestObject[["string"]] <-
+ self$`string`
+ }
+ if (!is.null(self$`byte`)) {
+ FormatTestObject[["byte"]] <-
+ self$`byte`
+ }
+ if (!is.null(self$`binary`)) {
+ FormatTestObject[["binary"]] <-
+ self$`binary`
+ }
+ if (!is.null(self$`date`)) {
+ FormatTestObject[["date"]] <-
+ self$`date`
+ }
+ if (!is.null(self$`dateTime`)) {
+ FormatTestObject[["dateTime"]] <-
+ self$`dateTime`
+ }
+ if (!is.null(self$`uuid`)) {
+ FormatTestObject[["uuid"]] <-
+ self$`uuid`
+ }
+ if (!is.null(self$`password`)) {
+ FormatTestObject[["password"]] <-
+ self$`password`
+ }
+ if (!is.null(self$`pattern_with_digits`)) {
+ FormatTestObject[["pattern_with_digits"]] <-
+ self$`pattern_with_digits`
+ }
+ if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
+ FormatTestObject[["pattern_with_digits_and_delimiter"]] <-
+ self$`pattern_with_digits_and_delimiter`
+ }
+ for (key in names(self$additional_properties)) {
+ FormatTestObject[[key]] <- self$additional_properties[[key]]
+ }
+
+ FormatTestObject
+ },
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @description
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @param input_json the JSON input
+ #' @return the instance of FormatTest
+ #' @export
+ fromJSON = function(input_json) {
+ this_object <- jsonlite::fromJSON(input_json)
+ if (!is.null(this_object$`integer`)) {
+ self$`integer` <- this_object$`integer`
+ }
+ if (!is.null(this_object$`int32`)) {
+ self$`int32` <- this_object$`int32`
+ }
+ if (!is.null(this_object$`int64`)) {
+ self$`int64` <- this_object$`int64`
+ }
+ if (!is.null(this_object$`number`)) {
+ self$`number` <- this_object$`number`
+ }
+ if (!is.null(this_object$`float`)) {
+ self$`float` <- this_object$`float`
+ }
+ if (!is.null(this_object$`double`)) {
+ self$`double` <- this_object$`double`
+ }
+ if (!is.null(this_object$`string`)) {
+ self$`string` <- this_object$`string`
+ }
+ if (!is.null(this_object$`byte`)) {
+ self$`byte` <- this_object$`byte`
+ }
+ if (!is.null(this_object$`binary`)) {
+ self$`binary` <- this_object$`binary`
+ }
+ if (!is.null(this_object$`date`)) {
+ self$`date` <- this_object$`date`
+ }
+ if (!is.null(this_object$`dateTime`)) {
+ self$`dateTime` <- this_object$`dateTime`
+ }
+ if (!is.null(this_object$`uuid`)) {
+ self$`uuid` <- this_object$`uuid`
+ }
+ if (!is.null(this_object$`password`)) {
+ self$`password` <- this_object$`password`
+ }
+ if (!is.null(this_object$`pattern_with_digits`)) {
+ self$`pattern_with_digits` <- this_object$`pattern_with_digits`
+ }
+ if (!is.null(this_object$`pattern_with_digits_and_delimiter`)) {
+ self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
+ }
+ # process additional properties/fields in the payload
+ for (key in names(this_object)) {
+ if (!(key %in% self$`_field_list`)) { # json key not in list of fields
+ self$additional_properties[[key]] <- this_object[[key]]
+ }
+ }
+
+ self
+ },
+ #' To JSON string
+ #'
+ #' @description
+ #' To JSON String
+ #'
+ #' @return FormatTest in JSON format
+ #' @export
+ toJSONString = function() {
+ jsoncontent <- c(
+ if (!is.null(self$`integer`)) {
+ sprintf(
+ '"integer":
+ %d
+ ',
+ self$`integer`
+ )
+ },
+ if (!is.null(self$`int32`)) {
+ sprintf(
+ '"int32":
+ %d
+ ',
+ self$`int32`
+ )
+ },
+ if (!is.null(self$`int64`)) {
+ sprintf(
+ '"int64":
+ %d
+ ',
+ self$`int64`
+ )
+ },
+ if (!is.null(self$`number`)) {
+ sprintf(
+ '"number":
+ %d
+ ',
+ self$`number`
+ )
+ },
+ if (!is.null(self$`float`)) {
+ sprintf(
+ '"float":
+ %d
+ ',
+ self$`float`
+ )
+ },
+ if (!is.null(self$`double`)) {
+ sprintf(
+ '"double":
+ %d
+ ',
+ self$`double`
+ )
+ },
+ if (!is.null(self$`string`)) {
+ sprintf(
+ '"string":
+ "%s"
+ ',
+ self$`string`
+ )
+ },
+ if (!is.null(self$`byte`)) {
+ sprintf(
+ '"byte":
+ "%s"
+ ',
+ self$`byte`
+ )
+ },
+ if (!is.null(self$`binary`)) {
+ sprintf(
+ '"binary":
+ "%s"
+ ',
+ self$`binary`
+ )
+ },
+ if (!is.null(self$`date`)) {
+ sprintf(
+ '"date":
+ "%s"
+ ',
+ self$`date`
+ )
+ },
+ if (!is.null(self$`dateTime`)) {
+ sprintf(
+ '"dateTime":
+ "%s"
+ ',
+ self$`dateTime`
+ )
+ },
+ if (!is.null(self$`uuid`)) {
+ sprintf(
+ '"uuid":
+ "%s"
+ ',
+ self$`uuid`
+ )
+ },
+ if (!is.null(self$`password`)) {
+ sprintf(
+ '"password":
+ "%s"
+ ',
+ self$`password`
+ )
+ },
+ if (!is.null(self$`pattern_with_digits`)) {
+ sprintf(
+ '"pattern_with_digits":
+ "%s"
+ ',
+ self$`pattern_with_digits`
+ )
+ },
+ if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
+ sprintf(
+ '"pattern_with_digits_and_delimiter":
+ "%s"
+ ',
+ self$`pattern_with_digits_and_delimiter`
+ )
+ }
+ )
+ jsoncontent <- paste(jsoncontent, collapse = ",")
+ json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
+ json_obj <- jsonlite::fromJSON(json_string)
+ for (key in names(self$additional_properties)) {
+ json_obj[[key]] <- self$additional_properties[[key]]
+ }
+ json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
+ },
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @description
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @param input_json the JSON input
+ #' @return the instance of FormatTest
+ #' @export
+ fromJSONString = function(input_json) {
+ this_object <- jsonlite::fromJSON(input_json)
+ self$`integer` <- this_object$`integer`
+ self$`int32` <- this_object$`int32`
+ self$`int64` <- this_object$`int64`
+ self$`number` <- this_object$`number`
+ self$`float` <- this_object$`float`
+ self$`double` <- this_object$`double`
+ self$`string` <- this_object$`string`
+ self$`byte` <- this_object$`byte`
+ self$`binary` <- this_object$`binary`
+ self$`date` <- this_object$`date`
+ self$`dateTime` <- this_object$`dateTime`
+ self$`uuid` <- this_object$`uuid`
+ self$`password` <- this_object$`password`
+ self$`pattern_with_digits` <- this_object$`pattern_with_digits`
+ self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
+ # process additional properties/fields in the payload
+ for (key in names(this_object)) {
+ if (!(key %in% self$`_field_list`)) { # json key not in list of fields
+ self$additional_properties[[key]] <- this_object[[key]]
+ }
+ }
+
+ self
+ },
+ #' Validate JSON input with respect to FormatTest
+ #'
+ #' @description
+ #' Validate JSON input with respect to FormatTest and throw an exception if invalid
+ #'
+ #' @param input the JSON input
+ #' @export
+ validateJSON = function(input) {
+ input_json <- jsonlite::fromJSON(input)
+ # check the required field `number`
+ if (!is.null(input_json$`number`)) {
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `number` is missing."))
+ }
+ # check the required field `byte`
+ if (!is.null(input_json$`byte`)) {
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `byte` is missing."))
+ }
+ # check the required field `date`
+ if (!is.null(input_json$`date`)) {
+ if (!(is.character(input_json$`date`) && length(input_json$`date`) == 1)) {
+ stop(paste("Error! Invalid data for `date`. Must be a string:", input_json$`date`))
+ }
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `date` is missing."))
+ }
+ # check the required field `password`
+ if (!is.null(input_json$`password`)) {
+ if (!(is.character(input_json$`password`) && length(input_json$`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", input_json$`password`))
+ }
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing."))
+ }
+ },
+ #' To string (JSON format)
+ #'
+ #' @description
+ #' To string (JSON format)
+ #'
+ #' @return String representation of FormatTest
+ #' @export
+ toString = function() {
+ self$toJSONString()
+ },
+ #' Return true if the values in all fields are valid.
+ #'
+ #' @description
+ #' Return true if the values in all fields are valid.
+ #'
+ #' @return true if the values in all fields are valid.
+ #' @export
+ isValid = function() {
+ if (self$`integer` > 100) {
+ return(FALSE)
+ }
+ if (self$`integer` < 10) {
+ return(FALSE)
+ }
+
+ if (self$`int32` > 200) {
+ return(FALSE)
+ }
+ if (self$`int32` < 20) {
+ return(FALSE)
+ }
+
+ # check if the required `number` is null
+ if (is.null(self$`number`)) {
+ return(FALSE)
+ }
+
+ if (self$`number` > 543.2) {
+ return(FALSE)
+ }
+ if (self$`number` < 32.1) {
+ return(FALSE)
+ }
+
+ if (self$`float` > 987.6) {
+ return(FALSE)
+ }
+ if (self$`float` < 54.3) {
+ return(FALSE)
+ }
+
+ if (self$`double` > 123.4) {
+ return(FALSE)
+ }
+ if (self$`double` < 67.8) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`string`, "[a-z]/i")) {
+ return(FALSE)
+ }
+
+ # check if the required `byte` is null
+ if (is.null(self$`byte`)) {
+ return(FALSE)
+ }
+
+ # check if the required `date` is null
+ if (is.null(self$`date`)) {
+ return(FALSE)
+ }
+
+ # check if the required `password` is null
+ if (is.null(self$`password`)) {
+ return(FALSE)
+ }
+
+ if (nchar(self$`password`) > 64) {
+ return(FALSE)
+ }
+ if (nchar(self$`password`) < 10) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
+ return(FALSE)
+ }
+
+ TRUE
+ },
+ #' Return a list of invalid fields (if any).
+ #'
+ #' @description
+ #' Return a list of invalid fields (if any).
+ #'
+ #' @return A list of invalid fields (if any).
+ #' @export
+ getInvalidFields = function() {
+ invalid_fields <- list()
+ if (self$`integer` > 100) {
+ invalid_fields["integer"] <- "Invalid value for `integer`, must be smaller than or equal to 100."
+ }
+ if (self$`integer` < 10) {
+ invalid_fields["integer"] <- "Invalid value for `integer`, must be bigger than or equal to 10."
+ }
+
+ if (self$`int32` > 200) {
+ invalid_fields["int32"] <- "Invalid value for `int32`, must be smaller than or equal to 200."
+ }
+ if (self$`int32` < 20) {
+ invalid_fields["int32"] <- "Invalid value for `int32`, must be bigger than or equal to 20."
+ }
+
+ # check if the required `number` is null
+ if (is.null(self$`number`)) {
+ invalid_fields["number"] <- "Non-nullable required field `number` cannot be null."
+ }
+
+ if (self$`number` > 543.2) {
+ invalid_fields["number"] <- "Invalid value for `number`, must be smaller than or equal to 543.2."
+ }
+ if (self$`number` < 32.1) {
+ invalid_fields["number"] <- "Invalid value for `number`, must be bigger than or equal to 32.1."
+ }
+
+ if (self$`float` > 987.6) {
+ invalid_fields["float"] <- "Invalid value for `float`, must be smaller than or equal to 987.6."
+ }
+ if (self$`float` < 54.3) {
+ invalid_fields["float"] <- "Invalid value for `float`, must be bigger than or equal to 54.3."
+ }
+
+ if (self$`double` > 123.4) {
+ invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 123.4."
+ }
+ if (self$`double` < 67.8) {
+ invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 67.8."
+ }
+
+ if (!str_detect(self$`string`, "[a-z]/i")) {
+ invalid_fields["string"] <- "Invalid value for `string`, must conform to the pattern [a-z]/i."
+ }
+
+ # check if the required `byte` is null
+ if (is.null(self$`byte`)) {
+ invalid_fields["byte"] <- "Non-nullable required field `byte` cannot be null."
+ }
+
+ # check if the required `date` is null
+ if (is.null(self$`date`)) {
+ invalid_fields["date"] <- "Non-nullable required field `date` cannot be null."
+ }
+
+ # check if the required `password` is null
+ if (is.null(self$`password`)) {
+ invalid_fields["password"] <- "Non-nullable required field `password` cannot be null."
+ }
+
+ if (nchar(self$`password`) > 64) {
+ invalid_fields["password"] <- "Invalid length for `password`, must be smaller than or equal to 64."
+ }
+ if (nchar(self$`password`) < 10) {
+ invalid_fields["password"] <- "Invalid length for `password`, must be bigger than or equal to 10."
+ }
+
+ if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
+ invalid_fields["pattern_with_digits"] <- "Invalid value for `pattern_with_digits`, must conform to the pattern ^\\d{10}$."
+ }
+
+ if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
+ invalid_fields["pattern_with_digits_and_delimiter"] <- "Invalid value for `pattern_with_digits_and_delimiter`, must conform to the pattern ^image_\\d{1,3}$/i."
+ }
+
+ invalid_fields
+ },
+ #' Print the object
+ #'
+ #' @description
+ #' Print the object
+ #'
+ #' @export
+ print = function() {
+ print(jsonlite::prettify(self$toJSONString()))
+ invisible(self)
+ }
+ ),
+ # Lock the class to prevent modifications to the method or field
+ lock_class = TRUE
+)
+## Uncomment below to unlock the class to allow modifications of the method or field
+# FormatTest$unlock()
+#
+## Below is an example to define the print fnuction
+# FormatTest$set("public", "print", function(...) {
+# print(jsonlite::prettify(self$toJSONString()))
+# invisible(self)
+# })
+## Uncomment below to lock the class to prevent modifications to the method or field
+# FormatTest$lock()
+
diff --git a/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R b/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R
index 03059bb5225..b0e4bbba7e9 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R
@@ -36,15 +36,21 @@ ModelApiResponse <- R6::R6Class(
#' @export
initialize = function(`code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) {
if (!is.null(`code`)) {
- stopifnot(is.numeric(`code`), length(`code`) == 1)
+ if (!(is.numeric(`code`) && length(`code`) == 1)) {
+ stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`))
+ }
self$`code` <- `code`
}
if (!is.null(`type`)) {
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(`message`)) {
- stopifnot(is.character(`message`), length(`message`) == 1)
+ if (!(is.character(`message`) && length(`message`) == 1)) {
+ stop(paste("Error! Invalid data for `message`. Must be a string:", `message`))
+ }
self$`message` <- `message`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R b/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R
index 68b0db6b371..73f4e938cbd 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R
@@ -33,7 +33,9 @@ NestedOneOf <- R6::R6Class(
#' @export
initialize = function(`size` = NULL, `nested_pig` = NULL, additional_properties = NULL, ...) {
if (!is.null(`size`)) {
- stopifnot(is.numeric(`size`), length(`size`) == 1)
+ if (!(is.numeric(`size`) && length(`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`))
+ }
self$`size` <- `size`
}
if (!is.null(`nested_pig`)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/order.R b/samples/client/petstore/R-httr2-wrapper/R/order.R
index 6f43799918d..26646896269 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/order.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/order.R
@@ -45,30 +45,42 @@ Order <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`petId`)) {
- stopifnot(is.numeric(`petId`), length(`petId`) == 1)
+ if (!(is.numeric(`petId`) && length(`petId`) == 1)) {
+ stop(paste("Error! Invalid data for `petId`. Must be an integer:", `petId`))
+ }
self$`petId` <- `petId`
}
if (!is.null(`quantity`)) {
- stopifnot(is.numeric(`quantity`), length(`quantity`) == 1)
+ if (!(is.numeric(`quantity`) && length(`quantity`) == 1)) {
+ stop(paste("Error! Invalid data for `quantity`. Must be an integer:", `quantity`))
+ }
self$`quantity` <- `quantity`
}
if (!is.null(`shipDate`)) {
- stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
+ if (!is.character(`shipDate`)) {
+ stop(paste("Error! Invalid data for `shipDate`. Must be a string:", `shipDate`))
+ }
self$`shipDate` <- `shipDate`
}
if (!is.null(`status`)) {
if (!(`status` %in% c("placed", "approved", "delivered"))) {
stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"placed\", \"approved\", \"delivered\".", sep = ""))
}
- stopifnot(is.character(`status`), length(`status`) == 1)
+ if (!(is.character(`status`) && length(`status`) == 1)) {
+ stop(paste("Error! Invalid data for `status`. Must be a string:", `status`))
+ }
self$`status` <- `status`
}
if (!is.null(`complete`)) {
- stopifnot(is.logical(`complete`), length(`complete`) == 1)
+ if (!(is.logical(`complete`) && length(`complete`) == 1)) {
+ stop(paste("Error! Invalid data for `complete`. Must be a boolean:", `complete`))
+ }
self$`complete` <- `complete`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/pet.R b/samples/client/petstore/R-httr2-wrapper/R/pet.R
index 63318448c0c..8be5a058335 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/pet.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/pet.R
@@ -45,7 +45,9 @@ Pet <- R6::R6Class(
#' @export
initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, additional_properties = NULL, ...) {
if (!missing(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!missing(`photoUrls`)) {
@@ -54,7 +56,9 @@ Pet <- R6::R6Class(
self$`photoUrls` <- `photoUrls`
}
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`category`)) {
@@ -70,7 +74,9 @@ Pet <- R6::R6Class(
if (!(`status` %in% c("available", "pending", "sold"))) {
stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = ""))
}
- stopifnot(is.character(`status`), length(`status`) == 1)
+ if (!(is.character(`status`) && length(`status`) == 1)) {
+ stop(paste("Error! Invalid data for `status`. Must be a string:", `status`))
+ }
self$`status` <- `status`
}
if (!is.null(additional_properties)) {
@@ -265,7 +271,9 @@ Pet <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `name`
if (!is.null(input_json$`name`)) {
- stopifnot(is.character(input_json$`name`), length(input_json$`name`) == 1)
+ if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/R/pet_api.R b/samples/client/petstore/R-httr2-wrapper/R/pet_api.R
index 837c4c3d5df..c860003e125 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/pet_api.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/pet_api.R
@@ -288,7 +288,7 @@
#' #################### add_pet ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
#'
#' #Add a new pet to the store
#' api_instance <- petstore_api$new()
@@ -326,7 +326,7 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | Pet id to delete
-#' var_api_key <- "api_key_example" # character |
+#' var_api_key <- "api_key_example" # character | (Optional)
#'
#' #Deletes a pet
#' api_instance <- petstore_api$new()
@@ -354,7 +354,7 @@
#' #################### find_pets_by_status ####################
#'
#' library(petstore)
-#' var_status <- ["status_example"] # array[character] | Status values that need to be considered for filter
+#' var_status <- c("available") # array[character] | Status values that need to be considered for filter
#'
#' #Finds Pets by status
#' api_instance <- petstore_api$new()
@@ -390,7 +390,7 @@
#' #################### find_pets_by_tags ####################
#'
#' library(petstore)
-#' var_tags <- ["tags_example"] # array[character] | Tags to filter by
+#' var_tags <- c("inner_example") # array[character] | Tags to filter by
#'
#' #Finds Pets by tags
#' api_instance <- petstore_api$new()
@@ -537,7 +537,7 @@
#' #################### update_pet ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
#'
#' #Update an existing pet
#' api_instance <- petstore_api$new()
@@ -574,8 +574,8 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | ID of pet that needs to be updated
-#' var_name <- "name_example" # character | Updated name of the pet
-#' var_status <- "status_example" # character | Updated status of the pet
+#' var_name <- "name_example" # character | Updated name of the pet (Optional)
+#' var_status <- "status_example" # character | Updated status of the pet (Optional)
#'
#' #Updates a pet in the store with form data
#' api_instance <- petstore_api$new()
@@ -601,8 +601,8 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | ID of pet to update
-#' var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server
-#' var_file <- File.new('/path/to/file') # data.frame | file to upload
+#' var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server (Optional)
+#' var_file <- File.new('/path/to/file') # data.frame | file to upload (Optional)
#'
#' #uploads an image
#' api_instance <- petstore_api$new()
diff --git a/samples/client/petstore/R-httr2-wrapper/R/special.R b/samples/client/petstore/R-httr2-wrapper/R/special.R
index 33f06cc6a67..39664bea75c 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/special.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/special.R
@@ -56,27 +56,39 @@ Special <- R6::R6Class(
self$`set_test` <- `set_test`
}
if (!is.null(`item_self`)) {
- stopifnot(is.numeric(`item_self`), length(`item_self`) == 1)
+ if (!(is.numeric(`item_self`) && length(`item_self`) == 1)) {
+ stop(paste("Error! Invalid data for `item_self`. Must be an integer:", `item_self`))
+ }
self$`item_self` <- `item_self`
}
if (!is.null(`item_private`)) {
- stopifnot(is.character(`item_private`), length(`item_private`) == 1)
+ if (!(is.character(`item_private`) && length(`item_private`) == 1)) {
+ stop(paste("Error! Invalid data for `item_private`. Must be a string:", `item_private`))
+ }
self$`item_private` <- `item_private`
}
if (!is.null(`item_super`)) {
- stopifnot(is.character(`item_super`), length(`item_super`) == 1)
+ if (!(is.character(`item_super`) && length(`item_super`) == 1)) {
+ stop(paste("Error! Invalid data for `item_super`. Must be a string:", `item_super`))
+ }
self$`item_super` <- `item_super`
}
if (!is.null(`123_number`)) {
- stopifnot(is.character(`123_number`), length(`123_number`) == 1)
+ if (!(is.character(`123_number`) && length(`123_number`) == 1)) {
+ stop(paste("Error! Invalid data for `123_number`. Must be a string:", `123_number`))
+ }
self$`123_number` <- `123_number`
}
if (!is.null(`array[test]`)) {
- stopifnot(is.character(`array[test]`), length(`array[test]`) == 1)
+ if (!(is.character(`array[test]`) && length(`array[test]`) == 1)) {
+ stop(paste("Error! Invalid data for `array[test]`. Must be a string:", `array[test]`))
+ }
self$`array[test]` <- `array[test]`
}
if (!is.null(`empty_string`)) {
- stopifnot(is.character(`empty_string`), length(`empty_string`) == 1)
+ if (!(is.character(`empty_string`) && length(`empty_string`) == 1)) {
+ stop(paste("Error! Invalid data for `empty_string`. Must be a string:", `empty_string`))
+ }
self$`empty_string` <- `empty_string`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/store_api.R b/samples/client/petstore/R-httr2-wrapper/R/store_api.R
index 3811d0e6a45..129e5d06d2b 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/store_api.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/store_api.R
@@ -211,7 +211,7 @@
#' #################### place_order ####################
#'
#' library(petstore)
-#' var_order <- Order$new() # Order | order placed for purchasing the pet
+#' var_order <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet
#'
#' #Place an order for a pet
#' api_instance <- petstore_api$new()
diff --git a/samples/client/petstore/R-httr2-wrapper/R/tag.R b/samples/client/petstore/R-httr2-wrapper/R/tag.R
index bd4aac10e2f..be068d1474c 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/tag.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/tag.R
@@ -33,11 +33,15 @@ Tag <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/user.R b/samples/client/petstore/R-httr2-wrapper/R/user.R
index 153aacb3ea5..43b51ffa41c 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/user.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/user.R
@@ -51,35 +51,51 @@ User <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`username`)) {
- stopifnot(is.character(`username`), length(`username`) == 1)
+ if (!(is.character(`username`) && length(`username`) == 1)) {
+ stop(paste("Error! Invalid data for `username`. Must be a string:", `username`))
+ }
self$`username` <- `username`
}
if (!is.null(`firstName`)) {
- stopifnot(is.character(`firstName`), length(`firstName`) == 1)
+ if (!(is.character(`firstName`) && length(`firstName`) == 1)) {
+ stop(paste("Error! Invalid data for `firstName`. Must be a string:", `firstName`))
+ }
self$`firstName` <- `firstName`
}
if (!is.null(`lastName`)) {
- stopifnot(is.character(`lastName`), length(`lastName`) == 1)
+ if (!(is.character(`lastName`) && length(`lastName`) == 1)) {
+ stop(paste("Error! Invalid data for `lastName`. Must be a string:", `lastName`))
+ }
self$`lastName` <- `lastName`
}
if (!is.null(`email`)) {
- stopifnot(is.character(`email`), length(`email`) == 1)
+ if (!(is.character(`email`) && length(`email`) == 1)) {
+ stop(paste("Error! Invalid data for `email`. Must be a string:", `email`))
+ }
self$`email` <- `email`
}
if (!is.null(`password`)) {
- stopifnot(is.character(`password`), length(`password`) == 1)
+ if (!(is.character(`password`) && length(`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", `password`))
+ }
self$`password` <- `password`
}
if (!is.null(`phone`)) {
- stopifnot(is.character(`phone`), length(`phone`) == 1)
+ if (!(is.character(`phone`) && length(`phone`) == 1)) {
+ stop(paste("Error! Invalid data for `phone`. Must be a string:", `phone`))
+ }
self$`phone` <- `phone`
}
if (!is.null(`userStatus`)) {
- stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1)
+ if (!(is.numeric(`userStatus`) && length(`userStatus`) == 1)) {
+ stop(paste("Error! Invalid data for `userStatus`. Must be an integer:", `userStatus`))
+ }
self$`userStatus` <- `userStatus`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R-httr2-wrapper/R/user_api.R b/samples/client/petstore/R-httr2-wrapper/R/user_api.R
index bc8daa69c9d..f047afe243d 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/user_api.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/user_api.R
@@ -197,7 +197,7 @@
#' #################### create_user ####################
#'
#' library(petstore)
-#' var_user <- User$new() # User | Created user object
+#' var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Created user object
#'
#' #Create user
#' api_instance <- petstore_api$new()
@@ -225,7 +225,7 @@
#' #################### create_users_with_array_input ####################
#'
#' library(petstore)
-#' var_user <- [User$new()] # array[User] | List of user object
+#' var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
#'
#' #Creates list of users with given input array
#' api_instance <- petstore_api$new()
@@ -253,7 +253,7 @@
#' #################### create_users_with_list_input ####################
#'
#' library(petstore)
-#' var_user <- [User$new()] # array[User] | List of user object
+#' var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
#'
#' #Creates list of users with given input array
#' api_instance <- petstore_api$new()
@@ -404,7 +404,7 @@
#'
#' library(petstore)
#' var_username <- "username_example" # character | name that need to be deleted
-#' var_user <- User$new() # User | Updated user object
+#' var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object
#'
#' #Updated user
#' api_instance <- petstore_api$new()
diff --git a/samples/client/petstore/R-httr2-wrapper/R/whale.R b/samples/client/petstore/R-httr2-wrapper/R/whale.R
index 936b3a2573e..dc70b1dd33e 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/whale.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/whale.R
@@ -36,15 +36,21 @@ Whale <- R6::R6Class(
#' @export
initialize = function(`className`, `hasBaleen` = NULL, `hasTeeth` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`hasBaleen`)) {
- stopifnot(is.logical(`hasBaleen`), length(`hasBaleen`) == 1)
+ if (!(is.logical(`hasBaleen`) && length(`hasBaleen`) == 1)) {
+ stop(paste("Error! Invalid data for `hasBaleen`. Must be a boolean:", `hasBaleen`))
+ }
self$`hasBaleen` <- `hasBaleen`
}
if (!is.null(`hasTeeth`)) {
- stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1)
+ if (!(is.logical(`hasTeeth`) && length(`hasTeeth`) == 1)) {
+ stop(paste("Error! Invalid data for `hasTeeth`. Must be a boolean:", `hasTeeth`))
+ }
self$`hasTeeth` <- `hasTeeth`
}
if (!is.null(additional_properties)) {
@@ -183,7 +189,9 @@ Whale <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Whale: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/R/zebra.R b/samples/client/petstore/R-httr2-wrapper/R/zebra.R
index 5c090e84cbb..c8d06d23d6a 100644
--- a/samples/client/petstore/R-httr2-wrapper/R/zebra.R
+++ b/samples/client/petstore/R-httr2-wrapper/R/zebra.R
@@ -33,14 +33,18 @@ Zebra <- R6::R6Class(
#' @export
initialize = function(`className`, `type` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`type`)) {
if (!(`type` %in% c("plains", "mountain", "grevys"))) {
stop(paste("Error! \"", `type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = ""))
}
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(additional_properties)) {
@@ -169,7 +173,9 @@ Zebra <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Zebra: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2-wrapper/README.md b/samples/client/petstore/R-httr2-wrapper/README.md
index bb481451cbd..12e7b2a7aac 100644
--- a/samples/client/petstore/R-httr2-wrapper/README.md
+++ b/samples/client/petstore/R-httr2-wrapper/README.md
@@ -115,6 +115,7 @@ Class | Method | HTTP request | Description
- [Date](docs/Date.md)
- [Dog](docs/Dog.md)
- [DogAllOf](docs/DogAllOf.md)
+ - [FormatTest](docs/FormatTest.md)
- [Mammal](docs/Mammal.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [NestedOneOf](docs/NestedOneOf.md)
diff --git a/samples/client/petstore/R-httr2-wrapper/docs/FakeApi.md b/samples/client/petstore/R-httr2-wrapper/docs/FakeApi.md
index 85182dfc8ff..67510c5f7de 100644
--- a/samples/client/petstore/R-httr2-wrapper/docs/FakeApi.md
+++ b/samples/client/petstore/R-httr2-wrapper/docs/FakeApi.md
@@ -25,7 +25,7 @@ library(petstore)
# Add a new pet to the store (optional body)
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
api_instance <- petstore_api$new()
# Configure HTTP basic authorization: http_auth
@@ -153,7 +153,7 @@ library(petstore)
# test array parameter in path
#
# prepare function argument(s)
-var_path_array <- list("inner_example") # array[character] | dummy path parameter
+var_path_array <- c("inner_example") # array[character] | dummy path parameter
api_instance <- petstore_api$new()
result <- tryCatch(
@@ -263,8 +263,8 @@ library(petstore)
# test set query parameter
#
# prepare function argument(s)
-var_set_dummy <- list("inner_example") # set[character] | set query
-var_array_dummy <- list("inner_example") # array[character] | array query
+var_set_dummy <- c("inner_example") # set[character] | set query
+var_array_dummy <- c("inner_example") # array[character] | array query
api_instance <- petstore_api$new()
result <- tryCatch(
diff --git a/samples/client/petstore/R-httr2-wrapper/docs/FormatTest.md b/samples/client/petstore/R-httr2-wrapper/docs/FormatTest.md
new file mode 100644
index 00000000000..1d483f62704
--- /dev/null
+++ b/samples/client/petstore/R-httr2-wrapper/docs/FormatTest.md
@@ -0,0 +1,23 @@
+# petstore::FormatTest
+
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**integer** | **integer** | | [optional] [Max: 100] [Min: 10]
+**int32** | **integer** | | [optional] [Max: 200] [Min: 20]
+**int64** | **integer** | | [optional]
+**number** | **numeric** | | [Max: 543.2] [Min: 32.1]
+**float** | **numeric** | | [optional] [Max: 987.6] [Min: 54.3]
+**double** | **numeric** | | [optional] [Max: 123.4] [Min: 67.8]
+**string** | **character** | | [optional] [Pattern: [a-z]/i]
+**byte** | **character** | |
+**binary** | **data.frame** | | [optional]
+**date** | **character** | | [default to "Fri Jul 19 00:00:00 UTC 2019"]
+**dateTime** | **character** | | [optional] [default to "2015-10-28T14:38:02Z"]
+**uuid** | **character** | | [optional]
+**password** | **character** | | [Max. length: 64] [Min. length: 10]
+**pattern_with_digits** | **character** | A string that is a 10 digit number. Can have leading zeros. | [optional] [Pattern: ^\\d{10}$]
+**pattern_with_digits_and_delimiter** | **character** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] [Pattern: ^image_\\d{1,3}$/i]
+
+
diff --git a/samples/client/petstore/R-httr2-wrapper/docs/PetApi.md b/samples/client/petstore/R-httr2-wrapper/docs/PetApi.md
index c7cc5d95696..e6c6c4f7980 100644
--- a/samples/client/petstore/R-httr2-wrapper/docs/PetApi.md
+++ b/samples/client/petstore/R-httr2-wrapper/docs/PetApi.md
@@ -30,7 +30,7 @@ library(petstore)
# Add a new pet to the store
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
api_instance <- petstore_api$new()
# Configure HTTP basic authorization: http_auth
@@ -154,7 +154,7 @@ library(petstore)
# Finds Pets by status
#
# prepare function argument(s)
-var_status <- list("available") # array[character] | Status values that need to be considered for filter
+var_status <- c("available") # array[character] | Status values that need to be considered for filter
api_instance <- petstore_api$new()
# Configure OAuth2 access token for authorization: petstore_auth
@@ -218,7 +218,7 @@ library(petstore)
# Finds Pets by tags
#
# prepare function argument(s)
-var_tags <- list("inner_example") # array[character] | Tags to filter by
+var_tags <- c("inner_example") # array[character] | Tags to filter by
api_instance <- petstore_api$new()
result <- tryCatch(
@@ -479,7 +479,7 @@ library(petstore)
# Update an existing pet
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
api_instance <- petstore_api$new()
# Configure OAuth2 access token for authorization: petstore_auth
diff --git a/samples/client/petstore/R-httr2-wrapper/docs/UserApi.md b/samples/client/petstore/R-httr2-wrapper/docs/UserApi.md
index 4417f05e9b9..f5961a389ba 100644
--- a/samples/client/petstore/R-httr2-wrapper/docs/UserApi.md
+++ b/samples/client/petstore/R-httr2-wrapper/docs/UserApi.md
@@ -85,7 +85,7 @@ library(petstore)
# Creates list of users with given input array
#
# prepare function argument(s)
-var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
+var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
api_instance <- petstore_api$new()
# Configure API key authorization: api_key
@@ -142,7 +142,7 @@ library(petstore)
# Creates list of users with given input array
#
# prepare function argument(s)
-var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
+var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
api_instance <- petstore_api$new()
# Configure API key authorization: api_key
diff --git a/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_format_test.R b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_format_test.R
new file mode 100644
index 00000000000..47963949104
--- /dev/null
+++ b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_format_test.R
@@ -0,0 +1,113 @@
+# Automatically generated by openapi-generator (https://openapi-generator.tech)
+# Please update as you see appropriate
+
+context("Test FormatTest")
+
+model_instance <- FormatTest$new()
+
+test_that("integer", {
+ # tests for the property `integer` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`integer`, "EXPECTED_RESULT")
+})
+
+test_that("int32", {
+ # tests for the property `int32` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`int32`, "EXPECTED_RESULT")
+})
+
+test_that("int64", {
+ # tests for the property `int64` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`int64`, "EXPECTED_RESULT")
+})
+
+test_that("number", {
+ # tests for the property `number` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`number`, "EXPECTED_RESULT")
+})
+
+test_that("float", {
+ # tests for the property `float` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`float`, "EXPECTED_RESULT")
+})
+
+test_that("double", {
+ # tests for the property `double` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`double`, "EXPECTED_RESULT")
+})
+
+test_that("string", {
+ # tests for the property `string` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`string`, "EXPECTED_RESULT")
+})
+
+test_that("byte", {
+ # tests for the property `byte` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`byte`, "EXPECTED_RESULT")
+})
+
+test_that("binary", {
+ # tests for the property `binary` (data.frame)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`binary`, "EXPECTED_RESULT")
+})
+
+test_that("date", {
+ # tests for the property `date` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`date`, "EXPECTED_RESULT")
+})
+
+test_that("dateTime", {
+ # tests for the property `dateTime` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`dateTime`, "EXPECTED_RESULT")
+})
+
+test_that("uuid", {
+ # tests for the property `uuid` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`uuid`, "EXPECTED_RESULT")
+})
+
+test_that("password", {
+ # tests for the property `password` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`password`, "EXPECTED_RESULT")
+})
+
+test_that("pattern_with_digits", {
+ # tests for the property `pattern_with_digits` (character)
+ # A string that is a 10 digit number. Can have leading zeros.
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`pattern_with_digits`, "EXPECTED_RESULT")
+})
+
+test_that("pattern_with_digits_and_delimiter", {
+ # tests for the property `pattern_with_digits_and_delimiter` (character)
+ # A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`pattern_with_digits_and_delimiter`, "EXPECTED_RESULT")
+})
diff --git a/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R
index 7c19739714f..38ce56f5733 100644
--- a/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R
+++ b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R
@@ -600,7 +600,7 @@ test_that("Tests URL validation", {
Date$public_methods$validateJSON(valid_json) # shouldn't throw exception
invalid_json <- '{"className":"date","percent_description":"abc","url_property":"invalid_url"}'
- expect_error(Date$public_methods$validateJSON(invalid_json), 'Error! Invalid URL: invalid_url') # should throw exception
+ expect_error(Date$public_methods$validateJSON(invalid_json), 'Error! Invalid data for `url_property`. Must be a URL: invalid_url') # should throw exception
# test fromJSONString with valid data
d <- Date$new()
@@ -611,5 +611,15 @@ test_that("Tests URL validation", {
# test fromJSONString with invalid data
d <- Date$new()
- expect_error(d$fromJSONString(invalid_json), 'Error! Invalid URL: invalid_url') # should throw exception
+ expect_error(d$fromJSONString(invalid_json), 'Error! Invalid data for `url_property`. Must be a URL: invalid_url') # should throw exception
+})
+
+
+test_that("Order and datetime test", {
+ # test tag
+ t <- Order$new(id = 393, petId = 12930, quantity = 12, shipDate = "2019-09-29T19:39:29Z", status = "approved")
+
+ expect_equal(t$toJSONString(), "{\"id\":393,\"petId\":12930,\"quantity\":12,\"shipDate\":\"2019-09-29T19:39:29Z\",\"status\":\"approved\",\"complete\":false}")
+
+ expect_error(Order$new(id = 393, petId = 12930, quantity = 12, shipDate = TRUE, status = "approved"), "Error! Invalid data for `shipDate`. Must be a string: TRUE")
})
diff --git a/samples/client/petstore/R-httr2/.openapi-generator/FILES b/samples/client/petstore/R-httr2/.openapi-generator/FILES
index d539ea462da..766a7cea2d5 100644
--- a/samples/client/petstore/R-httr2/.openapi-generator/FILES
+++ b/samples/client/petstore/R-httr2/.openapi-generator/FILES
@@ -21,6 +21,7 @@ R/date.R
R/dog.R
R/dog_all_of.R
R/fake_api.R
+R/format_test.R
R/mammal.R
R/model_api_response.R
R/nested_one_of.R
@@ -51,6 +52,7 @@ docs/Date.md
docs/Dog.md
docs/DogAllOf.md
docs/FakeApi.md
+docs/FormatTest.md
docs/Mammal.md
docs/ModelApiResponse.md
docs/NestedOneOf.md
diff --git a/samples/client/petstore/R-httr2/NAMESPACE b/samples/client/petstore/R-httr2/NAMESPACE
index fbdc3618b41..4337308c71a 100644
--- a/samples/client/petstore/R-httr2/NAMESPACE
+++ b/samples/client/petstore/R-httr2/NAMESPACE
@@ -26,6 +26,7 @@ export(DanishPig)
export(Date)
export(Dog)
export(DogAllOf)
+export(FormatTest)
export(Mammal)
export(ModelApiResponse)
export(NestedOneOf)
diff --git a/samples/client/petstore/R-httr2/R/allof_tag_api_response.R b/samples/client/petstore/R-httr2/R/allof_tag_api_response.R
index de8c4c80034..c4134b53e68 100644
--- a/samples/client/petstore/R-httr2/R/allof_tag_api_response.R
+++ b/samples/client/petstore/R-httr2/R/allof_tag_api_response.R
@@ -37,23 +37,33 @@ AllofTagApiResponse <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!is.null(`code`)) {
- stopifnot(is.numeric(`code`), length(`code`) == 1)
+ if (!(is.numeric(`code`) && length(`code`) == 1)) {
+ stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`))
+ }
self$`code` <- `code`
}
if (!is.null(`type`)) {
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(`message`)) {
- stopifnot(is.character(`message`), length(`message`) == 1)
+ if (!(is.character(`message`) && length(`message`) == 1)) {
+ stop(paste("Error! Invalid data for `message`. Must be a string:", `message`))
+ }
self$`message` <- `message`
}
},
diff --git a/samples/client/petstore/R-httr2/R/animal.R b/samples/client/petstore/R-httr2/R/animal.R
index f111fd1252b..6b4d78ff5ed 100644
--- a/samples/client/petstore/R-httr2/R/animal.R
+++ b/samples/client/petstore/R-httr2/R/animal.R
@@ -30,11 +30,15 @@ Animal <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
},
@@ -129,7 +133,9 @@ Animal <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/R/basque_pig.R b/samples/client/petstore/R-httr2/R/basque_pig.R
index 0a83d2b2548..28a10e6ddc4 100644
--- a/samples/client/petstore/R-httr2/R/basque_pig.R
+++ b/samples/client/petstore/R-httr2/R/basque_pig.R
@@ -28,11 +28,15 @@ BasquePig <- R6::R6Class(
#' @export
initialize = function(`className`, `color`, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
},
@@ -127,13 +131,17 @@ BasquePig <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `className` is missing."))
}
# check the required field `color`
if (!is.null(input_json$`color`)) {
- stopifnot(is.character(input_json$`color`), length(input_json$`color`) == 1)
+ if (!(is.character(input_json$`color`) && length(input_json$`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", input_json$`color`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/R/cat.R b/samples/client/petstore/R-httr2/R/cat.R
index f9bfc07a9ab..eaba966de58 100644
--- a/samples/client/petstore/R-httr2/R/cat.R
+++ b/samples/client/petstore/R-httr2/R/cat.R
@@ -32,15 +32,21 @@ Cat <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", `declawed` = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(`declawed`)) {
- stopifnot(is.logical(`declawed`), length(`declawed`) == 1)
+ if (!(is.logical(`declawed`) && length(`declawed`) == 1)) {
+ stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`))
+ }
self$`declawed` <- `declawed`
}
},
@@ -151,7 +157,9 @@ Cat <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/R/cat_all_of.R b/samples/client/petstore/R-httr2/R/cat_all_of.R
index b54b944cd26..d2889ac4990 100644
--- a/samples/client/petstore/R-httr2/R/cat_all_of.R
+++ b/samples/client/petstore/R-httr2/R/cat_all_of.R
@@ -25,7 +25,9 @@ CatAllOf <- R6::R6Class(
#' @export
initialize = function(`declawed` = NULL, ...) {
if (!is.null(`declawed`)) {
- stopifnot(is.logical(`declawed`), length(`declawed`) == 1)
+ if (!(is.logical(`declawed`) && length(`declawed`) == 1)) {
+ stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`))
+ }
self$`declawed` <- `declawed`
}
},
diff --git a/samples/client/petstore/R-httr2/R/category.R b/samples/client/petstore/R-httr2/R/category.R
index ab4f475202e..82c56228604 100644
--- a/samples/client/petstore/R-httr2/R/category.R
+++ b/samples/client/petstore/R-httr2/R/category.R
@@ -28,11 +28,15 @@ Category <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
},
diff --git a/samples/client/petstore/R-httr2/R/danish_pig.R b/samples/client/petstore/R-httr2/R/danish_pig.R
index 206cdeca85a..aea435d0fbf 100644
--- a/samples/client/petstore/R-httr2/R/danish_pig.R
+++ b/samples/client/petstore/R-httr2/R/danish_pig.R
@@ -28,11 +28,15 @@ DanishPig <- R6::R6Class(
#' @export
initialize = function(`className`, `size`, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`size`)) {
- stopifnot(is.numeric(`size`), length(`size`) == 1)
+ if (!(is.numeric(`size`) && length(`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`))
+ }
self$`size` <- `size`
}
},
@@ -127,13 +131,17 @@ DanishPig <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `className` is missing."))
}
# check the required field `size`
if (!is.null(input_json$`size`)) {
- stopifnot(is.numeric(input_json$`size`), length(input_json$`size`) == 1)
+ if (!(is.numeric(input_json$`size`) && length(input_json$`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", input_json$`size`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/R/date.R b/samples/client/petstore/R-httr2/R/date.R
index 8af974b7ae5..a188cad8fce 100644
--- a/samples/client/petstore/R-httr2/R/date.R
+++ b/samples/client/petstore/R-httr2/R/date.R
@@ -31,19 +31,25 @@ Date <- R6::R6Class(
#' @export
initialize = function(`className`, `url_property`, `percent_description` = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`url_property`)) {
- stopifnot(is.character(`url_property`), length(`url_property`) == 1)
+ if (!(is.character(`url_property`) && length(`url_property`) == 1)) {
+ stop(paste("Error! Invalid data for `url_property`. Must be a string:", `url_property`))
+ }
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", `url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", `url_property`))
}
self$`url_property` <- `url_property`
}
if (!is.null(`percent_description`)) {
- stopifnot(is.character(`percent_description`), length(`percent_description`) == 1)
+ if (!(is.character(`percent_description`) && length(`percent_description`) == 1)) {
+ stop(paste("Error! Invalid data for `percent_description`. Must be a string:", `percent_description`))
+ }
self$`percent_description` <- `percent_description`
}
},
@@ -89,7 +95,7 @@ Date <- R6::R6Class(
if (!is.null(this_object$`url_property`)) {
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`))
}
self$`url_property` <- this_object$`url_property`
}
@@ -146,7 +152,7 @@ Date <- R6::R6Class(
self$`percent_description` <- this_object$`percent_description`
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`))
}
self$`url_property` <- this_object$`url_property`
self
@@ -162,16 +168,20 @@ Date <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing."))
}
# check the required field `url_property`
if (!is.null(input_json$`url_property`)) {
- stopifnot(is.character(input_json$`url_property`), length(input_json$`url_property`) == 1)
+ if (!(is.character(input_json$`url_property`) && length(input_json$`url_property`) == 1)) {
+ stop(paste("Error! Invalid data for `url_property`. Must be a string:", input_json$`url_property`))
+ }
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(input_json$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", input_json$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", input_json$`url_property`))
}
} else {
stop(paste("The JSON input `", input, "` is invalid for Date: the required field `url_property` is missing."))
diff --git a/samples/client/petstore/R-httr2/R/dog.R b/samples/client/petstore/R-httr2/R/dog.R
index 75299cdfc78..9585ef81a58 100644
--- a/samples/client/petstore/R-httr2/R/dog.R
+++ b/samples/client/petstore/R-httr2/R/dog.R
@@ -32,15 +32,21 @@ Dog <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", `breed` = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(`breed`)) {
- stopifnot(is.character(`breed`), length(`breed`) == 1)
+ if (!(is.character(`breed`) && length(`breed`) == 1)) {
+ stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`))
+ }
self$`breed` <- `breed`
}
},
@@ -151,7 +157,9 @@ Dog <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/R/dog_all_of.R b/samples/client/petstore/R-httr2/R/dog_all_of.R
index fc8e7d0a6d6..c9ad5531225 100644
--- a/samples/client/petstore/R-httr2/R/dog_all_of.R
+++ b/samples/client/petstore/R-httr2/R/dog_all_of.R
@@ -25,7 +25,9 @@ DogAllOf <- R6::R6Class(
#' @export
initialize = function(`breed` = NULL, ...) {
if (!is.null(`breed`)) {
- stopifnot(is.character(`breed`), length(`breed`) == 1)
+ if (!(is.character(`breed`) && length(`breed`) == 1)) {
+ stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`))
+ }
self$`breed` <- `breed`
}
},
diff --git a/samples/client/petstore/R-httr2/R/fake_api.R b/samples/client/petstore/R-httr2/R/fake_api.R
index 3ead57443af..e5977eb139a 100644
--- a/samples/client/petstore/R-httr2/R/fake_api.R
+++ b/samples/client/petstore/R-httr2/R/fake_api.R
@@ -117,7 +117,7 @@
#' #################### add_pet_optional ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
#'
#' #Add a new pet to the store (optional body)
#' api_instance <- FakeApi$new()
@@ -155,7 +155,7 @@
#'
#' library(petstore)
#' var_dummy <- "dummy_example" # character | dummy required parameter
-#' var_var_data_file <- "var_data_file_example" # character | header data file
+#' var_var_data_file <- "var_data_file_example" # character | header data file (Optional)
#'
#' #test data_file to ensure it's escaped correctly
#' api_instance <- FakeApi$new()
@@ -188,7 +188,7 @@
#' #################### fake_path_array ####################
#'
#' library(petstore)
-#' var_path_array <- ["path_array_example"] # array[character] | dummy path parameter
+#' var_path_array <- c("inner_example") # array[character] | dummy path parameter
#'
#' #test array parameter in path
#' api_instance <- FakeApi$new()
@@ -238,8 +238,8 @@
#' #################### fake_set_query ####################
#'
#' library(petstore)
-#' var_set_dummy <- ["set_dummy_example"] # set[character] | set query
-#' var_array_dummy <- ["array_dummy_example"] # array[character] | array query
+#' var_set_dummy <- c("inner_example") # set[character] | set query
+#' var_array_dummy <- c("inner_example") # array[character] | array query
#'
#' #test set query parameter
#' api_instance <- FakeApi$new()
diff --git a/samples/client/petstore/R-httr2/R/format_test.R b/samples/client/petstore/R-httr2/R/format_test.R
new file mode 100644
index 00000000000..8361a769f0f
--- /dev/null
+++ b/samples/client/petstore/R-httr2/R/format_test.R
@@ -0,0 +1,678 @@
+#' Create a new FormatTest
+#'
+#' @description
+#' FormatTest Class
+#'
+#' @docType class
+#' @title FormatTest
+#' @description FormatTest Class
+#' @format An \code{R6Class} generator object
+#' @field integer integer [optional]
+#' @field int32 integer [optional]
+#' @field int64 integer [optional]
+#' @field number numeric
+#' @field float numeric [optional]
+#' @field double numeric [optional]
+#' @field string character [optional]
+#' @field byte character
+#' @field binary data.frame [optional]
+#' @field date character
+#' @field dateTime character [optional]
+#' @field uuid character [optional]
+#' @field password character
+#' @field pattern_with_digits A string that is a 10 digit number. Can have leading zeros. character [optional]
+#' @field pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. character [optional]
+#' @importFrom R6 R6Class
+#' @importFrom jsonlite fromJSON toJSON
+#' @export
+FormatTest <- R6::R6Class(
+ "FormatTest",
+ public = list(
+ `integer` = NULL,
+ `int32` = NULL,
+ `int64` = NULL,
+ `number` = NULL,
+ `float` = NULL,
+ `double` = NULL,
+ `string` = NULL,
+ `byte` = NULL,
+ `binary` = NULL,
+ `date` = NULL,
+ `dateTime` = NULL,
+ `uuid` = NULL,
+ `password` = NULL,
+ `pattern_with_digits` = NULL,
+ `pattern_with_digits_and_delimiter` = NULL,
+ #' Initialize a new FormatTest class.
+ #'
+ #' @description
+ #' Initialize a new FormatTest class.
+ #'
+ #' @param number number
+ #' @param byte byte
+ #' @param date date
+ #' @param password password
+ #' @param integer integer
+ #' @param int32 int32
+ #' @param int64 int64
+ #' @param float float
+ #' @param double double
+ #' @param string string
+ #' @param binary binary
+ #' @param dateTime dateTime. Default to "2015-10-28T14:38:02Z".
+ #' @param uuid uuid
+ #' @param pattern_with_digits A string that is a 10 digit number. Can have leading zeros.
+ #' @param pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+ #' @param ... Other optional arguments.
+ #' @export
+ initialize = function(`number`, `byte`, `date`, `password`, `integer` = NULL, `int32` = NULL, `int64` = NULL, `float` = NULL, `double` = NULL, `string` = NULL, `binary` = NULL, `dateTime` = "2015-10-28T14:38:02Z", `uuid` = NULL, `pattern_with_digits` = NULL, `pattern_with_digits_and_delimiter` = NULL, ...) {
+ if (!missing(`number`)) {
+ self$`number` <- `number`
+ }
+ if (!missing(`byte`)) {
+ self$`byte` <- `byte`
+ }
+ if (!missing(`date`)) {
+ if (!(is.character(`date`) && length(`date`) == 1)) {
+ stop(paste("Error! Invalid data for `date`. Must be a string:", `date`))
+ }
+ self$`date` <- `date`
+ }
+ if (!missing(`password`)) {
+ if (!(is.character(`password`) && length(`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", `password`))
+ }
+ self$`password` <- `password`
+ }
+ if (!is.null(`integer`)) {
+ if (!(is.numeric(`integer`) && length(`integer`) == 1)) {
+ stop(paste("Error! Invalid data for `integer`. Must be an integer:", `integer`))
+ }
+ self$`integer` <- `integer`
+ }
+ if (!is.null(`int32`)) {
+ if (!(is.numeric(`int32`) && length(`int32`) == 1)) {
+ stop(paste("Error! Invalid data for `int32`. Must be an integer:", `int32`))
+ }
+ self$`int32` <- `int32`
+ }
+ if (!is.null(`int64`)) {
+ if (!(is.numeric(`int64`) && length(`int64`) == 1)) {
+ stop(paste("Error! Invalid data for `int64`. Must be an integer:", `int64`))
+ }
+ self$`int64` <- `int64`
+ }
+ if (!is.null(`float`)) {
+ if (!(is.numeric(`float`) && length(`float`) == 1)) {
+ stop(paste("Error! Invalid data for `float`. Must be a number:", `float`))
+ }
+ self$`float` <- `float`
+ }
+ if (!is.null(`double`)) {
+ if (!(is.numeric(`double`) && length(`double`) == 1)) {
+ stop(paste("Error! Invalid data for `double`. Must be a number:", `double`))
+ }
+ self$`double` <- `double`
+ }
+ if (!is.null(`string`)) {
+ if (!(is.character(`string`) && length(`string`) == 1)) {
+ stop(paste("Error! Invalid data for `string`. Must be a string:", `string`))
+ }
+ self$`string` <- `string`
+ }
+ if (!is.null(`binary`)) {
+ self$`binary` <- `binary`
+ }
+ if (!is.null(`dateTime`)) {
+ if (!is.character(`dateTime`)) {
+ stop(paste("Error! Invalid data for `dateTime`. Must be a string:", `dateTime`))
+ }
+ self$`dateTime` <- `dateTime`
+ }
+ if (!is.null(`uuid`)) {
+ if (!(is.character(`uuid`) && length(`uuid`) == 1)) {
+ stop(paste("Error! Invalid data for `uuid`. Must be a string:", `uuid`))
+ }
+ self$`uuid` <- `uuid`
+ }
+ if (!is.null(`pattern_with_digits`)) {
+ if (!(is.character(`pattern_with_digits`) && length(`pattern_with_digits`) == 1)) {
+ stop(paste("Error! Invalid data for `pattern_with_digits`. Must be a string:", `pattern_with_digits`))
+ }
+ self$`pattern_with_digits` <- `pattern_with_digits`
+ }
+ if (!is.null(`pattern_with_digits_and_delimiter`)) {
+ if (!(is.character(`pattern_with_digits_and_delimiter`) && length(`pattern_with_digits_and_delimiter`) == 1)) {
+ stop(paste("Error! Invalid data for `pattern_with_digits_and_delimiter`. Must be a string:", `pattern_with_digits_and_delimiter`))
+ }
+ self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter`
+ }
+ },
+ #' To JSON string
+ #'
+ #' @description
+ #' To JSON String
+ #'
+ #' @return FormatTest in JSON format
+ #' @export
+ toJSON = function() {
+ FormatTestObject <- list()
+ if (!is.null(self$`integer`)) {
+ FormatTestObject[["integer"]] <-
+ self$`integer`
+ }
+ if (!is.null(self$`int32`)) {
+ FormatTestObject[["int32"]] <-
+ self$`int32`
+ }
+ if (!is.null(self$`int64`)) {
+ FormatTestObject[["int64"]] <-
+ self$`int64`
+ }
+ if (!is.null(self$`number`)) {
+ FormatTestObject[["number"]] <-
+ self$`number`
+ }
+ if (!is.null(self$`float`)) {
+ FormatTestObject[["float"]] <-
+ self$`float`
+ }
+ if (!is.null(self$`double`)) {
+ FormatTestObject[["double"]] <-
+ self$`double`
+ }
+ if (!is.null(self$`string`)) {
+ FormatTestObject[["string"]] <-
+ self$`string`
+ }
+ if (!is.null(self$`byte`)) {
+ FormatTestObject[["byte"]] <-
+ self$`byte`
+ }
+ if (!is.null(self$`binary`)) {
+ FormatTestObject[["binary"]] <-
+ self$`binary`
+ }
+ if (!is.null(self$`date`)) {
+ FormatTestObject[["date"]] <-
+ self$`date`
+ }
+ if (!is.null(self$`dateTime`)) {
+ FormatTestObject[["dateTime"]] <-
+ self$`dateTime`
+ }
+ if (!is.null(self$`uuid`)) {
+ FormatTestObject[["uuid"]] <-
+ self$`uuid`
+ }
+ if (!is.null(self$`password`)) {
+ FormatTestObject[["password"]] <-
+ self$`password`
+ }
+ if (!is.null(self$`pattern_with_digits`)) {
+ FormatTestObject[["pattern_with_digits"]] <-
+ self$`pattern_with_digits`
+ }
+ if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
+ FormatTestObject[["pattern_with_digits_and_delimiter"]] <-
+ self$`pattern_with_digits_and_delimiter`
+ }
+ FormatTestObject
+ },
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @description
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @param input_json the JSON input
+ #' @return the instance of FormatTest
+ #' @export
+ fromJSON = function(input_json) {
+ this_object <- jsonlite::fromJSON(input_json)
+ if (!is.null(this_object$`integer`)) {
+ self$`integer` <- this_object$`integer`
+ }
+ if (!is.null(this_object$`int32`)) {
+ self$`int32` <- this_object$`int32`
+ }
+ if (!is.null(this_object$`int64`)) {
+ self$`int64` <- this_object$`int64`
+ }
+ if (!is.null(this_object$`number`)) {
+ self$`number` <- this_object$`number`
+ }
+ if (!is.null(this_object$`float`)) {
+ self$`float` <- this_object$`float`
+ }
+ if (!is.null(this_object$`double`)) {
+ self$`double` <- this_object$`double`
+ }
+ if (!is.null(this_object$`string`)) {
+ self$`string` <- this_object$`string`
+ }
+ if (!is.null(this_object$`byte`)) {
+ self$`byte` <- this_object$`byte`
+ }
+ if (!is.null(this_object$`binary`)) {
+ self$`binary` <- this_object$`binary`
+ }
+ if (!is.null(this_object$`date`)) {
+ self$`date` <- this_object$`date`
+ }
+ if (!is.null(this_object$`dateTime`)) {
+ self$`dateTime` <- this_object$`dateTime`
+ }
+ if (!is.null(this_object$`uuid`)) {
+ self$`uuid` <- this_object$`uuid`
+ }
+ if (!is.null(this_object$`password`)) {
+ self$`password` <- this_object$`password`
+ }
+ if (!is.null(this_object$`pattern_with_digits`)) {
+ self$`pattern_with_digits` <- this_object$`pattern_with_digits`
+ }
+ if (!is.null(this_object$`pattern_with_digits_and_delimiter`)) {
+ self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
+ }
+ self
+ },
+ #' To JSON string
+ #'
+ #' @description
+ #' To JSON String
+ #'
+ #' @return FormatTest in JSON format
+ #' @export
+ toJSONString = function() {
+ jsoncontent <- c(
+ if (!is.null(self$`integer`)) {
+ sprintf(
+ '"integer":
+ %d
+ ',
+ self$`integer`
+ )
+ },
+ if (!is.null(self$`int32`)) {
+ sprintf(
+ '"int32":
+ %d
+ ',
+ self$`int32`
+ )
+ },
+ if (!is.null(self$`int64`)) {
+ sprintf(
+ '"int64":
+ %d
+ ',
+ self$`int64`
+ )
+ },
+ if (!is.null(self$`number`)) {
+ sprintf(
+ '"number":
+ %d
+ ',
+ self$`number`
+ )
+ },
+ if (!is.null(self$`float`)) {
+ sprintf(
+ '"float":
+ %d
+ ',
+ self$`float`
+ )
+ },
+ if (!is.null(self$`double`)) {
+ sprintf(
+ '"double":
+ %d
+ ',
+ self$`double`
+ )
+ },
+ if (!is.null(self$`string`)) {
+ sprintf(
+ '"string":
+ "%s"
+ ',
+ self$`string`
+ )
+ },
+ if (!is.null(self$`byte`)) {
+ sprintf(
+ '"byte":
+ "%s"
+ ',
+ self$`byte`
+ )
+ },
+ if (!is.null(self$`binary`)) {
+ sprintf(
+ '"binary":
+ "%s"
+ ',
+ self$`binary`
+ )
+ },
+ if (!is.null(self$`date`)) {
+ sprintf(
+ '"date":
+ "%s"
+ ',
+ self$`date`
+ )
+ },
+ if (!is.null(self$`dateTime`)) {
+ sprintf(
+ '"dateTime":
+ "%s"
+ ',
+ self$`dateTime`
+ )
+ },
+ if (!is.null(self$`uuid`)) {
+ sprintf(
+ '"uuid":
+ "%s"
+ ',
+ self$`uuid`
+ )
+ },
+ if (!is.null(self$`password`)) {
+ sprintf(
+ '"password":
+ "%s"
+ ',
+ self$`password`
+ )
+ },
+ if (!is.null(self$`pattern_with_digits`)) {
+ sprintf(
+ '"pattern_with_digits":
+ "%s"
+ ',
+ self$`pattern_with_digits`
+ )
+ },
+ if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
+ sprintf(
+ '"pattern_with_digits_and_delimiter":
+ "%s"
+ ',
+ self$`pattern_with_digits_and_delimiter`
+ )
+ }
+ )
+ jsoncontent <- paste(jsoncontent, collapse = ",")
+ json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
+ },
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @description
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @param input_json the JSON input
+ #' @return the instance of FormatTest
+ #' @export
+ fromJSONString = function(input_json) {
+ this_object <- jsonlite::fromJSON(input_json)
+ self$`integer` <- this_object$`integer`
+ self$`int32` <- this_object$`int32`
+ self$`int64` <- this_object$`int64`
+ self$`number` <- this_object$`number`
+ self$`float` <- this_object$`float`
+ self$`double` <- this_object$`double`
+ self$`string` <- this_object$`string`
+ self$`byte` <- this_object$`byte`
+ self$`binary` <- this_object$`binary`
+ self$`date` <- this_object$`date`
+ self$`dateTime` <- this_object$`dateTime`
+ self$`uuid` <- this_object$`uuid`
+ self$`password` <- this_object$`password`
+ self$`pattern_with_digits` <- this_object$`pattern_with_digits`
+ self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
+ self
+ },
+ #' Validate JSON input with respect to FormatTest
+ #'
+ #' @description
+ #' Validate JSON input with respect to FormatTest and throw an exception if invalid
+ #'
+ #' @param input the JSON input
+ #' @export
+ validateJSON = function(input) {
+ input_json <- jsonlite::fromJSON(input)
+ # check the required field `number`
+ if (!is.null(input_json$`number`)) {
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `number` is missing."))
+ }
+ # check the required field `byte`
+ if (!is.null(input_json$`byte`)) {
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `byte` is missing."))
+ }
+ # check the required field `date`
+ if (!is.null(input_json$`date`)) {
+ if (!(is.character(input_json$`date`) && length(input_json$`date`) == 1)) {
+ stop(paste("Error! Invalid data for `date`. Must be a string:", input_json$`date`))
+ }
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `date` is missing."))
+ }
+ # check the required field `password`
+ if (!is.null(input_json$`password`)) {
+ if (!(is.character(input_json$`password`) && length(input_json$`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", input_json$`password`))
+ }
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing."))
+ }
+ },
+ #' To string (JSON format)
+ #'
+ #' @description
+ #' To string (JSON format)
+ #'
+ #' @return String representation of FormatTest
+ #' @export
+ toString = function() {
+ self$toJSONString()
+ },
+ #' Return true if the values in all fields are valid.
+ #'
+ #' @description
+ #' Return true if the values in all fields are valid.
+ #'
+ #' @return true if the values in all fields are valid.
+ #' @export
+ isValid = function() {
+ if (self$`integer` > 100) {
+ return(FALSE)
+ }
+ if (self$`integer` < 10) {
+ return(FALSE)
+ }
+
+ if (self$`int32` > 200) {
+ return(FALSE)
+ }
+ if (self$`int32` < 20) {
+ return(FALSE)
+ }
+
+ # check if the required `number` is null
+ if (is.null(self$`number`)) {
+ return(FALSE)
+ }
+
+ if (self$`number` > 543.2) {
+ return(FALSE)
+ }
+ if (self$`number` < 32.1) {
+ return(FALSE)
+ }
+
+ if (self$`float` > 987.6) {
+ return(FALSE)
+ }
+ if (self$`float` < 54.3) {
+ return(FALSE)
+ }
+
+ if (self$`double` > 123.4) {
+ return(FALSE)
+ }
+ if (self$`double` < 67.8) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`string`, "[a-z]/i")) {
+ return(FALSE)
+ }
+
+ # check if the required `byte` is null
+ if (is.null(self$`byte`)) {
+ return(FALSE)
+ }
+
+ # check if the required `date` is null
+ if (is.null(self$`date`)) {
+ return(FALSE)
+ }
+
+ # check if the required `password` is null
+ if (is.null(self$`password`)) {
+ return(FALSE)
+ }
+
+ if (nchar(self$`password`) > 64) {
+ return(FALSE)
+ }
+ if (nchar(self$`password`) < 10) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
+ return(FALSE)
+ }
+
+ TRUE
+ },
+ #' Return a list of invalid fields (if any).
+ #'
+ #' @description
+ #' Return a list of invalid fields (if any).
+ #'
+ #' @return A list of invalid fields (if any).
+ #' @export
+ getInvalidFields = function() {
+ invalid_fields <- list()
+ if (self$`integer` > 100) {
+ invalid_fields["integer"] <- "Invalid value for `integer`, must be smaller than or equal to 100."
+ }
+ if (self$`integer` < 10) {
+ invalid_fields["integer"] <- "Invalid value for `integer`, must be bigger than or equal to 10."
+ }
+
+ if (self$`int32` > 200) {
+ invalid_fields["int32"] <- "Invalid value for `int32`, must be smaller than or equal to 200."
+ }
+ if (self$`int32` < 20) {
+ invalid_fields["int32"] <- "Invalid value for `int32`, must be bigger than or equal to 20."
+ }
+
+ # check if the required `number` is null
+ if (is.null(self$`number`)) {
+ invalid_fields["number"] <- "Non-nullable required field `number` cannot be null."
+ }
+
+ if (self$`number` > 543.2) {
+ invalid_fields["number"] <- "Invalid value for `number`, must be smaller than or equal to 543.2."
+ }
+ if (self$`number` < 32.1) {
+ invalid_fields["number"] <- "Invalid value for `number`, must be bigger than or equal to 32.1."
+ }
+
+ if (self$`float` > 987.6) {
+ invalid_fields["float"] <- "Invalid value for `float`, must be smaller than or equal to 987.6."
+ }
+ if (self$`float` < 54.3) {
+ invalid_fields["float"] <- "Invalid value for `float`, must be bigger than or equal to 54.3."
+ }
+
+ if (self$`double` > 123.4) {
+ invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 123.4."
+ }
+ if (self$`double` < 67.8) {
+ invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 67.8."
+ }
+
+ if (!str_detect(self$`string`, "[a-z]/i")) {
+ invalid_fields["string"] <- "Invalid value for `string`, must conform to the pattern [a-z]/i."
+ }
+
+ # check if the required `byte` is null
+ if (is.null(self$`byte`)) {
+ invalid_fields["byte"] <- "Non-nullable required field `byte` cannot be null."
+ }
+
+ # check if the required `date` is null
+ if (is.null(self$`date`)) {
+ invalid_fields["date"] <- "Non-nullable required field `date` cannot be null."
+ }
+
+ # check if the required `password` is null
+ if (is.null(self$`password`)) {
+ invalid_fields["password"] <- "Non-nullable required field `password` cannot be null."
+ }
+
+ if (nchar(self$`password`) > 64) {
+ invalid_fields["password"] <- "Invalid length for `password`, must be smaller than or equal to 64."
+ }
+ if (nchar(self$`password`) < 10) {
+ invalid_fields["password"] <- "Invalid length for `password`, must be bigger than or equal to 10."
+ }
+
+ if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
+ invalid_fields["pattern_with_digits"] <- "Invalid value for `pattern_with_digits`, must conform to the pattern ^\\d{10}$."
+ }
+
+ if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
+ invalid_fields["pattern_with_digits_and_delimiter"] <- "Invalid value for `pattern_with_digits_and_delimiter`, must conform to the pattern ^image_\\d{1,3}$/i."
+ }
+
+ invalid_fields
+ },
+ #' Print the object
+ #'
+ #' @description
+ #' Print the object
+ #'
+ #' @export
+ print = function() {
+ print(jsonlite::prettify(self$toJSONString()))
+ invisible(self)
+ }
+ ),
+ # Lock the class to prevent modifications to the method or field
+ lock_class = TRUE
+)
+## Uncomment below to unlock the class to allow modifications of the method or field
+# FormatTest$unlock()
+#
+## Below is an example to define the print fnuction
+# FormatTest$set("public", "print", function(...) {
+# print(jsonlite::prettify(self$toJSONString()))
+# invisible(self)
+# })
+## Uncomment below to lock the class to prevent modifications to the method or field
+# FormatTest$lock()
+
diff --git a/samples/client/petstore/R-httr2/R/model_api_response.R b/samples/client/petstore/R-httr2/R/model_api_response.R
index de8760bdf23..0fd0c71e99c 100644
--- a/samples/client/petstore/R-httr2/R/model_api_response.R
+++ b/samples/client/petstore/R-httr2/R/model_api_response.R
@@ -31,15 +31,21 @@ ModelApiResponse <- R6::R6Class(
#' @export
initialize = function(`code` = NULL, `type` = NULL, `message` = NULL, ...) {
if (!is.null(`code`)) {
- stopifnot(is.numeric(`code`), length(`code`) == 1)
+ if (!(is.numeric(`code`) && length(`code`) == 1)) {
+ stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`))
+ }
self$`code` <- `code`
}
if (!is.null(`type`)) {
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(`message`)) {
- stopifnot(is.character(`message`), length(`message`) == 1)
+ if (!(is.character(`message`) && length(`message`) == 1)) {
+ stop(paste("Error! Invalid data for `message`. Must be a string:", `message`))
+ }
self$`message` <- `message`
}
},
diff --git a/samples/client/petstore/R-httr2/R/nested_one_of.R b/samples/client/petstore/R-httr2/R/nested_one_of.R
index 542a11c4d21..beef5124f9b 100644
--- a/samples/client/petstore/R-httr2/R/nested_one_of.R
+++ b/samples/client/petstore/R-httr2/R/nested_one_of.R
@@ -28,7 +28,9 @@ NestedOneOf <- R6::R6Class(
#' @export
initialize = function(`size` = NULL, `nested_pig` = NULL, ...) {
if (!is.null(`size`)) {
- stopifnot(is.numeric(`size`), length(`size`) == 1)
+ if (!(is.numeric(`size`) && length(`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`))
+ }
self$`size` <- `size`
}
if (!is.null(`nested_pig`)) {
diff --git a/samples/client/petstore/R-httr2/R/order.R b/samples/client/petstore/R-httr2/R/order.R
index 01b511bb351..b5604d99900 100644
--- a/samples/client/petstore/R-httr2/R/order.R
+++ b/samples/client/petstore/R-httr2/R/order.R
@@ -40,30 +40,42 @@ Order <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`petId`)) {
- stopifnot(is.numeric(`petId`), length(`petId`) == 1)
+ if (!(is.numeric(`petId`) && length(`petId`) == 1)) {
+ stop(paste("Error! Invalid data for `petId`. Must be an integer:", `petId`))
+ }
self$`petId` <- `petId`
}
if (!is.null(`quantity`)) {
- stopifnot(is.numeric(`quantity`), length(`quantity`) == 1)
+ if (!(is.numeric(`quantity`) && length(`quantity`) == 1)) {
+ stop(paste("Error! Invalid data for `quantity`. Must be an integer:", `quantity`))
+ }
self$`quantity` <- `quantity`
}
if (!is.null(`shipDate`)) {
- stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
+ if (!is.character(`shipDate`)) {
+ stop(paste("Error! Invalid data for `shipDate`. Must be a string:", `shipDate`))
+ }
self$`shipDate` <- `shipDate`
}
if (!is.null(`status`)) {
if (!(`status` %in% c("placed", "approved", "delivered"))) {
stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"placed\", \"approved\", \"delivered\".", sep = ""))
}
- stopifnot(is.character(`status`), length(`status`) == 1)
+ if (!(is.character(`status`) && length(`status`) == 1)) {
+ stop(paste("Error! Invalid data for `status`. Must be a string:", `status`))
+ }
self$`status` <- `status`
}
if (!is.null(`complete`)) {
- stopifnot(is.logical(`complete`), length(`complete`) == 1)
+ if (!(is.logical(`complete`) && length(`complete`) == 1)) {
+ stop(paste("Error! Invalid data for `complete`. Must be a boolean:", `complete`))
+ }
self$`complete` <- `complete`
}
},
diff --git a/samples/client/petstore/R-httr2/R/pet.R b/samples/client/petstore/R-httr2/R/pet.R
index f840c7ca9ab..be5b2767ef1 100644
--- a/samples/client/petstore/R-httr2/R/pet.R
+++ b/samples/client/petstore/R-httr2/R/pet.R
@@ -40,7 +40,9 @@ Pet <- R6::R6Class(
#' @export
initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, ...) {
if (!missing(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!missing(`photoUrls`)) {
@@ -49,7 +51,9 @@ Pet <- R6::R6Class(
self$`photoUrls` <- `photoUrls`
}
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`category`)) {
@@ -65,7 +69,9 @@ Pet <- R6::R6Class(
if (!(`status` %in% c("available", "pending", "sold"))) {
stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = ""))
}
- stopifnot(is.character(`status`), length(`status`) == 1)
+ if (!(is.character(`status`) && length(`status`) == 1)) {
+ stop(paste("Error! Invalid data for `status`. Must be a string:", `status`))
+ }
self$`status` <- `status`
}
},
@@ -232,7 +238,9 @@ Pet <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `name`
if (!is.null(input_json$`name`)) {
- stopifnot(is.character(input_json$`name`), length(input_json$`name`) == 1)
+ if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/R/pet_api.R b/samples/client/petstore/R-httr2/R/pet_api.R
index 563895e44bf..77d3de45219 100644
--- a/samples/client/petstore/R-httr2/R/pet_api.R
+++ b/samples/client/petstore/R-httr2/R/pet_api.R
@@ -288,7 +288,7 @@
#' #################### add_pet ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
#'
#' #Add a new pet to the store
#' api_instance <- PetApi$new()
@@ -326,7 +326,7 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | Pet id to delete
-#' var_api_key <- "api_key_example" # character |
+#' var_api_key <- "api_key_example" # character | (Optional)
#'
#' #Deletes a pet
#' api_instance <- PetApi$new()
@@ -354,7 +354,7 @@
#' #################### find_pets_by_status ####################
#'
#' library(petstore)
-#' var_status <- ["status_example"] # array[character] | Status values that need to be considered for filter
+#' var_status <- c("available") # array[character] | Status values that need to be considered for filter
#'
#' #Finds Pets by status
#' api_instance <- PetApi$new()
@@ -390,7 +390,7 @@
#' #################### find_pets_by_tags ####################
#'
#' library(petstore)
-#' var_tags <- ["tags_example"] # array[character] | Tags to filter by
+#' var_tags <- c("inner_example") # array[character] | Tags to filter by
#'
#' #Finds Pets by tags
#' api_instance <- PetApi$new()
@@ -537,7 +537,7 @@
#' #################### update_pet ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
#'
#' #Update an existing pet
#' api_instance <- PetApi$new()
@@ -574,8 +574,8 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | ID of pet that needs to be updated
-#' var_name <- "name_example" # character | Updated name of the pet
-#' var_status <- "status_example" # character | Updated status of the pet
+#' var_name <- "name_example" # character | Updated name of the pet (Optional)
+#' var_status <- "status_example" # character | Updated status of the pet (Optional)
#'
#' #Updates a pet in the store with form data
#' api_instance <- PetApi$new()
@@ -601,8 +601,8 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | ID of pet to update
-#' var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server
-#' var_file <- File.new('/path/to/file') # data.frame | file to upload
+#' var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server (Optional)
+#' var_file <- File.new('/path/to/file') # data.frame | file to upload (Optional)
#'
#' #uploads an image
#' api_instance <- PetApi$new()
diff --git a/samples/client/petstore/R-httr2/R/special.R b/samples/client/petstore/R-httr2/R/special.R
index 32ced477530..e2089142e9d 100644
--- a/samples/client/petstore/R-httr2/R/special.R
+++ b/samples/client/petstore/R-httr2/R/special.R
@@ -51,27 +51,39 @@ Special <- R6::R6Class(
self$`set_test` <- `set_test`
}
if (!is.null(`item_self`)) {
- stopifnot(is.numeric(`item_self`), length(`item_self`) == 1)
+ if (!(is.numeric(`item_self`) && length(`item_self`) == 1)) {
+ stop(paste("Error! Invalid data for `item_self`. Must be an integer:", `item_self`))
+ }
self$`item_self` <- `item_self`
}
if (!is.null(`item_private`)) {
- stopifnot(is.character(`item_private`), length(`item_private`) == 1)
+ if (!(is.character(`item_private`) && length(`item_private`) == 1)) {
+ stop(paste("Error! Invalid data for `item_private`. Must be a string:", `item_private`))
+ }
self$`item_private` <- `item_private`
}
if (!is.null(`item_super`)) {
- stopifnot(is.character(`item_super`), length(`item_super`) == 1)
+ if (!(is.character(`item_super`) && length(`item_super`) == 1)) {
+ stop(paste("Error! Invalid data for `item_super`. Must be a string:", `item_super`))
+ }
self$`item_super` <- `item_super`
}
if (!is.null(`123_number`)) {
- stopifnot(is.character(`123_number`), length(`123_number`) == 1)
+ if (!(is.character(`123_number`) && length(`123_number`) == 1)) {
+ stop(paste("Error! Invalid data for `123_number`. Must be a string:", `123_number`))
+ }
self$`123_number` <- `123_number`
}
if (!is.null(`array[test]`)) {
- stopifnot(is.character(`array[test]`), length(`array[test]`) == 1)
+ if (!(is.character(`array[test]`) && length(`array[test]`) == 1)) {
+ stop(paste("Error! Invalid data for `array[test]`. Must be a string:", `array[test]`))
+ }
self$`array[test]` <- `array[test]`
}
if (!is.null(`empty_string`)) {
- stopifnot(is.character(`empty_string`), length(`empty_string`) == 1)
+ if (!(is.character(`empty_string`) && length(`empty_string`) == 1)) {
+ stop(paste("Error! Invalid data for `empty_string`. Must be a string:", `empty_string`))
+ }
self$`empty_string` <- `empty_string`
}
},
diff --git a/samples/client/petstore/R-httr2/R/store_api.R b/samples/client/petstore/R-httr2/R/store_api.R
index ef974aa9a56..b5941c11d85 100644
--- a/samples/client/petstore/R-httr2/R/store_api.R
+++ b/samples/client/petstore/R-httr2/R/store_api.R
@@ -211,7 +211,7 @@
#' #################### place_order ####################
#'
#' library(petstore)
-#' var_order <- Order$new() # Order | order placed for purchasing the pet
+#' var_order <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet
#'
#' #Place an order for a pet
#' api_instance <- StoreApi$new()
diff --git a/samples/client/petstore/R-httr2/R/tag.R b/samples/client/petstore/R-httr2/R/tag.R
index 8db55133014..51603e72ab3 100644
--- a/samples/client/petstore/R-httr2/R/tag.R
+++ b/samples/client/petstore/R-httr2/R/tag.R
@@ -28,11 +28,15 @@ Tag <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
},
diff --git a/samples/client/petstore/R-httr2/R/user.R b/samples/client/petstore/R-httr2/R/user.R
index c3db6eb00d7..78896afef3c 100644
--- a/samples/client/petstore/R-httr2/R/user.R
+++ b/samples/client/petstore/R-httr2/R/user.R
@@ -46,35 +46,51 @@ User <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`username`)) {
- stopifnot(is.character(`username`), length(`username`) == 1)
+ if (!(is.character(`username`) && length(`username`) == 1)) {
+ stop(paste("Error! Invalid data for `username`. Must be a string:", `username`))
+ }
self$`username` <- `username`
}
if (!is.null(`firstName`)) {
- stopifnot(is.character(`firstName`), length(`firstName`) == 1)
+ if (!(is.character(`firstName`) && length(`firstName`) == 1)) {
+ stop(paste("Error! Invalid data for `firstName`. Must be a string:", `firstName`))
+ }
self$`firstName` <- `firstName`
}
if (!is.null(`lastName`)) {
- stopifnot(is.character(`lastName`), length(`lastName`) == 1)
+ if (!(is.character(`lastName`) && length(`lastName`) == 1)) {
+ stop(paste("Error! Invalid data for `lastName`. Must be a string:", `lastName`))
+ }
self$`lastName` <- `lastName`
}
if (!is.null(`email`)) {
- stopifnot(is.character(`email`), length(`email`) == 1)
+ if (!(is.character(`email`) && length(`email`) == 1)) {
+ stop(paste("Error! Invalid data for `email`. Must be a string:", `email`))
+ }
self$`email` <- `email`
}
if (!is.null(`password`)) {
- stopifnot(is.character(`password`), length(`password`) == 1)
+ if (!(is.character(`password`) && length(`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", `password`))
+ }
self$`password` <- `password`
}
if (!is.null(`phone`)) {
- stopifnot(is.character(`phone`), length(`phone`) == 1)
+ if (!(is.character(`phone`) && length(`phone`) == 1)) {
+ stop(paste("Error! Invalid data for `phone`. Must be a string:", `phone`))
+ }
self$`phone` <- `phone`
}
if (!is.null(`userStatus`)) {
- stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1)
+ if (!(is.numeric(`userStatus`) && length(`userStatus`) == 1)) {
+ stop(paste("Error! Invalid data for `userStatus`. Must be an integer:", `userStatus`))
+ }
self$`userStatus` <- `userStatus`
}
},
diff --git a/samples/client/petstore/R-httr2/R/user_api.R b/samples/client/petstore/R-httr2/R/user_api.R
index 379460748f0..50c752bd7e6 100644
--- a/samples/client/petstore/R-httr2/R/user_api.R
+++ b/samples/client/petstore/R-httr2/R/user_api.R
@@ -197,7 +197,7 @@
#' #################### create_user ####################
#'
#' library(petstore)
-#' var_user <- User$new() # User | Created user object
+#' var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Created user object
#'
#' #Create user
#' api_instance <- UserApi$new()
@@ -225,7 +225,7 @@
#' #################### create_users_with_array_input ####################
#'
#' library(petstore)
-#' var_user <- [User$new()] # array[User] | List of user object
+#' var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
#'
#' #Creates list of users with given input array
#' api_instance <- UserApi$new()
@@ -253,7 +253,7 @@
#' #################### create_users_with_list_input ####################
#'
#' library(petstore)
-#' var_user <- [User$new()] # array[User] | List of user object
+#' var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
#'
#' #Creates list of users with given input array
#' api_instance <- UserApi$new()
@@ -404,7 +404,7 @@
#'
#' library(petstore)
#' var_username <- "username_example" # character | name that need to be deleted
-#' var_user <- User$new() # User | Updated user object
+#' var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object
#'
#' #Updated user
#' api_instance <- UserApi$new()
diff --git a/samples/client/petstore/R-httr2/R/whale.R b/samples/client/petstore/R-httr2/R/whale.R
index 51a3f0b69f2..084df84385a 100644
--- a/samples/client/petstore/R-httr2/R/whale.R
+++ b/samples/client/petstore/R-httr2/R/whale.R
@@ -31,15 +31,21 @@ Whale <- R6::R6Class(
#' @export
initialize = function(`className`, `hasBaleen` = NULL, `hasTeeth` = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`hasBaleen`)) {
- stopifnot(is.logical(`hasBaleen`), length(`hasBaleen`) == 1)
+ if (!(is.logical(`hasBaleen`) && length(`hasBaleen`) == 1)) {
+ stop(paste("Error! Invalid data for `hasBaleen`. Must be a boolean:", `hasBaleen`))
+ }
self$`hasBaleen` <- `hasBaleen`
}
if (!is.null(`hasTeeth`)) {
- stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1)
+ if (!(is.logical(`hasTeeth`) && length(`hasTeeth`) == 1)) {
+ stop(paste("Error! Invalid data for `hasTeeth`. Must be a boolean:", `hasTeeth`))
+ }
self$`hasTeeth` <- `hasTeeth`
}
},
@@ -150,7 +156,9 @@ Whale <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Whale: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/R/zebra.R b/samples/client/petstore/R-httr2/R/zebra.R
index 7feafc3745c..0a1aa587e11 100644
--- a/samples/client/petstore/R-httr2/R/zebra.R
+++ b/samples/client/petstore/R-httr2/R/zebra.R
@@ -28,14 +28,18 @@ Zebra <- R6::R6Class(
#' @export
initialize = function(`className`, `type` = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`type`)) {
if (!(`type` %in% c("plains", "mountain", "grevys"))) {
stop(paste("Error! \"", `type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = ""))
}
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
},
@@ -136,7 +140,9 @@ Zebra <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Zebra: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R-httr2/README.md b/samples/client/petstore/R-httr2/README.md
index bb481451cbd..12e7b2a7aac 100644
--- a/samples/client/petstore/R-httr2/README.md
+++ b/samples/client/petstore/R-httr2/README.md
@@ -115,6 +115,7 @@ Class | Method | HTTP request | Description
- [Date](docs/Date.md)
- [Dog](docs/Dog.md)
- [DogAllOf](docs/DogAllOf.md)
+ - [FormatTest](docs/FormatTest.md)
- [Mammal](docs/Mammal.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [NestedOneOf](docs/NestedOneOf.md)
diff --git a/samples/client/petstore/R-httr2/docs/FakeApi.md b/samples/client/petstore/R-httr2/docs/FakeApi.md
index 0c5e8a0af97..a6a30c06e09 100644
--- a/samples/client/petstore/R-httr2/docs/FakeApi.md
+++ b/samples/client/petstore/R-httr2/docs/FakeApi.md
@@ -25,7 +25,7 @@ library(petstore)
# Add a new pet to the store (optional body)
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
api_instance <- FakeApi$new()
# Configure HTTP basic authorization: http_auth
@@ -153,7 +153,7 @@ library(petstore)
# test array parameter in path
#
# prepare function argument(s)
-var_path_array <- list("inner_example") # array[character] | dummy path parameter
+var_path_array <- c("inner_example") # array[character] | dummy path parameter
api_instance <- FakeApi$new()
result <- tryCatch(
@@ -263,8 +263,8 @@ library(petstore)
# test set query parameter
#
# prepare function argument(s)
-var_set_dummy <- list("inner_example") # set[character] | set query
-var_array_dummy <- list("inner_example") # array[character] | array query
+var_set_dummy <- c("inner_example") # set[character] | set query
+var_array_dummy <- c("inner_example") # array[character] | array query
api_instance <- FakeApi$new()
result <- tryCatch(
diff --git a/samples/client/petstore/R-httr2/docs/FormatTest.md b/samples/client/petstore/R-httr2/docs/FormatTest.md
new file mode 100644
index 00000000000..1d483f62704
--- /dev/null
+++ b/samples/client/petstore/R-httr2/docs/FormatTest.md
@@ -0,0 +1,23 @@
+# petstore::FormatTest
+
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**integer** | **integer** | | [optional] [Max: 100] [Min: 10]
+**int32** | **integer** | | [optional] [Max: 200] [Min: 20]
+**int64** | **integer** | | [optional]
+**number** | **numeric** | | [Max: 543.2] [Min: 32.1]
+**float** | **numeric** | | [optional] [Max: 987.6] [Min: 54.3]
+**double** | **numeric** | | [optional] [Max: 123.4] [Min: 67.8]
+**string** | **character** | | [optional] [Pattern: [a-z]/i]
+**byte** | **character** | |
+**binary** | **data.frame** | | [optional]
+**date** | **character** | | [default to "Fri Jul 19 00:00:00 UTC 2019"]
+**dateTime** | **character** | | [optional] [default to "2015-10-28T14:38:02Z"]
+**uuid** | **character** | | [optional]
+**password** | **character** | | [Max. length: 64] [Min. length: 10]
+**pattern_with_digits** | **character** | A string that is a 10 digit number. Can have leading zeros. | [optional] [Pattern: ^\\d{10}$]
+**pattern_with_digits_and_delimiter** | **character** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] [Pattern: ^image_\\d{1,3}$/i]
+
+
diff --git a/samples/client/petstore/R-httr2/docs/PetApi.md b/samples/client/petstore/R-httr2/docs/PetApi.md
index 26936a4b787..d33dc0b9357 100644
--- a/samples/client/petstore/R-httr2/docs/PetApi.md
+++ b/samples/client/petstore/R-httr2/docs/PetApi.md
@@ -30,7 +30,7 @@ library(petstore)
# Add a new pet to the store
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
api_instance <- PetApi$new()
# Configure HTTP basic authorization: http_auth
@@ -154,7 +154,7 @@ library(petstore)
# Finds Pets by status
#
# prepare function argument(s)
-var_status <- list("available") # array[character] | Status values that need to be considered for filter
+var_status <- c("available") # array[character] | Status values that need to be considered for filter
api_instance <- PetApi$new()
# Configure OAuth2 access token for authorization: petstore_auth
@@ -218,7 +218,7 @@ library(petstore)
# Finds Pets by tags
#
# prepare function argument(s)
-var_tags <- list("inner_example") # array[character] | Tags to filter by
+var_tags <- c("inner_example") # array[character] | Tags to filter by
api_instance <- PetApi$new()
result <- tryCatch(
@@ -479,7 +479,7 @@ library(petstore)
# Update an existing pet
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
api_instance <- PetApi$new()
# Configure OAuth2 access token for authorization: petstore_auth
diff --git a/samples/client/petstore/R-httr2/docs/UserApi.md b/samples/client/petstore/R-httr2/docs/UserApi.md
index 7bb012fd1b4..ed7ddfbc35e 100644
--- a/samples/client/petstore/R-httr2/docs/UserApi.md
+++ b/samples/client/petstore/R-httr2/docs/UserApi.md
@@ -85,7 +85,7 @@ library(petstore)
# Creates list of users with given input array
#
# prepare function argument(s)
-var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
+var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
api_instance <- UserApi$new()
# Configure API key authorization: api_key
@@ -142,7 +142,7 @@ library(petstore)
# Creates list of users with given input array
#
# prepare function argument(s)
-var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
+var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
api_instance <- UserApi$new()
# Configure API key authorization: api_key
diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_format_test.R b/samples/client/petstore/R-httr2/tests/testthat/test_format_test.R
new file mode 100644
index 00000000000..47963949104
--- /dev/null
+++ b/samples/client/petstore/R-httr2/tests/testthat/test_format_test.R
@@ -0,0 +1,113 @@
+# Automatically generated by openapi-generator (https://openapi-generator.tech)
+# Please update as you see appropriate
+
+context("Test FormatTest")
+
+model_instance <- FormatTest$new()
+
+test_that("integer", {
+ # tests for the property `integer` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`integer`, "EXPECTED_RESULT")
+})
+
+test_that("int32", {
+ # tests for the property `int32` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`int32`, "EXPECTED_RESULT")
+})
+
+test_that("int64", {
+ # tests for the property `int64` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`int64`, "EXPECTED_RESULT")
+})
+
+test_that("number", {
+ # tests for the property `number` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`number`, "EXPECTED_RESULT")
+})
+
+test_that("float", {
+ # tests for the property `float` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`float`, "EXPECTED_RESULT")
+})
+
+test_that("double", {
+ # tests for the property `double` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`double`, "EXPECTED_RESULT")
+})
+
+test_that("string", {
+ # tests for the property `string` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`string`, "EXPECTED_RESULT")
+})
+
+test_that("byte", {
+ # tests for the property `byte` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`byte`, "EXPECTED_RESULT")
+})
+
+test_that("binary", {
+ # tests for the property `binary` (data.frame)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`binary`, "EXPECTED_RESULT")
+})
+
+test_that("date", {
+ # tests for the property `date` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`date`, "EXPECTED_RESULT")
+})
+
+test_that("dateTime", {
+ # tests for the property `dateTime` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`dateTime`, "EXPECTED_RESULT")
+})
+
+test_that("uuid", {
+ # tests for the property `uuid` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`uuid`, "EXPECTED_RESULT")
+})
+
+test_that("password", {
+ # tests for the property `password` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`password`, "EXPECTED_RESULT")
+})
+
+test_that("pattern_with_digits", {
+ # tests for the property `pattern_with_digits` (character)
+ # A string that is a 10 digit number. Can have leading zeros.
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`pattern_with_digits`, "EXPECTED_RESULT")
+})
+
+test_that("pattern_with_digits_and_delimiter", {
+ # tests for the property `pattern_with_digits_and_delimiter` (character)
+ # A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`pattern_with_digits_and_delimiter`, "EXPECTED_RESULT")
+})
diff --git a/samples/client/petstore/R/.openapi-generator/FILES b/samples/client/petstore/R/.openapi-generator/FILES
index d539ea462da..766a7cea2d5 100644
--- a/samples/client/petstore/R/.openapi-generator/FILES
+++ b/samples/client/petstore/R/.openapi-generator/FILES
@@ -21,6 +21,7 @@ R/date.R
R/dog.R
R/dog_all_of.R
R/fake_api.R
+R/format_test.R
R/mammal.R
R/model_api_response.R
R/nested_one_of.R
@@ -51,6 +52,7 @@ docs/Date.md
docs/Dog.md
docs/DogAllOf.md
docs/FakeApi.md
+docs/FormatTest.md
docs/Mammal.md
docs/ModelApiResponse.md
docs/NestedOneOf.md
diff --git a/samples/client/petstore/R/NAMESPACE b/samples/client/petstore/R/NAMESPACE
index a38534972b8..b1057393be9 100644
--- a/samples/client/petstore/R/NAMESPACE
+++ b/samples/client/petstore/R/NAMESPACE
@@ -26,6 +26,7 @@ export(DanishPig)
export(Date)
export(Dog)
export(DogAllOf)
+export(FormatTest)
export(Mammal)
export(ModelApiResponse)
export(NestedOneOf)
diff --git a/samples/client/petstore/R/R/allof_tag_api_response.R b/samples/client/petstore/R/R/allof_tag_api_response.R
index e485c15e4ca..220d89ee503 100644
--- a/samples/client/petstore/R/R/allof_tag_api_response.R
+++ b/samples/client/petstore/R/R/allof_tag_api_response.R
@@ -42,23 +42,33 @@ AllofTagApiResponse <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!is.null(`code`)) {
- stopifnot(is.numeric(`code`), length(`code`) == 1)
+ if (!(is.numeric(`code`) && length(`code`) == 1)) {
+ stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`))
+ }
self$`code` <- `code`
}
if (!is.null(`type`)) {
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(`message`)) {
- stopifnot(is.character(`message`), length(`message`) == 1)
+ if (!(is.character(`message`) && length(`message`) == 1)) {
+ stop(paste("Error! Invalid data for `message`. Must be a string:", `message`))
+ }
self$`message` <- `message`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/animal.R b/samples/client/petstore/R/R/animal.R
index 632b160087d..b506bced42f 100644
--- a/samples/client/petstore/R/R/animal.R
+++ b/samples/client/petstore/R/R/animal.R
@@ -35,11 +35,15 @@ Animal <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(additional_properties)) {
@@ -162,7 +166,9 @@ Animal <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R/R/basque_pig.R b/samples/client/petstore/R/R/basque_pig.R
index 2335bbe37c0..ac83042c8cf 100644
--- a/samples/client/petstore/R/R/basque_pig.R
+++ b/samples/client/petstore/R/R/basque_pig.R
@@ -33,11 +33,15 @@ BasquePig <- R6::R6Class(
#' @export
initialize = function(`className`, `color`, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(additional_properties)) {
@@ -160,13 +164,17 @@ BasquePig <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `className` is missing."))
}
# check the required field `color`
if (!is.null(input_json$`color`)) {
- stopifnot(is.character(input_json$`color`), length(input_json$`color`) == 1)
+ if (!(is.character(input_json$`color`) && length(input_json$`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", input_json$`color`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing."))
}
diff --git a/samples/client/petstore/R/R/cat.R b/samples/client/petstore/R/R/cat.R
index 60d417950b1..f74e2d887dd 100644
--- a/samples/client/petstore/R/R/cat.R
+++ b/samples/client/petstore/R/R/cat.R
@@ -37,15 +37,21 @@ Cat <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", `declawed` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(`declawed`)) {
- stopifnot(is.logical(`declawed`), length(`declawed`) == 1)
+ if (!(is.logical(`declawed`) && length(`declawed`) == 1)) {
+ stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`))
+ }
self$`declawed` <- `declawed`
}
if (!is.null(additional_properties)) {
@@ -184,7 +190,9 @@ Cat <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R/R/cat_all_of.R b/samples/client/petstore/R/R/cat_all_of.R
index c3969fc0550..197e1a46e3a 100644
--- a/samples/client/petstore/R/R/cat_all_of.R
+++ b/samples/client/petstore/R/R/cat_all_of.R
@@ -30,7 +30,9 @@ CatAllOf <- R6::R6Class(
#' @export
initialize = function(`declawed` = NULL, additional_properties = NULL, ...) {
if (!is.null(`declawed`)) {
- stopifnot(is.logical(`declawed`), length(`declawed`) == 1)
+ if (!(is.logical(`declawed`) && length(`declawed`) == 1)) {
+ stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`))
+ }
self$`declawed` <- `declawed`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/category.R b/samples/client/petstore/R/R/category.R
index 2de263a5682..2646d01bd72 100644
--- a/samples/client/petstore/R/R/category.R
+++ b/samples/client/petstore/R/R/category.R
@@ -33,11 +33,15 @@ Category <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/danish_pig.R b/samples/client/petstore/R/R/danish_pig.R
index 737bfad4b97..06cf5096a88 100644
--- a/samples/client/petstore/R/R/danish_pig.R
+++ b/samples/client/petstore/R/R/danish_pig.R
@@ -33,11 +33,15 @@ DanishPig <- R6::R6Class(
#' @export
initialize = function(`className`, `size`, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`size`)) {
- stopifnot(is.numeric(`size`), length(`size`) == 1)
+ if (!(is.numeric(`size`) && length(`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`))
+ }
self$`size` <- `size`
}
if (!is.null(additional_properties)) {
@@ -160,13 +164,17 @@ DanishPig <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `className` is missing."))
}
# check the required field `size`
if (!is.null(input_json$`size`)) {
- stopifnot(is.numeric(input_json$`size`), length(input_json$`size`) == 1)
+ if (!(is.numeric(input_json$`size`) && length(input_json$`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", input_json$`size`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing."))
}
diff --git a/samples/client/petstore/R/R/date.R b/samples/client/petstore/R/R/date.R
index a26b7977d4f..79945bc8cfc 100644
--- a/samples/client/petstore/R/R/date.R
+++ b/samples/client/petstore/R/R/date.R
@@ -36,19 +36,25 @@ Date <- R6::R6Class(
#' @export
initialize = function(`className`, `url_property`, `percent_description` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!missing(`url_property`)) {
- stopifnot(is.character(`url_property`), length(`url_property`) == 1)
+ if (!(is.character(`url_property`) && length(`url_property`) == 1)) {
+ stop(paste("Error! Invalid data for `url_property`. Must be a string:", `url_property`))
+ }
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", `url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", `url_property`))
}
self$`url_property` <- `url_property`
}
if (!is.null(`percent_description`)) {
- stopifnot(is.character(`percent_description`), length(`percent_description`) == 1)
+ if (!(is.character(`percent_description`) && length(`percent_description`) == 1)) {
+ stop(paste("Error! Invalid data for `percent_description`. Must be a string:", `percent_description`))
+ }
self$`percent_description` <- `percent_description`
}
if (!is.null(additional_properties)) {
@@ -103,7 +109,7 @@ Date <- R6::R6Class(
if (!is.null(this_object$`url_property`)) {
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`))
}
self$`url_property` <- this_object$`url_property`
}
@@ -172,7 +178,7 @@ Date <- R6::R6Class(
self$`percent_description` <- this_object$`percent_description`
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", this_object$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`))
}
self$`url_property` <- this_object$`url_property`
# process additional properties/fields in the payload
@@ -195,16 +201,20 @@ Date <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing."))
}
# check the required field `url_property`
if (!is.null(input_json$`url_property`)) {
- stopifnot(is.character(input_json$`url_property`), length(input_json$`url_property`) == 1)
+ if (!(is.character(input_json$`url_property`) && length(input_json$`url_property`) == 1)) {
+ stop(paste("Error! Invalid data for `url_property`. Must be a string:", input_json$`url_property`))
+ }
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
if (!stringr::str_detect(input_json$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) {
- stop(paste("Error! Invalid URL:", input_json$`url_property`))
+ stop(paste("Error! Invalid data for `url_property`. Must be a URL:", input_json$`url_property`))
}
} else {
stop(paste("The JSON input `", input, "` is invalid for Date: the required field `url_property` is missing."))
diff --git a/samples/client/petstore/R/R/dog.R b/samples/client/petstore/R/R/dog.R
index 67fb8a315e2..a814c57d586 100644
--- a/samples/client/petstore/R/R/dog.R
+++ b/samples/client/petstore/R/R/dog.R
@@ -37,15 +37,21 @@ Dog <- R6::R6Class(
#' @export
initialize = function(`className`, `color` = "red", `breed` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`color`)) {
- stopifnot(is.character(`color`), length(`color`) == 1)
+ if (!(is.character(`color`) && length(`color`) == 1)) {
+ stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
+ }
self$`color` <- `color`
}
if (!is.null(`breed`)) {
- stopifnot(is.character(`breed`), length(`breed`) == 1)
+ if (!(is.character(`breed`) && length(`breed`) == 1)) {
+ stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`))
+ }
self$`breed` <- `breed`
}
if (!is.null(additional_properties)) {
@@ -184,7 +190,9 @@ Dog <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R/R/dog_all_of.R b/samples/client/petstore/R/R/dog_all_of.R
index ea44d583d74..17608478eed 100644
--- a/samples/client/petstore/R/R/dog_all_of.R
+++ b/samples/client/petstore/R/R/dog_all_of.R
@@ -30,7 +30,9 @@ DogAllOf <- R6::R6Class(
#' @export
initialize = function(`breed` = NULL, additional_properties = NULL, ...) {
if (!is.null(`breed`)) {
- stopifnot(is.character(`breed`), length(`breed`) == 1)
+ if (!(is.character(`breed`) && length(`breed`) == 1)) {
+ stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`))
+ }
self$`breed` <- `breed`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/fake_api.R b/samples/client/petstore/R/R/fake_api.R
index b20d9bcd7f5..dd909ca79ad 100644
--- a/samples/client/petstore/R/R/fake_api.R
+++ b/samples/client/petstore/R/R/fake_api.R
@@ -117,7 +117,7 @@
#' #################### AddPetOptional ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
#'
#' #Add a new pet to the store (optional body)
#' api_instance <- FakeApi$new()
@@ -155,7 +155,7 @@
#'
#' library(petstore)
#' var_dummy <- "dummy_example" # character | dummy required parameter
-#' var_var_data_file <- "var_data_file_example" # character | header data file
+#' var_var_data_file <- "var_data_file_example" # character | header data file (Optional)
#'
#' #test data_file to ensure it's escaped correctly
#' api_instance <- FakeApi$new()
@@ -188,7 +188,7 @@
#' #################### FakePathArray ####################
#'
#' library(petstore)
-#' var_path_array <- ["path_array_example"] # array[character] | dummy path parameter
+#' var_path_array <- c("inner_example") # array[character] | dummy path parameter
#'
#' #test array parameter in path
#' api_instance <- FakeApi$new()
@@ -238,8 +238,8 @@
#' #################### FakeSetQuery ####################
#'
#' library(petstore)
-#' var_set_dummy <- ["set_dummy_example"] # set[character] | set query
-#' var_array_dummy <- ["array_dummy_example"] # array[character] | array query
+#' var_set_dummy <- c("inner_example") # set[character] | set query
+#' var_array_dummy <- c("inner_example") # array[character] | array query
#'
#' #test set query parameter
#' api_instance <- FakeApi$new()
diff --git a/samples/client/petstore/R/R/format_test.R b/samples/client/petstore/R/R/format_test.R
new file mode 100644
index 00000000000..4bd74e3a727
--- /dev/null
+++ b/samples/client/petstore/R/R/format_test.R
@@ -0,0 +1,711 @@
+#' Create a new FormatTest
+#'
+#' @description
+#' FormatTest Class
+#'
+#' @docType class
+#' @title FormatTest
+#' @description FormatTest Class
+#' @format An \code{R6Class} generator object
+#' @field integer integer [optional]
+#' @field int32 integer [optional]
+#' @field int64 integer [optional]
+#' @field number numeric
+#' @field float numeric [optional]
+#' @field double numeric [optional]
+#' @field string character [optional]
+#' @field byte character
+#' @field binary data.frame [optional]
+#' @field date character
+#' @field dateTime character [optional]
+#' @field uuid character [optional]
+#' @field password character
+#' @field pattern_with_digits A string that is a 10 digit number. Can have leading zeros. character [optional]
+#' @field pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. character [optional]
+#' @field _field_list a list of fields list(character)
+#' @field additional_properties additional properties list(character) [optional]
+#' @importFrom R6 R6Class
+#' @importFrom jsonlite fromJSON toJSON
+#' @export
+FormatTest <- R6::R6Class(
+ "FormatTest",
+ public = list(
+ `integer` = NULL,
+ `int32` = NULL,
+ `int64` = NULL,
+ `number` = NULL,
+ `float` = NULL,
+ `double` = NULL,
+ `string` = NULL,
+ `byte` = NULL,
+ `binary` = NULL,
+ `date` = NULL,
+ `dateTime` = NULL,
+ `uuid` = NULL,
+ `password` = NULL,
+ `pattern_with_digits` = NULL,
+ `pattern_with_digits_and_delimiter` = NULL,
+ `_field_list` = c("integer", "int32", "int64", "number", "float", "double", "string", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"),
+ `additional_properties` = list(),
+ #' Initialize a new FormatTest class.
+ #'
+ #' @description
+ #' Initialize a new FormatTest class.
+ #'
+ #' @param number number
+ #' @param byte byte
+ #' @param date date
+ #' @param password password
+ #' @param integer integer
+ #' @param int32 int32
+ #' @param int64 int64
+ #' @param float float
+ #' @param double double
+ #' @param string string
+ #' @param binary binary
+ #' @param dateTime dateTime. Default to "2015-10-28T14:38:02Z".
+ #' @param uuid uuid
+ #' @param pattern_with_digits A string that is a 10 digit number. Can have leading zeros.
+ #' @param pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+ #' @param additional_properties additonal properties (optional)
+ #' @param ... Other optional arguments.
+ #' @export
+ initialize = function(`number`, `byte`, `date`, `password`, `integer` = NULL, `int32` = NULL, `int64` = NULL, `float` = NULL, `double` = NULL, `string` = NULL, `binary` = NULL, `dateTime` = "2015-10-28T14:38:02Z", `uuid` = NULL, `pattern_with_digits` = NULL, `pattern_with_digits_and_delimiter` = NULL, additional_properties = NULL, ...) {
+ if (!missing(`number`)) {
+ self$`number` <- `number`
+ }
+ if (!missing(`byte`)) {
+ self$`byte` <- `byte`
+ }
+ if (!missing(`date`)) {
+ if (!(is.character(`date`) && length(`date`) == 1)) {
+ stop(paste("Error! Invalid data for `date`. Must be a string:", `date`))
+ }
+ self$`date` <- `date`
+ }
+ if (!missing(`password`)) {
+ if (!(is.character(`password`) && length(`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", `password`))
+ }
+ self$`password` <- `password`
+ }
+ if (!is.null(`integer`)) {
+ if (!(is.numeric(`integer`) && length(`integer`) == 1)) {
+ stop(paste("Error! Invalid data for `integer`. Must be an integer:", `integer`))
+ }
+ self$`integer` <- `integer`
+ }
+ if (!is.null(`int32`)) {
+ if (!(is.numeric(`int32`) && length(`int32`) == 1)) {
+ stop(paste("Error! Invalid data for `int32`. Must be an integer:", `int32`))
+ }
+ self$`int32` <- `int32`
+ }
+ if (!is.null(`int64`)) {
+ if (!(is.numeric(`int64`) && length(`int64`) == 1)) {
+ stop(paste("Error! Invalid data for `int64`. Must be an integer:", `int64`))
+ }
+ self$`int64` <- `int64`
+ }
+ if (!is.null(`float`)) {
+ if (!(is.numeric(`float`) && length(`float`) == 1)) {
+ stop(paste("Error! Invalid data for `float`. Must be a number:", `float`))
+ }
+ self$`float` <- `float`
+ }
+ if (!is.null(`double`)) {
+ if (!(is.numeric(`double`) && length(`double`) == 1)) {
+ stop(paste("Error! Invalid data for `double`. Must be a number:", `double`))
+ }
+ self$`double` <- `double`
+ }
+ if (!is.null(`string`)) {
+ if (!(is.character(`string`) && length(`string`) == 1)) {
+ stop(paste("Error! Invalid data for `string`. Must be a string:", `string`))
+ }
+ self$`string` <- `string`
+ }
+ if (!is.null(`binary`)) {
+ self$`binary` <- `binary`
+ }
+ if (!is.null(`dateTime`)) {
+ if (!is.character(`dateTime`)) {
+ stop(paste("Error! Invalid data for `dateTime`. Must be a string:", `dateTime`))
+ }
+ self$`dateTime` <- `dateTime`
+ }
+ if (!is.null(`uuid`)) {
+ if (!(is.character(`uuid`) && length(`uuid`) == 1)) {
+ stop(paste("Error! Invalid data for `uuid`. Must be a string:", `uuid`))
+ }
+ self$`uuid` <- `uuid`
+ }
+ if (!is.null(`pattern_with_digits`)) {
+ if (!(is.character(`pattern_with_digits`) && length(`pattern_with_digits`) == 1)) {
+ stop(paste("Error! Invalid data for `pattern_with_digits`. Must be a string:", `pattern_with_digits`))
+ }
+ self$`pattern_with_digits` <- `pattern_with_digits`
+ }
+ if (!is.null(`pattern_with_digits_and_delimiter`)) {
+ if (!(is.character(`pattern_with_digits_and_delimiter`) && length(`pattern_with_digits_and_delimiter`) == 1)) {
+ stop(paste("Error! Invalid data for `pattern_with_digits_and_delimiter`. Must be a string:", `pattern_with_digits_and_delimiter`))
+ }
+ self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter`
+ }
+ if (!is.null(additional_properties)) {
+ for (key in names(additional_properties)) {
+ self$additional_properties[[key]] <- additional_properties[[key]]
+ }
+ }
+ },
+ #' To JSON string
+ #'
+ #' @description
+ #' To JSON String
+ #'
+ #' @return FormatTest in JSON format
+ #' @export
+ toJSON = function() {
+ FormatTestObject <- list()
+ if (!is.null(self$`integer`)) {
+ FormatTestObject[["integer"]] <-
+ self$`integer`
+ }
+ if (!is.null(self$`int32`)) {
+ FormatTestObject[["int32"]] <-
+ self$`int32`
+ }
+ if (!is.null(self$`int64`)) {
+ FormatTestObject[["int64"]] <-
+ self$`int64`
+ }
+ if (!is.null(self$`number`)) {
+ FormatTestObject[["number"]] <-
+ self$`number`
+ }
+ if (!is.null(self$`float`)) {
+ FormatTestObject[["float"]] <-
+ self$`float`
+ }
+ if (!is.null(self$`double`)) {
+ FormatTestObject[["double"]] <-
+ self$`double`
+ }
+ if (!is.null(self$`string`)) {
+ FormatTestObject[["string"]] <-
+ self$`string`
+ }
+ if (!is.null(self$`byte`)) {
+ FormatTestObject[["byte"]] <-
+ self$`byte`
+ }
+ if (!is.null(self$`binary`)) {
+ FormatTestObject[["binary"]] <-
+ self$`binary`
+ }
+ if (!is.null(self$`date`)) {
+ FormatTestObject[["date"]] <-
+ self$`date`
+ }
+ if (!is.null(self$`dateTime`)) {
+ FormatTestObject[["dateTime"]] <-
+ self$`dateTime`
+ }
+ if (!is.null(self$`uuid`)) {
+ FormatTestObject[["uuid"]] <-
+ self$`uuid`
+ }
+ if (!is.null(self$`password`)) {
+ FormatTestObject[["password"]] <-
+ self$`password`
+ }
+ if (!is.null(self$`pattern_with_digits`)) {
+ FormatTestObject[["pattern_with_digits"]] <-
+ self$`pattern_with_digits`
+ }
+ if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
+ FormatTestObject[["pattern_with_digits_and_delimiter"]] <-
+ self$`pattern_with_digits_and_delimiter`
+ }
+ for (key in names(self$additional_properties)) {
+ FormatTestObject[[key]] <- self$additional_properties[[key]]
+ }
+
+ FormatTestObject
+ },
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @description
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @param input_json the JSON input
+ #' @return the instance of FormatTest
+ #' @export
+ fromJSON = function(input_json) {
+ this_object <- jsonlite::fromJSON(input_json)
+ if (!is.null(this_object$`integer`)) {
+ self$`integer` <- this_object$`integer`
+ }
+ if (!is.null(this_object$`int32`)) {
+ self$`int32` <- this_object$`int32`
+ }
+ if (!is.null(this_object$`int64`)) {
+ self$`int64` <- this_object$`int64`
+ }
+ if (!is.null(this_object$`number`)) {
+ self$`number` <- this_object$`number`
+ }
+ if (!is.null(this_object$`float`)) {
+ self$`float` <- this_object$`float`
+ }
+ if (!is.null(this_object$`double`)) {
+ self$`double` <- this_object$`double`
+ }
+ if (!is.null(this_object$`string`)) {
+ self$`string` <- this_object$`string`
+ }
+ if (!is.null(this_object$`byte`)) {
+ self$`byte` <- this_object$`byte`
+ }
+ if (!is.null(this_object$`binary`)) {
+ self$`binary` <- this_object$`binary`
+ }
+ if (!is.null(this_object$`date`)) {
+ self$`date` <- this_object$`date`
+ }
+ if (!is.null(this_object$`dateTime`)) {
+ self$`dateTime` <- this_object$`dateTime`
+ }
+ if (!is.null(this_object$`uuid`)) {
+ self$`uuid` <- this_object$`uuid`
+ }
+ if (!is.null(this_object$`password`)) {
+ self$`password` <- this_object$`password`
+ }
+ if (!is.null(this_object$`pattern_with_digits`)) {
+ self$`pattern_with_digits` <- this_object$`pattern_with_digits`
+ }
+ if (!is.null(this_object$`pattern_with_digits_and_delimiter`)) {
+ self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
+ }
+ # process additional properties/fields in the payload
+ for (key in names(this_object)) {
+ if (!(key %in% self$`_field_list`)) { # json key not in list of fields
+ self$additional_properties[[key]] <- this_object[[key]]
+ }
+ }
+
+ self
+ },
+ #' To JSON string
+ #'
+ #' @description
+ #' To JSON String
+ #'
+ #' @return FormatTest in JSON format
+ #' @export
+ toJSONString = function() {
+ jsoncontent <- c(
+ if (!is.null(self$`integer`)) {
+ sprintf(
+ '"integer":
+ %d
+ ',
+ self$`integer`
+ )
+ },
+ if (!is.null(self$`int32`)) {
+ sprintf(
+ '"int32":
+ %d
+ ',
+ self$`int32`
+ )
+ },
+ if (!is.null(self$`int64`)) {
+ sprintf(
+ '"int64":
+ %d
+ ',
+ self$`int64`
+ )
+ },
+ if (!is.null(self$`number`)) {
+ sprintf(
+ '"number":
+ %d
+ ',
+ self$`number`
+ )
+ },
+ if (!is.null(self$`float`)) {
+ sprintf(
+ '"float":
+ %d
+ ',
+ self$`float`
+ )
+ },
+ if (!is.null(self$`double`)) {
+ sprintf(
+ '"double":
+ %d
+ ',
+ self$`double`
+ )
+ },
+ if (!is.null(self$`string`)) {
+ sprintf(
+ '"string":
+ "%s"
+ ',
+ self$`string`
+ )
+ },
+ if (!is.null(self$`byte`)) {
+ sprintf(
+ '"byte":
+ "%s"
+ ',
+ self$`byte`
+ )
+ },
+ if (!is.null(self$`binary`)) {
+ sprintf(
+ '"binary":
+ "%s"
+ ',
+ self$`binary`
+ )
+ },
+ if (!is.null(self$`date`)) {
+ sprintf(
+ '"date":
+ "%s"
+ ',
+ self$`date`
+ )
+ },
+ if (!is.null(self$`dateTime`)) {
+ sprintf(
+ '"dateTime":
+ "%s"
+ ',
+ self$`dateTime`
+ )
+ },
+ if (!is.null(self$`uuid`)) {
+ sprintf(
+ '"uuid":
+ "%s"
+ ',
+ self$`uuid`
+ )
+ },
+ if (!is.null(self$`password`)) {
+ sprintf(
+ '"password":
+ "%s"
+ ',
+ self$`password`
+ )
+ },
+ if (!is.null(self$`pattern_with_digits`)) {
+ sprintf(
+ '"pattern_with_digits":
+ "%s"
+ ',
+ self$`pattern_with_digits`
+ )
+ },
+ if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
+ sprintf(
+ '"pattern_with_digits_and_delimiter":
+ "%s"
+ ',
+ self$`pattern_with_digits_and_delimiter`
+ )
+ }
+ )
+ jsoncontent <- paste(jsoncontent, collapse = ",")
+ json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
+ json_obj <- jsonlite::fromJSON(json_string)
+ for (key in names(self$additional_properties)) {
+ json_obj[[key]] <- self$additional_properties[[key]]
+ }
+ json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
+ },
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @description
+ #' Deserialize JSON string into an instance of FormatTest
+ #'
+ #' @param input_json the JSON input
+ #' @return the instance of FormatTest
+ #' @export
+ fromJSONString = function(input_json) {
+ this_object <- jsonlite::fromJSON(input_json)
+ self$`integer` <- this_object$`integer`
+ self$`int32` <- this_object$`int32`
+ self$`int64` <- this_object$`int64`
+ self$`number` <- this_object$`number`
+ self$`float` <- this_object$`float`
+ self$`double` <- this_object$`double`
+ self$`string` <- this_object$`string`
+ self$`byte` <- this_object$`byte`
+ self$`binary` <- this_object$`binary`
+ self$`date` <- this_object$`date`
+ self$`dateTime` <- this_object$`dateTime`
+ self$`uuid` <- this_object$`uuid`
+ self$`password` <- this_object$`password`
+ self$`pattern_with_digits` <- this_object$`pattern_with_digits`
+ self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
+ # process additional properties/fields in the payload
+ for (key in names(this_object)) {
+ if (!(key %in% self$`_field_list`)) { # json key not in list of fields
+ self$additional_properties[[key]] <- this_object[[key]]
+ }
+ }
+
+ self
+ },
+ #' Validate JSON input with respect to FormatTest
+ #'
+ #' @description
+ #' Validate JSON input with respect to FormatTest and throw an exception if invalid
+ #'
+ #' @param input the JSON input
+ #' @export
+ validateJSON = function(input) {
+ input_json <- jsonlite::fromJSON(input)
+ # check the required field `number`
+ if (!is.null(input_json$`number`)) {
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `number` is missing."))
+ }
+ # check the required field `byte`
+ if (!is.null(input_json$`byte`)) {
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `byte` is missing."))
+ }
+ # check the required field `date`
+ if (!is.null(input_json$`date`)) {
+ if (!(is.character(input_json$`date`) && length(input_json$`date`) == 1)) {
+ stop(paste("Error! Invalid data for `date`. Must be a string:", input_json$`date`))
+ }
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `date` is missing."))
+ }
+ # check the required field `password`
+ if (!is.null(input_json$`password`)) {
+ if (!(is.character(input_json$`password`) && length(input_json$`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", input_json$`password`))
+ }
+ } else {
+ stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing."))
+ }
+ },
+ #' To string (JSON format)
+ #'
+ #' @description
+ #' To string (JSON format)
+ #'
+ #' @return String representation of FormatTest
+ #' @export
+ toString = function() {
+ self$toJSONString()
+ },
+ #' Return true if the values in all fields are valid.
+ #'
+ #' @description
+ #' Return true if the values in all fields are valid.
+ #'
+ #' @return true if the values in all fields are valid.
+ #' @export
+ isValid = function() {
+ if (self$`integer` > 100) {
+ return(FALSE)
+ }
+ if (self$`integer` < 10) {
+ return(FALSE)
+ }
+
+ if (self$`int32` > 200) {
+ return(FALSE)
+ }
+ if (self$`int32` < 20) {
+ return(FALSE)
+ }
+
+ # check if the required `number` is null
+ if (is.null(self$`number`)) {
+ return(FALSE)
+ }
+
+ if (self$`number` > 543.2) {
+ return(FALSE)
+ }
+ if (self$`number` < 32.1) {
+ return(FALSE)
+ }
+
+ if (self$`float` > 987.6) {
+ return(FALSE)
+ }
+ if (self$`float` < 54.3) {
+ return(FALSE)
+ }
+
+ if (self$`double` > 123.4) {
+ return(FALSE)
+ }
+ if (self$`double` < 67.8) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`string`, "[a-z]/i")) {
+ return(FALSE)
+ }
+
+ # check if the required `byte` is null
+ if (is.null(self$`byte`)) {
+ return(FALSE)
+ }
+
+ # check if the required `date` is null
+ if (is.null(self$`date`)) {
+ return(FALSE)
+ }
+
+ # check if the required `password` is null
+ if (is.null(self$`password`)) {
+ return(FALSE)
+ }
+
+ if (nchar(self$`password`) > 64) {
+ return(FALSE)
+ }
+ if (nchar(self$`password`) < 10) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
+ return(FALSE)
+ }
+
+ if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
+ return(FALSE)
+ }
+
+ TRUE
+ },
+ #' Return a list of invalid fields (if any).
+ #'
+ #' @description
+ #' Return a list of invalid fields (if any).
+ #'
+ #' @return A list of invalid fields (if any).
+ #' @export
+ getInvalidFields = function() {
+ invalid_fields <- list()
+ if (self$`integer` > 100) {
+ invalid_fields["integer"] <- "Invalid value for `integer`, must be smaller than or equal to 100."
+ }
+ if (self$`integer` < 10) {
+ invalid_fields["integer"] <- "Invalid value for `integer`, must be bigger than or equal to 10."
+ }
+
+ if (self$`int32` > 200) {
+ invalid_fields["int32"] <- "Invalid value for `int32`, must be smaller than or equal to 200."
+ }
+ if (self$`int32` < 20) {
+ invalid_fields["int32"] <- "Invalid value for `int32`, must be bigger than or equal to 20."
+ }
+
+ # check if the required `number` is null
+ if (is.null(self$`number`)) {
+ invalid_fields["number"] <- "Non-nullable required field `number` cannot be null."
+ }
+
+ if (self$`number` > 543.2) {
+ invalid_fields["number"] <- "Invalid value for `number`, must be smaller than or equal to 543.2."
+ }
+ if (self$`number` < 32.1) {
+ invalid_fields["number"] <- "Invalid value for `number`, must be bigger than or equal to 32.1."
+ }
+
+ if (self$`float` > 987.6) {
+ invalid_fields["float"] <- "Invalid value for `float`, must be smaller than or equal to 987.6."
+ }
+ if (self$`float` < 54.3) {
+ invalid_fields["float"] <- "Invalid value for `float`, must be bigger than or equal to 54.3."
+ }
+
+ if (self$`double` > 123.4) {
+ invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 123.4."
+ }
+ if (self$`double` < 67.8) {
+ invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 67.8."
+ }
+
+ if (!str_detect(self$`string`, "[a-z]/i")) {
+ invalid_fields["string"] <- "Invalid value for `string`, must conform to the pattern [a-z]/i."
+ }
+
+ # check if the required `byte` is null
+ if (is.null(self$`byte`)) {
+ invalid_fields["byte"] <- "Non-nullable required field `byte` cannot be null."
+ }
+
+ # check if the required `date` is null
+ if (is.null(self$`date`)) {
+ invalid_fields["date"] <- "Non-nullable required field `date` cannot be null."
+ }
+
+ # check if the required `password` is null
+ if (is.null(self$`password`)) {
+ invalid_fields["password"] <- "Non-nullable required field `password` cannot be null."
+ }
+
+ if (nchar(self$`password`) > 64) {
+ invalid_fields["password"] <- "Invalid length for `password`, must be smaller than or equal to 64."
+ }
+ if (nchar(self$`password`) < 10) {
+ invalid_fields["password"] <- "Invalid length for `password`, must be bigger than or equal to 10."
+ }
+
+ if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
+ invalid_fields["pattern_with_digits"] <- "Invalid value for `pattern_with_digits`, must conform to the pattern ^\\d{10}$."
+ }
+
+ if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
+ invalid_fields["pattern_with_digits_and_delimiter"] <- "Invalid value for `pattern_with_digits_and_delimiter`, must conform to the pattern ^image_\\d{1,3}$/i."
+ }
+
+ invalid_fields
+ },
+ #' Print the object
+ #'
+ #' @description
+ #' Print the object
+ #'
+ #' @export
+ print = function() {
+ print(jsonlite::prettify(self$toJSONString()))
+ invisible(self)
+ }
+ ),
+ # Lock the class to prevent modifications to the method or field
+ lock_class = TRUE
+)
+## Uncomment below to unlock the class to allow modifications of the method or field
+# FormatTest$unlock()
+#
+## Below is an example to define the print fnuction
+# FormatTest$set("public", "print", function(...) {
+# print(jsonlite::prettify(self$toJSONString()))
+# invisible(self)
+# })
+## Uncomment below to lock the class to prevent modifications to the method or field
+# FormatTest$lock()
+
diff --git a/samples/client/petstore/R/R/model_api_response.R b/samples/client/petstore/R/R/model_api_response.R
index 03059bb5225..b0e4bbba7e9 100644
--- a/samples/client/petstore/R/R/model_api_response.R
+++ b/samples/client/petstore/R/R/model_api_response.R
@@ -36,15 +36,21 @@ ModelApiResponse <- R6::R6Class(
#' @export
initialize = function(`code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) {
if (!is.null(`code`)) {
- stopifnot(is.numeric(`code`), length(`code`) == 1)
+ if (!(is.numeric(`code`) && length(`code`) == 1)) {
+ stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`))
+ }
self$`code` <- `code`
}
if (!is.null(`type`)) {
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(`message`)) {
- stopifnot(is.character(`message`), length(`message`) == 1)
+ if (!(is.character(`message`) && length(`message`) == 1)) {
+ stop(paste("Error! Invalid data for `message`. Must be a string:", `message`))
+ }
self$`message` <- `message`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/nested_one_of.R b/samples/client/petstore/R/R/nested_one_of.R
index 68b0db6b371..73f4e938cbd 100644
--- a/samples/client/petstore/R/R/nested_one_of.R
+++ b/samples/client/petstore/R/R/nested_one_of.R
@@ -33,7 +33,9 @@ NestedOneOf <- R6::R6Class(
#' @export
initialize = function(`size` = NULL, `nested_pig` = NULL, additional_properties = NULL, ...) {
if (!is.null(`size`)) {
- stopifnot(is.numeric(`size`), length(`size`) == 1)
+ if (!(is.numeric(`size`) && length(`size`) == 1)) {
+ stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`))
+ }
self$`size` <- `size`
}
if (!is.null(`nested_pig`)) {
diff --git a/samples/client/petstore/R/R/order.R b/samples/client/petstore/R/R/order.R
index 6f43799918d..26646896269 100644
--- a/samples/client/petstore/R/R/order.R
+++ b/samples/client/petstore/R/R/order.R
@@ -45,30 +45,42 @@ Order <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`petId`)) {
- stopifnot(is.numeric(`petId`), length(`petId`) == 1)
+ if (!(is.numeric(`petId`) && length(`petId`) == 1)) {
+ stop(paste("Error! Invalid data for `petId`. Must be an integer:", `petId`))
+ }
self$`petId` <- `petId`
}
if (!is.null(`quantity`)) {
- stopifnot(is.numeric(`quantity`), length(`quantity`) == 1)
+ if (!(is.numeric(`quantity`) && length(`quantity`) == 1)) {
+ stop(paste("Error! Invalid data for `quantity`. Must be an integer:", `quantity`))
+ }
self$`quantity` <- `quantity`
}
if (!is.null(`shipDate`)) {
- stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
+ if (!is.character(`shipDate`)) {
+ stop(paste("Error! Invalid data for `shipDate`. Must be a string:", `shipDate`))
+ }
self$`shipDate` <- `shipDate`
}
if (!is.null(`status`)) {
if (!(`status` %in% c("placed", "approved", "delivered"))) {
stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"placed\", \"approved\", \"delivered\".", sep = ""))
}
- stopifnot(is.character(`status`), length(`status`) == 1)
+ if (!(is.character(`status`) && length(`status`) == 1)) {
+ stop(paste("Error! Invalid data for `status`. Must be a string:", `status`))
+ }
self$`status` <- `status`
}
if (!is.null(`complete`)) {
- stopifnot(is.logical(`complete`), length(`complete`) == 1)
+ if (!(is.logical(`complete`) && length(`complete`) == 1)) {
+ stop(paste("Error! Invalid data for `complete`. Must be a boolean:", `complete`))
+ }
self$`complete` <- `complete`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/pet.R b/samples/client/petstore/R/R/pet.R
index 63318448c0c..8be5a058335 100644
--- a/samples/client/petstore/R/R/pet.R
+++ b/samples/client/petstore/R/R/pet.R
@@ -45,7 +45,9 @@ Pet <- R6::R6Class(
#' @export
initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, additional_properties = NULL, ...) {
if (!missing(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!missing(`photoUrls`)) {
@@ -54,7 +56,9 @@ Pet <- R6::R6Class(
self$`photoUrls` <- `photoUrls`
}
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`category`)) {
@@ -70,7 +74,9 @@ Pet <- R6::R6Class(
if (!(`status` %in% c("available", "pending", "sold"))) {
stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = ""))
}
- stopifnot(is.character(`status`), length(`status`) == 1)
+ if (!(is.character(`status`) && length(`status`) == 1)) {
+ stop(paste("Error! Invalid data for `status`. Must be a string:", `status`))
+ }
self$`status` <- `status`
}
if (!is.null(additional_properties)) {
@@ -265,7 +271,9 @@ Pet <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `name`
if (!is.null(input_json$`name`)) {
- stopifnot(is.character(input_json$`name`), length(input_json$`name`) == 1)
+ if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing."))
}
diff --git a/samples/client/petstore/R/R/pet_api.R b/samples/client/petstore/R/R/pet_api.R
index 19f1a04b1f6..e407d3c708c 100644
--- a/samples/client/petstore/R/R/pet_api.R
+++ b/samples/client/petstore/R/R/pet_api.R
@@ -288,7 +288,7 @@
#' #################### AddPet ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
#'
#' #Add a new pet to the store
#' api_instance <- PetApi$new()
@@ -326,7 +326,7 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | Pet id to delete
-#' var_api_key <- "api_key_example" # character |
+#' var_api_key <- "api_key_example" # character | (Optional)
#'
#' #Deletes a pet
#' api_instance <- PetApi$new()
@@ -354,7 +354,7 @@
#' #################### FindPetsByStatus ####################
#'
#' library(petstore)
-#' var_status <- ["status_example"] # array[character] | Status values that need to be considered for filter
+#' var_status <- c("available") # array[character] | Status values that need to be considered for filter
#'
#' #Finds Pets by status
#' api_instance <- PetApi$new()
@@ -390,7 +390,7 @@
#' #################### FindPetsByTags ####################
#'
#' library(petstore)
-#' var_tags <- ["tags_example"] # array[character] | Tags to filter by
+#' var_tags <- c("inner_example") # array[character] | Tags to filter by
#'
#' #Finds Pets by tags
#' api_instance <- PetApi$new()
@@ -537,7 +537,7 @@
#' #################### UpdatePet ####################
#'
#' library(petstore)
-#' var_pet <- Pet$new() # Pet | Pet object that needs to be added to the store
+#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
#'
#' #Update an existing pet
#' api_instance <- PetApi$new()
@@ -574,8 +574,8 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | ID of pet that needs to be updated
-#' var_name <- "name_example" # character | Updated name of the pet
-#' var_status <- "status_example" # character | Updated status of the pet
+#' var_name <- "name_example" # character | Updated name of the pet (Optional)
+#' var_status <- "status_example" # character | Updated status of the pet (Optional)
#'
#' #Updates a pet in the store with form data
#' api_instance <- PetApi$new()
@@ -601,8 +601,8 @@
#'
#' library(petstore)
#' var_pet_id <- 56 # integer | ID of pet to update
-#' var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server
-#' var_file <- File.new('/path/to/file') # data.frame | file to upload
+#' var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server (Optional)
+#' var_file <- File.new('/path/to/file') # data.frame | file to upload (Optional)
#'
#' #uploads an image
#' api_instance <- PetApi$new()
diff --git a/samples/client/petstore/R/R/special.R b/samples/client/petstore/R/R/special.R
index 33f06cc6a67..39664bea75c 100644
--- a/samples/client/petstore/R/R/special.R
+++ b/samples/client/petstore/R/R/special.R
@@ -56,27 +56,39 @@ Special <- R6::R6Class(
self$`set_test` <- `set_test`
}
if (!is.null(`item_self`)) {
- stopifnot(is.numeric(`item_self`), length(`item_self`) == 1)
+ if (!(is.numeric(`item_self`) && length(`item_self`) == 1)) {
+ stop(paste("Error! Invalid data for `item_self`. Must be an integer:", `item_self`))
+ }
self$`item_self` <- `item_self`
}
if (!is.null(`item_private`)) {
- stopifnot(is.character(`item_private`), length(`item_private`) == 1)
+ if (!(is.character(`item_private`) && length(`item_private`) == 1)) {
+ stop(paste("Error! Invalid data for `item_private`. Must be a string:", `item_private`))
+ }
self$`item_private` <- `item_private`
}
if (!is.null(`item_super`)) {
- stopifnot(is.character(`item_super`), length(`item_super`) == 1)
+ if (!(is.character(`item_super`) && length(`item_super`) == 1)) {
+ stop(paste("Error! Invalid data for `item_super`. Must be a string:", `item_super`))
+ }
self$`item_super` <- `item_super`
}
if (!is.null(`123_number`)) {
- stopifnot(is.character(`123_number`), length(`123_number`) == 1)
+ if (!(is.character(`123_number`) && length(`123_number`) == 1)) {
+ stop(paste("Error! Invalid data for `123_number`. Must be a string:", `123_number`))
+ }
self$`123_number` <- `123_number`
}
if (!is.null(`array[test]`)) {
- stopifnot(is.character(`array[test]`), length(`array[test]`) == 1)
+ if (!(is.character(`array[test]`) && length(`array[test]`) == 1)) {
+ stop(paste("Error! Invalid data for `array[test]`. Must be a string:", `array[test]`))
+ }
self$`array[test]` <- `array[test]`
}
if (!is.null(`empty_string`)) {
- stopifnot(is.character(`empty_string`), length(`empty_string`) == 1)
+ if (!(is.character(`empty_string`) && length(`empty_string`) == 1)) {
+ stop(paste("Error! Invalid data for `empty_string`. Must be a string:", `empty_string`))
+ }
self$`empty_string` <- `empty_string`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/store_api.R b/samples/client/petstore/R/R/store_api.R
index ec9b71aabf0..1daff7db820 100644
--- a/samples/client/petstore/R/R/store_api.R
+++ b/samples/client/petstore/R/R/store_api.R
@@ -211,7 +211,7 @@
#' #################### PlaceOrder ####################
#'
#' library(petstore)
-#' var_order <- Order$new() # Order | order placed for purchasing the pet
+#' var_order <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet
#'
#' #Place an order for a pet
#' api_instance <- StoreApi$new()
diff --git a/samples/client/petstore/R/R/tag.R b/samples/client/petstore/R/R/tag.R
index bd4aac10e2f..be068d1474c 100644
--- a/samples/client/petstore/R/R/tag.R
+++ b/samples/client/petstore/R/R/tag.R
@@ -33,11 +33,15 @@ Tag <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`name`)) {
- stopifnot(is.character(`name`), length(`name`) == 1)
+ if (!(is.character(`name`) && length(`name`) == 1)) {
+ stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
+ }
self$`name` <- `name`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/user.R b/samples/client/petstore/R/R/user.R
index 153aacb3ea5..43b51ffa41c 100644
--- a/samples/client/petstore/R/R/user.R
+++ b/samples/client/petstore/R/R/user.R
@@ -51,35 +51,51 @@ User <- R6::R6Class(
#' @export
initialize = function(`id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, additional_properties = NULL, ...) {
if (!is.null(`id`)) {
- stopifnot(is.numeric(`id`), length(`id`) == 1)
+ if (!(is.numeric(`id`) && length(`id`) == 1)) {
+ stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
+ }
self$`id` <- `id`
}
if (!is.null(`username`)) {
- stopifnot(is.character(`username`), length(`username`) == 1)
+ if (!(is.character(`username`) && length(`username`) == 1)) {
+ stop(paste("Error! Invalid data for `username`. Must be a string:", `username`))
+ }
self$`username` <- `username`
}
if (!is.null(`firstName`)) {
- stopifnot(is.character(`firstName`), length(`firstName`) == 1)
+ if (!(is.character(`firstName`) && length(`firstName`) == 1)) {
+ stop(paste("Error! Invalid data for `firstName`. Must be a string:", `firstName`))
+ }
self$`firstName` <- `firstName`
}
if (!is.null(`lastName`)) {
- stopifnot(is.character(`lastName`), length(`lastName`) == 1)
+ if (!(is.character(`lastName`) && length(`lastName`) == 1)) {
+ stop(paste("Error! Invalid data for `lastName`. Must be a string:", `lastName`))
+ }
self$`lastName` <- `lastName`
}
if (!is.null(`email`)) {
- stopifnot(is.character(`email`), length(`email`) == 1)
+ if (!(is.character(`email`) && length(`email`) == 1)) {
+ stop(paste("Error! Invalid data for `email`. Must be a string:", `email`))
+ }
self$`email` <- `email`
}
if (!is.null(`password`)) {
- stopifnot(is.character(`password`), length(`password`) == 1)
+ if (!(is.character(`password`) && length(`password`) == 1)) {
+ stop(paste("Error! Invalid data for `password`. Must be a string:", `password`))
+ }
self$`password` <- `password`
}
if (!is.null(`phone`)) {
- stopifnot(is.character(`phone`), length(`phone`) == 1)
+ if (!(is.character(`phone`) && length(`phone`) == 1)) {
+ stop(paste("Error! Invalid data for `phone`. Must be a string:", `phone`))
+ }
self$`phone` <- `phone`
}
if (!is.null(`userStatus`)) {
- stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1)
+ if (!(is.numeric(`userStatus`) && length(`userStatus`) == 1)) {
+ stop(paste("Error! Invalid data for `userStatus`. Must be an integer:", `userStatus`))
+ }
self$`userStatus` <- `userStatus`
}
if (!is.null(additional_properties)) {
diff --git a/samples/client/petstore/R/R/user_api.R b/samples/client/petstore/R/R/user_api.R
index 34e6a7b10b4..0f0243a7b68 100644
--- a/samples/client/petstore/R/R/user_api.R
+++ b/samples/client/petstore/R/R/user_api.R
@@ -197,7 +197,7 @@
#' #################### CreateUser ####################
#'
#' library(petstore)
-#' var_user <- User$new() # User | Created user object
+#' var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Created user object
#'
#' #Create user
#' api_instance <- UserApi$new()
@@ -225,7 +225,7 @@
#' #################### CreateUsersWithArrayInput ####################
#'
#' library(petstore)
-#' var_user <- [User$new()] # array[User] | List of user object
+#' var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
#'
#' #Creates list of users with given input array
#' api_instance <- UserApi$new()
@@ -253,7 +253,7 @@
#' #################### CreateUsersWithListInput ####################
#'
#' library(petstore)
-#' var_user <- [User$new()] # array[User] | List of user object
+#' var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
#'
#' #Creates list of users with given input array
#' api_instance <- UserApi$new()
@@ -404,7 +404,7 @@
#'
#' library(petstore)
#' var_username <- "username_example" # character | name that need to be deleted
-#' var_user <- User$new() # User | Updated user object
+#' var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object
#'
#' #Updated user
#' api_instance <- UserApi$new()
diff --git a/samples/client/petstore/R/R/whale.R b/samples/client/petstore/R/R/whale.R
index 936b3a2573e..dc70b1dd33e 100644
--- a/samples/client/petstore/R/R/whale.R
+++ b/samples/client/petstore/R/R/whale.R
@@ -36,15 +36,21 @@ Whale <- R6::R6Class(
#' @export
initialize = function(`className`, `hasBaleen` = NULL, `hasTeeth` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`hasBaleen`)) {
- stopifnot(is.logical(`hasBaleen`), length(`hasBaleen`) == 1)
+ if (!(is.logical(`hasBaleen`) && length(`hasBaleen`) == 1)) {
+ stop(paste("Error! Invalid data for `hasBaleen`. Must be a boolean:", `hasBaleen`))
+ }
self$`hasBaleen` <- `hasBaleen`
}
if (!is.null(`hasTeeth`)) {
- stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1)
+ if (!(is.logical(`hasTeeth`) && length(`hasTeeth`) == 1)) {
+ stop(paste("Error! Invalid data for `hasTeeth`. Must be a boolean:", `hasTeeth`))
+ }
self$`hasTeeth` <- `hasTeeth`
}
if (!is.null(additional_properties)) {
@@ -183,7 +189,9 @@ Whale <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Whale: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R/R/zebra.R b/samples/client/petstore/R/R/zebra.R
index 5c090e84cbb..c8d06d23d6a 100644
--- a/samples/client/petstore/R/R/zebra.R
+++ b/samples/client/petstore/R/R/zebra.R
@@ -33,14 +33,18 @@ Zebra <- R6::R6Class(
#' @export
initialize = function(`className`, `type` = NULL, additional_properties = NULL, ...) {
if (!missing(`className`)) {
- stopifnot(is.character(`className`), length(`className`) == 1)
+ if (!(is.character(`className`) && length(`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", `className`))
+ }
self$`className` <- `className`
}
if (!is.null(`type`)) {
if (!(`type` %in% c("plains", "mountain", "grevys"))) {
stop(paste("Error! \"", `type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = ""))
}
- stopifnot(is.character(`type`), length(`type`) == 1)
+ if (!(is.character(`type`) && length(`type`) == 1)) {
+ stop(paste("Error! Invalid data for `type`. Must be a string:", `type`))
+ }
self$`type` <- `type`
}
if (!is.null(additional_properties)) {
@@ -169,7 +173,9 @@ Zebra <- R6::R6Class(
input_json <- jsonlite::fromJSON(input)
# check the required field `className`
if (!is.null(input_json$`className`)) {
- stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1)
+ if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) {
+ stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`))
+ }
} else {
stop(paste("The JSON input `", input, "` is invalid for Zebra: the required field `className` is missing."))
}
diff --git a/samples/client/petstore/R/README.md b/samples/client/petstore/R/README.md
index 263e44af2d5..39c03b3133c 100644
--- a/samples/client/petstore/R/README.md
+++ b/samples/client/petstore/R/README.md
@@ -115,6 +115,7 @@ Class | Method | HTTP request | Description
- [Date](docs/Date.md)
- [Dog](docs/Dog.md)
- [DogAllOf](docs/DogAllOf.md)
+ - [FormatTest](docs/FormatTest.md)
- [Mammal](docs/Mammal.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [NestedOneOf](docs/NestedOneOf.md)
diff --git a/samples/client/petstore/R/docs/FakeApi.md b/samples/client/petstore/R/docs/FakeApi.md
index 4e3f7464f14..fd8b6e450dc 100644
--- a/samples/client/petstore/R/docs/FakeApi.md
+++ b/samples/client/petstore/R/docs/FakeApi.md
@@ -25,7 +25,7 @@ library(petstore)
# Add a new pet to the store (optional body)
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional)
api_instance <- FakeApi$new()
# Configure HTTP basic authorization: http_auth
@@ -153,7 +153,7 @@ library(petstore)
# test array parameter in path
#
# prepare function argument(s)
-var_path_array <- list("inner_example") # array[character] | dummy path parameter
+var_path_array <- c("inner_example") # array[character] | dummy path parameter
api_instance <- FakeApi$new()
result <- tryCatch(
@@ -263,8 +263,8 @@ library(petstore)
# test set query parameter
#
# prepare function argument(s)
-var_set_dummy <- list("inner_example") # set[character] | set query
-var_array_dummy <- list("inner_example") # array[character] | array query
+var_set_dummy <- c("inner_example") # set[character] | set query
+var_array_dummy <- c("inner_example") # array[character] | array query
api_instance <- FakeApi$new()
result <- tryCatch(
diff --git a/samples/client/petstore/R/docs/FormatTest.md b/samples/client/petstore/R/docs/FormatTest.md
new file mode 100644
index 00000000000..1d483f62704
--- /dev/null
+++ b/samples/client/petstore/R/docs/FormatTest.md
@@ -0,0 +1,23 @@
+# petstore::FormatTest
+
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**integer** | **integer** | | [optional] [Max: 100] [Min: 10]
+**int32** | **integer** | | [optional] [Max: 200] [Min: 20]
+**int64** | **integer** | | [optional]
+**number** | **numeric** | | [Max: 543.2] [Min: 32.1]
+**float** | **numeric** | | [optional] [Max: 987.6] [Min: 54.3]
+**double** | **numeric** | | [optional] [Max: 123.4] [Min: 67.8]
+**string** | **character** | | [optional] [Pattern: [a-z]/i]
+**byte** | **character** | |
+**binary** | **data.frame** | | [optional]
+**date** | **character** | | [default to "Fri Jul 19 00:00:00 UTC 2019"]
+**dateTime** | **character** | | [optional] [default to "2015-10-28T14:38:02Z"]
+**uuid** | **character** | | [optional]
+**password** | **character** | | [Max. length: 64] [Min. length: 10]
+**pattern_with_digits** | **character** | A string that is a 10 digit number. Can have leading zeros. | [optional] [Pattern: ^\\d{10}$]
+**pattern_with_digits_and_delimiter** | **character** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] [Pattern: ^image_\\d{1,3}$/i]
+
+
diff --git a/samples/client/petstore/R/docs/PetApi.md b/samples/client/petstore/R/docs/PetApi.md
index c493fe2da37..58cb4a02d06 100644
--- a/samples/client/petstore/R/docs/PetApi.md
+++ b/samples/client/petstore/R/docs/PetApi.md
@@ -30,7 +30,7 @@ library(petstore)
# Add a new pet to the store
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
api_instance <- PetApi$new()
# Configure HTTP basic authorization: http_auth
@@ -154,7 +154,7 @@ library(petstore)
# Finds Pets by status
#
# prepare function argument(s)
-var_status <- list("available") # array[character] | Status values that need to be considered for filter
+var_status <- c("available") # array[character] | Status values that need to be considered for filter
api_instance <- PetApi$new()
# Configure OAuth2 access token for authorization: petstore_auth
@@ -218,7 +218,7 @@ library(petstore)
# Finds Pets by tags
#
# prepare function argument(s)
-var_tags <- list("inner_example") # array[character] | Tags to filter by
+var_tags <- c("inner_example") # array[character] | Tags to filter by
api_instance <- PetApi$new()
result <- tryCatch(
@@ -479,7 +479,7 @@ library(petstore)
# Update an existing pet
#
# prepare function argument(s)
-var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
+var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
api_instance <- PetApi$new()
# Configure OAuth2 access token for authorization: petstore_auth
diff --git a/samples/client/petstore/R/docs/UserApi.md b/samples/client/petstore/R/docs/UserApi.md
index ffc5e09b9e6..4554672053e 100644
--- a/samples/client/petstore/R/docs/UserApi.md
+++ b/samples/client/petstore/R/docs/UserApi.md
@@ -85,7 +85,7 @@ library(petstore)
# Creates list of users with given input array
#
# prepare function argument(s)
-var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
+var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
api_instance <- UserApi$new()
# Configure API key authorization: api_key
@@ -142,7 +142,7 @@ library(petstore)
# Creates list of users with given input array
#
# prepare function argument(s)
-var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
+var_user <- c(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
api_instance <- UserApi$new()
# Configure API key authorization: api_key
diff --git a/samples/client/petstore/R/tests/testthat/test_format_test.R b/samples/client/petstore/R/tests/testthat/test_format_test.R
new file mode 100644
index 00000000000..47963949104
--- /dev/null
+++ b/samples/client/petstore/R/tests/testthat/test_format_test.R
@@ -0,0 +1,113 @@
+# Automatically generated by openapi-generator (https://openapi-generator.tech)
+# Please update as you see appropriate
+
+context("Test FormatTest")
+
+model_instance <- FormatTest$new()
+
+test_that("integer", {
+ # tests for the property `integer` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`integer`, "EXPECTED_RESULT")
+})
+
+test_that("int32", {
+ # tests for the property `int32` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`int32`, "EXPECTED_RESULT")
+})
+
+test_that("int64", {
+ # tests for the property `int64` (integer)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`int64`, "EXPECTED_RESULT")
+})
+
+test_that("number", {
+ # tests for the property `number` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`number`, "EXPECTED_RESULT")
+})
+
+test_that("float", {
+ # tests for the property `float` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`float`, "EXPECTED_RESULT")
+})
+
+test_that("double", {
+ # tests for the property `double` (numeric)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`double`, "EXPECTED_RESULT")
+})
+
+test_that("string", {
+ # tests for the property `string` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`string`, "EXPECTED_RESULT")
+})
+
+test_that("byte", {
+ # tests for the property `byte` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`byte`, "EXPECTED_RESULT")
+})
+
+test_that("binary", {
+ # tests for the property `binary` (data.frame)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`binary`, "EXPECTED_RESULT")
+})
+
+test_that("date", {
+ # tests for the property `date` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`date`, "EXPECTED_RESULT")
+})
+
+test_that("dateTime", {
+ # tests for the property `dateTime` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`dateTime`, "EXPECTED_RESULT")
+})
+
+test_that("uuid", {
+ # tests for the property `uuid` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`uuid`, "EXPECTED_RESULT")
+})
+
+test_that("password", {
+ # tests for the property `password` (character)
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`password`, "EXPECTED_RESULT")
+})
+
+test_that("pattern_with_digits", {
+ # tests for the property `pattern_with_digits` (character)
+ # A string that is a 10 digit number. Can have leading zeros.
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`pattern_with_digits`, "EXPECTED_RESULT")
+})
+
+test_that("pattern_with_digits_and_delimiter", {
+ # tests for the property `pattern_with_digits_and_delimiter` (character)
+ # A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
+
+ # uncomment below to test the property
+ #expect_equal(model.instance$`pattern_with_digits_and_delimiter`, "EXPECTED_RESULT")
+})
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES
index e99cb9be46c..917a723fcc6 100644
--- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES
@@ -2,6 +2,8 @@
Org.OpenAPITools.sln
README.md
appveyor.yml
+docs/Activity.md
+docs/ActivityOutputElementRepresentation.md
docs/AdditionalPropertiesClass.md
docs/Animal.md
docs/AnotherFakeApi.md
@@ -116,6 +118,8 @@ src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs
src/Org.OpenAPITools/Client/RequestOptions.cs
src/Org.OpenAPITools/Client/RetryConfiguration.cs
src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs
+src/Org.OpenAPITools/Model/Activity.cs
+src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
src/Org.OpenAPITools/Model/Animal.cs
src/Org.OpenAPITools/Model/ApiResponse.cs
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md
index fdc4b49e799..99c92a26a6b 100644
--- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md
@@ -147,6 +147,8 @@ Class | Method | HTTP request | Description
## Documentation for Models
+ - [Model.Activity](docs/Activity.md)
+ - [Model.ActivityOutputElementRepresentation](docs/ActivityOutputElementRepresentation.md)
- [Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [Model.Animal](docs/Animal.md)
- [Model.ApiResponse](docs/ApiResponse.md)
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/Activity.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/Activity.md
new file mode 100644
index 00000000000..27a4e457199
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/Activity.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.Activity
+test map of maps
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**ActivityOutputs** | **Dictionary<string, List<ActivityOutputElementRepresentation>>** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/ActivityOutputElementRepresentation.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/ActivityOutputElementRepresentation.md
new file mode 100644
index 00000000000..21f226b3952
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/ActivityOutputElementRepresentation.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.ActivityOutputElementRepresentation
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**Prop1** | **string** | | [optional]
+**Prop2** | **Object** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
new file mode 100644
index 00000000000..f211a64884a
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
@@ -0,0 +1,78 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing ActivityOutputElementRepresentation
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityOutputElementRepresentationTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for ActivityOutputElementRepresentation
+ //private ActivityOutputElementRepresentation instance;
+
+ public ActivityOutputElementRepresentationTests()
+ {
+ // TODO uncomment below to create an instance of ActivityOutputElementRepresentation
+ //instance = new ActivityOutputElementRepresentation();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of ActivityOutputElementRepresentation
+ ///
+ [Fact]
+ public void ActivityOutputElementRepresentationInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" ActivityOutputElementRepresentation
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'Prop1'
+ ///
+ [Fact]
+ public void Prop1Test()
+ {
+ // TODO unit test for the property 'Prop1'
+ }
+ ///
+ /// Test the property 'Prop2'
+ ///
+ [Fact]
+ public void Prop2Test()
+ {
+ // TODO unit test for the property 'Prop2'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ActivityTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
new file mode 100644
index 00000000000..afe9e846ee9
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
@@ -0,0 +1,70 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing Activity
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for Activity
+ //private Activity instance;
+
+ public ActivityTests()
+ {
+ // TODO uncomment below to create an instance of Activity
+ //instance = new Activity();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of Activity
+ ///
+ [Fact]
+ public void ActivityInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" Activity
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'ActivityOutputs'
+ ///
+ [Fact]
+ public void ActivityOutputsTest()
+ {
+ // TODO unit test for the property 'ActivityOutputs'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ClientUtils.cs
index e499a7728e4..608bdbc195a 100644
--- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -13,6 +13,7 @@ using System.Collections;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
@@ -116,6 +117,8 @@ namespace Org.OpenAPITools.Client
return boolean ? "true" : "false";
if (obj is ICollection collection)
return string.Join(",", collection.Cast());
+ if (obj is Enum && HasEnumMemberAttrValue(obj))
+ return GetEnumMemberAttrValue(obj);
return Convert.ToString(obj, CultureInfo.InvariantCulture);
}
@@ -214,5 +217,40 @@ namespace Org.OpenAPITools.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
+
+ ///
+ /// Is the Enum decorated with EnumMember Attribute
+ ///
+ ///
+ /// true if found
+ private static bool HasEnumMemberAttrValue(object enumVal)
+ {
+ if (enumVal == null)
+ throw new ArgumentNullException(nameof(enumVal));
+ var enumType = enumVal.GetType();
+ var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
+ var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType().FirstOrDefault();
+ if (attr != null) return true;
+ return false;
+ }
+
+ ///
+ /// Get the EnumMember value
+ ///
+ ///
+ /// EnumMember value as string otherwise null
+ private static string GetEnumMemberAttrValue(object enumVal)
+ {
+ if (enumVal == null)
+ throw new ArgumentNullException(nameof(enumVal));
+ var enumType = enumVal.GetType();
+ var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
+ var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType().FirstOrDefault();
+ if (attr != null)
+ {
+ return attr.Value;
+ }
+ return null;
+ }
}
}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Activity.cs
new file mode 100644
index 00000000000..62b70440f67
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Activity.cs
@@ -0,0 +1,154 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Text.RegularExpressions;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Linq;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;
+using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
+
+namespace Org.OpenAPITools.Model
+{
+ ///
+ /// test map of maps
+ ///
+ [DataContract(Name = "Activity")]
+ public partial class Activity : IEquatable, IValidatableObject
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// activityOutputs.
+ public Activity(Dictionary> activityOutputs = default(Dictionary>))
+ {
+ this._ActivityOutputs = activityOutputs;
+ if (this.ActivityOutputs != null)
+ {
+ this._flagActivityOutputs = true;
+ }
+ this.AdditionalProperties = new Dictionary();
+ }
+
+ ///
+ /// Gets or Sets ActivityOutputs
+ ///
+ [DataMember(Name = "activity_outputs", EmitDefaultValue = false)]
+ public Dictionary> ActivityOutputs
+ {
+ get{ return _ActivityOutputs;}
+ set
+ {
+ _ActivityOutputs = value;
+ _flagActivityOutputs = true;
+ }
+ }
+ private Dictionary> _ActivityOutputs;
+ private bool _flagActivityOutputs;
+
+ ///
+ /// Returns false as ActivityOutputs should not be serialized given that it's read-only.
+ ///
+ /// false (boolean)
+ public bool ShouldSerializeActivityOutputs()
+ {
+ return _flagActivityOutputs;
+ }
+ ///
+ /// Gets or Sets additional properties
+ ///
+ [JsonExtensionData]
+ public IDictionary AdditionalProperties { get; set; }
+
+ ///
+ /// Returns the string presentation of the object
+ ///
+ /// String presentation of the object
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("class Activity {\n");
+ sb.Append(" ActivityOutputs: ").Append(ActivityOutputs).Append("\n");
+ sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
+ sb.Append("}\n");
+ return sb.ToString();
+ }
+
+ ///
+ /// Returns the JSON string presentation of the object
+ ///
+ /// JSON string presentation of the object
+ public virtual string ToJson()
+ {
+ return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
+ }
+
+ ///
+ /// Returns true if objects are equal
+ ///
+ /// Object to be compared
+ /// Boolean
+ public override bool Equals(object input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input as Activity).AreEqual;
+ }
+
+ ///
+ /// Returns true if Activity instances are equal
+ ///
+ /// Instance of Activity to be compared
+ /// Boolean
+ public bool Equals(Activity input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
+ }
+
+ ///
+ /// Gets the hash code
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ unchecked // Overflow is fine, just wrap
+ {
+ int hashCode = 41;
+ if (this.ActivityOutputs != null)
+ {
+ hashCode = (hashCode * 59) + this.ActivityOutputs.GetHashCode();
+ }
+ if (this.AdditionalProperties != null)
+ {
+ hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
+ }
+ return hashCode;
+ }
+ }
+
+ ///
+ /// To validate all properties of the instance
+ ///
+ /// Validation context
+ /// Validation Result
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ yield break;
+ }
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
new file mode 100644
index 00000000000..7395af5fbf1
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -0,0 +1,189 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Text.RegularExpressions;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Linq;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;
+using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
+
+namespace Org.OpenAPITools.Model
+{
+ ///
+ /// ActivityOutputElementRepresentation
+ ///
+ [DataContract(Name = "ActivityOutputElementRepresentation")]
+ public partial class ActivityOutputElementRepresentation : IEquatable, IValidatableObject
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// prop1.
+ /// prop2.
+ public ActivityOutputElementRepresentation(string prop1 = default(string), Object prop2 = default(Object))
+ {
+ this._Prop1 = prop1;
+ if (this.Prop1 != null)
+ {
+ this._flagProp1 = true;
+ }
+ this._Prop2 = prop2;
+ if (this.Prop2 != null)
+ {
+ this._flagProp2 = true;
+ }
+ this.AdditionalProperties = new Dictionary();
+ }
+
+ ///
+ /// Gets or Sets Prop1
+ ///
+ [DataMember(Name = "prop1", EmitDefaultValue = false)]
+ public string Prop1
+ {
+ get{ return _Prop1;}
+ set
+ {
+ _Prop1 = value;
+ _flagProp1 = true;
+ }
+ }
+ private string _Prop1;
+ private bool _flagProp1;
+
+ ///
+ /// Returns false as Prop1 should not be serialized given that it's read-only.
+ ///
+ /// false (boolean)
+ public bool ShouldSerializeProp1()
+ {
+ return _flagProp1;
+ }
+ ///
+ /// Gets or Sets Prop2
+ ///
+ [DataMember(Name = "prop2", EmitDefaultValue = false)]
+ public Object Prop2
+ {
+ get{ return _Prop2;}
+ set
+ {
+ _Prop2 = value;
+ _flagProp2 = true;
+ }
+ }
+ private Object _Prop2;
+ private bool _flagProp2;
+
+ ///
+ /// Returns false as Prop2 should not be serialized given that it's read-only.
+ ///
+ /// false (boolean)
+ public bool ShouldSerializeProp2()
+ {
+ return _flagProp2;
+ }
+ ///
+ /// Gets or Sets additional properties
+ ///
+ [JsonExtensionData]
+ public IDictionary AdditionalProperties { get; set; }
+
+ ///
+ /// Returns the string presentation of the object
+ ///
+ /// String presentation of the object
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("class ActivityOutputElementRepresentation {\n");
+ sb.Append(" Prop1: ").Append(Prop1).Append("\n");
+ sb.Append(" Prop2: ").Append(Prop2).Append("\n");
+ sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
+ sb.Append("}\n");
+ return sb.ToString();
+ }
+
+ ///
+ /// Returns the JSON string presentation of the object
+ ///
+ /// JSON string presentation of the object
+ public virtual string ToJson()
+ {
+ return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
+ }
+
+ ///
+ /// Returns true if objects are equal
+ ///
+ /// Object to be compared
+ /// Boolean
+ public override bool Equals(object input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input as ActivityOutputElementRepresentation).AreEqual;
+ }
+
+ ///
+ /// Returns true if ActivityOutputElementRepresentation instances are equal
+ ///
+ /// Instance of ActivityOutputElementRepresentation to be compared
+ /// Boolean
+ public bool Equals(ActivityOutputElementRepresentation input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
+ }
+
+ ///
+ /// Gets the hash code
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ unchecked // Overflow is fine, just wrap
+ {
+ int hashCode = 41;
+ if (this.Prop1 != null)
+ {
+ hashCode = (hashCode * 59) + this.Prop1.GetHashCode();
+ }
+ if (this.Prop2 != null)
+ {
+ hashCode = (hashCode * 59) + this.Prop2.GetHashCode();
+ }
+ if (this.AdditionalProperties != null)
+ {
+ hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
+ }
+ return hashCode;
+ }
+ }
+
+ ///
+ /// To validate all properties of the instance
+ ///
+ /// Validation context
+ /// Validation Result
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ yield break;
+ }
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES
index 9a99c9d18bc..cf0f5c871be 100644
--- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES
@@ -9,6 +9,8 @@ docs/apis/FakeClassnameTags123Api.md
docs/apis/PetApi.md
docs/apis/StoreApi.md
docs/apis/UserApi.md
+docs/models/Activity.md
+docs/models/ActivityOutputElementRepresentation.md
docs/models/AdditionalPropertiesClass.md
docs/models/Animal.md
docs/models/ApiResponse.md
@@ -115,6 +117,8 @@ src/Org.OpenAPITools/Client/RateLimitProvider`1.cs
src/Org.OpenAPITools/Client/TokenBase.cs
src/Org.OpenAPITools/Client/TokenContainer`1.cs
src/Org.OpenAPITools/Client/TokenProvider`1.cs
+src/Org.OpenAPITools/Model/Activity.cs
+src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
src/Org.OpenAPITools/Model/Animal.cs
src/Org.OpenAPITools/Model/ApiResponse.cs
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Activity.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Activity.md
new file mode 100644
index 00000000000..6f69ec32545
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Activity.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.Activity
+test map of maps
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**ActivityOutputs** | **Dictionary<string, List<ActivityOutputElementRepresentation>>** | | [optional]
+
+[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ActivityOutputElementRepresentation.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ActivityOutputElementRepresentation.md
new file mode 100644
index 00000000000..33d79a27692
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ActivityOutputElementRepresentation.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.ActivityOutputElementRepresentation
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**Prop1** | **string** | | [optional]
+**Prop2** | **Object** | | [optional]
+
+[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
new file mode 100644
index 00000000000..f211a64884a
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
@@ -0,0 +1,78 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing ActivityOutputElementRepresentation
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityOutputElementRepresentationTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for ActivityOutputElementRepresentation
+ //private ActivityOutputElementRepresentation instance;
+
+ public ActivityOutputElementRepresentationTests()
+ {
+ // TODO uncomment below to create an instance of ActivityOutputElementRepresentation
+ //instance = new ActivityOutputElementRepresentation();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of ActivityOutputElementRepresentation
+ ///
+ [Fact]
+ public void ActivityOutputElementRepresentationInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" ActivityOutputElementRepresentation
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'Prop1'
+ ///
+ [Fact]
+ public void Prop1Test()
+ {
+ // TODO unit test for the property 'Prop1'
+ }
+ ///
+ /// Test the property 'Prop2'
+ ///
+ [Fact]
+ public void Prop2Test()
+ {
+ // TODO unit test for the property 'Prop2'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ActivityTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
new file mode 100644
index 00000000000..afe9e846ee9
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
@@ -0,0 +1,70 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing Activity
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for Activity
+ //private Activity instance;
+
+ public ActivityTests()
+ {
+ // TODO uncomment below to create an instance of Activity
+ //instance = new Activity();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of Activity
+ ///
+ [Fact]
+ public void ActivityInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" Activity
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'ActivityOutputs'
+ ///
+ [Fact]
+ public void ActivityOutputsTest()
+ {
+ // TODO unit test for the property 'ActivityOutputs'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Activity.cs
new file mode 100644
index 00000000000..d8753f6553e
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Activity.cs
@@ -0,0 +1,121 @@
+//
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+#nullable enable
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
+
+namespace Org.OpenAPITools.Model
+{
+ ///
+ /// test map of maps
+ ///
+ public partial class Activity : IEquatable, IValidatableObject
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// activityOutputs
+ public Activity(Dictionary>? activityOutputs = default)
+ {
+ ActivityOutputs = activityOutputs;
+ }
+
+ ///
+ /// Gets or Sets ActivityOutputs
+ ///
+ [JsonPropertyName("activity_outputs")]
+ public Dictionary>? ActivityOutputs { get; set; }
+
+ ///
+ /// Gets or Sets additional properties
+ ///
+ [JsonExtensionData]
+ public Dictionary AdditionalProperties { get; set; } = new Dictionary();
+
+ ///
+ /// Returns the string presentation of the object
+ ///
+ /// String presentation of the object
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("class Activity {\n");
+ sb.Append(" ActivityOutputs: ").Append(ActivityOutputs).Append("\n");
+ sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
+ sb.Append("}\n");
+ return sb.ToString();
+ }
+
+ ///
+ /// Returns true if objects are equal
+ ///
+ /// Object to be compared
+ /// Boolean
+ public override bool Equals(object? input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input as Activity).AreEqual;
+ }
+
+ ///
+ /// Returns true if Activity instances are equal
+ ///
+ /// Instance of Activity to be compared
+ /// Boolean
+ public bool Equals(Activity? input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
+ }
+
+ ///
+ /// Gets the hash code
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ unchecked // Overflow is fine, just wrap
+ {
+ int hashCode = 41;
+ if (this.ActivityOutputs != null)
+ {
+ hashCode = (hashCode * 59) + this.ActivityOutputs.GetHashCode();
+ }
+ if (this.AdditionalProperties != null)
+ {
+ hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
+ }
+ return hashCode;
+ }
+ }
+
+ ///
+ /// To validate all properties of the instance
+ ///
+ /// Validation context
+ /// Validation Result
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ yield break;
+ }
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
new file mode 100644
index 00000000000..2cd5bb9372e
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -0,0 +1,134 @@
+//
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+#nullable enable
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
+
+namespace Org.OpenAPITools.Model
+{
+ ///
+ /// ActivityOutputElementRepresentation
+ ///
+ public partial class ActivityOutputElementRepresentation : IEquatable, IValidatableObject
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// prop1
+ /// prop2
+ public ActivityOutputElementRepresentation(string? prop1 = default, Object? prop2 = default)
+ {
+ Prop1 = prop1;
+ Prop2 = prop2;
+ }
+
+ ///
+ /// Gets or Sets Prop1
+ ///
+ [JsonPropertyName("prop1")]
+ public string? Prop1 { get; set; }
+
+ ///
+ /// Gets or Sets Prop2
+ ///
+ [JsonPropertyName("prop2")]
+ public Object? Prop2 { get; set; }
+
+ ///
+ /// Gets or Sets additional properties
+ ///
+ [JsonExtensionData]
+ public Dictionary AdditionalProperties { get; set; } = new Dictionary();
+
+ ///
+ /// Returns the string presentation of the object
+ ///
+ /// String presentation of the object
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("class ActivityOutputElementRepresentation {\n");
+ sb.Append(" Prop1: ").Append(Prop1).Append("\n");
+ sb.Append(" Prop2: ").Append(Prop2).Append("\n");
+ sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
+ sb.Append("}\n");
+ return sb.ToString();
+ }
+
+ ///
+ /// Returns true if objects are equal
+ ///
+ /// Object to be compared
+ /// Boolean
+ public override bool Equals(object? input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input as ActivityOutputElementRepresentation).AreEqual;
+ }
+
+ ///
+ /// Returns true if ActivityOutputElementRepresentation instances are equal
+ ///
+ /// Instance of ActivityOutputElementRepresentation to be compared
+ /// Boolean
+ public bool Equals(ActivityOutputElementRepresentation? input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
+ }
+
+ ///
+ /// Gets the hash code
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ unchecked // Overflow is fine, just wrap
+ {
+ int hashCode = 41;
+ if (this.Prop1 != null)
+ {
+ hashCode = (hashCode * 59) + this.Prop1.GetHashCode();
+ }
+ if (this.Prop2 != null)
+ {
+ hashCode = (hashCode * 59) + this.Prop2.GetHashCode();
+ }
+ if (this.AdditionalProperties != null)
+ {
+ hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
+ }
+ return hashCode;
+ }
+ }
+
+ ///
+ /// To validate all properties of the instance
+ ///
+ /// Validation context
+ /// Validation Result
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ yield break;
+ }
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES
index 9a99c9d18bc..cf0f5c871be 100644
--- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES
@@ -9,6 +9,8 @@ docs/apis/FakeClassnameTags123Api.md
docs/apis/PetApi.md
docs/apis/StoreApi.md
docs/apis/UserApi.md
+docs/models/Activity.md
+docs/models/ActivityOutputElementRepresentation.md
docs/models/AdditionalPropertiesClass.md
docs/models/Animal.md
docs/models/ApiResponse.md
@@ -115,6 +117,8 @@ src/Org.OpenAPITools/Client/RateLimitProvider`1.cs
src/Org.OpenAPITools/Client/TokenBase.cs
src/Org.OpenAPITools/Client/TokenContainer`1.cs
src/Org.OpenAPITools/Client/TokenProvider`1.cs
+src/Org.OpenAPITools/Model/Activity.cs
+src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
src/Org.OpenAPITools/Model/Animal.cs
src/Org.OpenAPITools/Model/ApiResponse.cs
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Activity.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Activity.md
new file mode 100644
index 00000000000..6f69ec32545
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Activity.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.Activity
+test map of maps
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**ActivityOutputs** | **Dictionary<string, List<ActivityOutputElementRepresentation>>** | | [optional]
+
+[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ActivityOutputElementRepresentation.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ActivityOutputElementRepresentation.md
new file mode 100644
index 00000000000..33d79a27692
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ActivityOutputElementRepresentation.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.ActivityOutputElementRepresentation
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**Prop1** | **string** | | [optional]
+**Prop2** | **Object** | | [optional]
+
+[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
new file mode 100644
index 00000000000..f211a64884a
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
@@ -0,0 +1,78 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing ActivityOutputElementRepresentation
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityOutputElementRepresentationTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for ActivityOutputElementRepresentation
+ //private ActivityOutputElementRepresentation instance;
+
+ public ActivityOutputElementRepresentationTests()
+ {
+ // TODO uncomment below to create an instance of ActivityOutputElementRepresentation
+ //instance = new ActivityOutputElementRepresentation();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of ActivityOutputElementRepresentation
+ ///
+ [Fact]
+ public void ActivityOutputElementRepresentationInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" ActivityOutputElementRepresentation
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'Prop1'
+ ///
+ [Fact]
+ public void Prop1Test()
+ {
+ // TODO unit test for the property 'Prop1'
+ }
+ ///
+ /// Test the property 'Prop2'
+ ///
+ [Fact]
+ public void Prop2Test()
+ {
+ // TODO unit test for the property 'Prop2'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ActivityTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
new file mode 100644
index 00000000000..afe9e846ee9
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
@@ -0,0 +1,70 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing Activity
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for Activity
+ //private Activity instance;
+
+ public ActivityTests()
+ {
+ // TODO uncomment below to create an instance of Activity
+ //instance = new Activity();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of Activity
+ ///
+ [Fact]
+ public void ActivityInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" Activity
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'ActivityOutputs'
+ ///
+ [Fact]
+ public void ActivityOutputsTest()
+ {
+ // TODO unit test for the property 'ActivityOutputs'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Activity.cs
new file mode 100644
index 00000000000..68647a4ae15
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Activity.cs
@@ -0,0 +1,119 @@
+//
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
+
+namespace Org.OpenAPITools.Model
+{
+ ///
+ /// test map of maps
+ ///
+ public partial class Activity : IEquatable, IValidatableObject
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// activityOutputs
+ public Activity(Dictionary> activityOutputs = default)
+ {
+ ActivityOutputs = activityOutputs;
+ }
+
+ ///
+ /// Gets or Sets ActivityOutputs
+ ///
+ [JsonPropertyName("activity_outputs")]
+ public Dictionary> ActivityOutputs { get; set; }
+
+ ///
+ /// Gets or Sets additional properties
+ ///
+ [JsonExtensionData]
+ public Dictionary AdditionalProperties { get; set; } = new Dictionary();
+
+ ///
+ /// Returns the string presentation of the object
+ ///
+ /// String presentation of the object
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("class Activity {\n");
+ sb.Append(" ActivityOutputs: ").Append(ActivityOutputs).Append("\n");
+ sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
+ sb.Append("}\n");
+ return sb.ToString();
+ }
+
+ ///
+ /// Returns true if objects are equal
+ ///
+ /// Object to be compared
+ /// Boolean
+ public override bool Equals(object input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input as Activity).AreEqual;
+ }
+
+ ///
+ /// Returns true if Activity instances are equal
+ ///
+ /// Instance of Activity to be compared
+ /// Boolean
+ public bool Equals(Activity input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
+ }
+
+ ///
+ /// Gets the hash code
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ unchecked // Overflow is fine, just wrap
+ {
+ int hashCode = 41;
+ if (this.ActivityOutputs != null)
+ {
+ hashCode = (hashCode * 59) + this.ActivityOutputs.GetHashCode();
+ }
+ if (this.AdditionalProperties != null)
+ {
+ hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
+ }
+ return hashCode;
+ }
+ }
+
+ ///
+ /// To validate all properties of the instance
+ ///
+ /// Validation context
+ /// Validation Result
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ yield break;
+ }
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
new file mode 100644
index 00000000000..ed290bab607
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -0,0 +1,132 @@
+//
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
+
+namespace Org.OpenAPITools.Model
+{
+ ///
+ /// ActivityOutputElementRepresentation
+ ///
+ public partial class ActivityOutputElementRepresentation : IEquatable, IValidatableObject
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// prop1
+ /// prop2
+ public ActivityOutputElementRepresentation(string prop1 = default, Object prop2 = default)
+ {
+ Prop1 = prop1;
+ Prop2 = prop2;
+ }
+
+ ///
+ /// Gets or Sets Prop1
+ ///
+ [JsonPropertyName("prop1")]
+ public string Prop1 { get; set; }
+
+ ///
+ /// Gets or Sets Prop2
+ ///
+ [JsonPropertyName("prop2")]
+ public Object Prop2 { get; set; }
+
+ ///
+ /// Gets or Sets additional properties
+ ///
+ [JsonExtensionData]
+ public Dictionary AdditionalProperties { get; set; } = new Dictionary();
+
+ ///
+ /// Returns the string presentation of the object
+ ///
+ /// String presentation of the object
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("class ActivityOutputElementRepresentation {\n");
+ sb.Append(" Prop1: ").Append(Prop1).Append("\n");
+ sb.Append(" Prop2: ").Append(Prop2).Append("\n");
+ sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
+ sb.Append("}\n");
+ return sb.ToString();
+ }
+
+ ///
+ /// Returns true if objects are equal
+ ///
+ /// Object to be compared
+ /// Boolean
+ public override bool Equals(object input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input as ActivityOutputElementRepresentation).AreEqual;
+ }
+
+ ///
+ /// Returns true if ActivityOutputElementRepresentation instances are equal
+ ///
+ /// Instance of ActivityOutputElementRepresentation to be compared
+ /// Boolean
+ public bool Equals(ActivityOutputElementRepresentation input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
+ }
+
+ ///
+ /// Gets the hash code
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ unchecked // Overflow is fine, just wrap
+ {
+ int hashCode = 41;
+ if (this.Prop1 != null)
+ {
+ hashCode = (hashCode * 59) + this.Prop1.GetHashCode();
+ }
+ if (this.Prop2 != null)
+ {
+ hashCode = (hashCode * 59) + this.Prop2.GetHashCode();
+ }
+ if (this.AdditionalProperties != null)
+ {
+ hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
+ }
+ return hashCode;
+ }
+ }
+
+ ///
+ /// To validate all properties of the instance
+ ///
+ /// Validation context
+ /// Validation Result
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ yield break;
+ }
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES
index 9a99c9d18bc..cf0f5c871be 100644
--- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES
@@ -9,6 +9,8 @@ docs/apis/FakeClassnameTags123Api.md
docs/apis/PetApi.md
docs/apis/StoreApi.md
docs/apis/UserApi.md
+docs/models/Activity.md
+docs/models/ActivityOutputElementRepresentation.md
docs/models/AdditionalPropertiesClass.md
docs/models/Animal.md
docs/models/ApiResponse.md
@@ -115,6 +117,8 @@ src/Org.OpenAPITools/Client/RateLimitProvider`1.cs
src/Org.OpenAPITools/Client/TokenBase.cs
src/Org.OpenAPITools/Client/TokenContainer`1.cs
src/Org.OpenAPITools/Client/TokenProvider`1.cs
+src/Org.OpenAPITools/Model/Activity.cs
+src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
src/Org.OpenAPITools/Model/Animal.cs
src/Org.OpenAPITools/Model/ApiResponse.cs
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Activity.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Activity.md
new file mode 100644
index 00000000000..6f69ec32545
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Activity.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.Activity
+test map of maps
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**ActivityOutputs** | **Dictionary<string, List<ActivityOutputElementRepresentation>>** | | [optional]
+
+[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ActivityOutputElementRepresentation.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ActivityOutputElementRepresentation.md
new file mode 100644
index 00000000000..33d79a27692
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ActivityOutputElementRepresentation.md
@@ -0,0 +1,11 @@
+# Org.OpenAPITools.Model.ActivityOutputElementRepresentation
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**Prop1** | **string** | | [optional]
+**Prop2** | **Object** | | [optional]
+
+[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
+
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
new file mode 100644
index 00000000000..f211a64884a
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs
@@ -0,0 +1,78 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing ActivityOutputElementRepresentation
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityOutputElementRepresentationTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for ActivityOutputElementRepresentation
+ //private ActivityOutputElementRepresentation instance;
+
+ public ActivityOutputElementRepresentationTests()
+ {
+ // TODO uncomment below to create an instance of ActivityOutputElementRepresentation
+ //instance = new ActivityOutputElementRepresentation();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of ActivityOutputElementRepresentation
+ ///
+ [Fact]
+ public void ActivityOutputElementRepresentationInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" ActivityOutputElementRepresentation
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'Prop1'
+ ///
+ [Fact]
+ public void Prop1Test()
+ {
+ // TODO unit test for the property 'Prop1'
+ }
+ ///
+ /// Test the property 'Prop2'
+ ///
+ [Fact]
+ public void Prop2Test()
+ {
+ // TODO unit test for the property 'Prop2'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ActivityTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
new file mode 100644
index 00000000000..afe9e846ee9
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ActivityTests.cs
@@ -0,0 +1,70 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using Xunit;
+
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using Org.OpenAPITools.Api;
+using Org.OpenAPITools.Model;
+using Org.OpenAPITools.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+namespace Org.OpenAPITools.Test.Model
+{
+ ///
+ /// Class for testing Activity
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the model.
+ ///
+ public class ActivityTests : IDisposable
+ {
+ // TODO uncomment below to declare an instance variable for Activity
+ //private Activity instance;
+
+ public ActivityTests()
+ {
+ // TODO uncomment below to create an instance of Activity
+ //instance = new Activity();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of Activity
+ ///
+ [Fact]
+ public void ActivityInstanceTest()
+ {
+ // TODO uncomment below to test "IsType" Activity
+ //Assert.IsType(instance);
+ }
+
+
+ ///
+ /// Test the property 'ActivityOutputs'
+ ///
+ [Fact]
+ public void ActivityOutputsTest()
+ {
+ // TODO unit test for the property 'ActivityOutputs'
+ }
+
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Activity.cs
new file mode 100644
index 00000000000..68647a4ae15
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Activity.cs
@@ -0,0 +1,119 @@
+//
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.ComponentModel.DataAnnotations;
+using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
+
+namespace Org.OpenAPITools.Model
+{
+ ///
+ /// test map of maps
+ ///
+ public partial class Activity : IEquatable, IValidatableObject
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// activityOutputs
+ public Activity(Dictionary> activityOutputs = default)
+ {
+ ActivityOutputs = activityOutputs;
+ }
+
+ ///
+ /// Gets or Sets ActivityOutputs
+ ///
+ [JsonPropertyName("activity_outputs")]
+ public Dictionary> ActivityOutputs { get; set; }
+
+ ///
+ /// Gets or Sets additional properties
+ ///
+ [JsonExtensionData]
+ public Dictionary AdditionalProperties { get; set; } = new Dictionary();
+
+ ///
+ /// Returns the string presentation of the object
+ ///
+ /// String presentation of the object
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("class Activity {\n");
+ sb.Append(" ActivityOutputs: ").Append(ActivityOutputs).Append("\n");
+ sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
+ sb.Append("}\n");
+ return sb.ToString();
+ }
+
+ ///
+ /// Returns true if objects are equal
+ ///
+ /// Object to be compared
+ /// Boolean
+ public override bool Equals(object input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input as Activity).AreEqual;
+ }
+
+ ///
+ /// Returns true if Activity instances are equal
+ ///
+ /// Instance of Activity to be compared
+ /// Boolean
+ public bool Equals(Activity input)
+ {
+ return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
+ }
+
+ ///
+ /// Gets the hash code
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ unchecked // Overflow is fine, just wrap
+ {
+ int hashCode = 41;
+ if (this.ActivityOutputs != null)
+ {
+ hashCode = (hashCode * 59) + this.ActivityOutputs.GetHashCode();
+ }
+ if (this.AdditionalProperties != null)
+ {
+ hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
+ }
+ return hashCode;
+ }
+ }
+
+ ///
+ /// To validate all properties of the instance
+ ///
+ /// Validation context
+ /// Validation Result
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ yield break;
+ }
+ }
+
+}
diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
new file mode 100644
index 00000000000..ed290bab607
--- /dev/null
+++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -0,0 +1,132 @@
+//