mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-06 23:06:07 +00:00
Compare commits
1 Commits
t0mk-fix_v
...
nested-one
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
225d590b53 |
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"name": "OpenAPIGenerator",
|
||||
"image": "mcr.microsoft.com/devcontainers/base:debian",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/java:1": {
|
||||
"version": "11",
|
||||
"installMaven": true
|
||||
},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "lts"
|
||||
},
|
||||
"ghcr.io/snebjorn/devcontainer-feature/chromium:latest": {}
|
||||
},
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {
|
||||
"java.configuration.runtimes": [
|
||||
{
|
||||
"name": "JavaSE-11",
|
||||
"path": "/usr/local/sdkman/candidates/java/11.0.16.1-ms",
|
||||
"sources": "/usr/local/sdkman/candidates/java/11.0.16.1-ms/lib/src.zip",
|
||||
"javadoc": "https://docs.oracle.com/en/java/javase/11/docs/api",
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
},
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"vscjava.vscode-java-pack",
|
||||
"attilabuti.mustache-syntax-vscode",
|
||||
"formulahendry.code-runner",
|
||||
"visualstudioexptteam.vscodeintellicode",
|
||||
"42crunch.vscode-openapi",
|
||||
"mermade.openapi-lint"
|
||||
]
|
||||
}
|
||||
},
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// "postCreateCommand": "mvn clean package -DskipTests",
|
||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "vscode"
|
||||
}
|
||||
2
.github/workflows/samples-go.yaml
vendored
2
.github/workflows/samples-go.yaml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
- samples/server/petstore/go-api-server/
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v4
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '>=1.17.0'
|
||||
- run: go version
|
||||
|
||||
@@ -34,9 +34,6 @@ jobs:
|
||||
path: |
|
||||
~/.m2
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: Build with Maven
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: mvn clean package
|
||||
- name: Build with Gradle
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: gradle clean build
|
||||
|
||||
10
.github/workflows/samples-spring.yaml
vendored
10
.github/workflows/samples-spring.yaml
vendored
@@ -22,30 +22,26 @@ jobs:
|
||||
- samples/openapi3/client/petstore/spring-cloud
|
||||
- samples/client/petstore/spring-cloud-date-time
|
||||
- samples/openapi3/client/petstore/spring-cloud-date-time
|
||||
- samples/client/petstore/spring-stubs
|
||||
- samples/openapi3/client/petstore/spring-stubs
|
||||
- samples/openapi3/client/petstore/spring-stubs-skip-default-interface
|
||||
- samples/openapi3/client/petstore/spring-cloud-async
|
||||
- samples/openapi3/client/petstore/spring-cloud-spring-pageable
|
||||
# servers
|
||||
- samples/server/petstore/springboot
|
||||
- samples/openapi3/server/petstore/springboot
|
||||
- samples/server/petstore/springboot-beanvalidation
|
||||
- samples/server/petstore/springboot-useoptional
|
||||
- samples/openapi3/server/petstore/springboot-useoptional
|
||||
- samples/server/petstore/springboot-reactive
|
||||
- samples/openapi3/server/petstore/springboot-reactive
|
||||
- samples/server/petstore/springboot-implicitHeaders
|
||||
- samples/openapi3/server/petstore/springboot-implicitHeaders
|
||||
- samples/server/petstore/springboot-delegate
|
||||
- samples/server/petstore/springboot-delegate-no-response-entity
|
||||
- samples/openapi3/server/petstore/springboot-delegate
|
||||
- samples/server/petstore/spring-boot-nullable-set
|
||||
- samples/server/petstore/spring-boot-defaultInterface-unhandledException
|
||||
- samples/openapi3/server/petstore/spring-boot-oneof
|
||||
- samples/server/petstore/springboot-virtualan
|
||||
- samples/server/petstore/springboot-implicitHeaders-annotationLibrary
|
||||
- samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8
|
||||
- samples/server/petstore/springboot-spring-pageable-delegatePattern
|
||||
- samples/server/petstore/springboot-spring-pageable-without-j8
|
||||
- samples/server/petstore/springboot-spring-pageable
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
@@ -150,15 +150,14 @@ script:
|
||||
- docker buildx version
|
||||
# run integration tests defined in maven pom.xml
|
||||
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
|
||||
# show "error" only to reduce the log size
|
||||
- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error 2>&1 | grep -i error
|
||||
- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
#- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
after_success:
|
||||
# push to maven repo
|
||||
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ]; then
|
||||
echo "Publishing from branch $TRAVIS_BRANCH";
|
||||
mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error;
|
||||
mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
pushd .;
|
||||
cd modules/openapi-generator-gradle-plugin;
|
||||
@@ -167,7 +166,7 @@ after_success:
|
||||
popd;
|
||||
elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then
|
||||
echo "Publishing from branch $TRAVIS_BRANCH";
|
||||
mvn clean deploy --settings CI/settings.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error;
|
||||
mvn clean deploy --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
pushd .;
|
||||
cd modules/openapi-generator-gradle-plugin;
|
||||
|
||||
@@ -78,7 +78,7 @@ 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 4.x, Apache HttpClient 5.x, 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), **Jetbrains HTTP Client**, **Julia**, **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 - 15.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
|
||||
| **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 4.x, Apache HttpClient 5.x, 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), **Jetbrains HTTP Client**, **Julia**, **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/)), **Julia**, **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/) |
|
||||
@@ -613,7 +613,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [DB Systel](https://www.dbsystel.de)
|
||||
- [Deeporute.ai](https://www.deeproute.ai/)
|
||||
- [Devsupply](https://www.devsupply.com/)
|
||||
- [dmTECH GmbH](https://www.dmTECH.de)
|
||||
- [DocSpring](https://docspring.com/)
|
||||
- [dwango](https://dwango.co.jp/)
|
||||
- [Edge Impulse](https://www.edgeimpulse.com/)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# for .net Unity
|
||||
generatorName: csharp-netcore
|
||||
outputDir: samples/client/petstore/csharp-netcore/OpenAPIClient-unityWebRequest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp-netcore
|
||||
library: unityWebRequest
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: jaxrs-cxf-cdi
|
||||
outputDir: samples/server/petstore/jaxrs-cxf-cdi
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
generatorName: jaxrs-spec
|
||||
outputDir: samples/server/petstore/jaxrs-spec-required-and-readonly-property
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/required-and-readonly-property.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
|
||||
additionalProperties:
|
||||
artifactId: jaxrs-spec-petstore-server
|
||||
serializableModel: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
implicitHeadersRegex: (api_key|enum_header_string)
|
||||
generateBuilders: "true"
|
||||
13
bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml
Normal file
13
bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springdoc
|
||||
java8: "false"
|
||||
useBeanValidation: true
|
||||
artifactId: spring-boot-beanvalidation-no-nullable
|
||||
hideGenerationTimestamp: "true"
|
||||
openApiNullable: "false"
|
||||
@@ -1,10 +1,9 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-beanvalidation-no-nullable
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springfox
|
||||
java8: "false"
|
||||
useBeanValidation: true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-beanvalidation
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/spring-boot-defaultInterface-unhandledException
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
artifactId: spring-boot-defaultInterface-unhandledException
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-delegate-j8
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-delegate-no-response-entity
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
artifactId: springboot-delegate-no-response-entity
|
||||
hideGenerationTimestamp: "true"
|
||||
java8: true
|
||||
delegatePattern: "true"
|
||||
useResponseEntity: "false"
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/server/petstore/springboot-delegate
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-delegate
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/server/petstore/springboot-implicitHeaders
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-implicitHeaders
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
artifactId: springboot-implicitHeaders
|
||||
|
||||
11
bin/configs/spring-boot-reactive-oas3.yaml
Normal file
11
bin/configs/spring-boot-reactive-oas3.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/server/petstore/springboot-reactive
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springdoc
|
||||
artifactId: springboot-reactive
|
||||
reactive: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
delegatePattern: "true"
|
||||
@@ -1,9 +1,8 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-reactive
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
artifactId: springboot-reactive
|
||||
documentationProvider: springfox
|
||||
reactive: "true"
|
||||
|
||||
10
bin/configs/spring-boot-useoptional-oas3.yaml
Normal file
10
bin/configs/spring-boot-useoptional-oas3.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/server/petstore/springboot-useoptional
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springdoc
|
||||
useOptional: true
|
||||
artifactId: spring-boot-useoptional
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -1,9 +1,8 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-useoptional
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springfox
|
||||
useOptional: true
|
||||
artifactId: spring-boot-useoptional
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-virtualan
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springdoc
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/client/petstore/spring-cloud-async
|
||||
library: spring-cloud
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
|
||||
11
bin/configs/spring-cloud-async.yaml
Normal file
11
bin/configs/spring-cloud-async.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/client/petstore/spring-cloud-async
|
||||
library: spring-cloud
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
async: "true"
|
||||
java8: "true"
|
||||
artifactId: petstore-spring-cloud
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
library: spring-cloud
|
||||
outputDir: samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
@@ -10,4 +10,3 @@ additionalProperties:
|
||||
interfaceOnly: "true"
|
||||
singleContentTypes: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
generatedConstructorWithRequiredArgs: "false"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/client/petstore/spring-cloud-spring-pageable
|
||||
library: spring-cloud
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/client/petstore/spring-cloud-spring-pageable
|
||||
library: spring-cloud
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
artifactId: spring-cloud-spring-pageable
|
||||
hideGenerationTimestamp: 'true'
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
library: spring-http-interface
|
||||
outputDir: samples/client/petstore/spring-http-interface-reactive
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
artifactId: spring-http-interface-reactive
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
generatorName: spring
|
||||
library: spring-http-interface
|
||||
outputDir: samples/client/petstore/spring-http-interface
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
artifactId: spring-http-interface
|
||||
snapshotVersion: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
modelNameSuffix: 'Dto'
|
||||
generatedConstructorWithRequiredArgs: "false"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/client/petstore/spring-stubs
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/client/petstore/spring-stubs-skip-default-interface
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
|
||||
10
bin/configs/spring-stubs.yaml
Normal file
10
bin/configs/spring-stubs.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/spring-stubs
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
artifactId: spring-stubs
|
||||
interfaceOnly: "true"
|
||||
singleContentTypes: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
delegatePattern: true
|
||||
java8: false
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-spring-pageable-delegatePattern
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
delegatePattern: true
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
artifactId: springboot-spring-pageable-delegatePattern
|
||||
hideGenerationTimestamp: 'true'
|
||||
implicitHeadersRegex: ^Version.*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-spring-pageable-without-j8
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
java8: false
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-spring-pageable
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
artifactId: springboot-spring-pageable
|
||||
hideGenerationTimestamp: 'true'
|
||||
implicitHeadersRegex: ^Version.*
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/anycodable
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/any_codable.yaml
|
||||
modelNamePrefix: Prefix
|
||||
modelNameSuffix: Suffix
|
||||
additionalProperties:
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
@@ -0,0 +1,6 @@
|
||||
generatorName: csharp-dotnet2
|
||||
outputDir: samples/client/petstore/csharp-dotnet2/OpenAPIClientTest/Lib/OpenAPIClient
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp-dotnet2
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
16
bitrise.yml
16
bitrise.yml
@@ -10,7 +10,10 @@ trigger_map:
|
||||
workflows:
|
||||
primary:
|
||||
steps:
|
||||
- git-clone@8.0.0: {}
|
||||
- git-clone@6.2.1: {}
|
||||
- brew-install@0.12.1:
|
||||
inputs:
|
||||
- packages: maven
|
||||
- script@1.2.0:
|
||||
title: Install Cocoapods
|
||||
inputs:
|
||||
@@ -18,6 +21,15 @@ workflows:
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sudo gem install cocoapods
|
||||
- script@1.2.0:
|
||||
inputs:
|
||||
- content: |
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
mvn --no-snapshot-updates package -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
title: Build openapi-generator
|
||||
- script@1.2.0:
|
||||
title: Run Swift5 tests
|
||||
inputs:
|
||||
@@ -30,4 +42,4 @@ workflows:
|
||||
|
||||
meta:
|
||||
bitrise.io:
|
||||
stack: osx-xcode-14.2.x
|
||||
stack: osx-xcode-14.1.x
|
||||
|
||||
@@ -485,7 +485,7 @@ Example:
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/simplifyBooleanEnum_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer SIMPLIFY_BOOLEAN_ENUM=true
|
||||
```
|
||||
|
||||
- `SIMPLIFY_ONEOF_ANYOF`: when set to `true`, simplify oneOf/anyOf by 1) removing null (sub-schema) or enum of null (sub-schema) and setting nullable to true instead, and 2) simplifying oneOf/anyOf with a single sub-schema to just the sub-schema itself.
|
||||
- `SIMPLIFY_ONEOF_ANYOF`: when set to `true`, simplify oneOf/anyOf by 1) removing null (sub-schema) and setting nullable to true instead, and 2) simplifying oneOf/anyOf with a single sub-schema to just the sub-schema itself.
|
||||
|
||||
Example:
|
||||
```
|
||||
@@ -505,10 +505,3 @@ Example:
|
||||
```
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/enableKeepOnlyFirstTagInOperation_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=true
|
||||
```
|
||||
|
||||
- `ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE`: when set to true, auto fix integer with maximum value 4294967295 (2^32-1) or long with 18446744073709551615 (2^64-1) by adding x-unsigned to the schema
|
||||
|
||||
Example:
|
||||
```
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/addUnsignedToIntegerWithInvalidMaxValue_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE=true
|
||||
```
|
||||
|
||||
@@ -19,6 +19,7 @@ The following generators are available:
|
||||
* [cpp-ue4 (beta)](generators/cpp-ue4.md)
|
||||
* [crystal (beta)](generators/crystal.md)
|
||||
* [csharp](generators/csharp.md)
|
||||
* [csharp-dotnet2 (deprecated)](generators/csharp-dotnet2.md)
|
||||
* [csharp-netcore](generators/csharp-netcore.md)
|
||||
* [dart](generators/dart.md)
|
||||
* [dart-dio](generators/dart-dio.md)
|
||||
|
||||
@@ -105,10 +105,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>long</li>
|
||||
<li>long?</li>
|
||||
<li>string</li>
|
||||
<li>uint</li>
|
||||
<li>uint?</li>
|
||||
<li>ulong</li>
|
||||
<li>ulong?</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
293
docs/generators/csharp-dotnet2.md
Normal file
293
docs/generators/csharp-dotnet2.md
Normal file
@@ -0,0 +1,293 @@
|
||||
---
|
||||
title: Documentation for the csharp-dotnet2 Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | csharp-dotnet2 | pass this to the generate command after -g |
|
||||
| generator stability | DEPRECATED | |
|
||||
| generator type | CLIENT | |
|
||||
| generator language | C# | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a C# .Net 2.0 client library (beta). | |
|
||||
|
||||
## CONFIG OPTIONS
|
||||
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|clientPackage|C# client package name (convention: Camel.Case).| |Org.OpenAPITools.Client|
|
||||
|packageName|C# package name (convention: Camel.Case).| |Org.OpenAPITools|
|
||||
|packageVersion|C# package version.| |1.0.0|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|array|List|
|
||||
|list|List|
|
||||
|map|Dictionary|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Boolean</li>
|
||||
<li>Collection</li>
|
||||
<li>DateTime</li>
|
||||
<li>DateTime?</li>
|
||||
<li>DateTimeOffset</li>
|
||||
<li>DateTimeOffset?</li>
|
||||
<li>Decimal</li>
|
||||
<li>Dictionary</li>
|
||||
<li>Double</li>
|
||||
<li>Float</li>
|
||||
<li>Guid</li>
|
||||
<li>Guid?</li>
|
||||
<li>ICollection</li>
|
||||
<li>Int32</li>
|
||||
<li>Int64</li>
|
||||
<li>List</li>
|
||||
<li>Object</li>
|
||||
<li>String</li>
|
||||
<li>System.IO.Stream</li>
|
||||
<li>bool</li>
|
||||
<li>bool?</li>
|
||||
<li>byte[]</li>
|
||||
<li>decimal</li>
|
||||
<li>decimal?</li>
|
||||
<li>double</li>
|
||||
<li>double?</li>
|
||||
<li>float</li>
|
||||
<li>float?</li>
|
||||
<li>int</li>
|
||||
<li>int?</li>
|
||||
<li>long</li>
|
||||
<li>long?</li>
|
||||
<li>string</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Client</li>
|
||||
<li>Configuration</li>
|
||||
<li>Version</li>
|
||||
<li>abstract</li>
|
||||
<li>as</li>
|
||||
<li>base</li>
|
||||
<li>bool</li>
|
||||
<li>break</li>
|
||||
<li>byte</li>
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>char</li>
|
||||
<li>checked</li>
|
||||
<li>class</li>
|
||||
<li>client</li>
|
||||
<li>const</li>
|
||||
<li>continue</li>
|
||||
<li>decimal</li>
|
||||
<li>default</li>
|
||||
<li>delegate</li>
|
||||
<li>do</li>
|
||||
<li>double</li>
|
||||
<li>else</li>
|
||||
<li>enum</li>
|
||||
<li>event</li>
|
||||
<li>explicit</li>
|
||||
<li>extern</li>
|
||||
<li>false</li>
|
||||
<li>finally</li>
|
||||
<li>fixed</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
<li>foreach</li>
|
||||
<li>goto</li>
|
||||
<li>if</li>
|
||||
<li>implicit</li>
|
||||
<li>in</li>
|
||||
<li>int</li>
|
||||
<li>interface</li>
|
||||
<li>internal</li>
|
||||
<li>is</li>
|
||||
<li>localVarFileParams</li>
|
||||
<li>localVarFormParams</li>
|
||||
<li>localVarHeaderParams</li>
|
||||
<li>localVarHttpContentType</li>
|
||||
<li>localVarHttpContentTypes</li>
|
||||
<li>localVarHttpHeaderAccept</li>
|
||||
<li>localVarHttpHeaderAccepts</li>
|
||||
<li>localVarPath</li>
|
||||
<li>localVarPathParams</li>
|
||||
<li>localVarPostBody</li>
|
||||
<li>localVarQueryParams</li>
|
||||
<li>localVarResponse</li>
|
||||
<li>localVarStatusCode</li>
|
||||
<li>lock</li>
|
||||
<li>long</li>
|
||||
<li>namespace</li>
|
||||
<li>new</li>
|
||||
<li>null</li>
|
||||
<li>object</li>
|
||||
<li>operator</li>
|
||||
<li>out</li>
|
||||
<li>override</li>
|
||||
<li>parameter</li>
|
||||
<li>params</li>
|
||||
<li>private</li>
|
||||
<li>protected</li>
|
||||
<li>public</li>
|
||||
<li>readonly</li>
|
||||
<li>ref</li>
|
||||
<li>return</li>
|
||||
<li>sbyte</li>
|
||||
<li>sealed</li>
|
||||
<li>short</li>
|
||||
<li>sizeof</li>
|
||||
<li>stackalloc</li>
|
||||
<li>static</li>
|
||||
<li>string</li>
|
||||
<li>struct</li>
|
||||
<li>switch</li>
|
||||
<li>this</li>
|
||||
<li>throw</li>
|
||||
<li>true</li>
|
||||
<li>try</li>
|
||||
<li>typeof</li>
|
||||
<li>uint</li>
|
||||
<li>ulong</li>
|
||||
<li>unchecked</li>
|
||||
<li>unsafe</li>
|
||||
<li>ushort</li>
|
||||
<li>using</li>
|
||||
<li>virtual</li>
|
||||
<li>void</li>
|
||||
<li>volatile</li>
|
||||
<li>while</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
||||
|
||||
### Client Modification Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasePath|✗|ToolingExtension
|
||||
|Authorizations|✗|ToolingExtension
|
||||
|UserAgent|✗|ToolingExtension
|
||||
|MockServer|✗|ToolingExtension
|
||||
|
||||
### Data Type Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Custom|✗|OAS2,OAS3
|
||||
|Int32|✓|OAS2,OAS3
|
||||
|Int64|✓|OAS2,OAS3
|
||||
|Float|✓|OAS2,OAS3
|
||||
|Double|✓|OAS2,OAS3
|
||||
|Decimal|✓|ToolingExtension
|
||||
|String|✓|OAS2,OAS3
|
||||
|Byte|✓|OAS2,OAS3
|
||||
|Binary|✓|OAS2,OAS3
|
||||
|Boolean|✓|OAS2,OAS3
|
||||
|Date|✓|OAS2,OAS3
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|CollectionFormatMulti|✓|OAS2
|
||||
|Enum|✓|OAS2,OAS3
|
||||
|ArrayOfEnum|✓|ToolingExtension
|
||||
|ArrayOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
||||
|MapOfEnum|✓|ToolingExtension
|
||||
|MapOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|MapOfCollectionOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfEnum|✓|ToolingExtension
|
||||
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✓|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
### Global Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Host|✓|OAS2,OAS3
|
||||
|BasePath|✓|OAS2,OAS3
|
||||
|Info|✓|OAS2,OAS3
|
||||
|Schemes|✗|OAS2,OAS3
|
||||
|PartialSchemes|✓|OAS2,OAS3
|
||||
|Consumes|✓|OAS2
|
||||
|Produces|✓|OAS2
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✓|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✓|OAS2
|
||||
|Cookie|✓|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✓|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✓|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
|
||||
|
||||
### Wire Format Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✓|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✗|OAS2,OAS3
|
||||
@@ -98,10 +98,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>long</li>
|
||||
<li>long?</li>
|
||||
<li>string</li>
|
||||
<li>uint</li>
|
||||
<li>uint?</li>
|
||||
<li>ulong</li>
|
||||
<li>ulong?</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
@@ -22,12 +22,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|apiName|Must be a valid C# class name. Only used in Generic Host library. Default: Api| |Api|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive| |false|
|
||||
|conditionalSerialization|Serialize only those properties which are initialized by user, accepted values are true or false, default value is false.| |false|
|
||||
|dateFormat|The default Date format (only `generichost` library supports this option).| |yyyy'-'MM'-'dd|
|
||||
|dateTimeFormat|The default DateTime format (only `generichost` library supports this option).| |yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK|
|
||||
|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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| |I|
|
||||
|library|HTTP library template (sub-template) to use|<dl><dt>**generichost**</dt><dd>HttpClient with Generic Host dependency injection (https://docs.microsoft.com/en-us/dotnet/core/extensions/generic-host) (Experimental. Subject to breaking changes without notice.)</dd><dt>**httpclient**</dt><dd>HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) (Experimental. Subject to breaking changes without notice.)</dd><dt>**unityWebRequest**</dt><dd>UnityWebRequest (...) (Experimental. Subject to breaking changes without notice.)</dd><dt>**restsharp**</dt><dd>RestSharp (https://github.com/restsharp/RestSharp)</dd></dl>|restsharp|
|
||||
|library|HTTP library template (sub-template) to use|<dl><dt>**generichost**</dt><dd>HttpClient with Generic Host dependency injection (https://docs.microsoft.com/en-us/dotnet/core/extensions/generic-host) (Experimental. Subject to breaking changes without notice.)</dd><dt>**httpclient**</dt><dd>HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) (Experimental. Subject to breaking changes without notice.)</dd><dt>**restsharp**</dt><dd>RestSharp (https://github.com/restsharp/RestSharp)</dd></dl>|restsharp|
|
||||
|licenseId|The identifier of the license| |null|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |PascalCase|
|
||||
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|
||||
@@ -101,10 +99,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>long</li>
|
||||
<li>long?</li>
|
||||
<li>string</li>
|
||||
<li>uint</li>
|
||||
<li>uint?</li>
|
||||
<li>ulong</li>
|
||||
<li>ulong?</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
@@ -93,10 +93,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>long</li>
|
||||
<li>long?</li>
|
||||
<li>string</li>
|
||||
<li>uint</li>
|
||||
<li>uint?</li>
|
||||
<li>ulong</li>
|
||||
<li>ulong?</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
@@ -218,7 +218,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|BearerToken|✗|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|
||||
@@ -56,7 +56,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generatedConstructorWithRequiredArgs|Whether to generate constructors with required args for models| |true|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|hateoas|Use Spring HATEOAS library to allow adding HATEOAS links| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|
||||
@@ -97,7 +96,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||
|useOptional|Use Optional container for optional parameters| |false|
|
||||
|useResponseEntity|Use the `ResponseEntity` type to wrap return values of generated API methods. If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition| |true|
|
||||
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|
||||
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
||||
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
||||
@@ -118,7 +116,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false
|
||||
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
@@ -44,7 +44,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|serverPort|configuration the port in which the sever is to run on| |8080|
|
||||
|serviceImplementation|generate stub service implementations that extends service interfaces. If this is set to true service interfaces will also be generated| |false|
|
||||
|serviceInterface|generate service interfaces to go alongside controllers. In most cases this option would be used to update an existing project, so not to override implementations. Useful to help facilitate the generation gap pattern| |false|
|
||||
|skipDefaultInterface|Whether to skip generation of default implementations for interfaces| |false|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |null|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |null|
|
||||
|sourceFolder|source folder for generated code| |src/main/kotlin|
|
||||
|
||||
@@ -20,8 +20,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowStringInDateTimeParameters|Allow string as input to datetime/date parameters for backward compartibility.| |false|
|
||||
|dateFormat|date format for query parameters| |%Y-%m-%d|
|
||||
|datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z|
|
||||
|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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|floatStrictType|Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)| |true|
|
||||
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|
||||
|
||||
@@ -49,7 +49,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generatedConstructorWithRequiredArgs|Whether to generate constructors with required args for models| |true|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|hateoas|Use Spring HATEOAS library to allow adding HATEOAS links| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|
||||
@@ -90,7 +89,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||
|useOptional|Use Optional container for optional parameters| |false|
|
||||
|useResponseEntity|Use the `ResponseEntity` type to wrap return values of generated API methods. If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition| |true|
|
||||
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|
||||
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
||||
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
||||
@@ -111,7 +109,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false
|
||||
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
@@ -74,7 +74,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Any</li>
|
||||
<li>AnyCodable</li>
|
||||
<li>AnyObject</li>
|
||||
<li>Bool</li>
|
||||
<li>Character</li>
|
||||
|
||||
@@ -125,7 +125,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>native</li>
|
||||
<li>new</li>
|
||||
<li>null</li>
|
||||
<li>options</li>
|
||||
<li>package</li>
|
||||
<li>private</li>
|
||||
<li>protected</li>
|
||||
|
||||
@@ -272,12 +272,6 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-ext</artifactId>
|
||||
|
||||
@@ -75,7 +75,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public List<CodegenProperty> readOnlyVars = new ArrayList<>(); // a list of read-only properties
|
||||
public List<CodegenProperty> readWriteVars = new ArrayList<>(); // a list of properties for read, write
|
||||
public List<CodegenProperty> parentVars = new ArrayList<>();
|
||||
public List<CodegenProperty> parentRequiredVars = new ArrayList<>();
|
||||
public List<CodegenProperty> nonNullableVars = new ArrayList<>(); // a list of non-nullable properties
|
||||
public Map<String, Object> allowableValues;
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ public class CodegenOperation {
|
||||
public boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams, hasRequiredParams,
|
||||
returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMap,
|
||||
isArray, isMultipart,
|
||||
hasVersionHeaders = false, hasVersionQueryParams = false,
|
||||
isResponseBinary = false, isResponseFile = false, isResponseOptional = false, hasReference = false, defaultReturnType = false,
|
||||
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
isRestful, isDeprecated, isCallbackRequest, uniqueItems, hasDefaultResponse = false,
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
public String example; // example value (x-example)
|
||||
public String jsonSchema;
|
||||
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary,
|
||||
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
|
||||
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
|
||||
public boolean isArray, isMap;
|
||||
public boolean isFile;
|
||||
public boolean isEnum;
|
||||
@@ -229,7 +229,6 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
output.isUuid = this.isUuid;
|
||||
output.isUri = this.isUri;
|
||||
output.isEmail = this.isEmail;
|
||||
output.isPassword = this.isPassword;
|
||||
output.isFreeFormObject = this.isFreeFormObject;
|
||||
output.isAnyType = this.isAnyType;
|
||||
output.isArray = this.isArray;
|
||||
@@ -245,7 +244,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumDefaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content, requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties);
|
||||
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumDefaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content, requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,7 +281,6 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
isUuid == that.isUuid &&
|
||||
isUri == that.isUri &&
|
||||
isEmail == that.isEmail &&
|
||||
isPassword == that.isPassword &&
|
||||
isFreeFormObject == that.isFreeFormObject &&
|
||||
isAnyType == that.isAnyType &&
|
||||
isArray == that.isArray &&
|
||||
@@ -396,7 +394,6 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
sb.append(", isUuid=").append(isUuid);
|
||||
sb.append(", isUri=").append(isUri);
|
||||
sb.append(", isEmail=").append(isEmail);
|
||||
sb.append(", isPassword=").append(isPassword);
|
||||
sb.append(", isFreeFormObject=").append(isFreeFormObject);
|
||||
sb.append(", isAnyType=").append(isAnyType);
|
||||
sb.append(", isArray=").append(isArray);
|
||||
|
||||
@@ -134,7 +134,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
public boolean isUuid;
|
||||
public boolean isUri;
|
||||
public boolean isEmail;
|
||||
public boolean isPassword;
|
||||
public boolean isNull;
|
||||
/**
|
||||
* The type is a free-form object, i.e. it is a map of string to values with no declared properties.
|
||||
@@ -1052,7 +1051,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
sb.append(", isUuid=").append(isUuid);
|
||||
sb.append(", isUri=").append(isUri);
|
||||
sb.append(", isEmail=").append(isEmail);
|
||||
sb.append(", isPassword=").append(isPassword);
|
||||
sb.append(", isFreeFormObject=").append(isFreeFormObject);
|
||||
sb.append(", isArray=").append(isArray);
|
||||
sb.append(", isMap=").append(isMap);
|
||||
@@ -1144,7 +1142,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
isUuid == that.isUuid &&
|
||||
isUri == that.isUri &&
|
||||
isEmail == that.isEmail &&
|
||||
isPassword == that.isPassword &&
|
||||
isFreeFormObject == that.isFreeFormObject &&
|
||||
isArray == that.isArray &&
|
||||
isMap == that.isMap &&
|
||||
@@ -1234,7 +1231,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
exclusiveMinimum, exclusiveMaximum, required, deprecated,
|
||||
hasMoreNonReadOnly, isPrimitiveType, isModel, isContainer, isString, isNumeric,
|
||||
isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isFile,
|
||||
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject,
|
||||
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject,
|
||||
isArray, isMap, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
|
||||
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, _enum,
|
||||
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
|
||||
|
||||
@@ -50,7 +50,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
public boolean isDateTime;
|
||||
public boolean isUuid;
|
||||
public boolean isEmail;
|
||||
public boolean isPassword;
|
||||
public boolean isModel;
|
||||
public boolean isFreeFormObject;
|
||||
public boolean isAnyType;
|
||||
@@ -99,7 +98,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
public int hashCode() {
|
||||
return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, hasHeaders,
|
||||
isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBoolean, isDate,
|
||||
isDateTime, isUuid, isEmail, isPassword, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
|
||||
isDateTime, isUuid, isEmail, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
|
||||
isMap, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties,
|
||||
vars, requiredVars, isNull, hasValidation, isShort, isUnboundedInteger,
|
||||
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
|
||||
@@ -131,7 +130,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
isDateTime == that.isDateTime &&
|
||||
isUuid == that.isUuid &&
|
||||
isEmail == that.isEmail &&
|
||||
isPassword == that.isPassword &&
|
||||
isModel == that.isModel &&
|
||||
isFreeFormObject == that.isFreeFormObject &&
|
||||
isAnyType == that.isAnyType &&
|
||||
@@ -570,7 +568,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
sb.append(", isDateTime=").append(isDateTime);
|
||||
sb.append(", isUuid=").append(isUuid);
|
||||
sb.append(", isEmail=").append(isEmail);
|
||||
sb.append(", isPassword=").append(isPassword);
|
||||
sb.append(", isModel=").append(isModel);
|
||||
sb.append(", isFreeFormObject=").append(isFreeFormObject);
|
||||
sb.append(", isAnyType=").append(isAnyType);
|
||||
|
||||
@@ -25,27 +25,11 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Mustache.Compiler;
|
||||
import com.samskivert.mustache.Mustache.Lambda;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
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.callbacks.Callback;
|
||||
import io.swagger.v3.oas.models.examples.Example;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.*;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.models.security.OAuthFlow;
|
||||
import io.swagger.v3.oas.models.security.OAuthFlows;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.oas.models.servers.ServerVariable;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
|
||||
import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
@@ -650,7 +634,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
parent.hasChildren = true;
|
||||
Schema parentSchema = this.openAPI.getComponents().getSchemas().get(parent.name);
|
||||
if (parentSchema == null) {
|
||||
throw new NullPointerException(parent.name + " in " + this.openAPI.getComponents().getSchemas());
|
||||
throw new NullPointerException(parent.name+" in "+this.openAPI.getComponents().getSchemas());
|
||||
}
|
||||
if (parentSchema.getDiscriminator() == null) {
|
||||
parent = allModels.get(parent.getParent());
|
||||
@@ -1744,11 +1728,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("DateTime", "Date");
|
||||
typeMapping.put("long", "Long");
|
||||
typeMapping.put("short", "Short");
|
||||
typeMapping.put("integer", "Integer");
|
||||
typeMapping.put("UnsignedInteger", "Integer");
|
||||
typeMapping.put("UnsignedLong", "Long");
|
||||
typeMapping.put("char", "String");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("integer", "Integer");
|
||||
// FIXME: java specific type should be in Java Based Abstract Impl's
|
||||
typeMapping.put("ByteArray", "byte[]");
|
||||
typeMapping.put("binary", "File");
|
||||
@@ -2080,7 +2062,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (encoding != null) {
|
||||
boolean styleGiven = true;
|
||||
Encoding.StyleEnum style = encoding.getStyle();
|
||||
if (style == null || style == Encoding.StyleEnum.FORM) {
|
||||
if(style == null || style == Encoding.StyleEnum.FORM) {
|
||||
// (Unfortunately, swagger-parser-v3 will always provide 'form'
|
||||
// when style is not specified, so we can't detect that)
|
||||
style = Encoding.StyleEnum.FORM;
|
||||
@@ -2088,12 +2070,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
boolean explodeGiven = true;
|
||||
Boolean explode = encoding.getExplode();
|
||||
if (explode == null) {
|
||||
if(explode == null) {
|
||||
explode = style == Encoding.StyleEnum.FORM; // Default to True when form, False otherwise
|
||||
explodeGiven = false;
|
||||
}
|
||||
|
||||
if (!styleGiven && !explodeGiven) {
|
||||
if(!styleGiven && !explodeGiven) {
|
||||
// Ignore contentType if style or explode are specified.
|
||||
codegenParameter.contentType = encoding.getContentType();
|
||||
}
|
||||
@@ -2101,7 +2083,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.style = style.toString();
|
||||
codegenParameter.isDeepObject = Encoding.StyleEnum.DEEP_OBJECT == style;
|
||||
|
||||
if (codegenParameter.isContainer) {
|
||||
if(codegenParameter.isContainer) {
|
||||
codegenParameter.isExplode = explode;
|
||||
String collectionFormat = getCollectionFormat(codegenParameter);
|
||||
codegenParameter.collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;
|
||||
@@ -2412,14 +2394,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return "number";
|
||||
}
|
||||
} else if (ModelUtils.isIntegerSchema(schema)) {
|
||||
if (ModelUtils.isUnsignedLongSchema(schema)) {
|
||||
return "UnsignedLong";
|
||||
} else if (ModelUtils.isUnsignedIntegerSchema(schema)) {
|
||||
return "UnsignedInteger";
|
||||
} else if (ModelUtils.isLongSchema(schema)) {
|
||||
if (ModelUtils.isLongSchema(schema)) {
|
||||
return "long";
|
||||
} else if (ModelUtils.isShortSchema(schema)) {// int32
|
||||
return "integer";
|
||||
} else {
|
||||
return schema.getType(); // integer
|
||||
}
|
||||
@@ -3048,6 +3024,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// referenced models here, component that refs another component which is a model
|
||||
// if a component references a schema which is not a generated model, the refed schema will be loaded into
|
||||
// schema by unaliasSchema and one of the above code paths will be taken
|
||||
;
|
||||
}
|
||||
if (schema.get$ref() != null) {
|
||||
m.setRef(schema.get$ref());
|
||||
@@ -3695,8 +3672,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.isUri = true;
|
||||
} else if (ModelUtils.isEmailSchema(p)) {
|
||||
property.isEmail = true;
|
||||
} else if (ModelUtils.isPasswordSchema(p)) {
|
||||
property.isPassword = true;
|
||||
} else if (ModelUtils.isDateSchema(p)) { // date format
|
||||
property.setIsString(false); // for backward compatibility with 2.x
|
||||
property.isDate = true;
|
||||
@@ -3789,18 +3764,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return cpc;
|
||||
}
|
||||
|
||||
Schema original = null;
|
||||
// check if it's allOf (only 1 sub schema) with default/nullable/etc set in the top level
|
||||
if (ModelUtils.isAllOf(p) && p.getAllOf().size() == 1 && ModelUtils.hasCommonAttributesDefined(p) ) {
|
||||
if (p.getAllOf().get(0) instanceof Schema) {
|
||||
original = p;
|
||||
p = (Schema) p.getAllOf().get(0);
|
||||
} else {
|
||||
LOGGER.error("Unknown type in allOf schema. Please report the issue via openapi-generator's Github issue tracker.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
|
||||
if (p.equals(trueSchema)) {
|
||||
property.setIsBooleanSchemaTrue(true);
|
||||
@@ -3957,7 +3920,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
property.baseType = getSchemaType(p);
|
||||
if (p.getXml() != null) {
|
||||
property.isXmlWrapped = p.getXml().getWrapped() != null && p.getXml().getWrapped();
|
||||
property.isXmlWrapped = p.getXml().getWrapped() == null ? false : p.getXml().getWrapped();
|
||||
property.xmlPrefix = p.getXml().getPrefix();
|
||||
property.xmlNamespace = p.getXml().getNamespace();
|
||||
property.xmlName = p.getXml().getName();
|
||||
@@ -3994,25 +3957,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.isModel = (ModelUtils.isComposedSchema(referencedSchema) || ModelUtils.isObjectSchema(referencedSchema)) && ModelUtils.isModel(referencedSchema);
|
||||
}
|
||||
|
||||
// restore original schema with default value, nullable, readonly etc
|
||||
if (original != null) {
|
||||
p = original;
|
||||
// evaluate common attributes defined in the top level
|
||||
if (p.getNullable() != null) {
|
||||
property.isNullable = p.getNullable();
|
||||
} else if (p.getExtensions() != null && p.getExtensions().containsKey("x-nullable")) {
|
||||
property.isNullable = (Boolean) p.getExtensions().get("x-nullable");
|
||||
}
|
||||
|
||||
if (p.getReadOnly() != null) {
|
||||
property.isReadOnly = p.getReadOnly();
|
||||
}
|
||||
|
||||
if (p.getWriteOnly() != null) {
|
||||
property.isWriteOnly = p.getWriteOnly();
|
||||
}
|
||||
}
|
||||
|
||||
// set the default value
|
||||
property.defaultValue = toDefaultValue(property, p);
|
||||
property.defaultValueWithParam = toDefaultValueWithParam(name, p);
|
||||
@@ -4755,8 +4699,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else if (ModelUtils.isStringSchema(responseSchema)) {
|
||||
if (ModelUtils.isEmailSchema(responseSchema)) {
|
||||
r.isEmail = true;
|
||||
} else if (ModelUtils.isPasswordSchema(responseSchema)) {
|
||||
r.isPassword = true;
|
||||
} else if (ModelUtils.isUUIDSchema(responseSchema)) {
|
||||
r.isUuid = true;
|
||||
} else if (ModelUtils.isByteArraySchema(responseSchema)) {
|
||||
@@ -5067,7 +5009,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// the default value is false
|
||||
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterexplode
|
||||
codegenParameter.isExplode = parameter.getExplode() != null && parameter.getExplode();
|
||||
codegenParameter.isExplode = parameter.getExplode() == null ? false : parameter.getExplode();
|
||||
|
||||
// TODO revise collectionFormat, default collection format in OAS 3 appears to multi at least for query parameters
|
||||
// https://swagger.io/docs/specification/serialization/
|
||||
@@ -5096,6 +5038,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isShortSchema(parameterSchema)) { // int32/short format
|
||||
codegenParameter.isShort = true;
|
||||
} else { // unbounded integer
|
||||
;
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isTypeObjectSchema(parameterSchema)) {
|
||||
@@ -5107,6 +5050,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
addVarsRequiredVarsAdditionalProps(parameterSchema, codegenParameter);
|
||||
} else if (ModelUtils.isNullType(parameterSchema)) {
|
||||
;
|
||||
} else if (ModelUtils.isAnyType(parameterSchema)) {
|
||||
// any schema with no type set, composed schemas often do this
|
||||
if (ModelUtils.isMapSchema(parameterSchema)) { // for map parameter
|
||||
@@ -5134,6 +5078,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
} else {
|
||||
// referenced schemas
|
||||
;
|
||||
}
|
||||
|
||||
CodegenProperty codegenProperty = fromProperty(parameter.getName(), parameterSchema, false);
|
||||
@@ -6302,8 +6247,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
if (Boolean.TRUE.equals(property.isEmail) && Boolean.TRUE.equals(property.isString)) {
|
||||
parameter.isEmail = true;
|
||||
} else if (Boolean.TRUE.equals(property.isPassword) && Boolean.TRUE.equals(property.isString)) {
|
||||
parameter.isPassword = true;
|
||||
} else if (Boolean.TRUE.equals(property.isUuid) && Boolean.TRUE.equals(property.isString)) {
|
||||
parameter.isUuid = true;
|
||||
} else if (Boolean.TRUE.equals(property.isByteArray)) {
|
||||
@@ -6819,8 +6762,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else if (ModelUtils.isStringSchema(ps)) {
|
||||
if (ModelUtils.isEmailSchema(ps)) {
|
||||
codegenParameter.isEmail = true;
|
||||
} else if (ModelUtils.isPasswordSchema(ps)) {
|
||||
codegenParameter.isPassword = true;
|
||||
} else if (ModelUtils.isUUIDSchema(ps)) {
|
||||
codegenParameter.isUuid = true;
|
||||
} else if (ModelUtils.isByteArraySchema(ps)) {
|
||||
@@ -6865,6 +6806,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isShortSchema(ps)) { // int32/short format
|
||||
codegenParameter.isShort = true;
|
||||
} else { // unbounded integer
|
||||
;
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isTypeObjectSchema(ps)) {
|
||||
@@ -6872,8 +6814,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
}
|
||||
} else if (ModelUtils.isNullType(ps)) {
|
||||
;
|
||||
} else if (ModelUtils.isAnyType(ps)) {
|
||||
// any schema with no type set, composed schemas often do this
|
||||
;
|
||||
} else if (ModelUtils.isArraySchema(ps)) {
|
||||
Schema inner = getSchemaItems((ArraySchema) ps);
|
||||
CodegenProperty arrayInnerProperty = fromProperty("inner", inner, false);
|
||||
@@ -6914,6 +6858,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
} else {
|
||||
// referenced schemas
|
||||
;
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(codegenProperty.isModel)) {
|
||||
@@ -7817,9 +7762,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final String removeCharRegEx;
|
||||
private final List<String> exceptions;
|
||||
private String name;
|
||||
private String removeCharRegEx;
|
||||
private List<String> exceptions;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -7991,7 +7936,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
private CodegenComposedSchemas getComposedSchemas(Schema schema) {
|
||||
if (!(schema instanceof ComposedSchema) && schema.getNot() == null) {
|
||||
if (!(schema instanceof ComposedSchema) && schema.getNot()==null) {
|
||||
return null;
|
||||
}
|
||||
Schema notSchema = schema.getNot();
|
||||
|
||||
@@ -820,11 +820,6 @@ public class DefaultGenerator implements Generator {
|
||||
bundle.put("hasServers", true);
|
||||
}
|
||||
|
||||
boolean hasOperationServers = allOperations != null && allOperations.stream()
|
||||
.flatMap(om -> om.getOperations().getOperation().stream())
|
||||
.anyMatch(o -> o.servers != null && !o.servers.isEmpty());
|
||||
bundle.put("hasOperationServers", hasOperationServers);
|
||||
|
||||
if (openAPI.getExternalDocs() != null) {
|
||||
bundle.put("externalDocs", openAPI.getExternalDocs());
|
||||
}
|
||||
|
||||
@@ -247,8 +247,6 @@ public interface IJsonSchemaValidationProperties {
|
||||
;
|
||||
} else if (ModelUtils.isEmailSchema(p)) {
|
||||
;
|
||||
} else if (ModelUtils.isPasswordSchema(p)) {
|
||||
;
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
;
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
|
||||
@@ -224,7 +224,7 @@ public class InlineModelResolver {
|
||||
}
|
||||
|
||||
if (m.getAllOf() != null && !m.getAllOf().isEmpty()) {
|
||||
// check to ensure at least one of the allOf item is model
|
||||
// check to ensure at least of the allOf item is model
|
||||
for (Schema inner : m.getAllOf()) {
|
||||
if (isModelNeeded(ModelUtils.getReferencedSchema(openAPI, inner), visitedSchemas)) {
|
||||
return true;
|
||||
@@ -385,7 +385,6 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
m.setAnyOf(newAnyOf);
|
||||
|
||||
}
|
||||
if (m.getOneOf() != null) {
|
||||
List<Schema> newOneOf = new ArrayList<Schema>();
|
||||
@@ -542,15 +541,15 @@ public class InlineModelResolver {
|
||||
* allOf:
|
||||
* - $ref: '#/components/schemas/Animal'
|
||||
* - type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* age:
|
||||
* type: string
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* age:
|
||||
* type: string
|
||||
* - type: object
|
||||
* properties:
|
||||
* breed:
|
||||
* type: string
|
||||
* properties:
|
||||
* breed:
|
||||
* type: string
|
||||
*
|
||||
* @param key a unique name ofr the composed schema.
|
||||
* @param children the list of nested schemas within a composed schema (allOf, anyOf, oneOf).
|
||||
@@ -578,8 +577,6 @@ public class InlineModelResolver {
|
||||
// instead of inline.
|
||||
String innerModelName = resolveModelName(component.getTitle(), key);
|
||||
Schema innerModel = modelFromProperty(openAPI, component, innerModelName);
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(innerModel, innerModelName);
|
||||
String existing = matchGenerated(innerModel);
|
||||
if (existing == null) {
|
||||
innerModelName = addSchemas(innerModelName, innerModel);
|
||||
@@ -607,17 +604,13 @@ public class InlineModelResolver {
|
||||
List<String> modelNames = new ArrayList<String>(models.keySet());
|
||||
for (String modelName : modelNames) {
|
||||
Schema model = models.get(modelName);
|
||||
if (ModelUtils.isAnyOf(model)) { // contains anyOf only
|
||||
gatherInlineModels(model, modelName);
|
||||
} else if (ModelUtils.isOneOf(model)) { // contains oneOf only
|
||||
gatherInlineModels(model, modelName);
|
||||
} else if (ModelUtils.isComposedSchema(model)) {
|
||||
if (ModelUtils.isComposedSchema(model)) {
|
||||
ComposedSchema m = (ComposedSchema) model;
|
||||
// inline child schemas
|
||||
flattenComposedChildren(modelName + "_allOf", m.getAllOf());
|
||||
flattenComposedChildren(modelName + "_anyOf", m.getAnyOf());
|
||||
flattenComposedChildren(modelName + "_oneOf", m.getOneOf());
|
||||
} else {
|
||||
} else if (model instanceof Schema) {
|
||||
gatherInlineModels(model, modelName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ public class OpenAPINormalizer {
|
||||
|
||||
// when set to true, oneOf/anyOf schema with only one sub-schema is simplified to just the sub-schema
|
||||
// and if sub-schema contains "null", remove it and set nullable to true instead
|
||||
// and if sub-schema contains enum of "null", remove it and set nullable to true instead
|
||||
final String SIMPLIFY_ONEOF_ANYOF = "SIMPLIFY_ONEOF_ANYOF";
|
||||
boolean simplifyOneOfAnyOf;
|
||||
|
||||
@@ -77,11 +76,6 @@ public class OpenAPINormalizer {
|
||||
final String SET_TAGS_FOR_ALL_OPERATIONS = "SET_TAGS_FOR_ALL_OPERATIONS";
|
||||
String setTagsForAllOperations;
|
||||
|
||||
// when set to true, auto fix integer with maximum value 4294967295 (2^32-1) or long with 18446744073709551615 (2^64-1)
|
||||
// by adding x-unsigned to the schema
|
||||
final String ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE = "ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE";
|
||||
boolean addUnsignedToIntegerWithInvalidMaxValue;
|
||||
|
||||
// ============= end of rules =============
|
||||
|
||||
/**
|
||||
@@ -138,9 +132,6 @@ public class OpenAPINormalizer {
|
||||
setTagsForAllOperations = rules.get(SET_TAGS_FOR_ALL_OPERATIONS);
|
||||
}
|
||||
|
||||
if (enableAll || "true".equalsIgnoreCase(rules.get(ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE))) {
|
||||
addUnsignedToIntegerWithInvalidMaxValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,12 +333,6 @@ public class OpenAPINormalizer {
|
||||
normalizeSchema(schema.getItems(), visitedSchemas);
|
||||
} else if (schema.getAdditionalProperties() instanceof Schema) { // map
|
||||
normalizeSchema((Schema) schema.getAdditionalProperties(), visitedSchemas);
|
||||
} else if (ModelUtils.isOneOf(schema)) { // oneOf
|
||||
return normalizeOneOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isAnyOf(schema)) { // anyOf
|
||||
return normalizeAnyOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isAllOf(schema)) { // allOf
|
||||
return normalizeAllOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isComposedSchema(schema)) { // composed schema
|
||||
ComposedSchema cs = (ComposedSchema) schema;
|
||||
|
||||
@@ -376,12 +361,12 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
return cs;
|
||||
} else if (schema.getNot() != null) {// not schema
|
||||
normalizeSchema(schema.getNot(), visitedSchemas);
|
||||
} else if (schema.getProperties() != null && !schema.getProperties().isEmpty()) {
|
||||
normalizeProperties(schema.getProperties(), visitedSchemas);
|
||||
} else if (schema instanceof BooleanSchema) {
|
||||
normalizeBooleanSchema(schema, visitedSchemas);
|
||||
} else if (schema instanceof IntegerSchema) {
|
||||
normalizeIntegerSchema(schema, visitedSchemas);
|
||||
} else if (schema instanceof Schema) {
|
||||
normalizeSchemaWithOnlyProperties(schema, visitedSchemas);
|
||||
} else {
|
||||
@@ -395,10 +380,6 @@ public class OpenAPINormalizer {
|
||||
processSimplifyBooleanEnum(schema);
|
||||
}
|
||||
|
||||
private void normalizeIntegerSchema(Schema schema, Set<Schema> visitedSchemas) {
|
||||
processAddUnsignedToIntegerWithInvalidMaxValue(schema);
|
||||
}
|
||||
|
||||
private void normalizeSchemaWithOnlyProperties(Schema schema, Set<Schema> visitedSchemas) {
|
||||
// normalize non-composed schema (e.g. schema with only properties)
|
||||
}
|
||||
@@ -465,10 +446,6 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
private Schema normalizeComplexComposedSchema(Schema schema, Set<Schema> visitedSchemas) {
|
||||
// loop through properties, if any
|
||||
if (schema.getProperties() != null && !schema.getProperties().isEmpty()) {
|
||||
normalizeProperties(schema.getProperties(), visitedSchemas);
|
||||
}
|
||||
|
||||
processRemoveAnyOfOneOfAndKeepPropertiesOnly(schema);
|
||||
|
||||
@@ -587,7 +564,7 @@ public class OpenAPINormalizer {
|
||||
return schema;
|
||||
}
|
||||
|
||||
Schema result = null, s0 = null, s1 = null;
|
||||
Schema s0 = null, s1 = null;
|
||||
if (schema.getAnyOf().size() == 2) {
|
||||
s0 = ModelUtils.unaliasSchema(openAPI, (Schema) schema.getAnyOf().get(0));
|
||||
s1 = ModelUtils.unaliasSchema(openAPI, (Schema) schema.getAnyOf().get(1));
|
||||
@@ -601,27 +578,15 @@ public class OpenAPINormalizer {
|
||||
// find the string schema (not enum)
|
||||
if (s0 instanceof StringSchema && s1 instanceof StringSchema) {
|
||||
if (((StringSchema) s0).getEnum() != null) { // s0 is enum, s1 is string
|
||||
result = (StringSchema) s1;
|
||||
return (StringSchema) s1;
|
||||
} else if (((StringSchema) s1).getEnum() != null) { // s1 is enum, s0 is string
|
||||
result = (StringSchema) s0;
|
||||
return (StringSchema) s0;
|
||||
} else { // both are string
|
||||
result = schema;
|
||||
return schema;
|
||||
}
|
||||
} else {
|
||||
result = schema;
|
||||
return schema;
|
||||
}
|
||||
|
||||
// set nullable
|
||||
if (schema.getNullable() != null) {
|
||||
result.setNullable(schema.getNullable());
|
||||
}
|
||||
|
||||
// set default
|
||||
if (schema.getDefault() != null) {
|
||||
result.setDefault(schema.getDefault());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -637,22 +602,11 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
if (schema.getOneOf() != null && !schema.getOneOf().isEmpty()) {
|
||||
// convert null sub-schema to `nullable: true`
|
||||
for (int i = 0; i < schema.getOneOf().size(); i++) {
|
||||
// convert null sub-schema to `nullable: true`
|
||||
if (schema.getOneOf().get(i) == null || ((Schema) schema.getOneOf().get(i)).getType() == null) {
|
||||
schema.getOneOf().remove(i);
|
||||
schema.setNullable(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
// convert enum of null only to `nullable:true`
|
||||
Schema oneOfElement = ModelUtils.getReferencedSchema(openAPI, (Schema) schema.getOneOf().get(i));
|
||||
if (oneOfElement.getEnum() != null && oneOfElement.getEnum().size() == 1) {
|
||||
if ("null".equals(String.valueOf(oneOfElement.getEnum().get(0)))) {
|
||||
schema.setNullable(true);
|
||||
schema.getOneOf().remove(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,22 +635,11 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
if (schema.getAnyOf() != null && !schema.getAnyOf().isEmpty()) {
|
||||
// convert null sub-schema to `nullable: true`
|
||||
for (int i = 0; i < schema.getAnyOf().size(); i++) {
|
||||
// convert null sub-schema to `nullable: true`
|
||||
if (schema.getAnyOf().get(i) == null || ((Schema) schema.getAnyOf().get(i)).getType() == null) {
|
||||
schema.getAnyOf().remove(i);
|
||||
schema.setNullable(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
// convert enum of null only to `nullable:true`
|
||||
Schema anyOfElement = ModelUtils.getReferencedSchema(openAPI, (Schema) schema.getAnyOf().get(i));
|
||||
if (anyOfElement.getEnum() != null && anyOfElement.getEnum().size() == 1) {
|
||||
if ("null".equals(String.valueOf(anyOfElement.getEnum().get(0)))) {
|
||||
schema.setNullable(true);
|
||||
schema.getAnyOf().remove(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,32 +675,5 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the schema is integer and the max value is invalid (out of bound)
|
||||
* then add x-unsigned to use unsigned integer/long instead.
|
||||
*
|
||||
* @param schema Schema
|
||||
* @return Schema
|
||||
*/
|
||||
private void processAddUnsignedToIntegerWithInvalidMaxValue(Schema schema) {
|
||||
if (!addUnsignedToIntegerWithInvalidMaxValue && !enableAll) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (schema instanceof IntegerSchema) {
|
||||
if (ModelUtils.isLongSchema(schema)) {
|
||||
if ("18446744073709551615".equals(String.valueOf(schema.getMaximum())) &&
|
||||
"0".equals(String.valueOf(schema.getMinimum()))) {
|
||||
schema.addExtension("x-unsigned", true);
|
||||
}
|
||||
} else {
|
||||
if ("4294967295".equals(String.valueOf(schema.getMaximum())) &&
|
||||
"0".equals(String.valueOf(schema.getMinimum()))) {
|
||||
schema.addExtension("x-unsigned", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== end of rules =====================
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ public enum VendorExtension {
|
||||
X_CONTENT_TYPE("x-content-type", ExtensionLevel.OPERATION, "Specify custom value for 'Content-Type' header for operation", null),
|
||||
X_CLASS_EXTRA_ANNOTATION("x-class-extra-annotation", ExtensionLevel.MODEL, "List of custom annotations to be added to model", null),
|
||||
X_FIELD_EXTRA_ANNOTATION("x-field-extra-annotation", ExtensionLevel.FIELD, "List of custom annotations to be added to property", null),
|
||||
X_VERSION_PARAM("x-version-param", ExtensionLevel.OPERATION_PARAMETER, "Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false", null),
|
||||
;
|
||||
|
||||
private final String name;
|
||||
@@ -53,8 +52,7 @@ public enum VendorExtension {
|
||||
public enum ExtensionLevel {
|
||||
FIELD,
|
||||
MODEL,
|
||||
OPERATION,
|
||||
OPERATION_PARAMETER
|
||||
OPERATION
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -121,8 +120,8 @@ public class MergedSpecBuilder {
|
||||
|
||||
private List<String> getAllSpecFilesInDirectory() {
|
||||
Path rootDirectory = new File(inputSpecRootDirectory).toPath();
|
||||
try (Stream<Path> pathStream = Files.walk(rootDirectory)) {
|
||||
return pathStream
|
||||
try {
|
||||
return Files.walk(rootDirectory)
|
||||
.filter(path -> !Files.isDirectory(path))
|
||||
.map(path -> rootDirectory.relativize(path).toString())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -70,10 +70,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
protected String packageCompany = "OpenAPI";
|
||||
protected String packageCopyright = "No Copyright";
|
||||
protected String packageAuthors = "OpenAPI";
|
||||
public static final String DATE_FORMAT = "dateFormat";
|
||||
protected String dateFormat = "yyyy'-'MM'-'dd";
|
||||
public static final String DATETIME_FORMAT = "dateTimeFormat";
|
||||
protected String dateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK";
|
||||
|
||||
protected String interfacePrefix = "I";
|
||||
protected String enumNameSuffix = "Enum";
|
||||
@@ -164,12 +160,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
"decimal",
|
||||
"int?",
|
||||
"int",
|
||||
"uint",
|
||||
"uint?",
|
||||
"long?",
|
||||
"long",
|
||||
"ulong",
|
||||
"ulong?",
|
||||
"float?",
|
||||
"float",
|
||||
"byte[]",
|
||||
@@ -205,10 +197,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
typeMapping.put("ByteArray", "byte[]");
|
||||
typeMapping.put("boolean", "bool?");
|
||||
typeMapping.put("integer", "int?");
|
||||
typeMapping.put("UnsignedInteger", "uint?");
|
||||
typeMapping.put("UnsignedLong", "ulong?");
|
||||
typeMapping.put("long", "long?");
|
||||
typeMapping.put("float", "float?");
|
||||
typeMapping.put("long", "long?");
|
||||
typeMapping.put("double", "double?");
|
||||
typeMapping.put("number", "decimal?");
|
||||
typeMapping.put("BigDecimal", "decimal?");
|
||||
@@ -225,12 +215,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// nullable type
|
||||
nullableType = new HashSet<>(
|
||||
Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double",
|
||||
"DateTime", "DateTimeOffset", "Guid")
|
||||
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "DateTimeOffset", "Guid")
|
||||
);
|
||||
// value Types
|
||||
valueTypes = new HashSet<>(
|
||||
Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double")
|
||||
Arrays.asList("decimal", "bool", "int", "float", "long", "double")
|
||||
);
|
||||
|
||||
this.setSortParamsByRequiredFlag(true);
|
||||
@@ -337,20 +326,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_PRODUCTNAME, packageProductName);
|
||||
}
|
||||
|
||||
// {{dateFormat}}
|
||||
if (additionalProperties.containsKey(DATE_FORMAT)) {
|
||||
setDateFormat((String) additionalProperties.get(DATE_FORMAT));
|
||||
} else {
|
||||
additionalProperties.put(DATE_FORMAT, this.dateFormat);
|
||||
}
|
||||
|
||||
// {{dateTimeFormat}}
|
||||
if (additionalProperties.containsKey(DATETIME_FORMAT)) {
|
||||
setDateTimeFormat((String) additionalProperties.get(DATETIME_FORMAT));
|
||||
} else {
|
||||
additionalProperties.put(DATETIME_FORMAT, this.dateTimeFormat);
|
||||
}
|
||||
|
||||
// {{packageDescription}}
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_DESCRIPTION)) {
|
||||
setPackageDescription((String) additionalProperties.get(CodegenConstants.PACKAGE_DESCRIPTION));
|
||||
@@ -560,11 +535,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
property.datatypeWithEnum = property.datatypeWithEnum.replace("Dictionary>", property.items.datatypeWithEnum + ">");
|
||||
property.dataType = property.datatypeWithEnum;
|
||||
}
|
||||
|
||||
// HOTFIX: https://github.com/OpenAPITools/openapi-generator/issues/14944
|
||||
if (property.datatypeWithEnum.equals("decimal")) {
|
||||
property.isDecimal = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Mitigates https://github.com/OpenAPITools/openapi-generator/issues/13709 */
|
||||
@@ -1292,14 +1262,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
this.packageProductName = packageProductName;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public void setDateTimeFormat(String dateTimeFormat) {
|
||||
this.dateTimeFormat = dateTimeFormat;
|
||||
}
|
||||
|
||||
public void setPackageDescription(String packageDescription) {
|
||||
this.packageDescription = packageDescription;
|
||||
}
|
||||
@@ -1372,9 +1334,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
// Per: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/enum
|
||||
// The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong.
|
||||
// but we're not supporting unsigned integral types or shorts.
|
||||
if (datatype.startsWith("int") || datatype.startsWith("uint") ||
|
||||
datatype.startsWith("long") || datatype.startsWith("ulong") ||
|
||||
datatype.startsWith("byte")) {
|
||||
if (datatype.startsWith("int") || datatype.startsWith("long") || datatype.startsWith("byte")) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -1051,8 +1051,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
if (schema.getDefault() == null) {
|
||||
// nullable, optional or containerDefaultToNull set to true
|
||||
if (cp.isNullable || !cp.required || containerDefaultToNull) {
|
||||
if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
|
||||
return null;
|
||||
} else {
|
||||
if (ModelUtils.isSet(schema)) {
|
||||
|
||||
@@ -125,6 +125,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
*
|
||||
@@ -284,7 +285,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
private String toExampleValueRecursive(Schema schema, List<Schema> includedSchemas, int indentation) {
|
||||
boolean cycleFound = includedSchemas.stream().filter(s -> schema.equals(s)).count() > 1;
|
||||
boolean cycleFound = includedSchemas.stream().filter(s->schema.equals(s)).count() > 1;
|
||||
if (cycleFound) {
|
||||
return "";
|
||||
}
|
||||
@@ -715,7 +716,5 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() {
|
||||
return GeneratorLanguage.PYTHON;
|
||||
}
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.PYTHON; }
|
||||
}
|
||||
|
||||
@@ -123,10 +123,8 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("UnsignedInteger", "uint");
|
||||
typeMapping.put("UnsignedLong", "ulong");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("number", "decimal");
|
||||
typeMapping.put("decimal", "decimal");
|
||||
@@ -791,8 +789,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
// number
|
||||
if (datatype.startsWith("int") || datatype.startsWith("uint") ||
|
||||
datatype.startsWith("ulong") || datatype.startsWith("long") ||
|
||||
if (datatype.startsWith("int") || datatype.startsWith("long") ||
|
||||
datatype.startsWith("double") || datatype.startsWith("float")) {
|
||||
String varName = "NUMBER_" + value;
|
||||
varName = varName.replaceAll("-", "MINUS_");
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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.languages;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CSharpDotNet2ClientCodegen extends AbstractCSharpCodegen {
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(CSharpDotNet2ClientCodegen.class);
|
||||
|
||||
public static final String CLIENT_PACKAGE = "clientPackage";
|
||||
protected String clientPackage = "Org.OpenAPITools.Client";
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
|
||||
public CSharpDotNet2ClientCodegen() {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features.includeDocumentationFeatures(DocumentationFeature.Readme));
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.DEPRECATED)
|
||||
.build();
|
||||
|
||||
// clear import mapping (from default generator) as C# (2.0) does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
modelTemplateFiles.put("model.mustache", ".cs");
|
||||
apiTemplateFiles.put("api.mustache", ".cs");
|
||||
|
||||
setApiPackage(packageName + ".Api");
|
||||
setModelPackage(packageName + ".Model");
|
||||
setClientPackage(packageName + ".Client");
|
||||
setSourceFolder("src" + File.separator + "main" + File.separator + "CsharpDotNet2");
|
||||
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME,
|
||||
"C# package name (convention: Camel.Case).")
|
||||
.defaultValue(packageName));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION,
|
||||
"C# package version.")
|
||||
.defaultValue(packageVersion));
|
||||
cliOptions.add(new CliOption(CLIENT_PACKAGE,
|
||||
"C# client package name (convention: Camel.Case).")
|
||||
.defaultValue(clientPackage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
LOGGER.warn("Per Microsoft Product Lifecycle (https://support.microsoft.com/en-us/lifecycle/search?sort=PN&alpha=.NET%20Framework&Filter=FilterNO), support for .NET Framework 2.0 ended in 2011 so there may be security issues using the auto-generated C# 2.0 source code.");
|
||||
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(CLIENT_PACKAGE)) {
|
||||
setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
|
||||
} else {
|
||||
additionalProperties.put(CLIENT_PACKAGE, getClientPackage());
|
||||
}
|
||||
|
||||
final String clientPackage = getClientPackage();
|
||||
final String clientPackagePath = clientPackage.replace(".", java.io.File.separator);
|
||||
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
||||
sourceFolder + File.separator + clientPackagePath, "Configuration.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
||||
sourceFolder + File.separator + clientPackagePath, "ApiClient.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
||||
sourceFolder + File.separator + clientPackagePath, "ApiException.cs"));
|
||||
supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor", "packages.config"));
|
||||
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiPackage() {
|
||||
return packageName + ".Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelPackage() {
|
||||
return packageName + ".Model";
|
||||
}
|
||||
|
||||
public String getClientPackage() {
|
||||
return clientPackage;
|
||||
}
|
||||
|
||||
public void setClientPackage(String clientPackage) {
|
||||
this.clientPackage = clientPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "csharp-dotnet2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a C# .Net 2.0 client library (beta).";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiDocFileFolder() {
|
||||
return outputFolder + File.separator + apiDocPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelDocFileFolder() {
|
||||
return outputFolder + File.separator + modelDocPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,7 +61,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
protected static final String RESTSHARP = "restsharp";
|
||||
protected static final String HTTPCLIENT = "httpclient";
|
||||
protected static final String GENERICHOST = "generichost";
|
||||
protected static final String UNITY_WEB_REQUEST = "unityWebRequest";
|
||||
|
||||
// Project Variable, determined from target framework. Not intended to be user-settable.
|
||||
protected static final String TARGET_FRAMEWORK_IDENTIFIER = "targetFrameworkIdentifier";
|
||||
@@ -101,7 +100,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
protected boolean supportsRetry = Boolean.TRUE;
|
||||
protected boolean supportsAsync = Boolean.TRUE;
|
||||
protected boolean netStandard = Boolean.FALSE;
|
||||
protected boolean supportsFileParameters = Boolean.TRUE;
|
||||
|
||||
protected boolean validatable = Boolean.TRUE;
|
||||
protected Map<Character, String> regexModifiers;
|
||||
@@ -153,10 +151,8 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
typeMapping.put("ByteArray", "byte[]");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("UnsignedInteger", "uint");
|
||||
typeMapping.put("UnsignedLong", "ulong");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("number", "decimal");
|
||||
typeMapping.put("decimal", "decimal");
|
||||
@@ -219,14 +215,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
CodegenConstants.PACKAGE_TAGS_DESC,
|
||||
this.packageTags);
|
||||
|
||||
addOption(DATE_FORMAT,
|
||||
"The default Date format (only `generichost` library supports this option).",
|
||||
this.dateFormat);
|
||||
|
||||
addOption(DATETIME_FORMAT,
|
||||
"The default DateTime format (only `generichost` library supports this option).",
|
||||
this.dateTimeFormat);
|
||||
|
||||
CliOption framework = new CliOption(
|
||||
CodegenConstants.DOTNET_FRAMEWORK,
|
||||
CodegenConstants.DOTNET_FRAMEWORK_DESC
|
||||
@@ -337,8 +325,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
+ "(Experimental. Subject to breaking changes without notice.)");
|
||||
supportedLibraries.put(HTTPCLIENT, "HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) "
|
||||
+ "(Experimental. Subject to breaking changes without notice.)");
|
||||
supportedLibraries.put(UNITY_WEB_REQUEST, "UnityWebRequest (...) "
|
||||
+ "(Experimental. Subject to breaking changes without notice.)");
|
||||
supportedLibraries.put(RESTSHARP, "RestSharp (https://github.com/restsharp/RestSharp)");
|
||||
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "HTTP library template (sub-template) to use");
|
||||
@@ -715,10 +701,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
setLibrary(HTTPCLIENT);
|
||||
additionalProperties.put("useHttpClient", true);
|
||||
needsUriBuilder = true;
|
||||
} else if (UNITY_WEB_REQUEST.equals(getLibrary())) {
|
||||
setLibrary(UNITY_WEB_REQUEST);
|
||||
additionalProperties.put("useUnityWebRequest", true);
|
||||
needsUriBuilder = true;
|
||||
} else {
|
||||
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only restsharp, httpclient, and generichost are supported.");
|
||||
}
|
||||
@@ -798,7 +780,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
syncBooleanProperty(additionalProperties, CodegenConstants.OPTIONAL_METHOD_ARGUMENT, this::setOptionalMethodArgumentFlag, optionalMethodArgumentFlag);
|
||||
syncBooleanProperty(additionalProperties, CodegenConstants.NON_PUBLIC_API, this::setNonPublicApi, isNonPublicApi());
|
||||
syncBooleanProperty(additionalProperties, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, this::setUseOneOfDiscriminatorLookup, this.useOneOfDiscriminatorLookup);
|
||||
syncBooleanProperty(additionalProperties, "supportsFileParameters", this::setSupportsFileParameters, this.supportsFileParameters);
|
||||
|
||||
final String testPackageName = testPackageName();
|
||||
String packageFolder = sourceFolder + File.separator + packageName;
|
||||
@@ -835,20 +816,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
addGenericHostSupportingFiles(clientPackageDir, packageFolder, excludeTests, testPackageFolder, testPackageName, modelPackageDir);
|
||||
additionalProperties.put("apiDocPath", apiDocPath + File.separatorChar + "apis");
|
||||
additionalProperties.put("modelDocPath", modelDocPath + File.separatorChar + "models");
|
||||
} else if (UNITY_WEB_REQUEST.equals(getLibrary())) {
|
||||
additionalProperties.put(CodegenConstants.VALIDATABLE, false);
|
||||
setValidatable(false);
|
||||
setSupportsRetry(false);
|
||||
setSupportsAsync(true);
|
||||
// Some consoles and tvOS do not support either Application.persistentDataPath or will refuse to
|
||||
// compile/link if you even reference GetTempPath as well.
|
||||
additionalProperties.put("supportsFileParameters", false);
|
||||
setSupportsFileParameters(false);
|
||||
|
||||
addSupportingFiles(clientPackageDir, packageFolder, excludeTests, testPackageFolder, testPackageName, modelPackageDir, authPackageDir);
|
||||
|
||||
supportingFiles.add(new SupportingFile("ConnectionException.mustache", clientPackageDir, "ConnectionException.cs"));
|
||||
supportingFiles.add(new SupportingFile("UnexpectedResponseException.mustache", clientPackageDir, "UnexpectedResponseException.cs"));
|
||||
} else { //restsharp
|
||||
addSupportingFiles(clientPackageDir, packageFolder, excludeTests, testPackageFolder, testPackageName, modelPackageDir, authPackageDir);
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
@@ -944,24 +911,14 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
|
||||
if (UNITY_WEB_REQUEST.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("asmdef.mustache", packageFolder, packageName + ".asmdef"));
|
||||
} else {
|
||||
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
|
||||
supportingFiles.add(new SupportingFile("netcore_project.mustache", packageFolder, packageName + ".csproj"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
|
||||
supportingFiles.add(new SupportingFile("netcore_project.mustache", packageFolder, packageName + ".csproj"));
|
||||
|
||||
if (Boolean.FALSE.equals(excludeTests.get())) {
|
||||
if (UNITY_WEB_REQUEST.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("asmdef_test.mustache", testPackageFolder, testPackageName + ".asmdef"));
|
||||
} else {
|
||||
supportingFiles.add(new SupportingFile("netcore_testproject.mustache", testPackageFolder, testPackageName + ".csproj"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("netcore_testproject.mustache", testPackageFolder, testPackageName + ".csproj"));
|
||||
}
|
||||
|
||||
if (!UNITY_WEB_REQUEST.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("appveyor.mustache", "", "appveyor.yml"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("appveyor.mustache", "", "appveyor.yml"));
|
||||
supportingFiles.add(new SupportingFile("AbstractOpenAPISchema.mustache", modelPackageDir, "AbstractOpenAPISchema.cs"));
|
||||
}
|
||||
|
||||
@@ -1091,10 +1048,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
this.supportsAsync = supportsAsync;
|
||||
}
|
||||
|
||||
public void setSupportsFileParameters(Boolean supportsFileParameters) {
|
||||
this.supportsFileParameters = supportsFileParameters;
|
||||
}
|
||||
|
||||
public void setSupportsRetry(Boolean supportsRetry) {
|
||||
this.supportsRetry = supportsRetry;
|
||||
}
|
||||
@@ -1186,8 +1139,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
// number
|
||||
if (datatype.startsWith("int") || datatype.startsWith("uint") ||
|
||||
datatype.startsWith("long") || datatype.startsWith("ulong") ||
|
||||
if (datatype.startsWith("int") || datatype.startsWith("long") ||
|
||||
datatype.startsWith("double") || datatype.startsWith("float")) {
|
||||
String varName = "NUMBER_" + value;
|
||||
varName = varName.replaceAll("-", "MINUS_");
|
||||
|
||||
@@ -71,7 +71,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML))
|
||||
.securityFeatures(EnumSet.of(
|
||||
SecurityFeature.BasicAuth,
|
||||
SecurityFeature.BearerToken,
|
||||
SecurityFeature.ApiKey,
|
||||
SecurityFeature.OAuth2_Implicit
|
||||
))
|
||||
|
||||
@@ -50,8 +50,6 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen imp
|
||||
|
||||
// Use standard types
|
||||
typeMapping.put("DateTime", "java.util.Date");
|
||||
typeMapping.put("binary", "java.io.InputStream");
|
||||
typeMapping.put("file", "java.io.InputStream");
|
||||
|
||||
// Updated template directory
|
||||
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf-cdi";
|
||||
|
||||
@@ -289,7 +289,6 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
static class HTTPRequest {
|
||||
String operationId;
|
||||
String method;
|
||||
boolean isDelete;
|
||||
String path;
|
||||
@@ -305,13 +304,12 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@Nullable
|
||||
DataExtractSubstituteParameter dataExtract;
|
||||
|
||||
public HTTPRequest(String operationId, String method, String path, @Nullable List<Parameter> query, @Nullable HTTPBody body,
|
||||
public HTTPRequest(String method, String path, @Nullable List<Parameter> query, @Nullable HTTPBody body,
|
||||
boolean hasBodyExample, @Nullable HTTPParameters params, @Nullable List<k6Check> k6Checks,
|
||||
DataExtractSubstituteParameter dataExtract) {
|
||||
// NOTE: https://k6.io/docs/javascript-api/k6-http/del-url-body-params
|
||||
this.method = method.equals("delete") ? "del" : method;
|
||||
this.isDelete = method.equals("delete");
|
||||
this.operationId = operationId;
|
||||
this.path = path;
|
||||
this.query = query;
|
||||
this.body = body;
|
||||
@@ -647,7 +645,7 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// calculate order for this current request
|
||||
Integer requestOrder = calculateRequestOrder(operationGroupingOrder, requests.size());
|
||||
|
||||
requests.put(requestOrder, new HTTPRequest(operationId, method.toString().toLowerCase(Locale.ROOT), path,
|
||||
requests.put(requestOrder, new HTTPRequest(method.toString().toLowerCase(Locale.ROOT), path,
|
||||
queryParams.size() > 0 ? queryParams : null,
|
||||
bodyOrFormParams.size() > 0 ? new HTTPBody(bodyOrFormParams) : null, hasRequestBodyExample,
|
||||
params.headers.size() > 0 ? params : null, k6Checks.size() > 0 ? k6Checks : null,
|
||||
|
||||
@@ -66,7 +66,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
public static final String GRADLE_BUILD_FILE = "gradleBuildFile";
|
||||
public static final String SERVICE_INTERFACE = "serviceInterface";
|
||||
public static final String SERVICE_IMPLEMENTATION = "serviceImplementation";
|
||||
public static final String SKIP_DEFAULT_INTERFACE = "skipDefaultInterface";
|
||||
public static final String REACTIVE = "reactive";
|
||||
public static final String INTERFACE_ONLY = "interfaceOnly";
|
||||
public static final String DELEGATE_PATTERN = "delegatePattern";
|
||||
@@ -80,7 +79,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
private String serverPort = "8080";
|
||||
private String title = "OpenAPI Kotlin Spring";
|
||||
private boolean useBeanValidation = true;
|
||||
private boolean skipDefaultInterface = false;
|
||||
private boolean exceptionHandler = true;
|
||||
private boolean gradleBuildFile = true;
|
||||
private boolean useSwaggerUI = true;
|
||||
@@ -155,7 +153,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
addSwitch(SERVICE_IMPLEMENTATION, "generate stub service implementations that extends service " +
|
||||
"interfaces. If this is set to true service interfaces will also be generated", serviceImplementation);
|
||||
addSwitch(USE_BEANVALIDATION, "Use BeanValidation API annotations to validate data types", useBeanValidation);
|
||||
addSwitch(SKIP_DEFAULT_INTERFACE, "Whether to skip generation of default implementations for interfaces", skipDefaultInterface);
|
||||
addSwitch(REACTIVE, "use coroutines for reactive behavior", reactive);
|
||||
addSwitch(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.", interfaceOnly);
|
||||
addSwitch(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern", delegatePattern);
|
||||
@@ -337,10 +334,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
this.useBeanValidation = useBeanValidation;
|
||||
}
|
||||
|
||||
public void setSkipDefaultInterface(boolean skipDefaultInterface) {
|
||||
this.skipDefaultInterface = skipDefaultInterface;
|
||||
}
|
||||
|
||||
public boolean isReactive() {
|
||||
return reactive;
|
||||
}
|
||||
@@ -499,11 +492,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
}
|
||||
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
||||
|
||||
if (additionalProperties.containsKey(SKIP_DEFAULT_INTERFACE)) {
|
||||
this.setSkipDefaultInterface(convertPropertyToBoolean(SKIP_DEFAULT_INTERFACE));
|
||||
}
|
||||
writePropertyBack(SKIP_DEFAULT_INTERFACE, skipDefaultInterface);
|
||||
|
||||
if (additionalProperties.containsKey(REACTIVE) && library.equals(SPRING_BOOT)) {
|
||||
this.setReactive(convertPropertyToBoolean(REACTIVE));
|
||||
// spring webflux doesn't support @ControllerAdvice
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements CodegenConfig {
|
||||
@@ -49,8 +48,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
public static final String RECURSION_LIMIT = "recursionLimit";
|
||||
public static final String ALLOW_STRING_IN_DATETIME_PARAMETERS = "allowStringInDateTimeParameters";
|
||||
public static final String FLOAT_STRICT_TYPE = "floatStrictType";
|
||||
public static final String DATETIME_FORMAT = "datetimeFormat";
|
||||
public static final String DATE_FORMAT = "dateFormat";
|
||||
|
||||
protected String packageUrl;
|
||||
protected String apiDocPath = "docs" + File.separator;
|
||||
@@ -59,8 +56,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
|
||||
protected boolean allowStringInDateTimeParameters = false; // use StrictStr instead of datetime in parameters
|
||||
protected boolean floatStrictType = true;
|
||||
protected String datetimeFormat = "%Y-%m-%dT%H:%M:%S.%f%z";
|
||||
protected String dateFormat = "%Y-%m-%d";
|
||||
|
||||
protected Map<Character, String> regexModifiers;
|
||||
|
||||
@@ -176,10 +171,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(FLOAT_STRICT_TYPE, "Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)")
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(new CliOption(DATETIME_FORMAT, "datetime format for query parameters")
|
||||
.defaultValue("%Y-%m-%dT%H:%M:%S%z"));
|
||||
cliOptions.add(new CliOption(DATE_FORMAT, "date format for query parameters")
|
||||
.defaultValue("%Y-%m-%d"));
|
||||
|
||||
supportedLibraries.put("urllib3", "urllib3-based client");
|
||||
supportedLibraries.put("asyncio", "asyncio-based client");
|
||||
@@ -209,9 +200,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
|
||||
super.processOpts();
|
||||
|
||||
// map to Dot instead of Period
|
||||
specialCharReplacements.put(".", "Dot");
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("PYTHON_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE=\"/usr/local/bin/yapf -i\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
@@ -286,18 +274,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
setFloatStrictType(convertPropertyToBooleanAndWriteBack(FLOAT_STRICT_TYPE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(DATETIME_FORMAT)) {
|
||||
setDatetimeFormat((String) additionalProperties.get(DATETIME_FORMAT));
|
||||
} else {
|
||||
additionalProperties.put(DATETIME_FORMAT, datetimeFormat);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(DATE_FORMAT)) {
|
||||
setDateFormat((String) additionalProperties.get(DATE_FORMAT));
|
||||
} else {
|
||||
additionalProperties.put(DATE_FORMAT, dateFormat);
|
||||
}
|
||||
|
||||
String modelPath = packagePath() + File.separatorChar + modelPackage.replace('.', File.separatorChar);
|
||||
String apiPath = packagePath() + File.separatorChar + apiPackage.replace('.', File.separatorChar);
|
||||
|
||||
@@ -321,7 +297,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
supportingFiles.add(new SupportingFile("github-workflow.mustache", ".github/workflows", "python.yml"));
|
||||
supportingFiles.add(new SupportingFile("gitlab-ci.mustache", "", ".gitlab-ci.yml"));
|
||||
supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py"));
|
||||
supportingFiles.add(new SupportingFile("pyproject.mustache", "", "pyproject.toml"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", packagePath(), "configuration.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py"));
|
||||
@@ -605,7 +580,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
if (allowStringInDateTimeParameters) {
|
||||
pydanticImports.add("StrictStr");
|
||||
typingImports.add("Union");
|
||||
return String.format(Locale.ROOT, "Union[StrictStr, %s]", cp.dataType);
|
||||
return String.format(Locale.ROOT, "Union[%s, StrictStr]", cp.dataType);
|
||||
} else {
|
||||
return cp.dataType;
|
||||
}
|
||||
@@ -1134,17 +1109,15 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
modelImports.add(model.parent);
|
||||
}
|
||||
|
||||
// set enum type in extensions and update `name` in enumVars
|
||||
// set enum type in extensions
|
||||
if (model.isEnum) {
|
||||
for (Map<String, Object> enumVars : (List<Map<String, Object>>) model.getAllowableValues().get("enumVars")) {
|
||||
if ((Boolean) enumVars.get("isString")) {
|
||||
model.vendorExtensions.putIfAbsent("x-py-enum-type", "str");
|
||||
// update `name`, e.g.
|
||||
enumVars.put("name", toEnumVariableName((String) enumVars.get("value"), "str"));
|
||||
model.vendorExtensions.put("x-py-enum-type", "str");
|
||||
} else {
|
||||
model.vendorExtensions.putIfAbsent("x-py-enum-type", "int");
|
||||
enumVars.put("name", toEnumVariableName((String) enumVars.get("value"), "int"));
|
||||
model.vendorExtensions.put("x-py-enum-type", "int");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1328,50 +1301,38 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
if ("int".equals(datatype) || "float".equals(datatype)) {
|
||||
return name;
|
||||
} else {
|
||||
return "\'" + name + "\'";
|
||||
}
|
||||
}
|
||||
|
||||
public String toEnumVariableName(String name, String datatype) {
|
||||
if ("int".equals(datatype)) {
|
||||
return "NUMBER_" + name;
|
||||
}
|
||||
|
||||
// remove quote e.g. 'abc' => abc
|
||||
name = name.substring(1, name.length() - 1);
|
||||
|
||||
if (name.length() == 0) {
|
||||
return "EMPTY";
|
||||
}
|
||||
|
||||
if (" ".equals(name)) {
|
||||
return "SPACE";
|
||||
if (name.trim().length() == 0) {
|
||||
return "SPACE_" + name.length();
|
||||
}
|
||||
|
||||
if ("_".equals(name)) {
|
||||
return "UNDERSCORE";
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return (getSymbolName(name)).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
if (reservedWords.contains(name)) {
|
||||
name = name.toUpperCase(Locale.ROOT);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
|
||||
name = underscore(escape(name, specialCharReplacements, Collections.singletonList("_"), "_")).toUpperCase(Locale.ROOT);
|
||||
// number
|
||||
if ("int".equals(datatype) || "float".equals(datatype)) {
|
||||
String varName = name;
|
||||
varName = varName.replaceAll("-", "MINUS_");
|
||||
varName = varName.replaceAll("\\+", "PLUS_");
|
||||
varName = varName.replaceAll("\\.", "_DOT_");
|
||||
return "NUMBER_" + varName;
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
if (isReservedWord(enumName) || enumName.matches("\\d.*")) { // reserved word or starts with number
|
||||
return escapeReservedWord(enumName);
|
||||
} else {
|
||||
name = name.toUpperCase(Locale.ROOT);
|
||||
return enumName;
|
||||
}
|
||||
|
||||
name = name.replace(" ", "_");
|
||||
name = name.replaceFirst("^_", "");
|
||||
name = name.replaceFirst("_$", "");
|
||||
|
||||
if (name.matches("\\d.*")) {
|
||||
name = "ENUM_" + name.toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1385,7 +1346,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
|
||||
@Override
|
||||
public String toEnumDefaultValue(String value, String datatype) {
|
||||
return value;
|
||||
return "self::" + datatype + "_" + value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1416,18 +1377,4 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
public void setFloatStrictType(boolean floatStrictType) {
|
||||
this.floatStrictType = floatStrictType;
|
||||
}
|
||||
|
||||
public void setDatetimeFormat(String datetimeFormat) {
|
||||
this.datetimeFormat = datetimeFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
// process enum in models
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
discriminatorVars.add(mas);
|
||||
}
|
||||
// TODO: figure out how to properly have the original property type that didn't go through toVarName
|
||||
String vendorExtensionTagName = cm.discriminator.getPropertyName();
|
||||
String vendorExtensionTagName = cm.discriminator.getPropertyName().replace("_", "");
|
||||
cm.vendorExtensions.put("x-tag-name", vendorExtensionTagName);
|
||||
cm.vendorExtensions.put("x-mapped-models", discriminatorVars);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.SplitStringLambda;
|
||||
import org.openapitools.codegen.templating.mustache.SpringHttpStatusLambda;
|
||||
import org.openapitools.codegen.templating.mustache.TrimWhitespaceLambda;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -97,7 +96,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
||||
public static final String VIRTUAL_SERVICE = "virtualService";
|
||||
public static final String SKIP_DEFAULT_INTERFACE = "skipDefaultInterface";
|
||||
public static final String GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS = "generatedConstructorWithRequiredArgs";
|
||||
|
||||
public static final String ASYNC = "async";
|
||||
public static final String REACTIVE = "reactive";
|
||||
@@ -111,7 +109,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
public static final String HATEOAS = "hateoas";
|
||||
public static final String RETURN_SUCCESS_CODE = "returnSuccessCode";
|
||||
public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
|
||||
public static final String USE_RESPONSE_ENTITY = "useResponseEntity";
|
||||
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
|
||||
public static final String REQUEST_MAPPING_OPTION = "requestMappingMode";
|
||||
public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
|
||||
@@ -159,9 +156,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
protected boolean unhandledException = false;
|
||||
protected boolean useSpringController = false;
|
||||
protected boolean useSwaggerUI = true;
|
||||
protected boolean useResponseEntity = true;
|
||||
protected boolean useSpringBoot3 = false;
|
||||
protected boolean generatedConstructorWithRequiredArgs = true;
|
||||
protected RequestMappingMode requestMappingMode = RequestMappingMode.controller;
|
||||
|
||||
public SpringCodegen() {
|
||||
@@ -250,16 +245,9 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(USE_SWAGGER_UI,
|
||||
"Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies",
|
||||
useSwaggerUI));
|
||||
cliOptions.add(CliOption.newBoolean(USE_RESPONSE_ENTITY,
|
||||
"Use the `ResponseEntity` type to wrap return values of generated API methods. "
|
||||
+ "If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition",
|
||||
useResponseEntity));
|
||||
cliOptions.add(CliOption.newBoolean(USE_SPRING_BOOT3,
|
||||
"Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.",
|
||||
useSpringBoot3));
|
||||
cliOptions.add(CliOption.newBoolean(GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS,
|
||||
"Whether to generate constructors with required args for models",
|
||||
generatedConstructorWithRequiredArgs));
|
||||
|
||||
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
|
||||
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
|
||||
@@ -469,11 +457,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
writePropertyBack(SPRING_CONTROLLER, useSpringController);
|
||||
|
||||
if (additionalProperties.containsKey(GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS)) {
|
||||
this.generatedConstructorWithRequiredArgs = convertPropertyToBoolean(GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS);
|
||||
}
|
||||
writePropertyBack(GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS, generatedConstructorWithRequiredArgs);
|
||||
|
||||
if (additionalProperties.containsKey(RETURN_SUCCESS_CODE)) {
|
||||
this.setReturnSuccessCode(Boolean.parseBoolean(additionalProperties.get(RETURN_SUCCESS_CODE).toString()));
|
||||
}
|
||||
@@ -494,13 +477,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());
|
||||
|
||||
if (additionalProperties.containsKey(USE_RESPONSE_ENTITY)) {
|
||||
this.setUseResponseEntity(
|
||||
Boolean.parseBoolean(additionalProperties.get(USE_RESPONSE_ENTITY).toString()));
|
||||
}
|
||||
writePropertyBack(USE_RESPONSE_ENTITY, useResponseEntity);
|
||||
additionalProperties.put("springHttpStatus", new SpringHttpStatusLambda());
|
||||
|
||||
if (additionalProperties.containsKey(USE_SPRING_BOOT3)) {
|
||||
this.setUseSpringBoot3(convertPropertyToBoolean(USE_SPRING_BOOT3));
|
||||
}
|
||||
@@ -517,7 +493,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
writePropertyBack(USE_SPRING_BOOT3, isUseSpringBoot3());
|
||||
|
||||
|
||||
typeMapping.put("file", "org.springframework.core.io.Resource");
|
||||
importMapping.put("org.springframework.core.io.Resource", "org.springframework.core.io.Resource");
|
||||
importMapping.put("Pageable", "org.springframework.data.domain.Pageable");
|
||||
@@ -829,7 +804,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
});
|
||||
|
||||
prepareVersioningParameters(ops);
|
||||
handleImplicitHeaders(operation);
|
||||
}
|
||||
// The tag for the controller is the first tag of the first operation
|
||||
@@ -883,32 +857,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareVersioningParameters(List<CodegenOperation> operations) {
|
||||
for (CodegenOperation operation : operations) {
|
||||
if (operation.getHasHeaderParams()) {
|
||||
List<CodegenParameter> versionParams = operation.headerParams.stream()
|
||||
.filter(param -> {
|
||||
String xVersionParam = Objects.toString(param.vendorExtensions.get(VendorExtension.X_VERSION_PARAM.getName()), "false");
|
||||
return Boolean.parseBoolean(xVersionParam);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
operation.hasVersionHeaders = !versionParams.isEmpty();
|
||||
operation.vendorExtensions.put("versionHeaderParamsList", versionParams);
|
||||
}
|
||||
|
||||
if (operation.getHasQueryParams()) {
|
||||
List<CodegenParameter> versionParams = operation.queryParams.stream()
|
||||
.filter(param -> {
|
||||
String xVersionParam = Objects.toString(param.vendorExtensions.get(VendorExtension.X_VERSION_PARAM.getName()), "false");
|
||||
return Boolean.parseBoolean(xVersionParam);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
operation.hasVersionQueryParams = !versionParams.isEmpty();
|
||||
operation.vendorExtensions.put("versionQueryParamsList", versionParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateYAMLSpecFile(objs);
|
||||
@@ -1043,10 +991,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
this.unhandledException = unhandledException;
|
||||
}
|
||||
|
||||
public void setUseResponseEntity(boolean useResponseEntity) {
|
||||
this.useResponseEntity = useResponseEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
@@ -1134,10 +1078,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
codegenModel.getImports().add(imp);
|
||||
}
|
||||
}
|
||||
|
||||
if (property.required) {
|
||||
codegenModel.parentRequiredVars.add(parentVar.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
parentCodegenModel = parentCodegenModel.getParentModel();
|
||||
@@ -1241,7 +1181,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
public List<VendorExtension> getSupportedVendorExtensions() {
|
||||
List<VendorExtension> extensions = super.getSupportedVendorExtensions();
|
||||
extensions.add(VendorExtension.X_SPRING_PAGINATED);
|
||||
extensions.add(VendorExtension.X_VERSION_PARAM);
|
||||
return extensions;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +145,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
"URL",
|
||||
"AnyObject",
|
||||
"Any",
|
||||
"Decimal",
|
||||
"AnyCodable") // from AnyCodable dependency
|
||||
"Decimal")
|
||||
);
|
||||
defaultIncludes = new HashSet<>(
|
||||
Arrays.asList(
|
||||
@@ -732,11 +731,11 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
// FIXME parameter should not be assigned. Also declare it as "final"
|
||||
name = sanitizeName(name);
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix) && !isLanguageSpecificType(name)) { // set model suffix
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) { // set model suffix
|
||||
name = name + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix) && !isLanguageSpecificType(name)) { // set model prefix
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) { // set model prefix
|
||||
name = modelNamePrefix + "_" + name;
|
||||
}
|
||||
|
||||
@@ -1087,10 +1086,6 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
LOWERCASE_FIRST_LETTER);
|
||||
}
|
||||
|
||||
private Boolean isLanguageSpecificType(String name) {
|
||||
return languageSpecificPrimitives.contains(name);
|
||||
}
|
||||
|
||||
private String replaceSpecialCharacters(String name) {
|
||||
for (Map.Entry<String, String> specialCharacters : specialCharReplacements.entrySet()) {
|
||||
String specialChar = specialCharacters.getKey();
|
||||
|
||||
@@ -607,7 +607,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
if (importMapping.containsKey(name)) {
|
||||
return importMapping.get(name);
|
||||
}
|
||||
return DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX + modelPackage() + "/" + toModelFilename(removeModelPrefixSuffix(name)).substring(DEFAULT_IMPORT_PREFIX.length());
|
||||
return DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX + modelPackage() + "/" + toModelFilename(name).substring(DEFAULT_IMPORT_PREFIX.length());
|
||||
}
|
||||
|
||||
public String getNpmRepository() {
|
||||
|
||||
@@ -56,8 +56,6 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
reservedWords.add("options");
|
||||
|
||||
outputFolder = "generated-code/typescript-axios";
|
||||
embeddedTemplateDir = templateDir = "typescript-axios";
|
||||
|
||||
|
||||
@@ -410,8 +410,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
// Use `/` instead of `File.Separator`. `File.Separator` is `\` in Windows, which is invalid Typescript.
|
||||
return "../" + modelPackage() + "/" + toModelName(name);
|
||||
return ".." + File.separator + modelPackage() + File.separator + toModelName(name);
|
||||
}
|
||||
|
||||
protected String addPrefix(String name, String prefix) {
|
||||
|
||||
@@ -1,220 +0,0 @@
|
||||
package org.openapitools.codegen.templating.mustache;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Returns the Spring {@code org.springframework.http.HttpStatus} enumeration for the given status text.
|
||||
* It throws an IllegalArgumentException if the status text is handled by the Spring framework.
|
||||
*
|
||||
* Register:
|
||||
* <pre>
|
||||
* additionalProperties.put("springHttpStatus", new SpringHttpStatusLambda());
|
||||
* </pre>
|
||||
*
|
||||
* Use:
|
||||
* <pre>
|
||||
* {{#springHttpStatus}}{{statusCode}}{{/springHttpStatus}}
|
||||
* </pre>
|
||||
*/
|
||||
public class SpringHttpStatusLambda implements Mustache.Lambda {
|
||||
|
||||
final static String HTTP_STATUS_PREFIX = "HttpStatus.";
|
||||
|
||||
@Override
|
||||
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
|
||||
final String httpCode = fragment.execute();
|
||||
switch (httpCode) {
|
||||
case "202":
|
||||
writer.write(HTTP_STATUS_PREFIX + "ACCEPTED");
|
||||
break;
|
||||
case "208":
|
||||
writer.write(HTTP_STATUS_PREFIX + "ALREADY_REPORTED");
|
||||
break;
|
||||
case "502":
|
||||
writer.write(HTTP_STATUS_PREFIX + "BAD_GATEWAY");
|
||||
break;
|
||||
case "400":
|
||||
writer.write(HTTP_STATUS_PREFIX + "BAD_REQUEST");
|
||||
break;
|
||||
case "509":
|
||||
writer.write(HTTP_STATUS_PREFIX + "BANDWIDTH_LIMIT_EXCEEDED");
|
||||
break;
|
||||
case "409":
|
||||
writer.write(HTTP_STATUS_PREFIX + "CONFLICT");
|
||||
break;
|
||||
case "100":
|
||||
writer.write(HTTP_STATUS_PREFIX + "CONTINUE");
|
||||
break;
|
||||
case "201":
|
||||
writer.write(HTTP_STATUS_PREFIX + "CREATED");
|
||||
break;
|
||||
case "103":
|
||||
writer.write(HTTP_STATUS_PREFIX + "EARLY_HINTS");
|
||||
break;
|
||||
case "417":
|
||||
writer.write(HTTP_STATUS_PREFIX + "EXPECTATION_FAILED");
|
||||
break;
|
||||
case "424":
|
||||
writer.write(HTTP_STATUS_PREFIX + "FAILED_DEPENDENCY");
|
||||
break;
|
||||
case "403":
|
||||
writer.write(HTTP_STATUS_PREFIX + "FORBIDDEN");
|
||||
break;
|
||||
case "302":
|
||||
writer.write(HTTP_STATUS_PREFIX + "FOUND");
|
||||
break;
|
||||
case "504":
|
||||
writer.write(HTTP_STATUS_PREFIX + "GATEWAY_TIMEOUT");
|
||||
break;
|
||||
case "410":
|
||||
writer.write(HTTP_STATUS_PREFIX + "GONE");
|
||||
break;
|
||||
case "505":
|
||||
writer.write(HTTP_STATUS_PREFIX + "HTTP_VERSION_NOT_SUPPORTED");
|
||||
break;
|
||||
case "418":
|
||||
writer.write(HTTP_STATUS_PREFIX + "I_AM_A_TEAPOT");
|
||||
break;
|
||||
case "226":
|
||||
writer.write(HTTP_STATUS_PREFIX + "IM_USED");
|
||||
break;
|
||||
case "507":
|
||||
writer.write(HTTP_STATUS_PREFIX + "INSUFFICIENT_STORAGE");
|
||||
break;
|
||||
case "500":
|
||||
writer.write(HTTP_STATUS_PREFIX + "INTERNAL_SERVER_ERROR");
|
||||
break;
|
||||
case "411":
|
||||
writer.write(HTTP_STATUS_PREFIX + "LENGTH_REQUIRED");
|
||||
break;
|
||||
case "423":
|
||||
writer.write(HTTP_STATUS_PREFIX + "LOCKED");
|
||||
break;
|
||||
case "508":
|
||||
writer.write(HTTP_STATUS_PREFIX + "LOOP_DETECTED");
|
||||
break;
|
||||
case "405":
|
||||
writer.write(HTTP_STATUS_PREFIX + "METHOD_NOT_ALLOWED");
|
||||
break;
|
||||
case "301":
|
||||
writer.write(HTTP_STATUS_PREFIX + "MOVED_PERMANENTLY");
|
||||
break;
|
||||
case "207":
|
||||
writer.write(HTTP_STATUS_PREFIX + "MULTI_STATUS");
|
||||
break;
|
||||
case "300":
|
||||
writer.write(HTTP_STATUS_PREFIX + "MULTIPLE_CHOICES");
|
||||
break;
|
||||
case "511":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NETWORK_AUTHENTICATION_REQUIRED");
|
||||
break;
|
||||
case "204":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NO_CONTENT");
|
||||
break;
|
||||
case "203":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NON_AUTHORITATIVE_INFORMATION");
|
||||
break;
|
||||
case "406":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NOT_ACCEPTABLE");
|
||||
break;
|
||||
case "510":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NOT_EXTENDED");
|
||||
break;
|
||||
case "404":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NOT_FOUND");
|
||||
break;
|
||||
case "501":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NOT_IMPLEMENTED");
|
||||
break;
|
||||
case "304":
|
||||
writer.write(HTTP_STATUS_PREFIX + "NOT_MODIFIED");
|
||||
break;
|
||||
case "":
|
||||
case "200":
|
||||
writer.write(HTTP_STATUS_PREFIX + "OK");
|
||||
break;
|
||||
case "206":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PARTIAL_CONTENT");
|
||||
break;
|
||||
case "413":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PAYLOAD_TOO_LARGE");
|
||||
break;
|
||||
case "402":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PAYMENT_REQUIRED");
|
||||
break;
|
||||
case "308":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PERMANENT_REDIRECT");
|
||||
break;
|
||||
case "412":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PRECONDITION_FAILED");
|
||||
break;
|
||||
case "428":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PRECONDITION_REQUIRED");
|
||||
break;
|
||||
case "102":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PROCESSING");
|
||||
break;
|
||||
case "407":
|
||||
writer.write(HTTP_STATUS_PREFIX + "PROXY_AUTHENTICATION_REQUIRED");
|
||||
break;
|
||||
case "431":
|
||||
writer.write(HTTP_STATUS_PREFIX + "REQUEST_HEADER_FIELDS_TOO_LARGE");
|
||||
break;
|
||||
case "408":
|
||||
writer.write(HTTP_STATUS_PREFIX + "REQUEST_TIMEOUT");
|
||||
break;
|
||||
case "416":
|
||||
writer.write(HTTP_STATUS_PREFIX + "REQUESTED_RANGE_NOT_SATISFIABLE");
|
||||
break;
|
||||
case "205":
|
||||
writer.write(HTTP_STATUS_PREFIX + "RESET_CONTENT");
|
||||
break;
|
||||
case "303":
|
||||
writer.write(HTTP_STATUS_PREFIX + "SEE_OTHER");
|
||||
break;
|
||||
case "503":
|
||||
writer.write(HTTP_STATUS_PREFIX + "SERVICE_UNAVAILABLE");
|
||||
break;
|
||||
case "101":
|
||||
writer.write(HTTP_STATUS_PREFIX + "SWITCHING_PROTOCOLS");
|
||||
break;
|
||||
case "307":
|
||||
writer.write(HTTP_STATUS_PREFIX + "TEMPORARY_REDIRECT");
|
||||
break;
|
||||
case "425":
|
||||
writer.write(HTTP_STATUS_PREFIX + "TOO_EARLY");
|
||||
break;
|
||||
case "429":
|
||||
writer.write(HTTP_STATUS_PREFIX + "TOO_MANY_REQUESTS");
|
||||
break;
|
||||
case "401":
|
||||
writer.write(HTTP_STATUS_PREFIX + "UNAUTHORIZED");
|
||||
break;
|
||||
case "451":
|
||||
writer.write(HTTP_STATUS_PREFIX + "UNAVAILABLE_FOR_LEGAL_REASONS");
|
||||
break;
|
||||
case "422":
|
||||
writer.write(HTTP_STATUS_PREFIX + "UNPROCESSABLE_ENTITY");
|
||||
break;
|
||||
case "415":
|
||||
writer.write(HTTP_STATUS_PREFIX + "UNSUPPORTED_MEDIA_TYPE");
|
||||
break;
|
||||
case "426":
|
||||
writer.write(HTTP_STATUS_PREFIX + "UPGRADE_REQUIRED");
|
||||
break;
|
||||
case "414":
|
||||
writer.write(HTTP_STATUS_PREFIX + "URI_TOO_LONG");
|
||||
break;
|
||||
case "506":
|
||||
writer.write(HTTP_STATUS_PREFIX + "VARIANT_ALSO_NEGOTIATES");
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("The given HTTP status code: " + httpCode
|
||||
+ " is not supported by the 'org.springframework.http.HttpStatus' enum.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,11 @@ import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.parser.ObjectMapperFactory;
|
||||
import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
import io.swagger.v3.parser.util.ClasspathHelper;
|
||||
import io.swagger.v3.parser.ObjectMapperFactory;
|
||||
import io.swagger.v3.parser.util.RemoteUrl;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.IJsonSchemaValidationProperties;
|
||||
@@ -42,17 +41,18 @@ import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.openapitools.codegen.utils.OnceLogger.once;
|
||||
|
||||
@@ -71,30 +71,29 @@ public class ModelUtils {
|
||||
|
||||
private static final String freeFormExplicit = "x-is-free-form";
|
||||
|
||||
private static final ObjectMapper JSON_MAPPER;
|
||||
private static final ObjectMapper YAML_MAPPER;
|
||||
private static ObjectMapper JSON_MAPPER, YAML_MAPPER;
|
||||
|
||||
static {
|
||||
JSON_MAPPER = ObjectMapperFactory.createJson();
|
||||
YAML_MAPPER = ObjectMapperFactory.createYaml();
|
||||
}
|
||||
|
||||
public static boolean isDisallowAdditionalPropertiesIfNotPresent() {
|
||||
return Boolean.parseBoolean(GlobalSettings.getProperty(disallowAdditionalPropertiesIfNotPresent, "true"));
|
||||
}
|
||||
|
||||
public static void setDisallowAdditionalPropertiesIfNotPresent(boolean value) {
|
||||
GlobalSettings.setProperty(disallowAdditionalPropertiesIfNotPresent, Boolean.toString(value));
|
||||
}
|
||||
|
||||
public static boolean isGenerateAliasAsModel() {
|
||||
return Boolean.parseBoolean(GlobalSettings.getProperty(generateAliasAsModelKey, "false"));
|
||||
public static boolean isDisallowAdditionalPropertiesIfNotPresent() {
|
||||
return Boolean.parseBoolean(GlobalSettings.getProperty(disallowAdditionalPropertiesIfNotPresent, "true"));
|
||||
}
|
||||
|
||||
public static void setGenerateAliasAsModel(boolean value) {
|
||||
GlobalSettings.setProperty(generateAliasAsModelKey, Boolean.toString(value));
|
||||
}
|
||||
|
||||
public static boolean isGenerateAliasAsModel() {
|
||||
return Boolean.parseBoolean(GlobalSettings.getProperty(generateAliasAsModelKey, "false"));
|
||||
}
|
||||
|
||||
public static boolean isGenerateAliasAsModel(Schema schema) {
|
||||
return isGenerateAliasAsModel() || (schema.getExtensions() != null && schema.getExtensions().getOrDefault("x-generate-alias-as-model", false).equals(true));
|
||||
}
|
||||
@@ -372,6 +371,12 @@ public class ModelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private static interface OpenAPISchemaVisitor {
|
||||
|
||||
public void visit(Schema schema, String mimeType);
|
||||
}
|
||||
|
||||
public static String getSimpleRef(String ref) {
|
||||
if (ref == null) {
|
||||
once(LOGGER).warn("Failed to get the schema name: null");
|
||||
@@ -451,7 +456,10 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
// must have at least one property
|
||||
return schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty();
|
||||
if (schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -552,7 +560,11 @@ public class ModelUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
return schema.getAdditionalProperties() instanceof Boolean && (Boolean) schema.getAdditionalProperties();
|
||||
if (schema.getAdditionalProperties() instanceof Boolean && (Boolean) schema.getAdditionalProperties()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -570,41 +582,33 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isStringSchema(Schema schema) {
|
||||
return schema instanceof StringSchema || SchemaTypeUtil.STRING_TYPE.equals(schema.getType());
|
||||
if (schema instanceof StringSchema || SchemaTypeUtil.STRING_TYPE.equals(schema.getType())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isIntegerSchema(Schema schema) {
|
||||
if (schema instanceof IntegerSchema) {
|
||||
return true;
|
||||
}
|
||||
return SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType());
|
||||
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isShortSchema(Schema schema) {
|
||||
// format: short (int32)
|
||||
return SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) // type: integer
|
||||
&& SchemaTypeUtil.INTEGER32_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isUnsignedIntegerSchema(Schema schema) {
|
||||
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) && // type: integer
|
||||
("int32".equals(schema.getFormat()) || schema.getFormat() == null) && // format: int32
|
||||
(schema.getExtensions() != null && (Boolean) schema.getExtensions().getOrDefault("x-unsigned", Boolean.FALSE))) { // x-unsigned: true
|
||||
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) // type: integer
|
||||
&& SchemaTypeUtil.INTEGER32_FORMAT.equals(schema.getFormat())) { // format: short (int32)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLongSchema(Schema schema) {
|
||||
// format: long (int64)
|
||||
return SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) // type: integer
|
||||
&& SchemaTypeUtil.INTEGER64_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isUnsignedLongSchema(Schema schema) {
|
||||
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) && // type: integer
|
||||
"int64".equals(schema.getFormat()) && // format: int64
|
||||
(schema.getExtensions() != null && (Boolean) schema.getExtensions().getOrDefault("x-unsigned", Boolean.FALSE))) { // x-unsigned: true
|
||||
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) // type: integer
|
||||
&& SchemaTypeUtil.INTEGER64_FORMAT.equals(schema.getFormat())) { // format: long (int64)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -614,26 +618,36 @@ public class ModelUtils {
|
||||
if (schema instanceof BooleanSchema) {
|
||||
return true;
|
||||
}
|
||||
return SchemaTypeUtil.BOOLEAN_TYPE.equals(schema.getType());
|
||||
if (SchemaTypeUtil.BOOLEAN_TYPE.equals(schema.getType())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isNumberSchema(Schema schema) {
|
||||
if (schema instanceof NumberSchema) {
|
||||
return true;
|
||||
}
|
||||
return SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType());
|
||||
if (SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isFloatSchema(Schema schema) {
|
||||
// format: float
|
||||
return SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.FLOAT_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.FLOAT_FORMAT.equals(schema.getFormat())) { // format: float
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDoubleSchema(Schema schema) {
|
||||
// format: double
|
||||
return SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DOUBLE_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DOUBLE_FORMAT.equals(schema.getFormat())) { // format: double
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDateSchema(Schema schema) {
|
||||
@@ -641,45 +655,55 @@ public class ModelUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
// format: date
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_FORMAT.equals(schema.getFormat())) { // format: date
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDateTimeSchema(Schema schema) {
|
||||
if (schema instanceof DateTimeSchema) {
|
||||
return true;
|
||||
}
|
||||
// format: date-time
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_TIME_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_TIME_FORMAT.equals(schema.getFormat())) { // format: date-time
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPasswordSchema(Schema schema) {
|
||||
if (schema instanceof PasswordSchema) {
|
||||
return true;
|
||||
}
|
||||
// double
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.PASSWORD_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.PASSWORD_FORMAT.equals(schema.getFormat())) { // double
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isByteArraySchema(Schema schema) {
|
||||
if (schema instanceof ByteArraySchema) {
|
||||
return true;
|
||||
}
|
||||
// format: byte
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BYTE_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BYTE_FORMAT.equals(schema.getFormat())) { // format: byte
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBinarySchema(Schema schema) {
|
||||
if (schema instanceof BinarySchema) {
|
||||
return true;
|
||||
}
|
||||
// format: binary
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BINARY_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BINARY_FORMAT.equals(schema.getFormat())) { // format: binary
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isFileSchema(Schema schema) {
|
||||
@@ -694,30 +718,38 @@ public class ModelUtils {
|
||||
if (schema instanceof UUIDSchema) {
|
||||
return true;
|
||||
}
|
||||
// format: uuid
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.UUID_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.UUID_FORMAT.equals(schema.getFormat())) { // format: uuid
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isURISchema(Schema schema) {
|
||||
// format: uri
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& URI_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& URI_FORMAT.equals(schema.getFormat())) { // format: uri
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEmailSchema(Schema schema) {
|
||||
if (schema instanceof EmailSchema) {
|
||||
return true;
|
||||
}
|
||||
// format: email
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.EMAIL_FORMAT.equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.EMAIL_FORMAT.equals(schema.getFormat())) { // format: email
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDecimalSchema(Schema schema) {
|
||||
// format: number
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType()) // type: string
|
||||
&& "number".equals(schema.getFormat());
|
||||
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType()) // type: string
|
||||
&& "number".equals(schema.getFormat())) { // format: number
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -846,10 +878,14 @@ public class ModelUtils {
|
||||
if (addlProps instanceof ObjectSchema) {
|
||||
ObjectSchema objSchema = (ObjectSchema) addlProps;
|
||||
// additionalProperties defined as {}
|
||||
return objSchema.getProperties() == null || objSchema.getProperties().isEmpty();
|
||||
if (objSchema.getProperties() == null || objSchema.getProperties().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
} else if (addlProps instanceof Schema) {
|
||||
// additionalProperties defined as {}
|
||||
return addlProps.getType() == null && addlProps.get$ref() == null && (addlProps.getProperties() == null || addlProps.getProperties().isEmpty());
|
||||
if (addlProps.getType() == null && addlProps.get$ref() == null && (addlProps.getProperties() == null || addlProps.getProperties().isEmpty())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1358,6 +1394,7 @@ public class ModelUtils {
|
||||
.collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue().stream().map(e -> e.getKey()).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the interfaces from the schema (composed)
|
||||
*
|
||||
@@ -1628,15 +1665,18 @@ public class ModelUtils {
|
||||
* either be null or a specified type:
|
||||
* <p>
|
||||
* OptionalOrder:
|
||||
* oneOf:
|
||||
* - type: 'null'
|
||||
* - $ref: '#/components/schemas/Order'
|
||||
* oneOf:
|
||||
* - type: 'null'
|
||||
* - $ref: '#/components/schemas/Order'
|
||||
*
|
||||
* @param schema the OpenAPI schema
|
||||
* @return true if the schema is the 'null' type
|
||||
*/
|
||||
public static boolean isNullType(Schema schema) {
|
||||
return "null".equals(schema.getType());
|
||||
if ("null".equals(schema.getType())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1657,90 +1697,47 @@ public class ModelUtils {
|
||||
|
||||
public static void syncValidationProperties(Schema schema, IJsonSchemaValidationProperties target) {
|
||||
// TODO move this method to IJsonSchemaValidationProperties
|
||||
if (schema == null ||
|
||||
target == null ||
|
||||
schema.get$ref() != null)
|
||||
return;
|
||||
SchemaValidations.ValidationSetBuilder vSB = new SchemaValidations.ValidationSetBuilder();
|
||||
if (schema != null && target != null) {
|
||||
if (isNullType(schema) || schema.get$ref() != null || isBooleanSchema(schema)) {
|
||||
return;
|
||||
}
|
||||
Integer minItems = schema.getMinItems();
|
||||
Integer maxItems = schema.getMaxItems();
|
||||
Boolean uniqueItems = schema.getUniqueItems();
|
||||
Integer minProperties = schema.getMinProperties();
|
||||
Integer maxProperties = schema.getMaxProperties();
|
||||
Integer minLength = schema.getMinLength();
|
||||
Integer maxLength = schema.getMaxLength();
|
||||
String pattern = schema.getPattern();
|
||||
BigDecimal multipleOf = schema.getMultipleOf();
|
||||
BigDecimal minimum = schema.getMinimum();
|
||||
BigDecimal maximum = schema.getMaximum();
|
||||
Boolean exclusiveMinimum = schema.getExclusiveMinimum();
|
||||
Boolean exclusiveMaximum = schema.getExclusiveMaximum();
|
||||
|
||||
Integer minItems = schema.getMinItems();
|
||||
if (minItems != null) vSB.withMinItems();
|
||||
|
||||
Integer maxItems = schema.getMaxItems();
|
||||
if (maxItems != null) vSB.withMaxItems();
|
||||
|
||||
Boolean uniqueItems = schema.getUniqueItems();
|
||||
if (uniqueItems != null) vSB.withUniqueItems();
|
||||
|
||||
Integer minProperties = schema.getMinProperties();
|
||||
if (minProperties != null) vSB.withMinProperties();
|
||||
|
||||
Integer maxProperties = schema.getMaxProperties();
|
||||
if (maxProperties != null) vSB.withMaxProperties();
|
||||
|
||||
Integer minLength = schema.getMinLength();
|
||||
if (minLength != null) vSB.withMinLength();
|
||||
|
||||
Integer maxLength = schema.getMaxLength();
|
||||
if (maxLength != null) vSB.withMaxLength();
|
||||
|
||||
String pattern = schema.getPattern();
|
||||
if (pattern != null) vSB.withPattern();
|
||||
|
||||
BigDecimal multipleOf = schema.getMultipleOf();
|
||||
if (multipleOf != null) vSB.withMultipleOf();
|
||||
|
||||
BigDecimal minimum = schema.getMinimum();
|
||||
if (minimum != null) vSB.withMinimum();
|
||||
|
||||
BigDecimal maximum = schema.getMaximum();
|
||||
if (maximum != null) vSB.withMaximum();
|
||||
|
||||
Boolean exclusiveMinimum = schema.getExclusiveMinimum();
|
||||
if (exclusiveMinimum != null) vSB.withExclusiveMinimum();
|
||||
|
||||
Boolean exclusiveMaximum = schema.getExclusiveMaximum();
|
||||
if (exclusiveMaximum != null) vSB.withExclusiveMaximum();
|
||||
|
||||
LinkedHashSet<String> setValidations = vSB.build();
|
||||
|
||||
if (isBooleanSchema(schema) || isNullType(schema)) {
|
||||
logWarnMessagesForIneffectiveValidations(setValidations, schema, new HashSet<>());
|
||||
} else if (isArraySchema(schema)) {
|
||||
if (minItems != null || maxItems != null || uniqueItems != null)
|
||||
if (isArraySchema(schema)) {
|
||||
setArrayValidations(minItems, maxItems, uniqueItems, target);
|
||||
logWarnMessagesForIneffectiveValidations(new LinkedHashSet(setValidations), schema, SchemaValidations.ARRAY_VALIDATIONS);
|
||||
} else if (isTypeObjectSchema(schema)) {
|
||||
if (minProperties != null || maxProperties != null)
|
||||
} else if (isTypeObjectSchema(schema)) {
|
||||
setObjectValidations(minProperties, maxProperties, target);
|
||||
logWarnMessagesForIneffectiveValidations(new LinkedHashSet(setValidations), schema, SchemaValidations.OBJECT_VALIDATIONS);
|
||||
} else if (isStringSchema(schema)) {
|
||||
if (minLength != null || maxLength != null || pattern != null)
|
||||
} else if (isStringSchema(schema)) {
|
||||
setStringValidations(minLength, maxLength, pattern, target);
|
||||
if (isDecimalSchema(schema)) {
|
||||
if (multipleOf != null || minimum != null || maximum != null || exclusiveMinimum != null || exclusiveMaximum != null)
|
||||
if (isDecimalSchema(schema)) {
|
||||
setNumericValidations(schema, multipleOf, minimum, maximum, exclusiveMinimum, exclusiveMaximum, target);
|
||||
|
||||
Set<String> stringAndNumericValidations = new HashSet<>(SchemaValidations.STRING_VALIDATIONS);
|
||||
stringAndNumericValidations.addAll(SchemaValidations.NUMERIC_VALIDATIONS);
|
||||
logWarnMessagesForIneffectiveValidations(new LinkedHashSet(setValidations), schema, stringAndNumericValidations);
|
||||
} else
|
||||
logWarnMessagesForIneffectiveValidations(new LinkedHashSet(setValidations), schema, SchemaValidations.STRING_VALIDATIONS);
|
||||
|
||||
} else if (isNumberSchema(schema) || isIntegerSchema(schema)) {
|
||||
if (multipleOf != null || minimum != null || maximum != null || exclusiveMinimum != null || exclusiveMaximum != null)
|
||||
}
|
||||
} else if (isNumberSchema(schema) || isIntegerSchema(schema)) {
|
||||
setNumericValidations(schema, multipleOf, minimum, maximum, exclusiveMinimum, exclusiveMaximum, target);
|
||||
logWarnMessagesForIneffectiveValidations(new LinkedHashSet(setValidations), schema, SchemaValidations.NUMERIC_VALIDATIONS);
|
||||
} else if (isAnyType(schema)) {
|
||||
// anyType can have any validations set on it
|
||||
setArrayValidations(minItems, maxItems, uniqueItems, target);
|
||||
setObjectValidations(minProperties, maxProperties, target);
|
||||
setStringValidations(minLength, maxLength, pattern, target);
|
||||
setNumericValidations(schema, multipleOf, minimum, maximum, exclusiveMinimum, exclusiveMaximum, target);
|
||||
}
|
||||
} else if (isAnyType(schema)) {
|
||||
// anyType can have any validations set on it
|
||||
setArrayValidations(minItems, maxItems, uniqueItems, target);
|
||||
setObjectValidations(minProperties, maxProperties, target);
|
||||
setStringValidations(minLength, maxLength, pattern, target);
|
||||
setNumericValidations(schema, multipleOf, minimum, maximum, exclusiveMinimum, exclusiveMaximum, target);
|
||||
}
|
||||
|
||||
if (!setValidations.isEmpty())
|
||||
target.setHasValidation(true);
|
||||
if (maxItems != null || minItems != null || minProperties != null || maxProperties != null || minLength != null || maxLength != null || multipleOf != null || pattern != null || minimum != null || maximum != null || exclusiveMinimum != null || exclusiveMaximum != null || uniqueItems != null) {
|
||||
target.setHasValidation(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setArrayValidations(Integer minItems, Integer maxItems, Boolean uniqueItems, IJsonSchemaValidationProperties target) {
|
||||
@@ -1781,13 +1778,6 @@ public class ModelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void logWarnMessagesForIneffectiveValidations(Set<String> setValidations, Schema schema, Set<String> effectiveValidations) {
|
||||
setValidations.removeAll(effectiveValidations);
|
||||
setValidations.stream().forEach(validation -> {
|
||||
LOGGER.warn("Validation '" + validation + "' has no effect on schema '"+ schema.getType() +"'. Ignoring!");
|
||||
});
|
||||
}
|
||||
|
||||
private static ObjectMapper getRightMapper(String data) {
|
||||
ObjectMapper mapper;
|
||||
if (data.trim().startsWith("{")) {
|
||||
@@ -1862,241 +1852,4 @@ public class ModelUtils {
|
||||
|
||||
return new SemVer(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains allOf but
|
||||
* no properties/oneOf/anyOf defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if the schema contains allOf but no properties/oneOf/anyOf defined.
|
||||
*/
|
||||
public static boolean isAllOf(Schema schema) {
|
||||
if (hasAllOf(schema) && (schema.getProperties() == null || schema.getProperties().isEmpty()) &&
|
||||
(schema.getOneOf() == null || schema.getOneOf().isEmpty()) &&
|
||||
(schema.getAnyOf() == null || schema.getAnyOf().isEmpty())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains allOf and may or may not have
|
||||
* properties/oneOf/anyOf defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if allOf is not empty
|
||||
*/
|
||||
public static boolean hasAllOf(Schema schema) {
|
||||
if (schema.getAllOf() != null && !schema.getAllOf().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains oneOf but
|
||||
* no properties/allOf/anyOf defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if the schema contains oneOf but no properties/allOf/anyOf defined.
|
||||
*/
|
||||
public static boolean isOneOf(Schema schema) {
|
||||
if (hasOneOf(schema) && (schema.getProperties() == null || schema.getProperties().isEmpty()) &&
|
||||
(schema.getAllOf() == null || schema.getAllOf().isEmpty()) &&
|
||||
(schema.getAnyOf() == null || schema.getAnyOf().isEmpty())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains oneOf and may or may not have
|
||||
* properties/allOf/anyOf defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if allOf is not empty
|
||||
*/
|
||||
public static boolean hasOneOf(Schema schema) {
|
||||
if (schema.getOneOf() != null && !schema.getOneOf().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains anyOf but
|
||||
* no properties/allOf/anyOf defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if the schema contains oneOf but no properties/allOf/anyOf defined.
|
||||
*/
|
||||
public static boolean isAnyOf(Schema schema) {
|
||||
if (hasAnyOf(schema) && (schema.getProperties() == null || schema.getProperties().isEmpty()) &&
|
||||
(schema.getAllOf() == null || schema.getAllOf().isEmpty()) &&
|
||||
(schema.getOneOf() == null || schema.getOneOf().isEmpty())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains anyOf and may or may not have
|
||||
* properties/allOf/oneOf defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if anyOf is not empty
|
||||
*/
|
||||
public static boolean hasAnyOf(Schema schema) {
|
||||
if (schema.getAnyOf() != null && !schema.getAnyOf().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if any of the common attributes of the schema (e.g. readOnly, default, maximum, etc) is defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if allOf is not empty
|
||||
*/
|
||||
public static boolean hasCommonAttributesDefined(Schema schema) {
|
||||
if (schema.getNullable() != null || schema.getDefault() != null ||
|
||||
schema.getMinimum() != null || schema.getMaximum() != null ||
|
||||
schema.getExclusiveMaximum() != null || schema.getExclusiveMinimum() != null ||
|
||||
schema.getMinLength() != null || schema.getMaxLength() != null ||
|
||||
schema.getMinItems() != null || schema.getMaxItems() != null ||
|
||||
schema.getReadOnly() != null || schema.getWriteOnly() != null ||
|
||||
schema.getPattern() != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface OpenAPISchemaVisitor {
|
||||
|
||||
void visit(Schema schema, String mimeType);
|
||||
}
|
||||
|
||||
private static final class SchemaValidations {
|
||||
|
||||
public static Set<String> ARRAY_VALIDATIONS = new ValidationSetBuilder()
|
||||
.withMinItems()
|
||||
.withMaxItems()
|
||||
.withUniqueItems()
|
||||
.build();
|
||||
public static Set<String> OBJECT_VALIDATIONS = new ValidationSetBuilder()
|
||||
.withMinProperties()
|
||||
.withMaxProperties()
|
||||
.build();
|
||||
public static Set<String> STRING_VALIDATIONS = new ValidationSetBuilder()
|
||||
.withMinLength()
|
||||
.withMaxLength()
|
||||
.withPattern()
|
||||
.build();
|
||||
public static Set<String> NUMERIC_VALIDATIONS = new ValidationSetBuilder()
|
||||
.withMultipleOf()
|
||||
.withMinimum()
|
||||
.withMaximum()
|
||||
.withExclusiveMinimum()
|
||||
.withExclusiveMaximum()
|
||||
.build();
|
||||
|
||||
public static Set<String> ALL_VALIDATIONS;
|
||||
|
||||
static {
|
||||
ALL_VALIDATIONS = new HashSet<>(ARRAY_VALIDATIONS);
|
||||
ALL_VALIDATIONS.addAll(OBJECT_VALIDATIONS);
|
||||
ALL_VALIDATIONS.addAll(STRING_VALIDATIONS);
|
||||
ALL_VALIDATIONS.addAll(NUMERIC_VALIDATIONS);
|
||||
}
|
||||
|
||||
SchemaValidations() {
|
||||
}
|
||||
|
||||
|
||||
public static class ValidationSetBuilder {
|
||||
LinkedHashSet<String> validationSet;
|
||||
|
||||
ValidationSetBuilder() {
|
||||
this.validationSet = new LinkedHashSet<String>();
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMinItems() {
|
||||
this.validationSet.add("minItems");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMaxItems() {
|
||||
this.validationSet.add("maxItems");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withUniqueItems() {
|
||||
this.validationSet.add("uniqueItems");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMinProperties() {
|
||||
this.validationSet.add("minProperties");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMaxProperties() {
|
||||
this.validationSet.add("maxProperties");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMinLength() {
|
||||
this.validationSet.add("minLength");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMaxLength() {
|
||||
this.validationSet.add("maxLength");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withPattern() {
|
||||
this.validationSet.add("pattern");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMultipleOf() {
|
||||
this.validationSet.add("multipleOf");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMinimum() {
|
||||
this.validationSet.add("minimum");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withMaximum() {
|
||||
this.validationSet.add("maximum");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withExclusiveMinimum() {
|
||||
this.validationSet.add("exclusiveMinimum");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidationSetBuilder withExclusiveMaximum() {
|
||||
this.validationSet.add("exclusiveMaximum");
|
||||
return this;
|
||||
}
|
||||
|
||||
public LinkedHashSet<String> build() {
|
||||
return this.validationSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,6 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
{{#openApiNullable}}
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
{{/openApiNullable}}
|
||||
|
||||
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||
import org.apache.hc.client5.http.cookie.Cookie;
|
||||
@@ -144,9 +141,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
objectMapper.registerModule(new JodaModule());
|
||||
{{/joda}}
|
||||
objectMapper.registerModule(new JavaTimeModule());
|
||||
{{#openApiNullable}}
|
||||
objectMapper.registerModule(new JsonNullableModule());
|
||||
{{/openApiNullable}}
|
||||
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
||||
|
||||
dateFormat = ApiClient.buildDefaultDateFormat();
|
||||
|
||||
@@ -15,7 +15,6 @@ import {{invokerPackage}}.Pair;
|
||||
|
||||
{{^fullJavaUtil}}
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -25,8 +24,6 @@ import java.util.StringJoiner;
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
|
||||
|
||||
private ApiClient apiClient;
|
||||
|
||||
public {{classname}}() {
|
||||
@@ -68,33 +65,6 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
|
||||
{{#returnType}}return {{/returnType}}this.{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}Collections.emptyMap());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
{{#allParams}}
|
||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
|
||||
{{/allParams}}
|
||||
* @param additionalHeaders additionalHeaders for this call
|
||||
{{#returnType}}
|
||||
* @return {{returnType}}
|
||||
{{/returnType}}
|
||||
* @throws ApiException if fails to make API call
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#externalDocs}}
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}Map<String, String> additionalHeaders) throws ApiException {
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
@@ -156,8 +126,6 @@ public class {{classname}} {
|
||||
localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
|
||||
{{/headerParams}}
|
||||
|
||||
localVarHeaderParams.putAll(additionalHeaders);
|
||||
|
||||
{{#cookieParams}}if ({{paramName}} != null)
|
||||
localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
|
||||
{{/cookieParams}}
|
||||
@@ -200,7 +168,6 @@ public class {{classname}} {
|
||||
{{#returnType}}localVarReturnType{{/returnType}}{{^returnType}}null{{/returnType}}
|
||||
);
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
||||
@@ -38,7 +38,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import org.glassfish.jersey.logging.LoggingFeature;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.Collection;
|
||||
@@ -46,14 +45,11 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
{{#jsr310}}
|
||||
import java.time.OffsetDateTime;
|
||||
{{/jsr310}}
|
||||
@@ -83,93 +79,80 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
private static final Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
|
||||
|
||||
protected Map<String, String> defaultHeaderMap = new HashMap<>();
|
||||
protected Map<String, String> defaultCookieMap = new HashMap<>();
|
||||
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||
protected String basePath = "{{{basePath}}}";
|
||||
protected String userAgent;
|
||||
private static final Logger log = Logger.getLogger(ApiClient.class.getName());
|
||||
|
||||
protected List<ServerConfiguration> servers = new ArrayList<>({{#servers}}{{#-first}}Arrays.asList(
|
||||
{{/-first}} new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
{{^variables}}
|
||||
new LinkedHashMap<>()
|
||||
{{/variables}}
|
||||
{{#variables}}
|
||||
{{#-first}}
|
||||
Stream.<Entry<String, ServerVariable>>of(
|
||||
{{/-first}}
|
||||
new SimpleEntry<>("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new LinkedHashSet<>({{#enumValues}}{{#-first}}Arrays.asList({{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}{{#-last}}
|
||||
){{/-last}}{{/enumValues}})
|
||||
)){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (a, b) -> a, LinkedHashMap::new))
|
||||
{{/-last}}
|
||||
{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
|
||||
{{/-first}} new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
new HashMap<String, ServerVariable>(){{#variables}}{{#-first}} {{
|
||||
{{/-first}} put("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new HashSet<String>(
|
||||
{{#enumValues}}
|
||||
{{#-first}}
|
||||
Arrays.asList(
|
||||
{{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
)
|
||||
{{/-last}}
|
||||
{{/enumValues}}
|
||||
)
|
||||
));
|
||||
{{#-last}}
|
||||
}}{{/-last}}{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
){{/-last}}{{/servers}});
|
||||
protected Integer serverIndex = 0;
|
||||
protected Map<String, String> serverVariables = null;
|
||||
{{^hasOperationServers}}
|
||||
protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<>();
|
||||
{{/hasOperationServers}}
|
||||
{{#hasOperationServers}}
|
||||
protected Map<String, List<ServerConfiguration>> operationServers;
|
||||
|
||||
{
|
||||
Map<String, List<ServerConfiguration>> operationServers = new HashMap<>();
|
||||
protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#servers}}
|
||||
{{#-first}}
|
||||
operationServers.put("{{{classname}}}.{{{operationId}}}", new ArrayList<>(Arrays.asList(
|
||||
put("{{{classname}}}.{{{operationId}}}", new ArrayList<ServerConfiguration>(Arrays.asList(
|
||||
{{/-first}}
|
||||
new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
{{^variables}}
|
||||
new LinkedHashMap<>()
|
||||
{{/variables}}
|
||||
{{#variables}}
|
||||
{{#-first}}
|
||||
Stream.<Entry<String, ServerVariable>>of(
|
||||
{{/-first}}
|
||||
new SimpleEntry<>("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new LinkedHashSet<>({{#enumValues}}{{#-first}}Arrays.asList({{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}{{#-last}}
|
||||
){{/-last}}{{/enumValues}})
|
||||
)){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (a, b) -> a, LinkedHashMap::new))
|
||||
{{/-last}}
|
||||
{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
new HashMap<String, ServerVariable>(){{#variables}}{{#-first}} {{
|
||||
{{/-first}} put("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new HashSet<String>(
|
||||
{{#enumValues}}
|
||||
{{#-first}}
|
||||
Arrays.asList(
|
||||
{{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
)
|
||||
{{/-last}}
|
||||
{{/enumValues}}
|
||||
)
|
||||
));
|
||||
{{#-last}}
|
||||
}}{{/-last}}{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
)));
|
||||
{{/-last}}
|
||||
)));{{/-last}}
|
||||
{{/servers}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
this.operationServers = operationServers;
|
||||
}
|
||||
|
||||
{{/hasOperationServers}}
|
||||
protected Map<String, Integer> operationServerIndex = new HashMap<>();
|
||||
protected Map<String, Map<String, String>> operationServerVariables = new HashMap<>();
|
||||
}};
|
||||
protected Map<String, Integer> operationServerIndex = new HashMap<String, Integer>();
|
||||
protected Map<String, Map<String, String>> operationServerVariables = new HashMap<String, Map<String, String>>();
|
||||
protected boolean debugging = false;
|
||||
protected ClientConfig clientConfig;
|
||||
protected int connectionTimeout = 0;
|
||||
@@ -206,7 +189,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
setUserAgent("{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{artifactVersion}}}/java{{/httpUserAgent}}");
|
||||
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<>();
|
||||
authentications = new HashMap<String, Authentication>();
|
||||
Authentication auth = null;
|
||||
{{#authMethods}}
|
||||
if (authMap != null) {
|
||||
@@ -252,7 +235,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
|
||||
// Setup authentication lookup (key: authentication alias, value: authentication name)
|
||||
authenticationLookup = new HashMap<>();{{#authMethods}}{{#vendorExtensions.x-auth-id-alias}}
|
||||
authenticationLookup = new HashMap<String, String>();{{#authMethods}}{{#vendorExtensions.x-auth-id-alias}}
|
||||
authenticationLookup.put("{{name}}", "{{.}}");{{/vendorExtensions.x-auth-id-alias}}{{/authMethods}}
|
||||
}
|
||||
|
||||
@@ -847,7 +830,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return List of pairs
|
||||
*/
|
||||
public List<Pair> parameterToPairs(String collectionFormat, String name, Object value){
|
||||
List<Pair> params = new ArrayList<>();
|
||||
List<Pair> params = new ArrayList<Pair>();
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty() || value == null) return params;
|
||||
@@ -906,13 +889,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* "*{@literal /}*" is also considered JSON by this method.
|
||||
* "* / *" is also default to JSON
|
||||
*
|
||||
* @param mime MIME
|
||||
* @return True if the MIME type is JSON
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
return mime != null && (mime.equals("*/*") || JSON_MIME_PATTERN.matcher(mime).matches());
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -924,8 +908,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return The Accept header to use. If the given array is empty,
|
||||
* null will be returned (not to set the Accept header explicitly).
|
||||
*/
|
||||
public String selectHeaderAccept(String... accepts) {
|
||||
if (accepts == null || accepts.length == 0) {
|
||||
public String selectHeaderAccept(String[] accepts) {
|
||||
if (accepts.length == 0) {
|
||||
return null;
|
||||
}
|
||||
for (String accept : accepts) {
|
||||
@@ -945,8 +929,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return The Content-Type header to use. If the given array is empty,
|
||||
* JSON will be used.
|
||||
*/
|
||||
public String selectHeaderContentType(String... contentTypes) {
|
||||
if (contentTypes == null || contentTypes.length == 0) {
|
||||
public String selectHeaderContentType(String[] contentTypes) {
|
||||
if (contentTypes.length == 0) {
|
||||
return "application/json";
|
||||
}
|
||||
for (String contentType : contentTypes) {
|
||||
@@ -1238,22 +1222,20 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
Map<String, String> allHeaderParams = new HashMap<>(defaultHeaderMap);
|
||||
allHeaderParams.putAll(headerParams);
|
||||
|
||||
if (authNames != null) {
|
||||
// update different parameters (e.g. headers) for authentication
|
||||
updateParamsForAuth(
|
||||
authNames,
|
||||
queryParams,
|
||||
allHeaderParams,
|
||||
cookieParams,
|
||||
{{#hasHttpSignatureMethods}}
|
||||
serializeToString(body, formParams, contentType, isBodyNullable),
|
||||
{{/hasHttpSignatureMethods}}
|
||||
{{^hasHttpSignatureMethods}}
|
||||
null,
|
||||
{{/hasHttpSignatureMethods}}
|
||||
method,
|
||||
target.getUri());
|
||||
}
|
||||
// update different parameters (e.g. headers) for authentication
|
||||
updateParamsForAuth(
|
||||
authNames,
|
||||
queryParams,
|
||||
allHeaderParams,
|
||||
cookieParams,
|
||||
{{#hasHttpSignatureMethods}}
|
||||
serializeToString(body, formParams, contentType, isBodyNullable),
|
||||
{{/hasHttpSignatureMethods}}
|
||||
{{^hasHttpSignatureMethods}}
|
||||
null,
|
||||
{{/hasHttpSignatureMethods}}
|
||||
method,
|
||||
target.getUri());
|
||||
|
||||
for (Entry<String, String> entry : allHeaderParams.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
@@ -1271,7 +1253,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
{{#hasOAuthMethods}}
|
||||
// If OAuth is used and a status 401 is received, renew the access token and retry the request
|
||||
if (authNames != null && statusCode == Status.UNAUTHORIZED.getStatusCode()) {
|
||||
if (statusCode == Status.UNAUTHORIZED.getStatusCode()) {
|
||||
for (String authName : authNames) {
|
||||
Authentication authentication = authentications.get(authName);
|
||||
if (authentication instanceof OAuth) {
|
||||
@@ -1443,10 +1425,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return a {@link java.util.Map} of response headers.
|
||||
*/
|
||||
protected Map<String, List<String>> buildResponseHeaders(Response response) {
|
||||
Map<String, List<String>> responseHeaders = new HashMap<>();
|
||||
Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();
|
||||
for (Entry<String, List<Object>> entry: response.getHeaders().entrySet()) {
|
||||
List<Object> values = entry.getValue();
|
||||
List<String> headers = new ArrayList<>();
|
||||
List<String> headers = new ArrayList<String>();
|
||||
for (Object o : values) {
|
||||
headers.add(String.valueOf(o));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
public static Class<?> getClassForElement(JsonNode node, Class<?> modelClass) {
|
||||
ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass);
|
||||
if (cdm != null) {
|
||||
return cdm.getClassForElement(node, new HashSet<>());
|
||||
return cdm.getClassForElement(node, new HashSet<Class<?>>());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
ClassDiscriminatorMapping(Class<?> cls, String propertyName, Map<String, Class<?>> mappings) {
|
||||
modelClass = cls;
|
||||
discriminatorName = propertyName;
|
||||
discriminatorMappings = new HashMap<>();
|
||||
discriminatorMappings = new HashMap<String, Class<?>>();
|
||||
if (mappings != null) {
|
||||
discriminatorMappings.putAll(mappings);
|
||||
}
|
||||
@@ -205,12 +205,12 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
/**
|
||||
* A map of discriminators for all model classes.
|
||||
*/
|
||||
private static Map<Class<?>, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>();
|
||||
private static Map<Class<?>, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<Class<?>, ClassDiscriminatorMapping>();
|
||||
|
||||
/**
|
||||
* A map of oneOf/anyOf descendants for each model class.
|
||||
*/
|
||||
private static Map<Class<?>, Map<String, GenericType>> modelDescendants = new HashMap<>();
|
||||
private static Map<Class<?>, Map<String, GenericType>> modelDescendants = new HashMap<Class<?>, Map<String, GenericType>>();
|
||||
|
||||
/**
|
||||
* Register a model class discriminator.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
@JsonAnySetter
|
||||
public {{classname}} putAdditionalProperty(String key, {{{.}}} value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<>();
|
||||
this.additionalProperties = new HashMap<String, {{{.}}}>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
}
|
||||
|
||||
// store a list of schema names defined in anyOf
|
||||
public static final Map<String, GenericType> schemas = new HashMap<>();
|
||||
public static final Map<String, GenericType> schemas = new HashMap<String, GenericType>();
|
||||
|
||||
public {{classname}}() {
|
||||
super("anyOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
@@ -134,7 +134,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
JSON.registerDescendants({{classname}}.class, Collections.unmodifiableMap(schemas));
|
||||
{{#discriminator}}
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class<?>> mappings = new HashMap<>();
|
||||
Map<String, Class<?>> mappings = new HashMap<String, Class<?>>();
|
||||
{{#mappedModels}}
|
||||
mappings.put("{{mappingName}}", {{modelName}}.class);
|
||||
{{/mappedModels}}
|
||||
@@ -166,7 +166,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
|
||||
{{/isNullable}}
|
||||
{{#anyOf}}
|
||||
if (JSON.isInstanceOf({{{.}}}.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf({{{.}}}.class, instance, new HashSet<Class<?>>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import {{javaxPackage}}.ws.rs.core.GenericType;
|
||||
{{^fullJavaUtil}}
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -117,84 +116,58 @@ public class {{classname}} {
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
|
||||
{{#hasRequiredParams}}
|
||||
// Check required parameters
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{operationId}}");
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
|
||||
{{/hasRequiredParams}}
|
||||
{{#hasPathParams}}
|
||||
// Path parameters
|
||||
{{/required}}{{/allParams}}
|
||||
// create path and map variables
|
||||
String localVarPath = "{{{path}}}"{{#pathParams}}
|
||||
.replaceAll({{=% %=}}"\\{%baseName%}"%={{ }}=%, apiClient.escapeString({{{paramName}}}{{^isString}}.toString(){{/isString}})){{/pathParams}};
|
||||
.replaceAll("\\{" + "{{baseName}}" + "\\}", apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
|
||||
|
||||
// query params
|
||||
{{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
|
||||
{{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>();
|
||||
{{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}HashMap<String, String>();
|
||||
{{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();
|
||||
|
||||
{{/hasPathParams}}
|
||||
{{#queryParams}}
|
||||
{{#-first}}
|
||||
// Query parameters
|
||||
{{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<>(
|
||||
apiClient.parameterToPairs("{{{collectionFormat}}}", "{{baseName}}", {{paramName}})
|
||||
);
|
||||
{{/-first}}
|
||||
{{^-first}}
|
||||
localVarQueryParams.addAll(apiClient.parameterToPairs("{{{collectionFormat}}}", "{{baseName}}", {{paramName}}));
|
||||
{{/-first}}
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
{{#-first}}
|
||||
// Header parameters
|
||||
{{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}LinkedHashMap<>();
|
||||
{{/-first}}
|
||||
{{^required}}if ({{paramName}} != null) {
|
||||
{{/required}}localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));{{^required}}
|
||||
}{{/required}}
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{#headerParams}}if ({{paramName}} != null)
|
||||
localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
|
||||
{{/headerParams}}
|
||||
{{#cookieParams}}
|
||||
{{#-first}}
|
||||
// Cookie parameters
|
||||
{{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}LinkedHashMap<>();
|
||||
{{/-first}}
|
||||
{{^required}}if ({{paramName}} != null) {
|
||||
{{/required}}localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));{{^required}}
|
||||
}{{/required}}
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{#cookieParams}}if ({{paramName}} != null)
|
||||
localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
|
||||
{{/cookieParams}}
|
||||
{{#formParams}}
|
||||
{{#-first}}
|
||||
// Form parameters
|
||||
{{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}LinkedHashMap<>();
|
||||
{{/-first}}
|
||||
{{^required}}if ({{paramName}} != null) {
|
||||
{{/required}}localVarFormParams.put("{{baseName}}", {{paramName}});{{^required}}
|
||||
}{{/required}}
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{#formParams}}if ({{paramName}} != null)
|
||||
localVarFormParams.put("{{baseName}}", {{paramName}});
|
||||
{{/formParams}}
|
||||
String localVarAccept = apiClient.selectHeaderAccept({{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}});
|
||||
String localVarContentType = apiClient.selectHeaderContentType({{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}});
|
||||
{{#hasAuthMethods}}
|
||||
String[] localVarAuthNames = {{=% %=}}new String[] {%#authMethods%"%name%"%^-last%, %/-last%%/authMethods%};%={{ }}=%
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
final String[] localVarAccepts = {
|
||||
{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}
|
||||
};
|
||||
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
|
||||
|
||||
final String[] localVarContentTypes = {
|
||||
{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}
|
||||
};
|
||||
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
||||
|
||||
String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} };
|
||||
|
||||
{{#returnType}}
|
||||
GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {};
|
||||
|
||||
{{/returnType}}
|
||||
return apiClient.invokeAPI("{{classname}}.{{operationId}}", {{#hasPathParams}}localVarPath{{/hasPathParams}}{{^hasPathParams}}"{{path}}"{{/hasPathParams}}, "{{httpMethod}}", {{#queryParams}}{{#-first}}localVarQueryParams{{/-first}}{{/queryParams}}{{^queryParams}}new ArrayList<>(){{/queryParams}}, {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}},
|
||||
{{#headerParams}}{{#-first}}localVarHeaderParams{{/-first}}{{/headerParams}}{{^headerParams}}new LinkedHashMap<>(){{/headerParams}}, {{#cookieParams}}{{#-first}}localVarCookieParams{{/-first}}{{/cookieParams}}{{^cookieParams}}new LinkedHashMap<>(){{/cookieParams}}, {{#formParams}}{{#-first}}localVarFormParams{{/-first}}{{/formParams}}{{^formParams}}new LinkedHashMap<>(){{/formParams}}, localVarAccept, localVarContentType,
|
||||
{{#hasAuthMethods}}localVarAuthNames{{/hasAuthMethods}}{{^hasAuthMethods}}null{{/hasAuthMethods}}, {{#returnType}}localVarReturnType{{/returnType}}{{^returnType}}null{{/returnType}}, {{#bodyParam}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/bodyParam}}{{^bodyParam}}false{{/bodyParam}});
|
||||
return apiClient.invokeAPI("{{classname}}.{{operationId}}", localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, {{#returnType}}localVarReturnType{{/returnType}}{{^returnType}}null{{/returnType}}, {{#bodyParam}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/bodyParam}}{{^bodyParam}}false{{/bodyParam}});
|
||||
}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
{{#useOneOfDiscriminatorLookup}}
|
||||
{{#discriminator}}
|
||||
{{classname}} new{{classname}} = new {{classname}}();
|
||||
Map<String, Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("{{{propertyBaseName}}}");
|
||||
switch (discriminatorValue) {
|
||||
{{#mappedModels}}
|
||||
@@ -132,7 +132,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
public static final Map<String, GenericType> schemas = new HashMap<>();
|
||||
public static final Map<String, GenericType> schemas = new HashMap<String, GenericType>();
|
||||
|
||||
public {{classname}}() {
|
||||
super("oneOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
@@ -167,7 +167,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
JSON.registerDescendants({{classname}}.class, Collections.unmodifiableMap(schemas));
|
||||
{{#discriminator}}
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class<?>> mappings = new HashMap<>();
|
||||
Map<String, Class<?>> mappings = new HashMap<String, Class<?>>();
|
||||
{{#mappedModels}}
|
||||
mappings.put("{{mappingName}}", {{modelName}}.class);
|
||||
{{/mappedModels}}
|
||||
@@ -199,7 +199,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
|
||||
{{/isNullable}}
|
||||
{{#oneOf}}
|
||||
if (JSON.isInstanceOf({{{.}}}.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf({{{.}}}.class, instance, new HashSet<Class<?>>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,9 +141,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^required}}
|
||||
{{#defaultValue}}
|
||||
if (this.{{name}} == null) {
|
||||
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
|
||||
this.{{name}} = {{{defaultValue}}};
|
||||
}
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
this.{{name}}.add({{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
@@ -164,9 +168,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^required}}
|
||||
{{#defaultValue}}
|
||||
if (this.{{name}} == null) {
|
||||
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
|
||||
this.{{name}} = {{{defaultValue}}};
|
||||
}
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
this.{{name}}.put(key, {{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
@@ -381,7 +389,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<{{classname}}> CREATOR = new Parcelable.Creator<>() {
|
||||
public static final Parcelable.Creator<{{classname}}> CREATOR = new Parcelable.Creator<{{classname}}>() {
|
||||
public {{classname}} createFromParcel(Parcel in) {
|
||||
{{#model}}
|
||||
{{#isArray}}
|
||||
@@ -400,14 +408,14 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
};
|
||||
{{/parcelableModel}}
|
||||
{{#discriminator}}
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class<?>> mappings = new HashMap<>();
|
||||
{{#mappedModels}}
|
||||
mappings.put("{{mappingName}}", {{modelName}}.class);
|
||||
{{/mappedModels}}
|
||||
mappings.put("{{name}}", {{classname}}.class);
|
||||
JSON.registerDiscriminator({{classname}}.class, "{{propertyBaseName}}", mappings);
|
||||
}
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class<?>> mappings = new HashMap<String, Class<?>>();
|
||||
{{#mappedModels}}
|
||||
mappings.put("{{mappingName}}", {{modelName}}.class);
|
||||
{{/mappedModels}}
|
||||
mappings.put("{{name}}", {{classname}}.class);
|
||||
JSON.registerDiscriminator({{classname}}.class, "{{propertyBaseName}}", mappings);
|
||||
}
|
||||
{{/discriminator}}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import org.glassfish.jersey.logging.LoggingFeature;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.Collection;
|
||||
@@ -46,14 +45,11 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
{{#jsr310}}
|
||||
import java.time.OffsetDateTime;
|
||||
{{/jsr310}}
|
||||
@@ -83,93 +79,80 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
private static final Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
|
||||
|
||||
protected Map<String, String> defaultHeaderMap = new HashMap<>();
|
||||
protected Map<String, String> defaultCookieMap = new HashMap<>();
|
||||
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||
protected String basePath = "{{{basePath}}}";
|
||||
protected String userAgent;
|
||||
private static final Logger log = Logger.getLogger(ApiClient.class.getName());
|
||||
|
||||
protected List<ServerConfiguration> servers = new ArrayList<>({{#servers}}{{#-first}}Arrays.asList(
|
||||
{{/-first}} new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
{{^variables}}
|
||||
new LinkedHashMap<>()
|
||||
{{/variables}}
|
||||
{{#variables}}
|
||||
{{#-first}}
|
||||
Stream.<Entry<String, ServerVariable>>of(
|
||||
{{/-first}}
|
||||
new SimpleEntry<>("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new LinkedHashSet<>({{#enumValues}}{{#-first}}Arrays.asList({{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}{{#-last}}
|
||||
){{/-last}}{{/enumValues}})
|
||||
)){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (a, b) -> a, LinkedHashMap::new))
|
||||
{{/-last}}
|
||||
{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
|
||||
{{/-first}} new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
new HashMap<String, ServerVariable>(){{#variables}}{{#-first}} {{
|
||||
{{/-first}} put("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new HashSet<String>(
|
||||
{{#enumValues}}
|
||||
{{#-first}}
|
||||
Arrays.asList(
|
||||
{{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
)
|
||||
{{/-last}}
|
||||
{{/enumValues}}
|
||||
)
|
||||
));
|
||||
{{#-last}}
|
||||
}}{{/-last}}{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
){{/-last}}{{/servers}});
|
||||
protected Integer serverIndex = 0;
|
||||
protected Map<String, String> serverVariables = null;
|
||||
{{^hasOperationServers}}
|
||||
protected Map<String, List<ServerConfiguration>> operationServers = new LinkedHashMap<>();
|
||||
{{/hasOperationServers}}
|
||||
{{#hasOperationServers}}
|
||||
protected Map<String, List<ServerConfiguration>> operationServers;
|
||||
|
||||
{
|
||||
Map<String, List<ServerConfiguration>> operationServers = new LinkedHashMap<>();
|
||||
protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#servers}}
|
||||
{{#-first}}
|
||||
operationServers.put("{{{classname}}}.{{{operationId}}}", new ArrayList<>(Arrays.asList(
|
||||
put("{{{classname}}}.{{{operationId}}}", new ArrayList<ServerConfiguration>(Arrays.asList(
|
||||
{{/-first}}
|
||||
new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
{{^variables}}
|
||||
new LinkedHashMap<>()
|
||||
{{/variables}}
|
||||
{{#variables}}
|
||||
{{#-first}}
|
||||
Stream.<Entry<String, ServerVariable>>of(
|
||||
{{/-first}}
|
||||
new SimpleEntry<>("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new LinkedHashSet<>({{#enumValues}}{{#-first}}Arrays.asList({{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}{{#-last}}
|
||||
){{/-last}}{{/enumValues}})
|
||||
)){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (a, b) -> a, LinkedHashMap::new))
|
||||
{{/-last}}
|
||||
{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
new ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
new HashMap<String, ServerVariable>(){{#variables}}{{#-first}} {{
|
||||
{{/-first}} put("{{{name}}}", new ServerVariable(
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
"{{{defaultValue}}}",
|
||||
new HashSet<String>(
|
||||
{{#enumValues}}
|
||||
{{#-first}}
|
||||
Arrays.asList(
|
||||
{{/-first}}
|
||||
"{{{.}}}"{{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
)
|
||||
{{/-last}}
|
||||
{{/enumValues}}
|
||||
)
|
||||
));
|
||||
{{#-last}}
|
||||
}}{{/-last}}{{/variables}}
|
||||
){{^-last}},{{/-last}}
|
||||
{{#-last}}
|
||||
)));
|
||||
{{/-last}}
|
||||
)));{{/-last}}
|
||||
{{/servers}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
this.operationServers = operationServers;
|
||||
}
|
||||
|
||||
{{/hasOperationServers}}
|
||||
protected Map<String, Integer> operationServerIndex = new HashMap<>();
|
||||
protected Map<String, Map<String, String>> operationServerVariables = new HashMap<>();
|
||||
}};
|
||||
protected Map<String, Integer> operationServerIndex = new HashMap<String, Integer>();
|
||||
protected Map<String, Map<String, String>> operationServerVariables = new HashMap<String, Map<String, String>>();
|
||||
protected boolean debugging = false;
|
||||
protected ClientConfig clientConfig;
|
||||
protected int connectionTimeout = 0;
|
||||
@@ -206,7 +189,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
setUserAgent("{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{artifactVersion}}}/java{{/httpUserAgent}}");
|
||||
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<>();
|
||||
authentications = new HashMap<String, Authentication>();
|
||||
Authentication auth = null;
|
||||
{{#authMethods}}
|
||||
if (authMap != null) {
|
||||
@@ -252,7 +235,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
|
||||
// Setup authentication lookup (key: authentication alias, value: authentication name)
|
||||
authenticationLookup = new HashMap<>();{{#authMethods}}{{#vendorExtensions.x-auth-id-alias}}
|
||||
authenticationLookup = new HashMap<String, String>();{{#authMethods}}{{#vendorExtensions.x-auth-id-alias}}
|
||||
authenticationLookup.put("{{name}}", "{{.}}");{{/vendorExtensions.x-auth-id-alias}}{{/authMethods}}
|
||||
}
|
||||
|
||||
@@ -847,7 +830,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return List of pairs
|
||||
*/
|
||||
public List<Pair> parameterToPairs(String collectionFormat, String name, Object value){
|
||||
List<Pair> params = new ArrayList<>();
|
||||
List<Pair> params = new ArrayList<Pair>();
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty() || value == null) return params;
|
||||
@@ -906,13 +889,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* "*{@literal /}*" is also considered JSON by this method.
|
||||
* "* / *" is also default to JSON
|
||||
*
|
||||
* @param mime MIME
|
||||
* @return True if the MIME type is JSON
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
return mime != null && (mime.equals("*/*") || JSON_MIME_PATTERN.matcher(mime).matches());
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -924,8 +908,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return The Accept header to use. If the given array is empty,
|
||||
* null will be returned (not to set the Accept header explicitly).
|
||||
*/
|
||||
public String selectHeaderAccept(String... accepts) {
|
||||
if (accepts == null || accepts.length == 0) {
|
||||
public String selectHeaderAccept(String[] accepts) {
|
||||
if (accepts.length == 0) {
|
||||
return null;
|
||||
}
|
||||
for (String accept : accepts) {
|
||||
@@ -945,8 +929,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return The Content-Type header to use. If the given array is empty,
|
||||
* JSON will be used.
|
||||
*/
|
||||
public String selectHeaderContentType(String... contentTypes) {
|
||||
if (contentTypes == null || contentTypes.length == 0) {
|
||||
public String selectHeaderContentType(String[] contentTypes) {
|
||||
if (contentTypes.length == 0) {
|
||||
return "application/json";
|
||||
}
|
||||
for (String contentType : contentTypes) {
|
||||
@@ -1238,22 +1222,20 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
Map<String, String> allHeaderParams = new HashMap<>(defaultHeaderMap);
|
||||
allHeaderParams.putAll(headerParams);
|
||||
|
||||
if (authNames != null) {
|
||||
// update different parameters (e.g. headers) for authentication
|
||||
updateParamsForAuth(
|
||||
authNames,
|
||||
queryParams,
|
||||
allHeaderParams,
|
||||
cookieParams,
|
||||
{{#hasHttpSignatureMethods}}
|
||||
serializeToString(body, formParams, contentType, isBodyNullable),
|
||||
{{/hasHttpSignatureMethods}}
|
||||
{{^hasHttpSignatureMethods}}
|
||||
null,
|
||||
{{/hasHttpSignatureMethods}}
|
||||
method,
|
||||
target.getUri());
|
||||
}
|
||||
// update different parameters (e.g. headers) for authentication
|
||||
updateParamsForAuth(
|
||||
authNames,
|
||||
queryParams,
|
||||
allHeaderParams,
|
||||
cookieParams,
|
||||
{{#hasHttpSignatureMethods}}
|
||||
serializeToString(body, formParams, contentType, isBodyNullable),
|
||||
{{/hasHttpSignatureMethods}}
|
||||
{{^hasHttpSignatureMethods}}
|
||||
null,
|
||||
{{/hasHttpSignatureMethods}}
|
||||
method,
|
||||
target.getUri());
|
||||
|
||||
for (Entry<String, String> entry : allHeaderParams.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
@@ -1271,7 +1253,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
{{#hasOAuthMethods}}
|
||||
// If OAuth is used and a status 401 is received, renew the access token and retry the request
|
||||
if (authNames != null && statusCode == Status.UNAUTHORIZED.getStatusCode()) {
|
||||
if (statusCode == Status.UNAUTHORIZED.getStatusCode()) {
|
||||
for (String authName : authNames) {
|
||||
Authentication authentication = authentications.get(authName);
|
||||
if (authentication instanceof OAuth) {
|
||||
@@ -1443,10 +1425,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @return a {@link java.util.Map} of response headers.
|
||||
*/
|
||||
protected Map<String, List<String>> buildResponseHeaders(Response response) {
|
||||
Map<String, List<String>> responseHeaders = new HashMap<>();
|
||||
Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();
|
||||
for (Entry<String, List<Object>> entry: response.getHeaders().entrySet()) {
|
||||
List<Object> values = entry.getValue();
|
||||
List<String> headers = new ArrayList<>();
|
||||
List<String> headers = new ArrayList<String>();
|
||||
for (Object o : values) {
|
||||
headers.add(String.valueOf(o));
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user