mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-07 20:16:09 +00:00
Compare commits
114 Commits
v7.0.0-bet
...
better-ap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ecf9e352d | ||
|
|
07d4f7d534 | ||
|
|
659885f509 | ||
|
|
526ca78e79 | ||
|
|
48ff57b4f6 | ||
|
|
d41fe12c1f | ||
|
|
d9fc039dcf | ||
|
|
e411b2ac0a | ||
|
|
adac3b127f | ||
|
|
7ca84e5c88 | ||
|
|
5d2e80977b | ||
|
|
954d41b9aa | ||
|
|
184dfd2edd | ||
|
|
86cf4f1eb1 | ||
|
|
f6a819686d | ||
|
|
d7311cd5cd | ||
|
|
90eacb685c | ||
|
|
30c38ed7ad | ||
|
|
596487aa6c | ||
|
|
7d6e7e4e75 | ||
|
|
a1558e3861 | ||
|
|
7ad8f6ef29 | ||
|
|
f32be9df0b | ||
|
|
9aa15d9f09 | ||
|
|
24656156ed | ||
|
|
54d996732f | ||
|
|
66155d622c | ||
|
|
584f8448ee | ||
|
|
0a02860b50 | ||
|
|
20d1743a36 | ||
|
|
c71b48fe1a | ||
|
|
f590ef1bcf | ||
|
|
056475f0a4 | ||
|
|
476c1a9397 | ||
|
|
b7346d09eb | ||
|
|
3c5b119252 | ||
|
|
b468e4bb15 | ||
|
|
7a7ecc832d | ||
|
|
fb2c866dfc | ||
|
|
d000f90759 | ||
|
|
ce4a6a37c6 | ||
|
|
76989db77a | ||
|
|
bd76c1b102 | ||
|
|
7252d1a698 | ||
|
|
f6fefd9268 | ||
|
|
de0bffb99d | ||
|
|
4ece8e992a | ||
|
|
ddc2b3e560 | ||
|
|
7dee666826 | ||
|
|
35ca486e1c | ||
|
|
0d002d381e | ||
|
|
a729cb4e09 | ||
|
|
bfcd646356 | ||
|
|
aed6a0661a | ||
|
|
178b8a7737 | ||
|
|
28e822d870 | ||
|
|
e722c42756 | ||
|
|
b2eb14b3a5 | ||
|
|
067b17252e | ||
|
|
f8e19b4ebc | ||
|
|
6983a3acf3 | ||
|
|
b107ff96ac | ||
|
|
6299af176d | ||
|
|
598c27ddb0 | ||
|
|
7258b3c171 | ||
|
|
80e2c05bad | ||
|
|
b7e7314d8e | ||
|
|
6a263565e7 | ||
|
|
1531ad48d0 | ||
|
|
7f480cb936 | ||
|
|
e77f9ea783 | ||
|
|
c6f6ef92d0 | ||
|
|
16c149a91e | ||
|
|
3678085017 | ||
|
|
c595a02b61 | ||
|
|
ec6381295a | ||
|
|
7cbdc861c7 | ||
|
|
9aa6e25886 | ||
|
|
3325edc5c5 | ||
|
|
0a6671044f | ||
|
|
7b3681af47 | ||
|
|
f31c2a4b17 | ||
|
|
ceb48d3af4 | ||
|
|
9362b49173 | ||
|
|
91a55fc6b6 | ||
|
|
cc47f45eac | ||
|
|
fe78be405e | ||
|
|
aa1e9097ea | ||
|
|
ac1f5f1e81 | ||
|
|
852eb956db | ||
|
|
75067b2581 | ||
|
|
f34e42b249 | ||
|
|
94d76ff5d4 | ||
|
|
f0084b39ac | ||
|
|
9baf4988f3 | ||
|
|
f63ef71432 | ||
|
|
c6877947ac | ||
|
|
1d470c3866 | ||
|
|
2c5f8b30b4 | ||
|
|
52dd41159f | ||
|
|
aaf9ce637a | ||
|
|
08c3f8973e | ||
|
|
83a12779fa | ||
|
|
f7edbbc572 | ||
|
|
5bae27cbbf | ||
|
|
2aa75802dc | ||
|
|
30d6a2ff80 | ||
|
|
a5f1c01548 | ||
|
|
315fbff680 | ||
|
|
9170306ffa | ||
|
|
a2d0b0c5b8 | ||
|
|
ba5c5f478e | ||
|
|
ba1c600830 | ||
|
|
a16a315fee |
@@ -38,9 +38,18 @@ commands: # a reusable command with parameters
|
||||
- run:
|
||||
command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
|
||||
- run:
|
||||
command: |-
|
||||
printf '127.0.0.1 petstore.swagger.io
|
||||
' | sudo tee -a /etc/hosts
|
||||
command: |
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.1 path.v1.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.1 path.v2.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.111 path.v3.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.1 operation.v1.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.1 operation.v2.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.111 operation.v3.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.1 server.v1.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.1 server.v2.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.111 server.v3.test.openapi-generator.tech"
|
||||
sudo tee -a /etc/hosts \<<< "127.0.0.1 petstore.swagger.io"
|
||||
cat /etc/hosts
|
||||
# - run: docker pull openapitools/openapi-petstore
|
||||
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
|
||||
- run: docker pull swaggerapi/petstore
|
||||
|
||||
12
.github/workflows/samples-dart.yaml
vendored
12
.github/workflows/samples-dart.yaml
vendored
@@ -22,22 +22,14 @@ jobs:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 11
|
||||
- name: Cache maven dependencies
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: maven-repository
|
||||
with:
|
||||
path: |
|
||||
~/.m2/repository
|
||||
~/.gradle
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||
cache: maven
|
||||
- name: Cache test dependencies
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: pub-cache
|
||||
with:
|
||||
path: $PUB_CACHE
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('samples/**/pubspec.yaml') }}
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('samples/**/pubspec.*') }}
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
with:
|
||||
sdk: 2.15.0
|
||||
|
||||
31
.github/workflows/samples-dotnet6-client-echo-api.yaml
vendored
Normal file
31
.github/workflows/samples-dotnet6-client-echo-api.yaml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: Samples C# .Net 6
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/client/echo_api/csharp-restsharp/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/echo_api/csharp-restsharp/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build .Net clients
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/client/echo_api/csharp-restsharp/
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
- name: Run echo server
|
||||
run: |
|
||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||
(cd http-echo-server && npm install && npm start &)
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: dotnet build Org.OpenAPITools.sln
|
||||
@@ -20,6 +20,8 @@ on:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net5.0/**
|
||||
# build C# API client (.net 5.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
|
||||
pull_request:
|
||||
paths:
|
||||
# build C# API client (multiple frameworks)
|
||||
@@ -39,6 +41,8 @@ on:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net5.0/**
|
||||
# build C# API client (.net 5.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build .Net clients
|
||||
@@ -65,6 +69,8 @@ jobs:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net5.0/
|
||||
# build C# API client (.net 5.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-dotnet@v3.2.0
|
||||
|
||||
41
.github/workflows/samples-julia.yaml
vendored
Normal file
41
.github/workflows/samples-julia.yaml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: Samples Julia
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'samples/client/petstore/julia/**'
|
||||
- 'samples/server/petstore/julia/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/client/petstore/julia/**'
|
||||
- 'samples/server/petstore/julia/**'
|
||||
|
||||
jobs:
|
||||
tests-julia:
|
||||
name: Tests Julia
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: julia-actions/setup-julia@v1
|
||||
with:
|
||||
version: 1.8
|
||||
arch: x64
|
||||
- name: Test
|
||||
shell: bash
|
||||
working-directory: 'samples'
|
||||
run: |
|
||||
currdir=`pwd`
|
||||
# Using a specific version of OpenAPI.jl helps avoid introducing version inter-dependencies
|
||||
# and allows breaking changes to be done in either repos independently
|
||||
# Using develop mode to install package so that it is easier to modify the package test files
|
||||
julia -e "using Pkg; Pkg.develop(\"OpenAPI\");"
|
||||
cd ~/.julia/dev/OpenAPI
|
||||
git checkout v0.1.14
|
||||
cd $currdir
|
||||
rm -rf ~/.julia/dev/OpenAPI/test/client/openapigenerator_petstore_v3/petstore
|
||||
rm -rf ~/.julia/dev/OpenAPI/test/server/openapigenerator_petstore_v3/petstore
|
||||
cp -r client/petstore/julia ~/.julia/dev/OpenAPI/test/client/openapigenerator_petstore_v3/petstore
|
||||
cp -r server/petstore/julia ~/.julia/dev/OpenAPI/test/server/openapigenerator_petstore_v3/petstore
|
||||
# setting this env runs only the tests relevant to the openapi-generator repo
|
||||
export OPENAPI_GENERATOR=true
|
||||
julia -e "using Pkg; Pkg.test(\"OpenAPI\");"
|
||||
1
.github/workflows/samples-kotlin-client.yaml
vendored
1
.github/workflows/samples-kotlin-client.yaml
vendored
@@ -59,6 +59,7 @@ jobs:
|
||||
- samples/client/petstore/kotlin-jvm-spring-2-webclient
|
||||
- samples/client/petstore/kotlin-jvm-spring-3-webclient
|
||||
- samples/client/petstore/kotlin-spring-cloud
|
||||
- samples/client/petstore/kotlin-name-parameter-mappings
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
11
.github/workflows/samples-rust.yaml
vendored
11
.github/workflows/samples-rust.yaml
vendored
@@ -3,12 +3,14 @@ name: Samples Rust
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'samples/client/petstore/rust/**'
|
||||
- 'samples/server/petstore/rust-server/**'
|
||||
- "samples/client/others/rust/**"
|
||||
- "samples/server/petstore/rust-server/**"
|
||||
- "samples/client/petstore/rust-server/**"
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/client/petstore/rust/**'
|
||||
- 'samples/server/petstore/rust-server/**'
|
||||
- "samples/client/others/rust/**"
|
||||
- "samples/client/petstore/rust/**"
|
||||
- "samples/server/petstore/rust-server/**"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -19,6 +21,7 @@ jobs:
|
||||
matrix:
|
||||
sample:
|
||||
# these folders contain sub-projects of rust clients, servers
|
||||
- samples/client/others/rust/
|
||||
- samples/client/petstore/rust/
|
||||
- samples/server/petstore/rust-server/
|
||||
steps:
|
||||
|
||||
36
.github/workflows/samples-spring-jdk17.yaml
vendored
Normal file
36
.github/workflows/samples-spring-jdk17.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Samples Java Spring (JDK17)
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
|
||||
jobs:
|
||||
build:
|
||||
name: Build Java Spring (JDK17)
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Cache maven dependencies
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: maven-repository
|
||||
with:
|
||||
path: |
|
||||
~/.m2
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: mvn clean package
|
||||
3
.github/workflows/samples-spring.yaml
vendored
3
.github/workflows/samples-spring.yaml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
- samples/openapi3/client/petstore/spring-stubs-skip-default-interface
|
||||
- samples/openapi3/client/petstore/spring-cloud-async
|
||||
- samples/openapi3/client/petstore/spring-cloud-spring-pageable
|
||||
- samples/openapi3/client/petstore/spring-cloud-3-with-optional.yaml
|
||||
- samples/client/petstore/spring-cloud-tags
|
||||
# servers
|
||||
- samples/server/petstore/springboot
|
||||
- samples/openapi3/server/petstore/springboot
|
||||
@@ -47,7 +47,6 @@ jobs:
|
||||
- samples/server/petstore/springboot-spring-pageable-delegatePattern
|
||||
- samples/server/petstore/springboot-spring-pageable-without-j8
|
||||
- samples/server/petstore/springboot-spring-pageable
|
||||
- samples/openapi3/client/petstore/spring-cloud-tags.yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
30
.github/workflows/samples-zapier.yaml
vendored
Normal file
30
.github/workflows/samples-zapier.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Samples Zapier
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'samples/client/petstore/zapier/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/client/petstore/zapier/**'
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
name: Test zapier generation
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- samples/client/petstore/zapier
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
- name: Install dependencies
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: |
|
||||
npm install
|
||||
- name: Validate
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: node index.js
|
||||
12
README.md
12
README.md
@@ -73,7 +73,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**, **N4JS**, **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 (9.x - 16.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo** |
|
||||
| **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**, **N4JS**, **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 (9.x - 16.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
|
||||
| **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](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **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/) |
|
||||
@@ -115,13 +115,15 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
| OpenAPI Generator Version | Release Date | Notes |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||
| 7.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.0.0-SNAPSHOT/) | May/Jun 2023 | Major release with breaking changes (no fallback) |
|
||||
| 7.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.0.0-SNAPSHOT/) | Jul/Aug 2023 | Major release with breaking changes (no fallback) |
|
||||
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) (latest stable release) | 11.05.2023 | Minor release with breaking changes (with fallback) |
|
||||
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | Minor release with breaking changes (with fallback) |
|
||||
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
(We do not publish daily/nightly build. Please use SNAPSHOT instead)
|
||||
|
||||
For old releases, please refer to the [**Release**](https://github.com/OpenAPITools/openapi-generator/releases) page.
|
||||
|
||||
For decomissioned generators/libraries/frameworks, please refer to [the "Decommission" label](https://github.com/OpenAPITools/openapi-generator/issues?q=label%3ADecommission+is%3Amerged+) in the pull request page.
|
||||
@@ -648,6 +650,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Klarna](https://www.klarna.com/)
|
||||
- [Kronsoft Development](https://www.kronsoft.ro/home/)
|
||||
- [Kubernetes](https://kubernetes.io)
|
||||
- [Landeshauptstadt München - it@M](https://muenchen.digital/it-at-m/)
|
||||
- [Linode](https://www.linode.com/)
|
||||
- [Logicdrop](https://www.logicdrop.com)
|
||||
- [Lumeris](https://www.lumeris.com)
|
||||
@@ -905,6 +908,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2023-04-27 - [Create an Angular Client using OpenAPI Specifications](Create an Angular Client using OpenAPI Specifications) by [Patric](https://pguso.medium.com/)
|
||||
- 2023-05-16 - [Adyen for Java developers](https://www.adyen.com/blog/adyen-java-library) by [Beppe Catanese, Developer Advocate, Adyen](https://github.com/gcatanese)
|
||||
- 2023-05-18 - [如何基于 Swagger 使用 OpenAPI Generator 生成 JMeter 脚本?](https://blog.51cto.com/u_15181572/6294974) by [高楼(Zee)](https://blog.51cto.com/u_15181572)
|
||||
- 2023-06-28 - [Generate API contract using OpenAPI Generator Maven plugin](https://huongdanjava.com/generate-api-contract-using-openapi-generator-maven-plugin.html) by [Khanh Nguyen](https://huongdanjava.com/)
|
||||
- 2023-06-30 - [Generate Client SDKs with OpenApi Generator in Springboot](https://medium.com/@ramavathvinayak/generate-client-sdks-with-openapi-generator-in-springboot-f9f012e73c0b) by [Vinayak Ramavath](https://medium.com/@ramavathvinayak)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -1024,6 +1029,7 @@ Here is a list of template creators:
|
||||
* TypeScript (Rxjs): @denyo
|
||||
* TypeScript (redux-query): @petejohansonxo
|
||||
* Xojo: @Topheee
|
||||
* Zapier: @valmoz, @emajo
|
||||
* Server Stubs
|
||||
* Ada: @stcarrez
|
||||
* C# ASP.NET 5: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||
@@ -1133,7 +1139,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) |
|
||||
| C | @zhemant (2018/11) @ityuhui (2019/12) @michelealbano (2020/03) |
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||
| C# | @mandrean (2017/08) @frankyjuang (2019/09) @shibayan (2020/02) @Blackclaws (2021/03) @lucamazzanti (2021/05) |
|
||||
| C# | @mandrean (2017/08) @frankyjuang (2019/09) @shibayan (2020/02) @Blackclaws (2021/03) @lucamazzanti (2021/05) @iBicha (2023/07) |
|
||||
| Clojure | |
|
||||
| Crystal | @cyangle (2021/01) |
|
||||
| Dart | @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08) |
|
||||
|
||||
15
bin/configs/ada.yaml
Normal file
15
bin/configs/ada.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: ada
|
||||
outputDir: samples/client/petstore/ada
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/ada/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Ada
|
||||
nameMappings:
|
||||
_type: P_UnderscoreType
|
||||
type_: P_TypeWithUnderscore
|
||||
http_debug_operation: P_HTTPDebugOperation
|
||||
parameterNameMappings:
|
||||
_type: UnderscoreType
|
||||
type_: TypeWithUnderscore
|
||||
http_debug_operation: HttpDebugOperation
|
||||
additionalProperties:
|
||||
modelPackage: Samples.Petstore
|
||||
projectName: Petstore
|
||||
9
bin/configs/csharp-restsharp-echo-api.yaml
Normal file
9
bin/configs/csharp-restsharp-echo-api.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/echo_api/csharp-restsharp
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{322C8CAF-0156-40C1-AE42-D59761FB9B6C}'
|
||||
targetFramework: net6.0
|
||||
setCompareNetObjects: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
15
bin/configs/csharp-restsharp-name-mappings.yaml
Normal file
15
bin/configs/csharp-restsharp-name-mappings.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp-restsharp-name-parameter-mappings
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/name-parameter-mappings.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
nameMappings:
|
||||
_type: UnderscoreType
|
||||
type_: TypeWithUnderscore
|
||||
http_debug_operation: HttpDebugOperation
|
||||
parameterNameMappings:
|
||||
_type: UnderscoreType
|
||||
type_: TypeWithUnderscore
|
||||
http_debug_operation: HttpDebugOperation
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -2,8 +2,17 @@ generatorName: go
|
||||
outputDir: samples/openapi3/client/petstore/go/go-petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/go
|
||||
nameMappings:
|
||||
_type: UnderscoreType
|
||||
type_: TypeWithUnderscore
|
||||
http_debug_operation: HTTPDebugOperation
|
||||
parameterNameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
http_debug_operation: httpDebugOperation
|
||||
additionalProperties:
|
||||
enumClassPrefix: "true"
|
||||
packageName: petstore
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
generateInterfaces: true
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@ outputDir: samples/client/petstore/java/okhttp-gson
|
||||
library: okhttp-gson
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
nameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
parameterNameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
additionalProperties:
|
||||
artifactId: petstore-okhttp-gson
|
||||
hideGenerationTimestamp: "true"
|
||||
|
||||
@@ -4,4 +4,6 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/julia-client
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
packageName: PetStoreClient
|
||||
packageName: OpenAPIGenPetStoreClient
|
||||
exportOperations: "true"
|
||||
exportModels: "true"
|
||||
@@ -4,4 +4,6 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/julia-server
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
packageName: PetStoreServer
|
||||
packageName: OpenAPIGenPetStoreServer
|
||||
exportOperations: "true"
|
||||
exportModels: "true"
|
||||
14
bin/configs/kotlin-name-mappings.yaml
Normal file
14
bin/configs/kotlin-name-mappings.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
generatorName: kotlin
|
||||
outputDir: samples/client/petstore/kotlin-name-parameter-mappings
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/name-parameter-mappings.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||
nameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
http_debug_operation: httpDebugOperation
|
||||
parameterNameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
http_debug_operation: httpDebugOperation
|
||||
additionalProperties:
|
||||
artifactId: kotlin-petstore-client
|
||||
@@ -7,3 +7,6 @@ additionalProperties:
|
||||
useOneOfDiscriminatorLookup: "true"
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
mapNumberTo: StrictFloat
|
||||
nameMappings:
|
||||
_type: underscore_type
|
||||
type_: type_with_underscore
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: ruby
|
||||
outputDir: samples/client/petstore/ruby
|
||||
library: typhoeus
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/ruby/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/ruby-client
|
||||
additionalProperties:
|
||||
gemVersion: 1.0.0
|
||||
@@ -9,3 +9,9 @@ additionalProperties:
|
||||
gemName: petstore
|
||||
skipFormModel: "true"
|
||||
strictSpecBehavior: false
|
||||
nameMappings:
|
||||
_type: underscore_type
|
||||
type_: type_with_underscore
|
||||
parameterNameMappings:
|
||||
_type: underscore_type
|
||||
type_: type_with_underscore
|
||||
|
||||
8
bin/configs/rust-reqwest-regression-16119.yaml
Normal file
8
bin/configs/rust-reqwest-regression-16119.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/others/rust/reqwest-regression-16119
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_1/regression-16119.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: false
|
||||
packageName: regression-16119-reqwest
|
||||
@@ -2,5 +2,13 @@ generatorName: scala-sttp
|
||||
outputDir: samples/client/petstore/scala-sttp
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/scala/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/scala-sttp
|
||||
nameMappings:
|
||||
_type: "`underscoreType`"
|
||||
type_: "`typeWithUnderscore`"
|
||||
http_debug_operation: "`httpDebugOperation`"
|
||||
parameterNameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
http_debug_operation: httpDebugOperation
|
||||
additionalProperties:
|
||||
artifactId: scala-sttp-petstore
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/others/typescript-angular/builds/composed-schemas-tagged-unions
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-angular/composed-schemas.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
stringEnums: true
|
||||
modelSuffix: Model
|
||||
enumSuffix: Enum
|
||||
taggedUnions: true
|
||||
8
bin/configs/typescript-angular-composed-schemas.yaml
Normal file
8
bin/configs/typescript-angular-composed-schemas.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/others/typescript-angular/builds/composed-schemas
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-angular/composed-schemas.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
stringEnums: true
|
||||
modelSuffix: Model
|
||||
enumSuffix: Enum
|
||||
@@ -1,7 +0,0 @@
|
||||
generatorName: ada
|
||||
outputDir: samples/client/petstore/ada
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Ada
|
||||
additionalProperties:
|
||||
modelPackage: Samples.Petstore
|
||||
projectName: Petstore
|
||||
7
bin/configs/zapier-petstore.yaml
Normal file
7
bin/configs/zapier-petstore.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
generatorName: zapier
|
||||
outputDir: samples/client/petstore/zapier
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/zapier
|
||||
additionalProperties:
|
||||
npmVersion: 0.0.1
|
||||
npmName: '@openapitools/zapier'
|
||||
@@ -395,11 +395,34 @@ or
|
||||
--import-mappings Pet=my.models.MyPet --import-mappings Order=my.models.MyOrder
|
||||
```
|
||||
|
||||
## Name Mapping
|
||||
|
||||
One can map the property name using `nameMappings` option and parameter name using `parameterNameMappings` option to something else. Consider the following schema:
|
||||
```
|
||||
PropertyNameCollision:
|
||||
properties:
|
||||
_type:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type_:
|
||||
type: string
|
||||
type: object
|
||||
```
|
||||
`_type`, `type`, `type_` will result in property name collision in the Java client generator for example. We can resolve the issue using `nameMappings` by mapping `_type` to `underscoreType`, `type_` to `typeWithUnderscore`.
|
||||
|
||||
Here is an example to use `nameMappings` and `parameterNameMapping` in CLI:
|
||||
```sh
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml -o /tmp/java2/ --name-mappings _type=underscoreType, type_=typeWithUnderscore, --parameter-name-mappings _type=paramType, type_=typeParam
|
||||
```
|
||||
|
||||
(Not all generators support this feature yet. Please give it a try to confirm the behaviour and open an issue (ticket) to let us know which generators you would like to have this feature enabled and we'll prioritize accordingly.)
|
||||
|
||||
## Schema Mapping
|
||||
|
||||
One can map the schema to something else (e.g. external objects/models outside of the package) using the `schemaMappings` option, e.g. in CLI
|
||||
```sh
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/type-alias.yaml -o /tmp/java2/ --schema-mapping TypeAlias=foo.bar.TypeAlias
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/type-alias.yaml -o /tmp/java2/ --schema-mappings TypeAlias=foo.bar.TypeAlias
|
||||
```
|
||||
Another example (in conjunction with --type-mappings):
|
||||
```sh
|
||||
@@ -445,16 +468,16 @@ For example, to name the inline schema `meta_200_response` as `MetaObject`, use
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/inline_model_resolver.yaml -o /tmp/java3/ --skip-validate-spec --inline-schema-name-mappings meta_200_response=MetaObject,arbitraryObjectRequestBodyProperty_request=ArbitraryRequest
|
||||
```
|
||||
|
||||
Another useful option is `inlineSchemaNameDefaults`, which allows you to customize the suffix of the auto-generated inline schema name, e.g. in CLI
|
||||
Another useful option is `inlineSchemaOptions`, which allows you to customize how inline schemas are handled or named
|
||||
```
|
||||
--inline-schema-name-defaults arrayItemSuffix=_array_item,mapItemSuffix=_map_item
|
||||
--inline-schema-options ARRAY_ITEM_SUFFIX=_array_item,MAP_ITEM_SUFFIX=_map_item,RESOLVE_INLINE_ENUMS=true
|
||||
```
|
||||
|
||||
Note: Only arrayItemSuffix, mapItemSuffix are supported at the moment.
|
||||
|
||||
There are 2 special values:
|
||||
- `SKIP_SCHEMA_REUSE=true` is a special value to skip reusing inline schemas.
|
||||
- `ARRAY_ITEM_SUFFIX` sets the array item suffix
|
||||
- `MAP_ITEM_SUFFIX` set the map item suffix
|
||||
- `SKIP_SCHEMA_REUSE=true` is a special value to skip reusing inline schemas during refactoring
|
||||
- `REFACTOR_ALLOF_INLINE_SCHEMAS=true` will restore the 6.x (or below) behaviour to refactor allOf inline schemas into $ref. (v7.0.0 will skip the refactoring of these allOf inline schmeas by default)
|
||||
- `RESOLVE_INLINE_ENUMS=true` will refactor inline enum definitions into $ref
|
||||
|
||||
## OpenAPI Normalizer
|
||||
|
||||
@@ -513,7 +536,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
|
||||
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
|
||||
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=another_tag_name
|
||||
```
|
||||
|
||||
- `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
|
||||
|
||||
@@ -74,6 +74,7 @@ The following generators are available:
|
||||
* [typescript-redux-query](generators/typescript-redux-query.md)
|
||||
* [typescript-rxjs](generators/typescript-rxjs.md)
|
||||
* [xojo-client](generators/xojo-client.md)
|
||||
* [zapier (beta)](generators/zapier.md)
|
||||
|
||||
|
||||
## SERVER generators
|
||||
@@ -118,7 +119,6 @@ The following generators are available:
|
||||
* [php-laravel](generators/php-laravel.md)
|
||||
* [php-lumen](generators/php-lumen.md)
|
||||
* [php-mezzio-ph](generators/php-mezzio-ph.md)
|
||||
* [php-slim-deprecated (deprecated)](generators/php-slim-deprecated.md)
|
||||
* [php-slim4](generators/php-slim4.md)
|
||||
* [php-symfony](generators/php-symfony.md)
|
||||
* [python-aiohttp](generators/python-aiohttp.md)
|
||||
|
||||
@@ -186,7 +186,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✓|ToolingExtension
|
||||
|Readme|✗|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
@@ -214,11 +214,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Header|✗|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✓|OAS2
|
||||
|Cookie|✓|OAS3
|
||||
|Cookie|✗|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
@@ -238,11 +238,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|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
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✓|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
|
||||
|SignatureAuth|✗|OAS3
|
||||
|
||||
### Wire Format Feature
|
||||
|
||||
@@ -25,6 +25,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|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|
|
||||
|equatable|Overrides Equals and GetHashCode methods.| |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|
|
||||
|
||||
@@ -48,7 +48,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>AnyType</li>
|
||||
<li>Atom</li>
|
||||
<li>Boolean</li>
|
||||
<li>DateTime</li>
|
||||
<li>Decimal</li>
|
||||
<li>Float</li>
|
||||
<li>Integer</li>
|
||||
|
||||
@@ -77,6 +77,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
|
||||
|requestMappingMode|Where to generate the class level @RequestMapping annotation.|<dl><dt>**api_interface**</dt><dd>Generate the @RequestMapping annotation on the generated Api Interface.</dd><dt>**controller**</dt><dd>Generate the @RequestMapping annotation on the generated Api Controller Implementation.</dd><dt>**none**</dt><dd>Do not add a class level @RequestMapping annotation.</dd></dl>|controller|
|
||||
|resourceFolder|resource folder for generated resources| |src/main/resources|
|
||||
|responseWrapper|wrap the responses in given type (Future, Callable, CompletableFuture,ListenableFuture, DeferredResult, RxObservable, RxSingle or fully qualified type)| |null|
|
||||
|returnSuccessCode|Generated server returns 2xx code| |false|
|
||||
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|
||||
|
||||
@@ -20,12 +20,17 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|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|
|
||||
|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|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|modern|use modern language features (generated code will require PHP 8.0)| |false|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|
||||
@@ -20,12 +20,17 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|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|
|
||||
|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|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -20,12 +20,17 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|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|
|
||||
|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|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -20,12 +20,17 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|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|
|
||||
|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|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|modern|use modern language features (generated code will require PHP 8.0)| |false|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|
||||
@@ -20,12 +20,17 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|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|
|
||||
|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|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -20,17 +20,22 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|bundleAlias|The alias of the Symfony bundle. The template uses {{aliasName}}| |null|
|
||||
|bundleName|The name of the Symfony bundle. The template uses {{bundleName}}| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|composerProjectName|The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client| |null|
|
||||
|composerVendorName|The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|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|
|
||||
|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|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|phpLegacySupport|Should the generated code be compatible with PHP 5.x?| |true|
|
||||
|
||||
@@ -20,13 +20,18 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|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|
|
||||
|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|
|
||||
|hideGenerationTimestamp|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |true|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|
||||
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|packageVersion|python package version.| |1.0.0|
|
||||
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|
||||
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
|
||||
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
|
||||
|requestMappingMode|Where to generate the class level @RequestMapping annotation.|<dl><dt>**api_interface**</dt><dd>Generate the @RequestMapping annotation on the generated Api Interface.</dd><dt>**controller**</dt><dd>Generate the @RequestMapping annotation on the generated Api Controller Implementation.</dd><dt>**none**</dt><dd>Do not add a class level @RequestMapping annotation.</dd></dl>|controller|
|
||||
|resourceFolder|resource folder for generated resources| |src/main/resources|
|
||||
|responseWrapper|wrap the responses in given type (Future, Callable, CompletableFuture,ListenableFuture, DeferredResult, RxObservable, RxSingle or fully qualified type)| |null|
|
||||
|returnSuccessCode|Generated server returns 2xx code| |false|
|
||||
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|
||||
|
||||
@@ -25,6 +25,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|fileNaming|Naming convention for the output files: 'camelCase', 'kebab-case'.| |camelCase|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|
||||
|
||||
@@ -24,6 +24,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|importFileExtension|File extension to use with relative imports. Set it to '.js' or '.mjs' when using [ESM](https://nodejs.org/api/esm.html).| ||
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|jqueryAlreadyImported|When using this in legacy app using mix of typescript and javascript, this will only declare jquery and not import it| |false|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|fileNaming|Naming convention for the output files: 'camelCase', 'kebab-case'.| |camelCase|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|
||||
|
||||
@@ -23,6 +23,7 @@ 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|
|
||||
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
|
||||
|enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false|
|
||||
|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|
|
||||
|fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser, Deno) / Buffer (node)| |Buffer|
|
||||
|framework|Specify the framework which should be used in the client code.|<dl><dt>**fetch-api**</dt><dd>fetch-api</dd><dt>**jquery**</dt><dd>jquery</dd></dl>|fetch-api|
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
---
|
||||
title: Documentation for the php-slim-deprecated Generator
|
||||
title: Documentation for the zapier Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | php-slim-deprecated | pass this to the generate command after -g |
|
||||
| generator stability | DEPRECATED | |
|
||||
| generator type | SERVER | |
|
||||
| generator language | PHP | |
|
||||
| generator name | zapier | pass this to the generate command after -g |
|
||||
| generator stability | BETA | |
|
||||
| generator type | CLIENT | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a PHP Slim Framework server library. IMPORTANT NOTE: this generator (Slim 3.x) is no longer actively maintained so please use 'php-slim4' generator instead. | |
|
||||
| helpTxt | Generates a zapier client. | |
|
||||
|
||||
## 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.
|
||||
@@ -19,20 +18,13 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|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|
|
||||
|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|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|srcBasePath|The directory to serve as source root.| |null|
|
||||
|variableNamingConvention|naming convention of variable name, e.g. camelCase.| |camelCase|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
@@ -45,103 +37,26 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|array|array|
|
||||
|map|array|
|
||||
|list|array|
|
||||
|map|object|
|
||||
|set|array|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>\DateTime</li>
|
||||
<li>\SplFileObject</li>
|
||||
<li>array</li>
|
||||
<li>bool</li>
|
||||
<li>boolean</li>
|
||||
<li>byte</li>
|
||||
<li>float</li>
|
||||
<li>int</li>
|
||||
<li>file</li>
|
||||
<li>integer</li>
|
||||
<li>mixed</li>
|
||||
<li>number</li>
|
||||
<li>object</li>
|
||||
<li>string</li>
|
||||
<li>void</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>__halt_compiler</li>
|
||||
<li>_header_accept</li>
|
||||
<li>_tempbody</li>
|
||||
<li>abstract</li>
|
||||
<li>and</li>
|
||||
<li>array</li>
|
||||
<li>as</li>
|
||||
<li>break</li>
|
||||
<li>callable</li>
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>class</li>
|
||||
<li>clone</li>
|
||||
<li>const</li>
|
||||
<li>continue</li>
|
||||
<li>declare</li>
|
||||
<li>default</li>
|
||||
<li>die</li>
|
||||
<li>do</li>
|
||||
<li>echo</li>
|
||||
<li>else</li>
|
||||
<li>elseif</li>
|
||||
<li>empty</li>
|
||||
<li>enddeclare</li>
|
||||
<li>endfor</li>
|
||||
<li>endforeach</li>
|
||||
<li>endif</li>
|
||||
<li>endswitch</li>
|
||||
<li>endwhile</li>
|
||||
<li>eval</li>
|
||||
<li>exit</li>
|
||||
<li>extends</li>
|
||||
<li>final</li>
|
||||
<li>for</li>
|
||||
<li>foreach</li>
|
||||
<li>formparams</li>
|
||||
<li>function</li>
|
||||
<li>global</li>
|
||||
<li>goto</li>
|
||||
<li>headerparams</li>
|
||||
<li>httpbody</li>
|
||||
<li>if</li>
|
||||
<li>implements</li>
|
||||
<li>include</li>
|
||||
<li>include_once</li>
|
||||
<li>instanceof</li>
|
||||
<li>insteadof</li>
|
||||
<li>interface</li>
|
||||
<li>isset</li>
|
||||
<li>list</li>
|
||||
<li>namespace</li>
|
||||
<li>new</li>
|
||||
<li>or</li>
|
||||
<li>print</li>
|
||||
<li>private</li>
|
||||
<li>protected</li>
|
||||
<li>public</li>
|
||||
<li>queryparams</li>
|
||||
<li>require</li>
|
||||
<li>require_once</li>
|
||||
<li>resourcepath</li>
|
||||
<li>return</li>
|
||||
<li>static</li>
|
||||
<li>switch</li>
|
||||
<li>throw</li>
|
||||
<li>trait</li>
|
||||
<li>try</li>
|
||||
<li>unset</li>
|
||||
<li>use</li>
|
||||
<li>var</li>
|
||||
<li>while</li>
|
||||
<li>xor</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
@@ -195,7 +110,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✓|ToolingExtension
|
||||
|Readme|✗|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
@@ -215,7 +130,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✗|OAS3
|
||||
|Callbacks|✓|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
@@ -234,7 +149,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✗|OAS2,OAS3
|
||||
|Polymorphism|✓|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
@@ -249,9 +164,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
||||
|OAuth2_Password|✓|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
|
||||
|SignatureAuth|✗|OAS3
|
||||
|
||||
### Wire Format Feature
|
||||
@@ -13,7 +13,7 @@
|
||||
devShells.default = pkgs.mkShell
|
||||
{
|
||||
buildInputs = with pkgs;[
|
||||
jdk8
|
||||
jdk11
|
||||
maven
|
||||
];
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -77,8 +77,14 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
|
||||
@Option(name = {"--inline-schema-name-mappings"}, title = "inline schema name mappings", description = "displays the inline schema name mappings (none)")
|
||||
private Boolean inlineSchemaNameMappings;
|
||||
|
||||
@Option(name = {"--inline-schema-name-defaults"}, title = "inline schema name defaults", description = "default values used when naming inline schema name")
|
||||
private Boolean inlineSchemaNameDefaults;
|
||||
@Option(name = {"--inline-schema-options"}, title = "inline schema options", description = "options for handling inline schemas in inline model resolver")
|
||||
private Boolean inlineSchemaOptions;
|
||||
|
||||
@Option(name = {"--name-mappings"}, title = "property name mappings", description = "displays the property name mappings (none)")
|
||||
private Boolean nameMappings;
|
||||
|
||||
@Option(name = {"--parameter-name-mappings"}, title = "parameter name mappings", description = "displays the parameter name mappings (none)")
|
||||
private Boolean parameterNameMappings;
|
||||
|
||||
@Option(name = {"--openapi-normalizer"}, title = "openapi normalizer rules", description = "displays the OpenAPI normalizer rules (none)")
|
||||
private Boolean openapiNormalizer;
|
||||
@@ -485,15 +491,39 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(inlineSchemaNameDefaults)) {
|
||||
sb.append(newline).append("INLINE SCHEMA NAME DEFAULTS").append(newline).append(newline);
|
||||
Map<String, String> map = config.inlineSchemaNameDefault()
|
||||
if (Boolean.TRUE.equals(inlineSchemaOptions)) {
|
||||
sb.append(newline).append("INLINE SCHEMA OPTIONS").append(newline).append(newline);
|
||||
Map<String, String> map = config.inlineSchemaOption()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Duplicated options! %s and %s", a, b));
|
||||
}, TreeMap::new));
|
||||
writePlainTextFromMap(sb, map, optIndent, optNestedIndent, "Inline scheme naming convention", "Defaulted to");
|
||||
writePlainTextFromMap(sb, map, optIndent, optNestedIndent, "Inline scheme options", "Defaulted to");
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(nameMappings)) {
|
||||
sb.append(newline).append("PROPERTY NAME MAPPING").append(newline).append(newline);
|
||||
Map<String, String> map = config.nameMapping()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Duplicated options! %s and %s", a, b));
|
||||
}, TreeMap::new));
|
||||
writePlainTextFromMap(sb, map, optIndent, optNestedIndent, "property name", "Mapped to");
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(parameterNameMappings)) {
|
||||
sb.append(newline).append("PARAMETER NAME MAPPING").append(newline).append(newline);
|
||||
Map<String, String> map = config.parameterNameMapping()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Duplicated options! %s and %s", a, b));
|
||||
}, TreeMap::new));
|
||||
writePlainTextFromMap(sb, map, optIndent, optNestedIndent, "parameter name", "Mapped to");
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,11 +182,25 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
private List<String> inlineSchemaNameMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--inline-schema-name-defaults"},
|
||||
title = "inline schema name defaults",
|
||||
description = "specifies the default values used when naming inline schema as such array items in the format of arrayItemSuffix=_inner,mapItemSuffix=_value. "
|
||||
+ " ONLY arrayItemSuffix, mapItemSuffix are supported at the moment. `SKIP_SCHEMA_REUSE=true` is a special value to skip reusing inline schemas.")
|
||||
private List<String> inlineSchemaNameDefaults = new ArrayList<>();
|
||||
name = {"--inline-schema-options"},
|
||||
title = "inline schema options",
|
||||
description = "specifies the options for handling inline schemas in the inline model resolver."
|
||||
+ " Please refer to https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md for a list of options.")
|
||||
private List<String> inlineSchemaOptions = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--name-mappings"},
|
||||
title = "property name mappings",
|
||||
description = "specifies mappings between the property name and the new name in the format of prop_name=PropName,prop_name2=PropName2."
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> nameMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--parameter-name-mappings"},
|
||||
title = "parameter name mappings",
|
||||
description = "specifies mappings between the parameter name and the new name in the format of param_name=paramName,param_name2=paramName2."
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> parameterNameMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--openapi-normalizer"},
|
||||
@@ -467,7 +481,9 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
applyImportMappingsKvpList(importMappings, configurator);
|
||||
applySchemaMappingsKvpList(schemaMappings, configurator);
|
||||
applyInlineSchemaNameMappingsKvpList(inlineSchemaNameMappings, configurator);
|
||||
applyInlineSchemaNameDefaultsKvpList(inlineSchemaNameDefaults, configurator);
|
||||
applyInlineSchemaOptionsKvpList(inlineSchemaOptions, configurator);
|
||||
applyNameMappingsKvpList(nameMappings, configurator);
|
||||
applyParameterNameMappingsKvpList(parameterNameMappings, configurator);
|
||||
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
|
||||
applyTypeMappingsKvpList(typeMappings, configurator);
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -52,7 +52,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
private final Map<String, String> importMappings;
|
||||
private final Map<String, String> schemaMappings;
|
||||
private final Map<String, String> inlineSchemaNameMappings;
|
||||
private final Map<String, String> inlineSchemaNameDefaults;
|
||||
private final Map<String, String> inlineSchemaOptions;
|
||||
private final Map<String, String> nameMappings;
|
||||
private final Map<String, String> parameterNameMappings;
|
||||
private final Map<String, String> openapiNormalizer;
|
||||
private final Set<String> languageSpecificPrimitives;
|
||||
private final Map<String, String> reservedWordsMappings;
|
||||
@@ -257,12 +259,30 @@ public final class GeneratorSettings implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets inline schema name defaults between an inline schema naming convention and the default values.
|
||||
* Gets inline schema options
|
||||
*
|
||||
* @return the inline schema name defaults
|
||||
* @return the inline schema options
|
||||
*/
|
||||
public Map<String, String> getInlineSchemaNameDefaults() {
|
||||
return inlineSchemaNameDefaults;
|
||||
public Map<String, String> getInlineSchemaOptions() {
|
||||
return inlineSchemaOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets property name mappings between a property name and the new name.
|
||||
*
|
||||
* @return the property name mappings
|
||||
*/
|
||||
public Map<String, String> getNameMappings() {
|
||||
return nameMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets parameter name mappings between a parameter name and the new name.
|
||||
*
|
||||
* @return the parameter name mappings
|
||||
*/
|
||||
public Map<String, String> getParameterNameMappings() {
|
||||
return parameterNameMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,7 +411,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = Collections.unmodifiableMap(builder.importMappings);
|
||||
schemaMappings = Collections.unmodifiableMap(builder.schemaMappings);
|
||||
inlineSchemaNameMappings = Collections.unmodifiableMap(builder.inlineSchemaNameMappings);
|
||||
inlineSchemaNameDefaults = Collections.unmodifiableMap(builder.inlineSchemaNameDefaults);
|
||||
inlineSchemaOptions = Collections.unmodifiableMap(builder.inlineSchemaOptions);
|
||||
nameMappings = Collections.unmodifiableMap(builder.nameMappings);
|
||||
parameterNameMappings = Collections.unmodifiableMap(builder.parameterNameMappings);
|
||||
openapiNormalizer = Collections.unmodifiableMap(builder.openapiNormalizer);
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(builder.languageSpecificPrimitives);
|
||||
reservedWordsMappings = Collections.unmodifiableMap(builder.reservedWordsMappings);
|
||||
@@ -465,7 +487,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
schemaMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
inlineSchemaNameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
inlineSchemaNameDefaults = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
inlineSchemaOptions = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
nameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
parameterNameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
openapiNormalizer = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(new HashSet<>(0));
|
||||
reservedWordsMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
@@ -524,8 +548,14 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (copy.getInlineSchemaNameMappings() != null) {
|
||||
builder.inlineSchemaNameMappings.putAll(copy.getInlineSchemaNameMappings());
|
||||
}
|
||||
if (copy.getInlineSchemaNameDefaults() != null) {
|
||||
builder.inlineSchemaNameDefaults.putAll(copy.getInlineSchemaNameDefaults());
|
||||
if (copy.getInlineSchemaOptions() != null) {
|
||||
builder.inlineSchemaOptions.putAll(copy.getInlineSchemaOptions());
|
||||
}
|
||||
if (copy.getNameMappings() != null) {
|
||||
builder.nameMappings.putAll(copy.getNameMappings());
|
||||
}
|
||||
if (copy.getParameterNameMappings() != null) {
|
||||
builder.parameterNameMappings.putAll(copy.getParameterNameMappings());
|
||||
}
|
||||
if (copy.getOpenAPINormalizer() != null) {
|
||||
builder.openapiNormalizer.putAll(copy.getOpenAPINormalizer());
|
||||
@@ -571,7 +601,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Map<String, String> importMappings;
|
||||
private Map<String, String> schemaMappings;
|
||||
private Map<String, String> inlineSchemaNameMappings;
|
||||
private Map<String, String> inlineSchemaNameDefaults;
|
||||
private Map<String, String> inlineSchemaOptions;
|
||||
private Map<String, String> nameMappings;
|
||||
private Map<String, String> parameterNameMappings;
|
||||
private Map<String, String> openapiNormalizer;
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordsMappings;
|
||||
@@ -592,7 +624,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
importMappings = new HashMap<>();
|
||||
schemaMappings = new HashMap<>();
|
||||
inlineSchemaNameMappings = new HashMap<>();
|
||||
inlineSchemaNameDefaults = new HashMap<>();
|
||||
inlineSchemaOptions = new HashMap<>();
|
||||
nameMappings = new HashMap<>();
|
||||
parameterNameMappings = new HashMap<>();
|
||||
openapiNormalizer = new HashMap<>();
|
||||
languageSpecificPrimitives = new HashSet<>();
|
||||
reservedWordsMappings = new HashMap<>();
|
||||
@@ -863,28 +897,28 @@ public final class GeneratorSettings implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code inlineSchemaNameDefaults} and returns a reference to this Builder so that the methods can be chained together.
|
||||
* Sets the {@code inlineSchemaOptions} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param inlineSchemaNameDefaults the {@code inlineSchemaNameDefaults} to set
|
||||
* @param inlineSchemaOptions the {@code inlineSchemaOptions} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameDefaults(Map<String, String> inlineSchemaNameDefaults) {
|
||||
this.inlineSchemaNameDefaults = inlineSchemaNameDefaults;
|
||||
public Builder withInlineSchemaOptions(Map<String, String> inlineSchemaOptions) {
|
||||
this.inlineSchemaOptions = inlineSchemaOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code inlineSchemaNameDefaults} and returns a reference to this Builder so that the methods can be chained together.
|
||||
* Sets a single {@code inlineSchemaOptions} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key Default naming convention
|
||||
* @param key Inline schema option
|
||||
* @param value The value
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameDefault(String key, String value) {
|
||||
if (this.inlineSchemaNameDefaults == null) {
|
||||
this.inlineSchemaNameDefaults = new HashMap<>();
|
||||
public Builder withInlineSchemaOption(String key, String value) {
|
||||
if (this.inlineSchemaOptions == null) {
|
||||
this.inlineSchemaOptions = new HashMap<>();
|
||||
}
|
||||
this.inlineSchemaNameDefaults.put(key, value);
|
||||
this.inlineSchemaOptions.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -914,6 +948,58 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code nameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param nameMappings the {@code nameMappings} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withNameMappings(Map<String, String> nameMappings) {
|
||||
this.nameMappings = nameMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code nameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for the name mapping
|
||||
* @param value The value of name mapping
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withNameMapping(String key, String value) {
|
||||
if (this.nameMappings == null) {
|
||||
this.nameMappings = new HashMap<>();
|
||||
}
|
||||
this.nameMappings.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code parameterNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param parameterNameMappings the {@code parameterNameMappings} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withParameterNameMappings(Map<String, String> parameterNameMappings) {
|
||||
this.parameterNameMappings = parameterNameMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code parameterNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for the name mapping
|
||||
* @param value The value of name mapping
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withParameterNameMapping(String key, String value) {
|
||||
if (this.parameterNameMappings == null) {
|
||||
this.parameterNameMappings = new HashMap<>();
|
||||
}
|
||||
this.parameterNameMappings.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code openapiNormalizer} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -1127,7 +1213,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getImportMappings(), that.getImportMappings()) &&
|
||||
Objects.equals(getSchemaMappings(), that.getSchemaMappings()) &&
|
||||
Objects.equals(getInlineSchemaNameMappings(), that.getInlineSchemaNameMappings()) &&
|
||||
Objects.equals(getInlineSchemaNameDefaults(), that.getInlineSchemaNameDefaults()) &&
|
||||
Objects.equals(getInlineSchemaOptions(), that.getInlineSchemaOptions()) &&
|
||||
Objects.equals(getNameMappings(), that.getNameMappings()) &&
|
||||
Objects.equals(getParameterNameMappings(), that.getParameterNameMappings()) &&
|
||||
Objects.equals(getOpenAPINormalizer(), that.getOpenAPINormalizer()) &&
|
||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||
Objects.equals(getReservedWordsMappings(), that.getReservedWordsMappings()) &&
|
||||
@@ -1159,7 +1247,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
getImportMappings(),
|
||||
getSchemaMappings(),
|
||||
getInlineSchemaNameMappings(),
|
||||
getInlineSchemaNameDefaults(),
|
||||
getInlineSchemaOptions(),
|
||||
getNameMappings(),
|
||||
getParameterNameMappings(),
|
||||
getOpenAPINormalizer(),
|
||||
getLanguageSpecificPrimitives(),
|
||||
getReservedWordsMappings(),
|
||||
|
||||
@@ -244,10 +244,10 @@ apply plugin: 'org.openapi.generator'
|
||||
|None
|
||||
|specifies mappings between the inline schema name and the new name in the format of inline_object_2=Cat,inline_object_5=Bird.
|
||||
|
||||
|inlineSchemaNameDefaults
|
||||
|inlineSchemaOptions
|
||||
|Map(String,String)
|
||||
|None
|
||||
|specifies the default values used when naming inline schema as such array items in the format of arrayItemSuffix=_inner,mapItemSuffix=_value. ONLY arrayItemSuffix, mapItemSuffix are supported at the moment. `SKIP_SCHEMA_REUSE=true` is a special value to skip reusing inline schemas.
|
||||
|specifies the options used when handling inline schema in inline model resolver
|
||||
|
||||
|additionalProperties
|
||||
|Map(String,Any)
|
||||
|
||||
@@ -3,7 +3,7 @@ import io.github.gradlenexus.publishplugin.ReleaseNexusStagingRepository
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("com.gradle.plugin-publish") version "1.0.0"
|
||||
id("com.gradle.plugin-publish") version "1.1.0"
|
||||
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
|
||||
id("java-gradle-plugin")
|
||||
id("maven-publish")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.0.0-beta
|
||||
openApiGeneratorVersion=7.0.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
@@ -93,6 +93,11 @@
|
||||
<gradleVersion>${gradleVersion}</gradleVersion>
|
||||
<args>
|
||||
<arg>-P openApiGeneratorVersion=${project.version}</arg>
|
||||
<!--
|
||||
<arg>-Psigning.keyId=${env.SIGNING_KEY}</arg>
|
||||
<arg>-Psigning.password=${env.SIGNING_PASSPHRASE}</arg>
|
||||
<arg>-Psigning.secretKeyRingFile=${env.TRAVIS_BUILD_DIR}/sec.gpg</arg>
|
||||
-->
|
||||
</args>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.0.0-beta
|
||||
openApiGeneratorVersion=7.0.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -118,7 +118,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
importMappings.set(generate.importMappings)
|
||||
schemaMappings.set(generate.schemaMappings)
|
||||
inlineSchemaNameMappings.set(generate.inlineSchemaNameMappings)
|
||||
inlineSchemaNameDefaults.set(generate.inlineSchemaNameDefaults)
|
||||
inlineSchemaOptions.set(generate.inlineSchemaOptions)
|
||||
openapiNormalizer.set(generate.openapiNormalizer)
|
||||
invokerPackage.set(generate.invokerPackage)
|
||||
groupId.set(generate.groupId)
|
||||
|
||||
@@ -163,9 +163,19 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
val inlineSchemaNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies default values for inline schema naming convention
|
||||
* Specifies options for inline schemas
|
||||
*/
|
||||
val inlineSchemaNameDefaults = project.objects.mapProperty<String, String>()
|
||||
val inlineSchemaOptions = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between a property name and the new name
|
||||
*/
|
||||
val nameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between a parameter name and the new name
|
||||
*/
|
||||
val parameterNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings (rules) in OpenAPI normalizer
|
||||
|
||||
@@ -266,11 +266,25 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
val inlineSchemaNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies default values for inline schema naming convention
|
||||
* Specifies options for inline schemas
|
||||
*/
|
||||
@Optional
|
||||
@Input
|
||||
val inlineSchemaNameDefaults = project.objects.mapProperty<String, String>()
|
||||
val inlineSchemaOptions = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between the property name and the new name
|
||||
*/
|
||||
@Optional
|
||||
@Input
|
||||
val nameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between the parameter name and the new name
|
||||
*/
|
||||
@Optional
|
||||
@Input
|
||||
val parameterNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings (rules) in OpenAPI normalizer
|
||||
@@ -801,9 +815,21 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
}
|
||||
}
|
||||
|
||||
if (inlineSchemaNameDefaults.isPresent) {
|
||||
inlineSchemaNameDefaults.get().forEach { entry ->
|
||||
configurator.addInlineSchemaNameDefault(entry.key, entry.value)
|
||||
if (inlineSchemaOptions.isPresent) {
|
||||
inlineSchemaOptions.get().forEach { entry ->
|
||||
configurator.addInlineSchemaOption(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (nameMappings.isPresent) {
|
||||
nameMappings.get().forEach { entry ->
|
||||
configurator.addNameMapping(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (parameterNameMappings.isPresent) {
|
||||
parameterNameMappings.get().forEach { entry ->
|
||||
configurator.addParameterNameMapping(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ mvn clean compile
|
||||
| `typeMappings` | `openapi.generator.maven.plugin.typeMappings` | sets mappings between OpenAPI spec types and generated code types in the format of OpenAPIType=generatedType,OpenAPIType=generatedType. For example: `array=List,map=Map,string=String`. You can also have multiple occurrences of this option. To map a specified format, use type+format, e.g. string+password=EncryptedString will map `type: string, format: password` to `EncryptedString`.
|
||||
| `schemaMappings` | `openapi.generator.maven.plugin.schemaMappings` | specifies mappings between the schema and the new name in the format of schema_a=Cat,schema_b=Bird. https://openapi-generator.tech/docs/customization/#schema-mapping
|
||||
| `inlineSchemaNameMappings` | `openapi.generator.maven.plugin.inlineSchemaNameMappings` | specifies mappings between the inline schema name and the new name in the format of inline_object_2=Cat,inline_object_5=Bird.
|
||||
| `inlineSchemaNameDefaults` | `openapi.generator.maven.plugin.inlineSchemaNameDefaults` | specifies the default values used when naming inline schema as such array items in the format of arrayItemSuffix=_inner,mapItemSuffix=_value. ONLY arrayItemSuffix, mapItemSuffix are supported at the moment. `SKIP_SCHEMA_REUSE=true` is a special value to skip reusing inline schemas.
|
||||
| `inlineSchemaOptions` | `openapi.generator.maven.plugin.inlineSchemaOptions` | specifies the options used when naming inline schema in inline model resolver
|
||||
| `languageSpecificPrimitives` | `openapi.generator.maven.plugin.languageSpecificPrimitives` | specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: `String,boolean,Boolean,Double`. You can also have multiple occurrences of this option
|
||||
| `additionalProperties` | `openapi.generator.maven.plugin.additionalProperties` | sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value. You can also have multiple occurrences of this option
|
||||
| `serverVariableOverrides` | `openapi.generator.maven.plugin.serverVariableOverrides` | A map of server variable overrides for specs that support server URL templating
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -327,10 +327,22 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
private List<String> inlineSchemaNameMappings;
|
||||
|
||||
/**
|
||||
* A map of inline scheme naming convention and the value
|
||||
* A map of inline scheme option and the value
|
||||
*/
|
||||
@Parameter(name = "inlineSchemaNameDefaults", property = "openapi.generator.maven.plugin.inlineSchemaNameDefaults")
|
||||
private List<String> inlineSchemaNameDefaults;
|
||||
@Parameter(name = "inlineSchemaOptions", property = "openapi.generator.maven.plugin.inlineSchemaOptions")
|
||||
private List<String> inlineSchemaOptions;
|
||||
|
||||
/**
|
||||
* A map of property names and the new names
|
||||
*/
|
||||
@Parameter(name = "nameMappings", property = "openapi.generator.maven.plugin.nameMappings")
|
||||
private List<String> nameMappings;
|
||||
|
||||
/**
|
||||
* A map of parameter names and the new names
|
||||
*/
|
||||
@Parameter(name = "parameterNameMappings", property = "openapi.generator.maven.plugin.parameterNameMappings")
|
||||
private List<String> parameterNameMappings;
|
||||
|
||||
/**
|
||||
* A set of rules for OpenAPI normalizer
|
||||
@@ -736,9 +748,9 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compatibility with configOptions -> inline-schema-name-defaults
|
||||
if (inlineSchemaNameDefaults == null && configOptions.containsKey("inline-schema-name-defaults")) {
|
||||
applyInlineSchemaNameDefaultsKvp(configOptions.get("inline-schema-name-defaults").toString(),
|
||||
// Retained for backwards-compatibility with configOptions -> inline-schema-options
|
||||
if (inlineSchemaOptions == null && configOptions.containsKey("inline-schema-options")) {
|
||||
applyInlineSchemaOptionsKvp(configOptions.get("inline-schema-options").toString(),
|
||||
configurator);
|
||||
}
|
||||
|
||||
@@ -796,9 +808,19 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
applyInlineSchemaNameMappingsKvpList(inlineSchemaNameMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply Inline Schema Name Defaults
|
||||
if (inlineSchemaNameDefaults != null && (configOptions == null || !configOptions.containsKey("inline-schema-name-defaults"))) {
|
||||
applyInlineSchemaNameDefaultsKvpList(inlineSchemaNameDefaults, configurator);
|
||||
// Apply Inline Schema Options
|
||||
if (inlineSchemaOptions != null && (configOptions == null || !configOptions.containsKey("inline-schema-options"))) {
|
||||
applyInlineSchemaOptionsKvpList(inlineSchemaOptions, configurator);
|
||||
}
|
||||
|
||||
// Apply Name Mappings
|
||||
if (nameMappings != null && (configOptions == null || !configOptions.containsKey("name-mappings"))) {
|
||||
applyNameMappingsKvpList(nameMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply Parameter Name Mappings
|
||||
if (parameterNameMappings != null && (configOptions == null || !configOptions.containsKey("paramter-name-mappings"))) {
|
||||
applyParameterNameMappingsKvpList(parameterNameMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply OpenAPI normalizer rules
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0-beta</version>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -145,7 +145,11 @@ public interface CodegenConfig {
|
||||
|
||||
Map<String, String> inlineSchemaNameMapping();
|
||||
|
||||
Map<String, String> inlineSchemaNameDefault();
|
||||
Map<String, String> inlineSchemaOption();
|
||||
|
||||
Map<String, String> nameMapping();
|
||||
|
||||
Map<String, String> parameterNameMapping();
|
||||
|
||||
Map<String, String> openapiNormalizer();
|
||||
|
||||
|
||||
@@ -172,8 +172,12 @@ public class CodegenConstants {
|
||||
public static final String PACKAGE_COMPANY_DESC = "Specifies an AssemblyCompany for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
|
||||
public static final String PACKAGE_AUTHORS = "packageAuthors";
|
||||
public static final String PACKAGE_AUTHORS_DESC = "Specifies Authors property in the .NET Core project file.";
|
||||
public static final String PACKAGE_AUTHORS_URL = "packageAuthorsUrl";
|
||||
public static final String PACKAGE_AUTHORS_URL_DESC = "Specifies Authors URL property in the PHP composer.json file.";
|
||||
public static final String PACKAGE_COPYRIGHT = "packageCopyright";
|
||||
public static final String PACKAGE_COPYRIGHT_DESC = "Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
|
||||
public static final String COMPOSER_PACKAGE_NAME = "composerPackageName";
|
||||
public static final String COMPOSER_PACKAGE_NAME_DESC = "The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).";
|
||||
|
||||
public static final String POD_VERSION = "podVersion";
|
||||
|
||||
@@ -316,6 +320,9 @@ public class CodegenConstants {
|
||||
public static final String VALIDATABLE = "validatable";
|
||||
public static final String VALIDATABLE_DESC = "Generates self-validatable models.";
|
||||
|
||||
public static final String EQUATABLE = "equatable";
|
||||
public static final String EQUATABLE_DESC = "Overrides Equals and GetHashCode methods.";
|
||||
|
||||
public static final String IGNORE_FILE_OVERRIDE = "ignoreFileOverride";
|
||||
public static final String IGNORE_FILE_OVERRIDE_DESC = "Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.";
|
||||
|
||||
|
||||
@@ -66,7 +66,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public String defaultValue;
|
||||
public String arrayModelType;
|
||||
public boolean isAlias; // Is this effectively an alias of another simple type
|
||||
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isDecimal, isShort, isUnboundedInteger, isPrimitiveType, isBoolean;
|
||||
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime,
|
||||
isDecimal, isShort, isUnboundedInteger, isPrimitiveType, isBoolean, isFreeFormObject;
|
||||
private boolean additionalPropertiesIsAnyType;
|
||||
public List<CodegenProperty> vars = new ArrayList<>(); // all properties (without parent's properties)
|
||||
public List<CodegenProperty> allVars = new ArrayList<>(); // all properties (with parent's properties)
|
||||
@@ -152,6 +153,23 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
*/
|
||||
public boolean isAdditionalPropertiesTrue;
|
||||
|
||||
/**
|
||||
* True if additional properties is set to any type
|
||||
*/
|
||||
public boolean isAdditionalPropertiesAnyType;
|
||||
|
||||
/**
|
||||
* True if additional properties is set to free form object
|
||||
*/
|
||||
public boolean isAdditionalPropertiesFreeFormObject;
|
||||
|
||||
/**
|
||||
* True if additional properties is enabled (boolean or any type)
|
||||
*/
|
||||
public boolean isAdditionalPropertiesEnabled() {
|
||||
return isAdditionalPropertiesTrue || isAdditionalPropertiesAnyType || isAdditionalPropertiesFreeFormObject;
|
||||
}
|
||||
|
||||
private Integer maxProperties;
|
||||
private Integer minProperties;
|
||||
private boolean uniqueItems;
|
||||
@@ -961,6 +979,16 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFreeFormObject() {
|
||||
return isFreeFormObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsFreeFormObject(boolean isFreeFormObject) {
|
||||
this.isFreeFormObject = isFreeFormObject;
|
||||
}
|
||||
|
||||
public boolean getIsUuid() { return isUuid; }
|
||||
|
||||
public void setIsUuid(boolean isUuid) { this.isUuid = isUuid; }
|
||||
@@ -1077,6 +1105,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
Objects.equals(externalDocumentation, that.externalDocumentation) &&
|
||||
Objects.equals(vendorExtensions, that.vendorExtensions) &&
|
||||
Objects.equals(additionalPropertiesType, that.additionalPropertiesType) &&
|
||||
Objects.equals(isAdditionalPropertiesAnyType, that.isAdditionalPropertiesAnyType) &&
|
||||
Objects.equals(isAdditionalPropertiesFreeFormObject, that.isAdditionalPropertiesFreeFormObject) &&
|
||||
Objects.equals(isAdditionalPropertiesTrue, that.isAdditionalPropertiesTrue) &&
|
||||
Objects.equals(getMaxProperties(), that.getMaxProperties()) &&
|
||||
Objects.equals(getMinProperties(), that.getMinProperties()) &&
|
||||
Objects.equals(getMaxItems(), that.getMaxItems()) &&
|
||||
@@ -1110,7 +1141,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping,
|
||||
isAnyType, getComposedSchemas(), hasMultipleTypes, isDecimal, isUuid, requiredVarsMap, ref,
|
||||
uniqueItemsBoolean, schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse,
|
||||
format, dependentRequired, contains);
|
||||
format, dependentRequired, contains, isAdditionalPropertiesTrue, isAdditionalPropertiesFreeFormObject,
|
||||
isAdditionalPropertiesFreeFormObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1216,6 +1248,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
sb.append(", format=").append(format);
|
||||
sb.append(", dependentRequired=").append(dependentRequired);
|
||||
sb.append(", contains=").append(contains);
|
||||
sb.append(", isAdditionalPropertiesAnyType=").append(isAdditionalPropertiesAnyType);
|
||||
sb.append(", isAdditionalPropertiesFreeFormObject=").append(isAdditionalPropertiesFreeFormObject);
|
||||
sb.append(", isAdditionalPropertiesTrue=").append(isAdditionalPropertiesTrue);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -914,6 +914,16 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFreeFormObject() {
|
||||
return isFreeFormObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsFreeFormObject(boolean isFreeFormObject) {
|
||||
this.isFreeFormObject = isFreeFormObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
|
||||
this.composedSchemas = composedSchemas;
|
||||
|
||||
@@ -989,6 +989,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFreeFormObject() {
|
||||
return isFreeFormObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsFreeFormObject(boolean isFreeFormObject) {
|
||||
this.isFreeFormObject = isFreeFormObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasMultipleTypes() {
|
||||
return hasMultipleTypes;
|
||||
|
||||
@@ -734,6 +734,16 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFreeFormObject() {
|
||||
return isFreeFormObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsFreeFormObject(boolean isFreeFormObject) {
|
||||
this.isFreeFormObject = isFreeFormObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
|
||||
this.composedSchemas = composedSchemas;
|
||||
|
||||
@@ -163,7 +163,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// a map to store the mapping between inline schema and the name provided by the user
|
||||
protected Map<String, String> inlineSchemaNameMapping = new HashMap<>();
|
||||
// a map to store the inline schema naming conventions
|
||||
protected Map<String, String> inlineSchemaNameDefault = new HashMap<>();
|
||||
protected Map<String, String> inlineSchemaOption = new HashMap<>();
|
||||
// a map to store the mapping between property name and the name provided by the user
|
||||
protected Map<String, String> nameMapping = new HashMap<>();
|
||||
// a map to store the mapping between parameter name and the name provided by the user
|
||||
protected Map<String, String> parameterNameMapping = new HashMap<>();
|
||||
// a map to store the rules in OpenAPI Normalizer
|
||||
protected Map<String, String> openapiNormalizer = new HashMap<>();
|
||||
protected String modelPackage = "", apiPackage = "", fileSuffix;
|
||||
@@ -201,6 +205,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected int removeOperationIdPrefixCount = 1;
|
||||
protected boolean skipOperationExample;
|
||||
|
||||
protected final static Pattern XML_MIME_PATTERN = Pattern.compile("(?i)application\\/(.*)[+]?xml(;.*)?");
|
||||
protected final static Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)application\\/json(;.*)?");
|
||||
protected final static Pattern JSON_VENDOR_MIME_PATTERN = Pattern.compile("(?i)application\\/vnd.(.*)+json(;.*)?");
|
||||
private static final Pattern COMMON_PREFIX_ENUM_NAME = Pattern.compile("[a-zA-Z0-9]+\\z");
|
||||
@@ -237,7 +242,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected String httpUserAgent;
|
||||
protected Boolean hideGenerationTimestamp = true;
|
||||
// How to encode special characters like $
|
||||
// They are translated to words like "Dollar" and prefixed with '
|
||||
// They are translated to words like "Dollar"
|
||||
// Then translated back during JSON encoding and decoding
|
||||
protected Map<String, String> specialCharReplacements = new LinkedHashMap<>();
|
||||
// When a model is an alias for a simple type
|
||||
@@ -1025,7 +1030,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (e.getKey().contains("/")) {
|
||||
// if this is property schema, we also need to generate the oneOf interface model
|
||||
addOneOfNameExtension((ComposedSchema) s, nOneOf);
|
||||
addOneOfInterfaceModel((ComposedSchema) s, nOneOf, openAPI);
|
||||
addOneOfInterfaceModel((ComposedSchema) s, nOneOf);
|
||||
} else {
|
||||
// else this is a component schema, so we will just use that as the oneOf interface model
|
||||
addOneOfNameExtension((ComposedSchema) s, n);
|
||||
@@ -1034,13 +1039,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Schema items = ((ArraySchema) s).getItems();
|
||||
if (ModelUtils.isComposedSchema(items)) {
|
||||
addOneOfNameExtension((ComposedSchema) items, nOneOf);
|
||||
addOneOfInterfaceModel((ComposedSchema) items, nOneOf, openAPI);
|
||||
addOneOfInterfaceModel((ComposedSchema) items, nOneOf);
|
||||
}
|
||||
} else if (ModelUtils.isMapSchema(s)) {
|
||||
Schema addProps = getAdditionalProperties(s);
|
||||
Schema addProps = ModelUtils.getAdditionalProperties(s);
|
||||
if (addProps != null && ModelUtils.isComposedSchema(addProps)) {
|
||||
addOneOfNameExtension((ComposedSchema) addProps, nOneOf);
|
||||
addOneOfInterfaceModel((ComposedSchema) addProps, nOneOf, openAPI);
|
||||
addOneOfInterfaceModel((ComposedSchema) addProps, nOneOf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1194,8 +1199,18 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> inlineSchemaNameDefault() {
|
||||
return inlineSchemaNameDefault;
|
||||
public Map<String, String> inlineSchemaOption() {
|
||||
return inlineSchemaOption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> nameMapping() {
|
||||
return nameMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> parameterNameMapping() {
|
||||
return parameterNameMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1602,6 +1617,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return the sanitized variable name
|
||||
*/
|
||||
public String toVarName(final String name) {
|
||||
// obtain the name from nameMapping directly if provided
|
||||
if (nameMapping.containsKey(name)) {
|
||||
return nameMapping.get(name);
|
||||
}
|
||||
|
||||
if (reservedWords.contains(name)) {
|
||||
return escapeReservedWord(name);
|
||||
} else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
|
||||
@@ -1619,6 +1639,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// obtain the name from parameterNameMapping directly if provided
|
||||
if (parameterNameMapping.containsKey(name)) {
|
||||
return parameterNameMapping.get(name);
|
||||
}
|
||||
|
||||
name = removeNonNameElementToCamelCase(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
if (reservedWords.contains(name)) {
|
||||
return escapeReservedWord(name);
|
||||
@@ -1951,7 +1976,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
public String toInstantiationType(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
Schema additionalProperties = getAdditionalProperties(schema);
|
||||
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
|
||||
String inner = getSchemaType(additionalProperties);
|
||||
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
@@ -2067,7 +2092,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (content.size() > 1) {
|
||||
// @see ModelUtils.getSchemaFromContent()
|
||||
once(LOGGER).warn("Multiple MediaTypes found, using only the first one");
|
||||
once(LOGGER).debug("Multiple MediaTypes found, using only the first one");
|
||||
}
|
||||
|
||||
MediaType mediaType = content.values().iterator().next();
|
||||
@@ -2274,7 +2299,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
protected Schema<?> getSchemaAdditionalProperties(Schema schema) {
|
||||
Schema<?> inner = getAdditionalProperties(schema);
|
||||
Schema<?> inner = ModelUtils.getAdditionalProperties(schema);
|
||||
if (inner == null) {
|
||||
LOGGER.error("`{}` (map property) does not have a proper inner type defined. Default to type:string", schema.getName());
|
||||
inner = new StringSchema().description("TODO default missing map inner type to string");
|
||||
@@ -2302,7 +2327,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else if (names.size() == 1) {
|
||||
return names.get(0);
|
||||
} else {
|
||||
LOGGER.warn("allOf with multiple schemas defined. Using only the first one: {}", names.get(0));
|
||||
LOGGER.debug("allOf with multiple schemas defined. Using only the first one: {}", names.get(0));
|
||||
return names.get(0);
|
||||
}
|
||||
}
|
||||
@@ -2452,7 +2477,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return schema.getFormat();
|
||||
}
|
||||
return "string";
|
||||
} else if (isFreeFormObject(schema)) {
|
||||
} else if (ModelUtils.isFreeFormObject(schema)) {
|
||||
// Note: the value of a free-form object cannot be an arbitrary type. Per OAS specification,
|
||||
// it must be a map of string to values.
|
||||
return "object";
|
||||
@@ -2662,7 +2687,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
for (Schema innerSchema : composed.getAllOf()) { // TODO need to work with anyOf, oneOf as well
|
||||
if (m.discriminator == null && innerSchema.getDiscriminator() != null) {
|
||||
LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", m.name);
|
||||
m.setDiscriminator(createDiscriminator(m.name, innerSchema, this.openAPI));
|
||||
m.setDiscriminator(createDiscriminator(m.name, innerSchema));
|
||||
modelDiscriminators++;
|
||||
}
|
||||
|
||||
@@ -2854,7 +2879,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
// an object or anyType composed schema that has additionalProperties set
|
||||
addAdditionPropertiesToCodeGenModel(m, schema);
|
||||
} else if (ModelUtils.isFreeFormObject(openAPI, schema)) {
|
||||
} else if (ModelUtils.isFreeFormObject(schema)) {
|
||||
// non-composed object type with no properties + additionalProperties
|
||||
// additionalProperties must be null, ObjectSchema, or empty Schema
|
||||
addAdditionPropertiesToCodeGenModel(m, schema);
|
||||
@@ -3029,7 +3054,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
m.isAlias = (typeAliases.containsKey(name)
|
||||
|| isAliasOfSimpleTypes(schema)); // check if the unaliased schema is an alias of simple OAS types
|
||||
m.setDiscriminator(createDiscriminator(name, schema, this.openAPI));
|
||||
m.setDiscriminator(createDiscriminator(name, schema));
|
||||
|
||||
if (schema.getDeprecated() != null) {
|
||||
m.isDeprecated = schema.getDeprecated();
|
||||
@@ -3142,13 +3167,16 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// if we are trying to set additionalProperties on an empty schema stop recursing
|
||||
return;
|
||||
}
|
||||
|
||||
boolean additionalPropertiesIsAnyType = false;
|
||||
boolean isAdditionalPropertiesTrue = false;
|
||||
boolean isAdditionalPropertiesFreeFormObject = false;
|
||||
|
||||
CodegenModel m = null;
|
||||
if (property instanceof CodegenModel) {
|
||||
m = (CodegenModel) property;
|
||||
}
|
||||
CodegenProperty addPropProp = null;
|
||||
boolean isAdditionalPropertiesTrue = false;
|
||||
if (schema.getAdditionalProperties() == null) {
|
||||
if (!disallowAdditionalPropertiesIfNotPresent) {
|
||||
isAdditionalPropertiesTrue = true;
|
||||
@@ -3158,20 +3186,25 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else if (schema.getAdditionalProperties() instanceof Boolean) {
|
||||
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
|
||||
isAdditionalPropertiesTrue = true;
|
||||
addPropProp = fromProperty(getAdditionalPropertiesName(), new Schema(), false);
|
||||
additionalPropertiesIsAnyType = true;
|
||||
}
|
||||
} else {
|
||||
addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false);
|
||||
if (ModelUtils.isAnyType((Schema) schema.getAdditionalProperties())) {
|
||||
isAdditionalPropertiesTrue = true;
|
||||
additionalPropertiesIsAnyType = true;
|
||||
}
|
||||
|
||||
if (ModelUtils.isFreeFormObject((Schema) schema.getAdditionalProperties())) {
|
||||
isAdditionalPropertiesFreeFormObject = true;
|
||||
}
|
||||
}
|
||||
if (additionalPropertiesIsAnyType) {
|
||||
property.setAdditionalPropertiesIsAnyType(true);
|
||||
}
|
||||
if (m != null && isAdditionalPropertiesTrue) {
|
||||
m.isAdditionalPropertiesTrue = true;
|
||||
if (m != null) {
|
||||
m.isAdditionalPropertiesTrue = isAdditionalPropertiesTrue;
|
||||
m.isAdditionalPropertiesAnyType = additionalPropertiesIsAnyType;
|
||||
m.isAdditionalPropertiesFreeFormObject = isAdditionalPropertiesFreeFormObject;
|
||||
}
|
||||
if (ModelUtils.isComposedSchema(schema) && !supportsAdditionalPropertiesWithComposedSchema) {
|
||||
return;
|
||||
@@ -3385,10 +3418,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param composedSchemaName The String model name of the composed schema where we are setting the discriminator map
|
||||
* @param discPropName The String that is the discriminator propertyName in the schema
|
||||
* @param c The ComposedSchema that contains the discriminator and oneOf/anyOf schemas
|
||||
* @param openAPI The OpenAPI spec that we are using
|
||||
* @return the list of oneOf and anyOf MappedModel that need to be added to the discriminator map
|
||||
*/
|
||||
protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName, String discPropName, ComposedSchema c, OpenAPI openAPI) {
|
||||
protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName, String discPropName, ComposedSchema c) {
|
||||
ArrayList<List<Schema>> listOLists = new ArrayList<>();
|
||||
listOLists.add(c.getOneOf());
|
||||
listOLists.add(c.getAnyOf());
|
||||
@@ -3452,7 +3484,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return descendentSchemas;
|
||||
}
|
||||
|
||||
protected List<MappedModel> getAllOfDescendants(String thisSchemaName, OpenAPI openAPI) {
|
||||
protected List<MappedModel> getAllOfDescendants(String thisSchemaName) {
|
||||
ArrayList<String> queue = new ArrayList();
|
||||
List<MappedModel> descendentSchemas = new ArrayList();
|
||||
Map<String, Schema> schemas = ModelUtils.getSchemas(openAPI);
|
||||
@@ -3508,7 +3540,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return descendentSchemas;
|
||||
}
|
||||
|
||||
protected CodegenDiscriminator createDiscriminator(String schemaName, Schema schema, OpenAPI openAPI) {
|
||||
protected CodegenDiscriminator createDiscriminator(String schemaName, Schema schema) {
|
||||
Discriminator sourceDiscriminator = recursiveGetDiscriminator(schema, new ArrayList<Schema>());
|
||||
if (sourceDiscriminator == null) {
|
||||
return null;
|
||||
@@ -3563,7 +3595,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
boolean legacyUseCase = (this.getLegacyDiscriminatorBehavior() && uniqueDescendants.isEmpty());
|
||||
if (!this.getLegacyDiscriminatorBehavior() || legacyUseCase) {
|
||||
// for schemas that allOf inherit from this schema, add those descendants to this discriminator map
|
||||
List<MappedModel> otherDescendants = getAllOfDescendants(schemaName, openAPI);
|
||||
List<MappedModel> otherDescendants = getAllOfDescendants(schemaName);
|
||||
for (MappedModel otherDescendant : otherDescendants) {
|
||||
// add only if the mapping names are not the same and the model names are not the same
|
||||
boolean matched = false;
|
||||
@@ -3582,7 +3614,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
// if there are composed oneOf/anyOf schemas, add them to this discriminator
|
||||
if (ModelUtils.isComposedSchema(schema) && !this.getLegacyDiscriminatorBehavior()) {
|
||||
List<MappedModel> otherDescendants = getOneOfAnyOfDescendants(schemaName, discriminatorPropertyName, (ComposedSchema) schema, openAPI);
|
||||
List<MappedModel> otherDescendants = getOneOfAnyOfDescendants(schemaName, discriminatorPropertyName, (ComposedSchema) schema);
|
||||
for (MappedModel otherDescendant : otherDescendants) {
|
||||
if (!uniqueDescendants.contains(otherDescendant)) {
|
||||
uniqueDescendants.add(otherDescendant);
|
||||
@@ -3686,7 +3718,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.maxItems = p.getMaxProperties();
|
||||
|
||||
// handle inner property
|
||||
Schema innerSchema = unaliasSchema(getAdditionalProperties(p));
|
||||
Schema innerSchema = unaliasSchema(ModelUtils.getAdditionalProperties(p));
|
||||
if (innerSchema == null) {
|
||||
LOGGER.error("Undefined map inner type for `{}`. Default to String.", p.getName());
|
||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
@@ -3697,7 +3729,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
protected void updatePropertyForObject(CodegenProperty property, Schema p) {
|
||||
if (isFreeFormObject(p)) {
|
||||
if (ModelUtils.isFreeFormObject(p)) {
|
||||
// non-composed object type with no properties + additionalProperties
|
||||
// additionalProperties must be null, ObjectSchema, or empty Schema
|
||||
property.isFreeFormObject = true;
|
||||
@@ -3951,7 +3983,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Schema referencedSchema = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||
|
||||
//Referenced enum case:
|
||||
if (referencedSchema.getEnum() != null && !referencedSchema.getEnum().isEmpty()) {
|
||||
if (referencedSchema != p && referencedSchema.getEnum() != null && !referencedSchema.getEnum().isEmpty()) {
|
||||
List<Object> _enum = referencedSchema.getEnum();
|
||||
|
||||
property.isEnumRef = true;
|
||||
@@ -4056,7 +4088,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
!ModelUtils.isComposedSchema(p) &&
|
||||
p.getAdditionalProperties() == null && p.getNot() == null && p.getEnum() == null);
|
||||
|
||||
if (!ModelUtils.isArraySchema(p) && !ModelUtils.isMapSchema(p) && !isFreeFormObject(p) && !isAnyTypeWithNothingElseSet) {
|
||||
if (!ModelUtils.isArraySchema(p) && !ModelUtils.isMapSchema(p) && !ModelUtils.isFreeFormObject(p) && !isAnyTypeWithNothingElseSet) {
|
||||
/* schemas that are not Array, not ModelUtils.isMapSchema, not isFreeFormObject, not AnyType with nothing else set
|
||||
* so primitive schemas int, str, number, referenced schemas, AnyType schemas with properties, enums, or composition
|
||||
*/
|
||||
@@ -4323,7 +4355,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as), false);
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", getAdditionalProperties(responseSchema), false);
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema), false);
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else {
|
||||
if (cm.complexType != null) {
|
||||
@@ -4874,7 +4906,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
r.isDouble = Boolean.TRUE;
|
||||
}
|
||||
} else if (ModelUtils.isTypeObjectSchema(responseSchema)) {
|
||||
if (ModelUtils.isFreeFormObject(openAPI, responseSchema)) {
|
||||
if (ModelUtils.isFreeFormObject(responseSchema)) {
|
||||
r.isFreeFormObject = true;
|
||||
} else {
|
||||
r.isModel = true;
|
||||
@@ -4985,7 +5017,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
|
||||
private void updateParameterForMap(CodegenParameter codegenParameter, Schema parameterSchema, Set<String> imports) {
|
||||
CodegenProperty codegenProperty = fromProperty("inner", getAdditionalProperties(parameterSchema), false);
|
||||
CodegenProperty codegenProperty = fromProperty("inner", ModelUtils.getAdditionalProperties(parameterSchema), false);
|
||||
codegenParameter.items = codegenProperty;
|
||||
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
|
||||
codegenParameter.baseType = codegenProperty.dataType;
|
||||
@@ -5177,7 +5209,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isMapSchema(parameterSchema)) { // for map parameter
|
||||
updateParameterForMap(codegenParameter, parameterSchema, imports);
|
||||
}
|
||||
if (ModelUtils.isFreeFormObject(openAPI, parameterSchema)) {
|
||||
if (ModelUtils.isFreeFormObject(parameterSchema)) {
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
}
|
||||
addVarsRequiredVarsAdditionalProps(parameterSchema, codegenParameter);
|
||||
@@ -6717,6 +6749,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
continue;
|
||||
} else {
|
||||
mediaType.put("mediaType", escapeQuotationMark(key));
|
||||
if (isJsonMimeType(key)) {
|
||||
mediaType.put("isJson", "true");
|
||||
} else if (isXmlMimeType(key)) {
|
||||
mediaType.put("isXml", "true");
|
||||
}
|
||||
}
|
||||
mediaTypeList.add(mediaType);
|
||||
}
|
||||
@@ -6736,7 +6773,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return requestBody.getContent().keySet();
|
||||
}
|
||||
|
||||
public boolean hasFormParameter(OpenAPI openAPI, Operation operation) {
|
||||
public boolean hasFormParameter(Operation operation) {
|
||||
Set<String> consumesInfo = getConsumesInfo(openAPI, operation);
|
||||
|
||||
if (consumesInfo == null || consumesInfo.isEmpty()) {
|
||||
@@ -6754,7 +6791,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBodyParameter(OpenAPI openAPI, Operation operation) {
|
||||
public boolean hasBodyParameter(Operation operation) {
|
||||
RequestBody requestBody = ModelUtils.getReferencedRequestBody(openAPI, operation.getRequestBody());
|
||||
if (requestBody == null) {
|
||||
return false;
|
||||
@@ -6787,6 +6824,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (!existingMediaTypes.contains(encodedKey)) {
|
||||
Map<String, String> mediaType = new HashMap<>();
|
||||
mediaType.put("mediaType", encodedKey);
|
||||
if (isJsonMimeType(encodedKey)) {
|
||||
mediaType.put("isJson", "true");
|
||||
} else if (isXmlMimeType(encodedKey)) {
|
||||
mediaType.put("isXml", "true");
|
||||
}
|
||||
codegenOperation.produces.add(mediaType);
|
||||
codegenOperation.hasProduces = Boolean.TRUE;
|
||||
}
|
||||
@@ -6976,7 +7018,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isTypeObjectSchema(ps)) {
|
||||
if (ModelUtils.isFreeFormObject(openAPI, ps)) {
|
||||
if (ModelUtils.isFreeFormObject(ps)) {
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
}
|
||||
} else if (ModelUtils.isNullType(ps)) {
|
||||
@@ -7146,7 +7188,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isGenerateAliasAsModel(schema) && StringUtils.isNotBlank(name)) {
|
||||
this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true);
|
||||
} else {
|
||||
Schema inner = getAdditionalProperties(schema);
|
||||
Schema inner = ModelUtils.getAdditionalProperties(schema);
|
||||
if (inner == null) {
|
||||
LOGGER.error("No inner type supplied for map parameter `{}`. Default to type:string", schema.getName());
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator");
|
||||
@@ -7213,7 +7255,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
// Schema with additionalproperties: true (including composed schemas with additionalproperties: true)
|
||||
updateRequestBodyForMap(codegenParameter, schema, name, imports, bodyParameterName);
|
||||
} else if (isFreeFormObject(schema)) {
|
||||
} else if (ModelUtils.isFreeFormObject(schema)) {
|
||||
// non-composed object type with no properties + additionalProperties
|
||||
// additionalProperties must be null, ObjectSchema, or empty Schema
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
@@ -7869,16 +7911,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*
|
||||
* @param cs ComposedSchema object to create as interface model
|
||||
* @param type name to use for the generated interface model
|
||||
* @param openAPI OpenAPI spec that we are using
|
||||
*/
|
||||
public void addOneOfInterfaceModel(ComposedSchema cs, String type, OpenAPI openAPI) {
|
||||
public void addOneOfInterfaceModel(ComposedSchema cs, String type) {
|
||||
if (cs.getOneOf() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CodegenModel cm = new CodegenModel();
|
||||
|
||||
cm.setDiscriminator(createDiscriminator("", cs, openAPI));
|
||||
cm.setDiscriminator(createDiscriminator("", cs));
|
||||
|
||||
for (Schema o : Optional.ofNullable(cs.getOneOf()).orElse(Collections.emptyList())) {
|
||||
if (o.get$ref() == null) {
|
||||
@@ -7987,7 +8028,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isFreeFormObject(schema)) {
|
||||
if (ModelUtils.isFreeFormObject(schema)) {
|
||||
// make sure it's not free form object
|
||||
return false;
|
||||
}
|
||||
@@ -8003,60 +8044,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the schema is a free form object.
|
||||
*
|
||||
* A free form object is an object (i.e. 'type: object' in a OAS document) that:
|
||||
* 1) Does not define properties, and
|
||||
* 2) Is not a composed schema (no anyOf, oneOf, allOf), and
|
||||
* 3) additionalproperties is not defined, or additionalproperties: true, or additionalproperties: {}.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* components:
|
||||
* schemas:
|
||||
* arbitraryObject:
|
||||
* type: object
|
||||
* description: This is a free-form object.
|
||||
* The value must be a map of strings to values. The value cannot be 'null'.
|
||||
* It cannot be array, string, integer, number.
|
||||
* arbitraryNullableObject:
|
||||
* type: object
|
||||
* description: This is a free-form object.
|
||||
* The value must be a map of strings to values. The value can be 'null',
|
||||
* It cannot be array, string, integer, number.
|
||||
* nullable: true
|
||||
* arbitraryTypeValue:
|
||||
* description: This is NOT a free-form object.
|
||||
* The value can be any type except the 'null' value.
|
||||
*
|
||||
* @param schema potentially containing a '$ref'
|
||||
* @return true if it's a free-form object
|
||||
*/
|
||||
protected boolean isFreeFormObject(Schema schema) {
|
||||
// TODO remove this method and replace all usages with ModelUtils.isFreeFormObject
|
||||
return ModelUtils.isFreeFormObject(this.openAPI, schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the additionalProperties Schema for the specified input schema.
|
||||
* <p>
|
||||
* The additionalProperties keyword is used to control the handling of additional, undeclared
|
||||
* properties, that is, properties whose names are not listed in the properties keyword.
|
||||
* The additionalProperties keyword may be either a boolean or an object.
|
||||
* If additionalProperties is a boolean and set to false, no additional properties are allowed.
|
||||
* By default when the additionalProperties keyword is not specified in the input schema,
|
||||
* any additional properties are allowed. This is equivalent to setting additionalProperties
|
||||
* to the boolean value True or setting additionalProperties: {}
|
||||
*
|
||||
* @param schema the input schema that may or may not have the additionalProperties keyword.
|
||||
* @return the Schema of the additionalProperties. The null value is returned if no additional
|
||||
* properties are allowed.
|
||||
*/
|
||||
protected Schema getAdditionalProperties(Schema schema) {
|
||||
return ModelUtils.getAdditionalProperties(openAPI, schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
@@ -8067,10 +8054,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param mime MIME string
|
||||
* @return true if the input matches the JSON MIME
|
||||
*/
|
||||
protected static boolean isJsonMimeType(String mime) {
|
||||
public static boolean isJsonMimeType(String mime) {
|
||||
return mime != null && (JSON_MIME_PATTERN.matcher(mime).matches());
|
||||
}
|
||||
|
||||
public static boolean isXmlMimeType(String mime) {
|
||||
return mime != null && (XML_MIME_PATTERN.matcher(mime).matches());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON Vendor MIME.
|
||||
* JSON MIME examples:
|
||||
|
||||
@@ -269,7 +269,7 @@ public class DefaultGenerator implements Generator {
|
||||
if (config.getUseInlineModelResolver()) {
|
||||
InlineModelResolver inlineModelResolver = new InlineModelResolver();
|
||||
inlineModelResolver.setInlineSchemaNameMapping(config.inlineSchemaNameMapping());
|
||||
inlineModelResolver.setInlineSchemaNameDefaults(config.inlineSchemaNameDefault());
|
||||
inlineModelResolver.setInlineSchemaOptions(config.inlineSchemaOption());
|
||||
|
||||
inlineModelResolver.flatten(openAPI);
|
||||
}
|
||||
@@ -488,7 +488,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
Schema schema = schemas.get(name);
|
||||
|
||||
if (ModelUtils.isFreeFormObject(this.openAPI, schema)) { // check to see if it's a free-form object
|
||||
if (ModelUtils.isFreeFormObject(schema)) { // check to see if it's a free-form object
|
||||
// there are 3 free form use cases
|
||||
// 1. free form with no validation that is not allOf included in any composed schemas
|
||||
// 2. free form with validation
|
||||
|
||||
@@ -189,6 +189,10 @@ public interface IJsonSchemaValidationProperties {
|
||||
|
||||
void setIsAnyType(boolean isAnyType);
|
||||
|
||||
boolean getIsFreeFormObject();
|
||||
|
||||
void setIsFreeFormObject(boolean isFreeFormObject);
|
||||
|
||||
String getRef();
|
||||
|
||||
void setRef(String ref);
|
||||
@@ -223,14 +227,12 @@ public interface IJsonSchemaValidationProperties {
|
||||
* Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance
|
||||
* for now this only supports types without format information
|
||||
* TODO: in the future move the format handling in here too
|
||||
*
|
||||
* @param p the schema which contains the type info
|
||||
*/
|
||||
default void setTypeProperties(Schema p) {
|
||||
if (ModelUtils.isTypeObjectSchema(p)) {
|
||||
setIsMap(true);
|
||||
if (ModelUtils.isModelWithPropertiesOnly(p)) {
|
||||
setIsModel(true);
|
||||
}
|
||||
if (ModelUtils.isModelWithPropertiesOnly(p)) {
|
||||
setIsModel(true);
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
setIsArray(true);
|
||||
} else if (ModelUtils.isFileSchema(p) && !ModelUtils.isStringSchema(p)) {
|
||||
@@ -252,7 +254,7 @@ public interface IJsonSchemaValidationProperties {
|
||||
} else if (ModelUtils.isEmailSchema(p)) {
|
||||
;
|
||||
} else if (ModelUtils.isPasswordSchema(p)) {
|
||||
;
|
||||
;
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
;
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
@@ -282,9 +284,12 @@ public interface IJsonSchemaValidationProperties {
|
||||
setIsNull(true);
|
||||
} else if (ModelUtils.isAnyType(p)) {
|
||||
setIsAnyType(true);
|
||||
if (ModelUtils.isModelWithPropertiesOnly(p)) {
|
||||
setIsModel(true);
|
||||
}
|
||||
} else if (ModelUtils.isFreeFormObject(p)) {
|
||||
setIsFreeFormObject(true);
|
||||
// TODO: remove below later after updating generators to properly use isFreeFormObject
|
||||
setIsMap(true);
|
||||
} else if (ModelUtils.isTypeObjectSchema(p)) {
|
||||
setIsMap(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,21 +298,21 @@ public interface IJsonSchemaValidationProperties {
|
||||
*/
|
||||
default String getBaseType() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return complex type that can contain type parameters - like {@code List<Items>} for Java
|
||||
*/
|
||||
default String getComplexType() {
|
||||
return getBaseType();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively collect all necessary imports to include so that the type may be resolved.
|
||||
*
|
||||
* @param importContainerType whether or not to include the container types in the returned imports.
|
||||
* @param importBaseType whether or not to include the base types in the returned imports.
|
||||
* @param featureSet the generator feature set, used to determine if composed schemas should be added
|
||||
* @param importBaseType whether or not to include the base types in the returned imports.
|
||||
* @param featureSet the generator feature set, used to determine if composed schemas should be added
|
||||
* @return all of the imports
|
||||
*/
|
||||
default Set<String> getImports(boolean importContainerType, boolean importBaseType, FeatureSet featureSet) {
|
||||
|
||||
@@ -30,20 +30,19 @@ 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.oas.models.responses.ApiResponses;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InlineModelResolver {
|
||||
private OpenAPI openAPI;
|
||||
private Map<String, Schema> addedModels = new HashMap<>();
|
||||
private Map<String, String> generatedSignature = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameMapping = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameDefaults = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaOptions = new HashMap<>();
|
||||
private Set<String> inlineSchemaNameMappingValues = new HashSet<>();
|
||||
public boolean resolveInlineEnums = false;
|
||||
public boolean skipSchemaReuse = false; // skip reusing inline schema if set to true
|
||||
@@ -65,8 +64,8 @@ public class InlineModelResolver {
|
||||
final Logger LOGGER = LoggerFactory.getLogger(InlineModelResolver.class);
|
||||
|
||||
public InlineModelResolver() {
|
||||
this.inlineSchemaNameDefaults.put("arrayItemSuffix", "_inner");
|
||||
this.inlineSchemaNameDefaults.put("mapItemSuffix", "_value");
|
||||
this.inlineSchemaOptions.put("ARRAY_ITEM_SUFFIX", "_inner");
|
||||
this.inlineSchemaOptions.put("MAP_ITEM_SUFFIX", "_value");
|
||||
}
|
||||
|
||||
public void setInlineSchemaNameMapping(Map inlineSchemaNameMapping) {
|
||||
@@ -74,20 +73,22 @@ public class InlineModelResolver {
|
||||
this.inlineSchemaNameMappingValues = new HashSet<>(inlineSchemaNameMapping.values());
|
||||
}
|
||||
|
||||
public void setInlineSchemaNameDefaults(Map inlineSchemaNameDefaults) {
|
||||
this.inlineSchemaNameDefaults.putAll(inlineSchemaNameDefaults);
|
||||
public void setInlineSchemaOptions(Map inlineSchemaOptions) {
|
||||
this.inlineSchemaOptions.putAll(inlineSchemaOptions);
|
||||
|
||||
if ("true".equalsIgnoreCase(
|
||||
this.inlineSchemaNameDefaults.getOrDefault("SKIP_SCHEMA_REUSE", "false"))) {
|
||||
this.inlineSchemaOptions.getOrDefault("SKIP_SCHEMA_REUSE", "false"))) {
|
||||
this.skipSchemaReuse = true;
|
||||
}
|
||||
|
||||
if (this.inlineSchemaNameDefaults.containsKey("REFACTOR_ALLOF_INLINE_SCHEMAS")) {
|
||||
if (Boolean.valueOf(this.inlineSchemaNameDefaults.get("REFACTOR_ALLOF_INLINE_SCHEMAS"))) {
|
||||
this.refactorAllOfInlineSchemas = true;
|
||||
} else { // set to false
|
||||
this.refactorAllOfInlineSchemas = false;
|
||||
}
|
||||
if (this.inlineSchemaOptions.containsKey("REFACTOR_ALLOF_INLINE_SCHEMAS")) {
|
||||
this.refactorAllOfInlineSchemas = Boolean.valueOf(this.inlineSchemaOptions.get("REFACTOR_ALLOF_INLINE_SCHEMAS"));
|
||||
} else {
|
||||
// not set so default to null;
|
||||
}
|
||||
|
||||
if (this.inlineSchemaOptions.containsKey("RESOLVE_INLINE_ENUMS")) {
|
||||
this.resolveInlineEnums = Boolean.valueOf(this.inlineSchemaOptions.get("RESOLVE_INLINE_ENUMS"));
|
||||
} else {
|
||||
// not set so default to null;
|
||||
}
|
||||
@@ -232,6 +233,9 @@ public class InlineModelResolver {
|
||||
if (m.equals(c)) {
|
||||
return isModelNeeded(m.getAllOf().get(0), visitedSchemas);
|
||||
}
|
||||
} else if (isSingleAllOf && StringUtils.isNotEmpty(m.getAllOf().get(0).get$ref())) {
|
||||
// single allOf and it's a ref
|
||||
return isModelNeeded(m.getAllOf().get(0), visitedSchemas);
|
||||
}
|
||||
|
||||
if (m.getAllOf() != null && !m.getAllOf().isEmpty()) {
|
||||
@@ -306,7 +310,7 @@ public class InlineModelResolver {
|
||||
if (schema.getAdditionalProperties() != null) {
|
||||
if (schema.getAdditionalProperties() instanceof Schema) {
|
||||
Schema inner = (Schema) schema.getAdditionalProperties();
|
||||
String schemaName = resolveModelName(schema.getTitle(), modelPrefix + this.inlineSchemaNameDefaults.get("mapItemSuffix"));
|
||||
String schemaName = resolveModelName(schema.getTitle(), modelPrefix + this.inlineSchemaOptions.get("MAP_ITEM_SUFFIX"));
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(inner, schemaName);
|
||||
if (isModelNeeded(inner)) {
|
||||
@@ -341,7 +345,7 @@ public class InlineModelResolver {
|
||||
" items must be defined for array schemas:\n " + schema.toString());
|
||||
return;
|
||||
}
|
||||
String schemaName = resolveModelName(items.getTitle(), modelPrefix + this.inlineSchemaNameDefaults.get("arrayItemSuffix"));
|
||||
String schemaName = resolveModelName(items.getTitle(), modelPrefix + this.inlineSchemaOptions.get("ARRAY_ITEM_SUFFIX"));
|
||||
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(items, schemaName);
|
||||
@@ -679,7 +683,7 @@ public class InlineModelResolver {
|
||||
* @return if provided the sanitized {@code title}, else the sanitized {@code key}
|
||||
*/
|
||||
private String resolveModelName(String title, String modelName) {
|
||||
if (title == null) {
|
||||
if (title == null || "".equals(sanitizeName(title).replace("_", ""))) {
|
||||
if (modelName == null) {
|
||||
return uniqueName("inline_object");
|
||||
}
|
||||
@@ -798,7 +802,7 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isMapSchema(property)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(openAPI, property);
|
||||
Schema inner = ModelUtils.getAdditionalProperties(property);
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
|
||||
@@ -70,7 +70,9 @@ public class CodegenConfigurator {
|
||||
private Map<String, String> importMappings = new HashMap<>();
|
||||
private Map<String, String> schemaMappings = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameMappings = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameDefaults = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaOptions = new HashMap<>();
|
||||
private Map<String, String> nameMappings = new HashMap<>();
|
||||
private Map<String, String> parameterNameMappings = new HashMap<>();
|
||||
private Map<String, String> openapiNormalizer = new HashMap<>();
|
||||
private Set<String> languageSpecificPrimitives = new HashSet<>();
|
||||
private Map<String, String> reservedWordsMappings = new HashMap<>();
|
||||
@@ -121,8 +123,14 @@ public class CodegenConfigurator {
|
||||
if(generatorSettings.getInlineSchemaNameMappings() != null) {
|
||||
configurator.inlineSchemaNameMappings.putAll(generatorSettings.getInlineSchemaNameMappings());
|
||||
}
|
||||
if(generatorSettings.getInlineSchemaNameDefaults() != null) {
|
||||
configurator.inlineSchemaNameDefaults.putAll(generatorSettings.getInlineSchemaNameDefaults());
|
||||
if(generatorSettings.getInlineSchemaOptions() != null) {
|
||||
configurator.inlineSchemaOptions.putAll(generatorSettings.getInlineSchemaOptions());
|
||||
}
|
||||
if(generatorSettings.getNameMappings() != null) {
|
||||
configurator.nameMappings.putAll(generatorSettings.getNameMappings());
|
||||
}
|
||||
if(generatorSettings.getParameterNameMappings() != null) {
|
||||
configurator.parameterNameMappings.putAll(generatorSettings.getParameterNameMappings());
|
||||
}
|
||||
if(generatorSettings.getOpenAPINormalizer() != null) {
|
||||
configurator.openapiNormalizer.putAll(generatorSettings.getOpenAPINormalizer());
|
||||
@@ -208,9 +216,21 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addInlineSchemaNameDefault(String key, String value) {
|
||||
this.inlineSchemaNameDefaults.put(key, value);
|
||||
generatorSettingsBuilder.withInlineSchemaNameDefault(key, value);
|
||||
public CodegenConfigurator addInlineSchemaOption(String key, String value) {
|
||||
this.inlineSchemaOptions.put(key, value);
|
||||
generatorSettingsBuilder.withInlineSchemaOption(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addNameMapping(String key, String value) {
|
||||
this.nameMappings.put(key, value);
|
||||
generatorSettingsBuilder.withNameMapping(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addParameterNameMapping(String key, String value) {
|
||||
this.parameterNameMappings.put(key, value);
|
||||
generatorSettingsBuilder.withParameterNameMapping(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -386,9 +406,21 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setInlineSchemaNameDefaults(Map<String, String> inlineSchemaNameDefaults) {
|
||||
this.inlineSchemaNameDefaults = inlineSchemaNameDefaults;
|
||||
generatorSettingsBuilder.withInlineSchemaNameDefaults(inlineSchemaNameDefaults);
|
||||
public CodegenConfigurator setInlineSchemaOptions(Map<String, String> inlineSchemaOptions) {
|
||||
this.inlineSchemaOptions = inlineSchemaOptions;
|
||||
generatorSettingsBuilder.withInlineSchemaOptions(inlineSchemaOptions);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setNameMappings(Map<String, String> nameMappings) {
|
||||
this.nameMappings = nameMappings;
|
||||
generatorSettingsBuilder.withNameMappings(nameMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setParameterNameMappings(Map<String, String> parameterNameMappings) {
|
||||
this.parameterNameMappings = parameterNameMappings;
|
||||
generatorSettingsBuilder.withParameterNameMappings(parameterNameMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -676,7 +708,9 @@ public class CodegenConfigurator {
|
||||
config.importMapping().putAll(generatorSettings.getImportMappings());
|
||||
config.schemaMapping().putAll(generatorSettings.getSchemaMappings());
|
||||
config.inlineSchemaNameMapping().putAll(generatorSettings.getInlineSchemaNameMappings());
|
||||
config.inlineSchemaNameDefault().putAll(generatorSettings.getInlineSchemaNameDefaults());
|
||||
config.inlineSchemaOption().putAll(generatorSettings.getInlineSchemaOptions());
|
||||
config.nameMapping().putAll(generatorSettings.getNameMappings());
|
||||
config.parameterNameMapping().putAll(generatorSettings.getParameterNameMappings());
|
||||
config.openapiNormalizer().putAll(generatorSettings.getOpenAPINormalizer());
|
||||
config.languageSpecificPrimitives().addAll(generatorSettings.getLanguageSpecificPrimitives());
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordsMappings());
|
||||
|
||||
@@ -107,16 +107,42 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyInlineSchemaNameDefaultsKvpList(List<String> inlineSchemaNameDefaults, CodegenConfigurator configurator) {
|
||||
for (String propString : inlineSchemaNameDefaults) {
|
||||
applyInlineSchemaNameDefaultsKvp(propString, configurator);
|
||||
public static void applyInlineSchemaOptionsKvpList(List<String> inlineSchemaOptions, CodegenConfigurator configurator) {
|
||||
for (String propString : inlineSchemaOptions) {
|
||||
applyInlineSchemaOptionsKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyInlineSchemaNameDefaultsKvp(String inlineSchemaNameDefaults, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(inlineSchemaNameDefaults);
|
||||
public static void applyInlineSchemaOptionsKvp(String inlineSchemaOptions, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(inlineSchemaOptions);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addInlineSchemaNameDefault(entry.getKey().trim(), entry.getValue().trim());
|
||||
configurator.addInlineSchemaOption(entry.getKey().trim(), entry.getValue().trim());
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyNameMappingsKvpList(List<String> nameMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : nameMappings) {
|
||||
applyNameMappingsKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyNameMappingsKvp(String nameMappings, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(nameMappings);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addNameMapping(entry.getKey().trim(), entry.getValue().trim());
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyParameterNameMappingsKvpList(List<String> parameterNameMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : parameterNameMappings) {
|
||||
applyParameterNameMappingsKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyParameterNameMappingsKvp(String parameterNameMappings, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(parameterNameMappings);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addParameterNameMapping(entry.getKey().trim(), entry.getValue().trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -269,10 +269,10 @@ public class ExampleGenerator {
|
||||
Map<String, Object> mp = new HashMap<String, Object>();
|
||||
if (property.getName() != null) {
|
||||
mp.put(property.getName(),
|
||||
resolvePropertyToExample(propertyName, mediaType, ModelUtils.getAdditionalProperties(openAPI, property), processedModels));
|
||||
resolvePropertyToExample(propertyName, mediaType, ModelUtils.getAdditionalProperties(property), processedModels));
|
||||
} else {
|
||||
mp.put("key",
|
||||
resolvePropertyToExample(propertyName, mediaType, ModelUtils.getAdditionalProperties(openAPI, property), processedModels));
|
||||
resolvePropertyToExample(propertyName, mediaType, ModelUtils.getAdditionalProperties(property), processedModels));
|
||||
}
|
||||
return mp;
|
||||
} else if (ModelUtils.isUUIDSchema(property)) {
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.ClientModificationFeature;
|
||||
@@ -42,6 +42,8 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
|
||||
@@ -53,16 +55,64 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
public static final String HTTP_SUPPORT_OPTION = "httpSupport";
|
||||
public static final String OPENAPI_PACKAGE_NAME_OPTION = "openApiName";
|
||||
|
||||
// Common media types.
|
||||
private static final String APPLICATION_XML = "application/xml";
|
||||
private static final String TEXT_XML = "text/xml";
|
||||
private static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
|
||||
private static final String TEXT_PLAIN = "text/plain";
|
||||
private static final String APPLICATION_JSON = "application/json";
|
||||
private static final String APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
||||
|
||||
// RFC 7807 Support
|
||||
private static final String APPLICATION_PROBLEM_JSON = "application/problem+json";
|
||||
private static final String APPLICATION_PROBLEM_XML = "application/problem+xml";
|
||||
|
||||
// RFC 7386 support
|
||||
private static final String APPLICATION_MERGE_PATCH_JSON = "application/merge-patch+json";
|
||||
|
||||
// Extension attributes used by the Ada code generator
|
||||
// "x-ada-type-name" allows to override the name generated for a type/object.
|
||||
// It can be a full qualified Ada type name and the type can be defined in an external package.
|
||||
// In that case, we don't generate the Ada type but use its external definition. Only the
|
||||
// Serialize/Deserialize are generated in the model. If there is an inconsistency, this will
|
||||
// be detected at compilation time.
|
||||
// "x-ada-no-vector" instructs to not instantiate the Vectors package for the given model type.
|
||||
// "x-ada-serialize-op" allows to control the name of the serialize operation for the field.
|
||||
private static final String X_ADA_TYPE_NAME = "x-ada-type-name";
|
||||
private static final String X_ADA_VECTOR_TYPE_NAME = "x-ada-vector-type-name";
|
||||
private static final String X_ADA_NO_VECTOR = "x-ada-no-vector";
|
||||
private static final String X_ADA_SERIALIZE_OP = "x-ada-serialize-op";
|
||||
|
||||
protected String packageName = "defaultPackage";
|
||||
protected String projectName = "defaultProject";
|
||||
protected List<ModelMap> orderedModels;
|
||||
protected final Map<String, List<String>> modelDepends;
|
||||
protected final Map<String, String> nullableTypeMapping;
|
||||
protected final Map<String, String> operationsScopes;
|
||||
protected final List<List<String>> mediaGroups;
|
||||
protected final List<List<NameBinding>> mediaLists;
|
||||
protected final Map<String, String> mediaToVariableName;
|
||||
protected final List<NameBinding> mediaVariables;
|
||||
protected final List<NameBinding> adaImports;
|
||||
protected final Set<String> adaImportSet = new TreeSet<>();
|
||||
protected int scopeIndex = 0;
|
||||
protected String httpClientPackageName = "Curl";
|
||||
protected String openApiPackageName = "Swagger";
|
||||
|
||||
private static final String bytesType = "swagger::ByteArray";
|
||||
|
||||
static class NameBinding {
|
||||
public int position;
|
||||
public String name;
|
||||
public String value;
|
||||
|
||||
NameBinding(int pos, String name, String value) {
|
||||
this.position = pos;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractAdaCodegen() {
|
||||
super();
|
||||
|
||||
@@ -169,12 +219,20 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
typeMapping.put("integer", "Integer");
|
||||
typeMapping.put("boolean", "Boolean");
|
||||
|
||||
typeMapping.put("binary", bytesType);
|
||||
typeMapping.put("ByteArray", bytesType);
|
||||
|
||||
// Mapping to convert an Ada required type to an optional type (nullable).
|
||||
nullableTypeMapping = new HashMap<>();
|
||||
|
||||
modelDepends = new HashMap<>();
|
||||
orderedModels = new ArrayList<>();
|
||||
operationsScopes = new HashMap<>();
|
||||
mediaGroups = new ArrayList<>();
|
||||
mediaLists = new ArrayList<>();
|
||||
mediaToVariableName = new HashMap<>();
|
||||
mediaVariables = new ArrayList<>();
|
||||
adaImports = new ArrayList<>();
|
||||
super.importMapping = new HashMap<>();
|
||||
|
||||
// CLI options
|
||||
@@ -221,8 +279,11 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
typeMapping.put("number", openApiPackageName + ".Number");
|
||||
typeMapping.put("UUID", openApiPackageName + ".UString");
|
||||
typeMapping.put("URI", openApiPackageName + ".UString");
|
||||
typeMapping.put("file", openApiPackageName + ".Http_Content_Type");
|
||||
typeMapping.put("binary", openApiPackageName + ".Binary");
|
||||
typeMapping.put("file", openApiPackageName + ".Blob_Ref");
|
||||
typeMapping.put("binary", openApiPackageName + ".Blob_Ref");
|
||||
typeMapping.put("float", openApiPackageName + ".Number");
|
||||
typeMapping.put("double", openApiPackageName + ".Number");
|
||||
importMapping.put("File", openApiPackageName + ".File");
|
||||
|
||||
// Mapping to convert an Ada required type to an optional type (nullable).
|
||||
nullableTypeMapping.put(openApiPackageName + ".Date", openApiPackageName + ".Nullable_Date");
|
||||
@@ -233,6 +294,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
nullableTypeMapping.put("Boolean", openApiPackageName + ".Nullable_Boolean");
|
||||
nullableTypeMapping.put(openApiPackageName + ".Object", openApiPackageName + ".Object");
|
||||
|
||||
mediaToVariableName.put(TEXT_PLAIN, openApiPackageName + ".Mime_Text");
|
||||
mediaToVariableName.put(APPLICATION_JSON, openApiPackageName + ".Mime_Json");
|
||||
mediaToVariableName.put(APPLICATION_XML, openApiPackageName + ".Mime_Xml");
|
||||
mediaToVariableName.put(APPLICATION_X_WWW_FORM_URLENCODED, openApiPackageName + ".Mime_Form");
|
||||
}
|
||||
|
||||
public String toFilename(String name) {
|
||||
@@ -299,11 +364,21 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// obtain the name from nameMapping directly if provided
|
||||
if (nameMapping.containsKey(name)) {
|
||||
return nameMapping.get(name);
|
||||
}
|
||||
|
||||
return toAdaIdentifier(sanitizeName(name), "P_");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// obtain the name from parameterNameMapping directly if provided
|
||||
if (parameterNameMapping.containsKey(name)) {
|
||||
return parameterNameMapping.get(name);
|
||||
}
|
||||
|
||||
return toAdaIdentifier(super.toParamName(name), "P_");
|
||||
}
|
||||
|
||||
@@ -353,7 +428,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
String var = null;
|
||||
String var;
|
||||
if (value.isEmpty()) {
|
||||
var = "EMPTY";
|
||||
}
|
||||
@@ -385,6 +460,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return var;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
|
||||
CodegenProperty property = super.fromProperty(name, p, required);
|
||||
@@ -442,6 +518,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
* @return a string value used as the `dataType` field for model templates,
|
||||
* `returnType` for api templates
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
String schemaType = getSchemaType(p);
|
||||
@@ -453,10 +530,15 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return getTypeDeclaration(inner) + "_Vectors.Vector";
|
||||
String itemType = getTypeDeclaration(inner);
|
||||
if (itemType.startsWith("OpenAPI.")) {
|
||||
return itemType + "_Vector";
|
||||
} else {
|
||||
return itemType + "_Vectors.Vector";
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = getAdditionalProperties(p);
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
String name = getTypeDeclaration(inner) + "_Map";
|
||||
if (name.startsWith(openApiPackageName)) {
|
||||
return name;
|
||||
@@ -480,44 +562,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return modelPackage + ".Models." + modelType;
|
||||
}
|
||||
|
||||
private boolean isStreamType(CodegenProperty parameter) {
|
||||
boolean isStreamType = parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
|
||||
return isStreamType;
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenProperty parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
private boolean isStreamType(CodegenParameter parameter) {
|
||||
boolean isStreamType = parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
|
||||
return isStreamType;
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenParameter parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides postProcessParameter to add a vendor extension "x-is-model-type".
|
||||
* This boolean indicates that the parameter comes from the model package.
|
||||
@@ -536,47 +580,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
parameter.vendorExtensions.put("x-is-stream-type", isStreamType(parameter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process the media types (produces and consumes) for Ada code generator.
|
||||
* <p>
|
||||
* For each media type, add an adaMediaType member that gives the Ada enum constant
|
||||
* for the corresponding type.
|
||||
*
|
||||
* @param types the list of media types.
|
||||
* @return the number of media types.
|
||||
*/
|
||||
protected int postProcessMediaTypes(List<Map<String, String>> types) {
|
||||
int count = 0;
|
||||
if (types != null) {
|
||||
for (Map<String, String> media : types) {
|
||||
String mt = media.get("mediaType");
|
||||
if (mt != null) {
|
||||
mt = mt.replace('/', '_');
|
||||
media.put("adaMediaType", mt.toUpperCase(Locale.ROOT));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
|
||||
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
|
||||
|
||||
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
|
||||
ApiResponse methodResponse = findMethodResponse(operation.getResponses());
|
||||
if (methodResponse != null && ModelUtils.getSchemaFromResponse(methodResponse) != null) {
|
||||
CodegenProperty cm = fromProperty("response", ModelUtils.getSchemaFromResponse(methodResponse), false);
|
||||
op.vendorExtensions.put("x-codegen-response", cm);
|
||||
op.vendorExtensions.put("x-is-model-type", isModelType(cm));
|
||||
op.vendorExtensions.put("x-is-stream-type", isStreamType(cm));
|
||||
if ("HttpContent".equals(cm.dataType)) {
|
||||
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a vendor extension attribute that provides a map of auth methods and the scopes
|
||||
// which are expected by the operation. This map is then used by postProcessOperationsWithModels
|
||||
// to build another vendor extension that provides a subset of the auth methods with only
|
||||
@@ -592,96 +599,261 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
op.vendorExtensions.put("x-scopes", scopes);
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
private Map<String, List<String>> getAuthScopes(List<SecurityRequirement> securities, Map<String, SecurityScheme> securitySchemes) {
|
||||
final Map<String, List<String>> scopes = new HashMap<>();
|
||||
Optional.ofNullable(securitySchemes).ifPresent(_securitySchemes -> {
|
||||
for (SecurityRequirement requirement : securities) {
|
||||
for (String key : requirement.keySet()) {
|
||||
Optional.ofNullable(securitySchemes.get(key))
|
||||
.ifPresent(securityScheme -> scopes.put(key, requirement.get(key)));
|
||||
// Determine the types that this operation produces. `getProducesInfo`
|
||||
// simply lists all the types, and then we collect the list of media types
|
||||
// for the operation and keep the global index assigned to that list in x-produces-media-index.
|
||||
Set<String> produces = getProducesInfo(openAPI, operation);
|
||||
boolean producesPlainText = false;
|
||||
if (produces != null && !produces.isEmpty()) {
|
||||
List<String> mediaList = new ArrayList<>();
|
||||
List<Map<String, String>> c = new ArrayList<>();
|
||||
for (String mimeType : produces) {
|
||||
Map<String, String> mediaType = new HashMap<>();
|
||||
|
||||
if (isMimetypePlain(mimeType)) {
|
||||
producesPlainText = true;
|
||||
}
|
||||
|
||||
mediaType.put("mediaType", mimeType);
|
||||
c.add(mediaType);
|
||||
mediaList.add(mimeType);
|
||||
}
|
||||
op.produces = c;
|
||||
op.hasProduces = true;
|
||||
op.vendorExtensions.put("x-produces-media-index", collectMediaList(mediaList));
|
||||
}
|
||||
|
||||
for (CodegenResponse rsp : op.responses) {
|
||||
|
||||
if (rsp.dataType != null) {
|
||||
|
||||
// Write out the type of data we actually expect this response
|
||||
// to make.
|
||||
if (producesPlainText) {
|
||||
// Plain text means that there is not structured data in
|
||||
// this response. So it'll either be a UTF-8 encoded string
|
||||
// 'plainText' or some generic 'bytes'.
|
||||
//
|
||||
// Note that we don't yet distinguish between string/binary
|
||||
// and string/bytes - that is we don't auto-detect whether
|
||||
// base64 encoding should be done. They both look like
|
||||
// 'producesBytes'.
|
||||
if (bytesType.equals(rsp.dataType)) {
|
||||
rsp.vendorExtensions.put("x-produces-bytes", true);
|
||||
} else {
|
||||
rsp.vendorExtensions.put("x-produces-plain-text", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return scopes;
|
||||
for (CodegenProperty header : rsp.headers) {
|
||||
header.nameInCamelCase = toModelName(header.baseName);
|
||||
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
// This is run after the postProcessModels
|
||||
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation op1 : operationList) {
|
||||
if (op1.summary != null) {
|
||||
op1.summary = op1.summary.trim();
|
||||
}
|
||||
if (op1.notes != null) {
|
||||
op1.notes = op1.notes.trim();
|
||||
}
|
||||
op1.vendorExtensions.put("x-has-uniq-produces", postProcessMediaTypes(op1.produces) == 1);
|
||||
op1.vendorExtensions.put("x-has-uniq-consumes", postProcessMediaTypes(op1.consumes) == 1);
|
||||
op1.vendorExtensions.put("x-has-notes", op1.notes != null && op1.notes.length() > 0);
|
||||
for (CodegenOperation op : operationList) {
|
||||
postProcessOperationWithModels(op, allModels);
|
||||
}
|
||||
|
||||
// Set the file parameter type for both allParams and formParams.
|
||||
for (CodegenParameter p : op1.allParams) {
|
||||
if (p.isFormParam && p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
// Convert optional parameters to use the Nullable_<T> type.
|
||||
if (!p.required && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
p.dataType = nullableTypeMapping.get(p.dataType);
|
||||
// Build the adaImports variable to create a list of Ada specific packages that must be imported.
|
||||
adaImportSet.remove(openApiPackageName);
|
||||
for (String adaImport : adaImportSet) {
|
||||
adaImports.add(new NameBinding(0, adaImport, adaImport));
|
||||
}
|
||||
additionalProperties.put("adaImports", adaImports);
|
||||
|
||||
// Add the media list variables.
|
||||
additionalProperties.put("mediaVariables", mediaVariables);
|
||||
additionalProperties.put("mediaLists", mediaLists);
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
private void postProcessOperationWithModels(CodegenOperation op, List<ModelMap> allModels) {
|
||||
|
||||
if (op.consumes != null) {
|
||||
List<String> mediaList = new ArrayList<>();
|
||||
for (Map<String, String> consume : op.consumes) {
|
||||
String mediaType = consume.get("mediaType");
|
||||
if (mediaType != null) {
|
||||
mediaList.add(mediaType.toLowerCase(Locale.ROOT));
|
||||
if (isMimetypeWwwFormUrlEncoded(mediaType)) {
|
||||
additionalProperties.put("usesUrlEncodedForm", true);
|
||||
} else if (isMimetypeMultipartFormData(mediaType)) {
|
||||
op.vendorExtensions.put("x-consumes-multipart", true);
|
||||
additionalProperties.put("apiUsesMultipartFormData", true);
|
||||
additionalProperties.put("apiUsesMultipart", true);
|
||||
} else if (isMimetypeMultipartRelated(mediaType)) {
|
||||
op.vendorExtensions.put("x-consumes-multipart-related", true);
|
||||
additionalProperties.put("apiUsesMultipartRelated", true);
|
||||
additionalProperties.put("apiUsesMultipart", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodegenParameter p : op1.formParams) {
|
||||
if (p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
op.vendorExtensions.put("x-consumes-media-index", collectMediaList(mediaList));
|
||||
}
|
||||
|
||||
if (op.summary != null) {
|
||||
op.summary = op.summary.trim();
|
||||
}
|
||||
if (op.notes != null) {
|
||||
op.notes = op.notes.trim();
|
||||
}
|
||||
op.vendorExtensions.put("x-has-notes", op.notes != null && op.notes.length() > 0);
|
||||
final String prefix = modelPackage() + ".Models";
|
||||
|
||||
// Set the file parameter type for both allParams and formParams.
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
if (p.isFormParam && p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
// Convert optional parameters to use the Nullable_<T> type.
|
||||
if (!p.required && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
p.dataType = nullableTypeMapping.get(p.dataType);
|
||||
}
|
||||
|
||||
// Given the operation scopes and the auth methods, build a list of auth methods that only
|
||||
// describe the auth methods and scopes required by the operation.
|
||||
final Map<String, List<String>> scopes = (Map<String, List<String>>) op1.vendorExtensions.get("x-scopes");
|
||||
List<CodegenSecurity> opScopes = postProcessAuthMethod(op1.authMethods, scopes);
|
||||
if (opScopes != null) {
|
||||
op1.vendorExtensions.put("x-auth-scopes", opScopes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the path parameter to construct a x-path-index that tells the index of
|
||||
* the path parameter.
|
||||
*/
|
||||
for (CodegenParameter p : op1.pathParams) {
|
||||
String path = op1.path;
|
||||
int pos = 0;
|
||||
int index = 0;
|
||||
while (pos >= 0 && pos < path.length()) {
|
||||
int last;
|
||||
pos = path.indexOf('{', pos);
|
||||
if (pos < 0) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
last = path.indexOf('}', pos);
|
||||
index++;
|
||||
if (last < 0) {
|
||||
break;
|
||||
}
|
||||
if (path.substring(pos, last).equals(p.baseName)) {
|
||||
break;
|
||||
}
|
||||
pos = last + 1;
|
||||
String dataType;
|
||||
if (p.vendorExtensions.containsKey(X_ADA_TYPE_NAME)) {
|
||||
dataType = (String) p.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
} else {
|
||||
CodegenProperty schema = p.getSchema();
|
||||
if (schema != null) {
|
||||
dataType = (String) schema.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
} else {
|
||||
dataType = p.dataType;
|
||||
}
|
||||
p.vendorExtensions.put("x-path-index", index);
|
||||
p.vendorExtensions.put(X_ADA_TYPE_NAME, dataType);
|
||||
}
|
||||
String pkgName = useType(dataType);
|
||||
if (pkgName != null && !pkgName.startsWith(prefix)) {
|
||||
adaImportSet.add(pkgName);
|
||||
}
|
||||
p.vendorExtensions.put("x-is-imported-type", pkgName != null);
|
||||
p.vendorExtensions.put("x-is-model-type", isModelType(p));
|
||||
p.vendorExtensions.put("x-is-stream-type", isStreamType(p));
|
||||
}
|
||||
for (CodegenParameter p : op.formParams) {
|
||||
if (p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
|
||||
// Given the operation scopes and the auth methods, build a list of auth methods that only
|
||||
// describe the auth methods and scopes required by the operation.
|
||||
final Map<String, List<String>> scopes = (Map<String, List<String>>) op.vendorExtensions.get("x-scopes");
|
||||
List<CodegenSecurity> opScopes = postProcessAuthMethod(op.authMethods, scopes);
|
||||
if (opScopes != null) {
|
||||
op.vendorExtensions.put("x-auth-scopes", opScopes);
|
||||
}
|
||||
|
||||
CodegenProperty returnProperty = op.returnProperty;
|
||||
if (returnProperty != null) {
|
||||
CodegenProperty itemType = returnProperty.getItems();
|
||||
if (itemType != null) {
|
||||
String dataType;
|
||||
if (itemType.vendorExtensions.containsKey(X_ADA_VECTOR_TYPE_NAME)) {
|
||||
dataType = (String) itemType.vendorExtensions.get(X_ADA_VECTOR_TYPE_NAME);
|
||||
returnProperty.vendorExtensions.put(X_ADA_TYPE_NAME, dataType);
|
||||
}
|
||||
returnProperty.vendorExtensions.put("x-is-model-type", isModelType(itemType));
|
||||
returnProperty.vendorExtensions.put("x-is-stream-type", isStreamType(itemType));
|
||||
} else {
|
||||
if (!returnProperty.vendorExtensions.containsKey(X_ADA_TYPE_NAME)) {
|
||||
returnProperty.vendorExtensions.put(X_ADA_TYPE_NAME, returnProperty.dataType);
|
||||
}
|
||||
returnProperty.vendorExtensions.put("x-is-model-type", isModelType(returnProperty));
|
||||
returnProperty.vendorExtensions.put("x-is-stream-type", isStreamType(returnProperty));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the path parameter to construct a x-path-index that tells the index of
|
||||
* the path parameter.
|
||||
*/
|
||||
for (CodegenParameter p : op.pathParams) {
|
||||
String path = op.path;
|
||||
int pos = 0;
|
||||
int index = 0;
|
||||
while (pos >= 0 && pos < path.length()) {
|
||||
int last;
|
||||
pos = path.indexOf('{', pos);
|
||||
if (pos < 0) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
last = path.indexOf('}', pos);
|
||||
index++;
|
||||
if (last < 0) {
|
||||
break;
|
||||
}
|
||||
if (path.substring(pos, last).equals(p.baseName)) {
|
||||
break;
|
||||
}
|
||||
pos = last + 1;
|
||||
}
|
||||
p.vendorExtensions.put("x-path-index", index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to sort the model according to their dependencies and names.
|
||||
*/
|
||||
static class ModelDepend implements Comparable<ModelDepend> {
|
||||
final List<String> depend;
|
||||
final ModelMap model;
|
||||
final String name;
|
||||
|
||||
ModelDepend(ModelMap model, List<String> depend, String name) {
|
||||
this.model = model;
|
||||
this.depend = depend;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int compareTo(ModelDepend second) {
|
||||
|
||||
if (depend != null && depend.contains(second.name)) {
|
||||
//LOGGER.debug("Compare " + name + " with " + second.name + "=1");
|
||||
return 1;
|
||||
}
|
||||
if (second.depend != null && second.depend.contains(name)) {
|
||||
//LOGGER.debug("Compare " + name + " with " + second.name + "=-1");
|
||||
return -1;
|
||||
}
|
||||
if (depend != null && (depend == null ? 0 : depend.size()) != (second.depend == null ? 0 : second.depend.size())) {
|
||||
//LOGGER.debug("Compare " + name + " with " + second.name + "=D"
|
||||
// + (depend.size() - second.depend.size()));
|
||||
return depend.size() - second.depend.size();
|
||||
}
|
||||
//LOGGER.debug("Compare " + name + " with " + second.name + "=<name>");
|
||||
return name.compareTo(second.name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
// This is run first, before the operations.
|
||||
// remove model imports to avoid error
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
final String prefix = modelPackage() + ".Models";
|
||||
Iterator<Map<String, String>> iterator = imports.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String _import = iterator.next().get("import");
|
||||
if (_import.startsWith(prefix))
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
// Collect the model dependencies.
|
||||
for (ModelMap model : objs.getModels()) {
|
||||
CodegenModel m = model.getModel();
|
||||
@@ -689,19 +861,56 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
for (CodegenProperty p : m.vars) {
|
||||
boolean isModel = false;
|
||||
CodegenProperty item = p;
|
||||
String dataType = null;
|
||||
String arrayDataType = null;
|
||||
if (p.vendorExtensions.containsKey(X_ADA_TYPE_NAME)) {
|
||||
dataType = (String) p.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
LOGGER.info("Data type {} mapped to {}", p.dataType, dataType);
|
||||
}
|
||||
arrayDataType = (String) p.vendorExtensions.get(X_ADA_VECTOR_TYPE_NAME);
|
||||
if (p.isContainer) {
|
||||
item = p.items;
|
||||
}
|
||||
if (item != null && !item.isString && !item.isPrimitiveType && !item.isContainer && !item.isInteger) {
|
||||
if (!d.contains(item.dataType)) {
|
||||
boolean isStreamType = isStreamType(p);
|
||||
if (!isStreamType && item != null && !item.isString && !item.isPrimitiveType && !item.isContainer && !item.isInteger) {
|
||||
if (dataType == null) {
|
||||
dataType = item.dataType;
|
||||
if (dataType.startsWith(modelPackage + ".Models.") || item.isFreeFormObject) {
|
||||
p.vendorExtensions.put(X_ADA_TYPE_NAME, dataType);
|
||||
} else {
|
||||
p.vendorExtensions.put(X_ADA_TYPE_NAME, modelPackage + ".Models." + dataType);
|
||||
}
|
||||
LOGGER.debug("Setting ada-type name {} for datatype {}", modelPackage + ".Models." + dataType,
|
||||
dataType);
|
||||
}
|
||||
if (!d.contains(dataType)) {
|
||||
// LOGGER.info("Model " + m.name + " uses " + p.datatype);
|
||||
d.add(item.dataType);
|
||||
d.add(dataType);
|
||||
}
|
||||
isModel = true;
|
||||
}
|
||||
Boolean noVector = Boolean.FALSE;
|
||||
if (p.vendorExtensions.get(X_ADA_NO_VECTOR) instanceof Boolean) {
|
||||
noVector = (Boolean) p.vendorExtensions.get(X_ADA_NO_VECTOR);
|
||||
}
|
||||
p.vendorExtensions.put(X_ADA_NO_VECTOR, noVector);
|
||||
p.vendorExtensions.put("x-is-model-type", isModel);
|
||||
p.vendorExtensions.put("x-is-stream-type", isStreamType(p));
|
||||
p.vendorExtensions.put("x-is-stream-type", isStreamType);
|
||||
String pkgImport = useType(dataType);
|
||||
p.vendorExtensions.put("x-is-imported-type", pkgImport != null);
|
||||
if (pkgImport != null) {
|
||||
adaImportSet.add(pkgImport);
|
||||
}
|
||||
Boolean required = p.getRequired();
|
||||
if (!p.vendorExtensions.containsKey(X_ADA_SERIALIZE_OP)) {
|
||||
if (p.isLong && !required) {
|
||||
p.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
} else if (p.isLong && "int64".equals(p.dataFormat)) {
|
||||
p.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Long_Entity");
|
||||
} else {
|
||||
p.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
}
|
||||
}
|
||||
|
||||
// Convert optional members to use the Nullable_<T> type.
|
||||
if (!Boolean.TRUE.equals(required) && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
@@ -710,53 +919,53 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
} else {
|
||||
p.vendorExtensions.put("x-is-required", true);
|
||||
}
|
||||
p.vendorExtensions.put("x-is-nullable", p.isNullable);
|
||||
}
|
||||
String name = (String) m.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
if (name == null) {
|
||||
name = modelPackage + ".Models." + m.classname;
|
||||
m.vendorExtensions.put(X_ADA_TYPE_NAME, name);
|
||||
}
|
||||
String pkgName = useType(name);
|
||||
if (pkgName != null) {
|
||||
adaImportSet.add(pkgName);
|
||||
}
|
||||
m.vendorExtensions.put(X_ADA_TYPE_NAME, name);
|
||||
|
||||
m.vendorExtensions.put("x-is-imported-type", pkgName != null);
|
||||
// let us work with fully qualified names only
|
||||
modelDepends.put(modelPackage + ".Models." + m.classname, d);
|
||||
modelDepends.put(name, d);
|
||||
orderedModels.add(model);
|
||||
}
|
||||
|
||||
objs.setImports(imports);
|
||||
|
||||
// Sort models using dependencies:
|
||||
// List revisedOrderedModels <- ()
|
||||
// if you have N model, do N passes. In each pass look for an independent model
|
||||
// cycle over orderedModels
|
||||
// if I find a model that has no dependencies, or all of its dependencies are in revisedOrderedModels, consider it the independentModel
|
||||
// put the independentModel at the end of revisedOrderedModels, and remove it from orderedModels
|
||||
//
|
||||
List<ModelMap> revisedOrderedModels = new ArrayList<>();
|
||||
List<String> collectedModelNames = new ArrayList<>();
|
||||
int sizeOrderedModels = orderedModels.size();
|
||||
for (int i = 0; i < sizeOrderedModels; i++) {
|
||||
ModelMap independentModel = null;
|
||||
String independentModelName = null;
|
||||
for (ModelMap model : orderedModels) {
|
||||
// let us work with fully qualified names only
|
||||
String modelName = modelPackage + ".Models." + model.getModel().classname;
|
||||
boolean dependent = false;
|
||||
for (String dependency : modelDepends.get(modelName)) {
|
||||
if (!collectedModelNames.contains(dependency)) {
|
||||
dependent = true;
|
||||
}
|
||||
}
|
||||
if (!dependent) {
|
||||
// this model was independent
|
||||
independentModel = model;
|
||||
independentModelName = modelName;
|
||||
}
|
||||
}
|
||||
if (null != independentModel) {
|
||||
// I have find an independentModel. Add it to revisedOrderedModels, and remove from orderedModels
|
||||
revisedOrderedModels.add(independentModel);
|
||||
collectedModelNames.add(independentModelName);
|
||||
orderedModels.remove(independentModel);
|
||||
}
|
||||
TreeSet<ModelDepend> sorted = new TreeSet<>();
|
||||
for (ModelMap model : orderedModels) {
|
||||
String modelName = modelPackage + ".Models." + model.getModel().classname;
|
||||
sorted.add(new ModelDepend(model, modelDepends.get(modelName), modelName));
|
||||
}
|
||||
|
||||
// The comparison method in ModelDepend does not provide a total order
|
||||
// we have to adjust the sorted list to make sure the dependent models are
|
||||
// written last.
|
||||
ArrayList<ModelDepend> models = new ArrayList<>();
|
||||
for (ModelDepend item : sorted) {
|
||||
int pos = models.size();
|
||||
for (int i = 0; i < models.size(); i++) {
|
||||
ModelDepend second = models.get(i);
|
||||
if (second.depend != null && second.depend.contains(item.name)) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
models.add(pos, item);
|
||||
}
|
||||
List<ModelMap> revisedOrderedModels = new ArrayList<>();
|
||||
for (ModelDepend model : models) {
|
||||
revisedOrderedModels.add(model.model);
|
||||
}
|
||||
// bookkeeping:
|
||||
// if I still have elements in orderedModels:
|
||||
// if it's NOT last time I postProcessModels(), it means there are some dependencies that were not considered yet. That's not a problem
|
||||
// if it's last iteration, there are circular dependencies.
|
||||
// In any case, I add models still in orderedModels to revisedOrderedModels
|
||||
revisedOrderedModels.addAll(orderedModels);
|
||||
orderedModels = revisedOrderedModels;
|
||||
|
||||
return postProcessModelsEnum(objs);
|
||||
@@ -766,18 +975,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
objs.put("orderedModels", orderedModels);
|
||||
generateJSONSpecFile(objs);
|
||||
/* TODO do we still need the SWAGGER_HOST logic below
|
||||
Swagger swagger = (Swagger) objs.get("swagger");
|
||||
if (swagger != null) {
|
||||
String host = swagger.getBasePath();
|
||||
try {
|
||||
swagger.setHost("SWAGGER_HOST");
|
||||
objs.put("swagger-json", Json.pretty().writeValueAsString(swagger).replace("\r\n", "\n"));
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
swagger.setHost(host);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Collect the scopes to generate unique identifiers for each of them.
|
||||
@@ -788,6 +985,44 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return super.postProcessSupportingFileData(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only process files with .ads or .adb extension
|
||||
String extension = FilenameUtils.getExtension(file.toString());
|
||||
if ("ads".equals(extension) || "adb".equals(extension)) {
|
||||
|
||||
String commandPrefix = System.getenv("ADA_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(commandPrefix)) {
|
||||
commandPrefix = "gnatpp";
|
||||
}
|
||||
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(new String[]{commandPrefix, "--no-compact", "--quiet", file.toString()});
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({} {}). Exit code: {}", commandPrefix, file, exitValue);
|
||||
} else {
|
||||
LOGGER.debug("Successfully executed: {} {}", commandPrefix, file);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({} {}). Exception: {}", commandPrefix, file, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() {
|
||||
return GeneratorLanguage.ADA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect the scopes to generate a unique identifier for each of them.
|
||||
*
|
||||
@@ -837,6 +1072,149 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.ADA; }
|
||||
private boolean isStreamType(CodegenProperty parameter) {
|
||||
return parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenProperty parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
private boolean isStreamType(CodegenParameter parameter) {
|
||||
return parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenParameter parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
private Map<String, List<String>> getAuthScopes(List<SecurityRequirement> securities, Map<String, SecurityScheme> securitySchemes) {
|
||||
final Map<String, List<String>> scopes = new HashMap<>();
|
||||
Optional.ofNullable(securitySchemes).ifPresent(_securitySchemes -> {
|
||||
for (SecurityRequirement requirement : securities) {
|
||||
for (String key : requirement.keySet()) {
|
||||
Optional.ofNullable(securitySchemes.get(key))
|
||||
.ifPresent(securityScheme -> scopes.put(key, requirement.get(key)));
|
||||
}
|
||||
}
|
||||
});
|
||||
return scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Ada type name is imported from another package.
|
||||
*
|
||||
* @param name the Ada full qualified type name.
|
||||
* @return true if this Ada type is imported.
|
||||
*/
|
||||
private String useType(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
int pos = name.lastIndexOf('.');
|
||||
if (pos <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String pkg = name.substring(0, pos);
|
||||
if (pkg.equals(modelPackage + ".Models")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return pkg;
|
||||
}
|
||||
|
||||
private boolean isMimetypeXml(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_XML) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_PROBLEM_XML) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(TEXT_XML);
|
||||
}
|
||||
|
||||
private boolean isMimetypeJson(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_JSON) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_MERGE_PATCH_JSON) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_PROBLEM_JSON);
|
||||
}
|
||||
|
||||
private boolean isMimetypeWwwFormUrlEncoded(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_X_WWW_FORM_URLENCODED);
|
||||
}
|
||||
|
||||
private boolean isMimetypeMultipartFormData(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/form-data");
|
||||
}
|
||||
|
||||
private boolean isMimetypeOctetStream(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_OCTET_STREAM);
|
||||
}
|
||||
|
||||
private boolean isMimetypeMultipartRelated(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/related");
|
||||
}
|
||||
|
||||
private boolean isMimetypeUnknown(String mimetype) {
|
||||
return "*/*".equals(mimetype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we have any special handling for this mimetype?
|
||||
*/
|
||||
private boolean isMimetypePlain(String mimetype) {
|
||||
return !(isMimetypeUnknown(mimetype) ||
|
||||
isMimetypeXml(mimetype) ||
|
||||
isMimetypeJson(mimetype) ||
|
||||
isMimetypeWwwFormUrlEncoded(mimetype) ||
|
||||
isMimetypeMultipartFormData(mimetype) ||
|
||||
isMimetypeMultipartRelated(mimetype));
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect the list of media types to emit unique arrays of media types.
|
||||
* An array represents a list of media types and it can be referenced by several operations.
|
||||
* These arrays are emitted at the top of the client/server body packages.
|
||||
*
|
||||
* @param mediaList the list of media types.
|
||||
* @return the unique index assigned to that media list.
|
||||
*/
|
||||
private int collectMediaList(List<String> mediaList) {
|
||||
for (int i = 0; i < mediaGroups.size(); i++) {
|
||||
if (mediaList.equals(mediaGroups.get(i))) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
mediaGroups.add(mediaList);
|
||||
List<NameBinding> varList = new ArrayList<>();
|
||||
int pos = 0;
|
||||
for (String media : mediaList) {
|
||||
String varName = mediaToVariableName.get(media);
|
||||
if (varName == null) {
|
||||
varName = "Mime_" + (mediaVariables.size() + 1);
|
||||
mediaVariables.add(new NameBinding(mediaVariables.size() + 1, varName, media));
|
||||
varName = varName + "'Access";
|
||||
}
|
||||
pos++;
|
||||
varList.add(new NameBinding(pos, varName, media));
|
||||
}
|
||||
mediaLists.add(varList);
|
||||
return mediaGroups.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = getAdditionalProperties(p);
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
if (inner == null) {
|
||||
LOGGER.warn("{}(map property) does not have a proper inner type defined", p.getName());
|
||||
@@ -230,11 +230,11 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
final MapSchema ap = (MapSchema) p;
|
||||
final String pattern = "new HashMap<%s>()";
|
||||
if (getAdditionalProperties(ap) == null) {
|
||||
if (ModelUtils.getAdditionalProperties(ap) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.format(Locale.ROOT, pattern, String.format(Locale.ROOT, "String, %s", getTypeDeclaration(getAdditionalProperties(ap))));
|
||||
return String.format(Locale.ROOT, pattern, String.format(Locale.ROOT, "String, %s", getTypeDeclaration(ModelUtils.getAdditionalProperties(ap))));
|
||||
} else if (ModelUtils.isLongSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString() + "l";
|
||||
@@ -367,7 +367,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
} else if (ModelUtils.isLongSchema(p)) {
|
||||
example = example.isEmpty() ? "123456789L" : example + "L";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
example = "new " + getTypeDeclaration(p) + "{'key'=>" + toExampleValue(getAdditionalProperties(p)) + "}";
|
||||
example = "new " + getTypeDeclaration(p) + "{'key'=>" + toExampleValue(ModelUtils.getAdditionalProperties(p)) + "}";
|
||||
|
||||
} else if (ModelUtils.isPasswordSchema(p)) {
|
||||
example = example.isEmpty() ? "password123" : escapeText(example);
|
||||
|
||||
@@ -416,7 +416,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
.put("joinWithComma", new JoinWithCommaLambda())
|
||||
.put("trimLineBreaks", new TrimLineBreaksLambda())
|
||||
.put("trimTrailingWhiteSpace", new TrimTrailingWhiteSpaceLambda())
|
||||
.put("first", new FirstLambda());
|
||||
.put("first", new FirstLambda(" "))
|
||||
.put("firstDot", new FirstLambda("\\."))
|
||||
.put("indent3", new IndentedLambda(12, " "))
|
||||
.put("indent4", new IndentedLambda(16, " "));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -538,6 +541,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
if (allOf != null) {
|
||||
for(CodegenProperty property : allOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
patchPropertyVendorExtensinos(property);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,6 +551,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
for(CodegenProperty property : anyOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.isNullable = true;
|
||||
patchPropertyVendorExtensinos(property);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,6 +561,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
for(CodegenProperty property : oneOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.isNullable = true;
|
||||
patchPropertyVendorExtensinos(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -630,6 +636,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
return value;
|
||||
}
|
||||
|
||||
private void patchPropertyVendorExtensinos(CodegenProperty property) {
|
||||
Boolean isValueType = isValueType(property);
|
||||
property.vendorExtensions.put("x-is-value-type", isValueType);
|
||||
property.vendorExtensions.put("x-is-reference-type", !isValueType);
|
||||
property.vendorExtensions.put("x-is-nullable-type", this.getNullableReferencesTypes() || isValueType);
|
||||
}
|
||||
|
||||
protected void patchProperty(Map<String, CodegenModel> enumRefs, CodegenModel model, CodegenProperty property) {
|
||||
if (enumRefs.containsKey(property.dataType)) {
|
||||
// Handle any enum properties referred to by $ref.
|
||||
@@ -643,17 +656,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
property.isPrimitiveType = true;
|
||||
}
|
||||
|
||||
Boolean isValueType = isValueType(property);
|
||||
|
||||
property.vendorExtensions.put("x-is-value-type", isValueType);
|
||||
|
||||
if (property.isNullable && !property.isContainer && isValueType) {
|
||||
property.vendorExtensions.put("x-nullable-value-type", true);
|
||||
}
|
||||
|
||||
if (this.getNullableReferencesTypes() || isValueType) {
|
||||
property.vendorExtensions.put("x-nullable-type", true);
|
||||
}
|
||||
patchPropertyVendorExtensinos(property);
|
||||
|
||||
String tmpPropertyName = escapeReservedWord(model, property.name);
|
||||
property.name = patchPropertyName(model, property.name);
|
||||
@@ -763,19 +766,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check if the payload is json and set x-is-json accordingly
|
||||
if (operation.consumes != null) {
|
||||
for (Map<String, String> consume : operation.consumes) {
|
||||
if (consume.containsKey("mediaType")) {
|
||||
if (isJsonMimeType(consume.get("mediaType"))) {
|
||||
operation.vendorExtensions.put("x-is-json", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (operation.examples != null) {
|
||||
for (Map<String, String> example : operation.examples) {
|
||||
for (Map.Entry<String, String> entry : example.entrySet()) {
|
||||
@@ -788,52 +778,59 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
for (ModelMap modelHashMap : allModels) {
|
||||
CodegenModel codegenModel = modelHashMap.getModel();
|
||||
for (CodegenParameter parameter : operation.allParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.allParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.bodyParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.bodyParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.cookieParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.cookieParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.formParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.formParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.headerParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.headerParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.implicitHeadersParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.implicitHeadersParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.optionalParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.optionalParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.pathParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.pathParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.queryParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.queryParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.notNullableParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.notNullableParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.requiredParams) {
|
||||
patchParameter(parameter, allModels);
|
||||
}
|
||||
for (CodegenParameter parameter : operation.requiredParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
List<CodegenParameter> referenceTypes = operation.allParams.stream().filter(p -> p.vendorExtensions.get("x-is-value-type") == null && !p.isNullable).collect(Collectors.toList());
|
||||
@@ -853,6 +850,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the model related to the given parameter */
|
||||
private CodegenModel getModelFromParameter(List<ModelMap> allModels, CodegenParameter parameter) {
|
||||
return parameter.isModel
|
||||
? allModels.stream().map(m -> m.getModel()).filter(m -> m.getClassname().equals(parameter.dataType)).findFirst().orElse(null)
|
||||
: null;
|
||||
}
|
||||
|
||||
/** This is the same as patchVendorExtensionNullableValueType except it uses the deprecated getNullableTypes property */
|
||||
protected void patchVendorExtensionNullableValueTypeLegacy(CodegenParameter parameter) {
|
||||
if (parameter.isNullable && !parameter.isContainer && (this.getNullableTypes().contains(parameter.dataType) || parameter.isEnum)) {
|
||||
@@ -860,25 +864,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
private void patchParameter(CodegenParameter parameter, List<ModelMap> allModels) {
|
||||
parameter.paramName = escapeReservedWord(parameter.paramName);
|
||||
|
||||
private void patchParameter(CodegenModel model, CodegenParameter parameter) {
|
||||
patchVendorExtensionNullableValueType(parameter);
|
||||
|
||||
if (this.getNullableReferencesTypes() || (parameter.vendorExtensions.get("x-nullable-value-type") != null)) {
|
||||
parameter.vendorExtensions.put("x-nullable-type", true);
|
||||
}
|
||||
|
||||
|
||||
CodegenModel model = null;
|
||||
for (ModelMap modelHashMap : allModels) {
|
||||
CodegenModel codegenModel = modelHashMap.getModel();
|
||||
if (codegenModel.getClassname().equals(parameter.dataType)) {
|
||||
model = codegenModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isSupportNullable()) {
|
||||
if (model == null) {
|
||||
parameter.isNullable = true;
|
||||
@@ -971,6 +963,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// obtain the name from nameMapping directly if provided
|
||||
if (nameMapping.containsKey(name)) {
|
||||
return nameMapping.get(name);
|
||||
}
|
||||
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
@@ -997,6 +994,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// obtain the name from parameterNameMapping directly if provided
|
||||
if (parameterNameMapping.containsKey(name)) {
|
||||
return parameterNameMapping.get(name);
|
||||
}
|
||||
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
@@ -1012,7 +1014,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
// pet_id => petId
|
||||
name = camelize(name, LOWERCASE_FIRST_LETTER);
|
||||
|
||||
return name;
|
||||
return escapeReservedWord(name);
|
||||
}
|
||||
|
||||
public String escapeReservedWord(CodegenModel model, String name) {
|
||||
@@ -1166,7 +1168,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
// Should we also support maps of maps?
|
||||
Schema inner = getAdditionalProperties(p);
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<string, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
|
||||
@@ -518,7 +518,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
if (ModelUtils.isMapSchema(target)) {
|
||||
// Note: ModelUtils.isMapSchema(p) returns true when p is a composed schema that also defines
|
||||
// additionalproperties: true
|
||||
Schema<?> inner = getAdditionalProperties(target);
|
||||
Schema<?> inner = ModelUtils.getAdditionalProperties(target);
|
||||
if (inner == null) {
|
||||
LOGGER.error("`{}` (map property) does not have a proper inner type defined. Default to type:string", p.getName());
|
||||
inner = new StringSchema().description("TODO default missing map inner type to string");
|
||||
|
||||
@@ -297,7 +297,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
Schema inner = ap.getItems();
|
||||
return "LIST [" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = getAdditionalProperties(p);
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
return getSchemaType(p) + " [" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
@@ -569,7 +569,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
public String toInstantiationType(Schema p) {
|
||||
return getTypeDeclaration(p);
|
||||
// if (ModelUtils.isMapSchema(p)) {
|
||||
// Schema additionalProperties2 = getAdditionalProperties(p);
|
||||
// Schema additionalProperties2 = ModelUtils.getAdditionalProperties(p);
|
||||
// String type = additionalProperties2.getType();
|
||||
// if (null == type) {
|
||||
// LOGGER.error("No Type defined for Additional Schema " + additionalProperties2 + "\n" //
|
||||
|
||||
@@ -880,7 +880,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
// Should we also support maps of maps?
|
||||
Schema inner = getAdditionalProperties(p);
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<string, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
|
||||
@@ -53,8 +53,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
protected String packageName = "openapi";
|
||||
protected Set<String> numberTypes;
|
||||
|
||||
protected boolean usesOptionals = true;
|
||||
|
||||
public AbstractGoCodegen() {
|
||||
super();
|
||||
|
||||
@@ -193,6 +191,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// obtain the name from nameMapping directly if provided
|
||||
if (nameMapping.containsKey(name)) {
|
||||
return nameMapping.get(name);
|
||||
}
|
||||
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = sanitizeName(name);
|
||||
@@ -230,6 +232,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// obtain the name from parameterNameMapping directly if provided
|
||||
if (parameterNameMapping.containsKey(name)) {
|
||||
return parameterNameMapping.get(name);
|
||||
}
|
||||
|
||||
// params should be lowerCamelCase. E.g. "person Person", instead of
|
||||
// "Person Person".
|
||||
//
|
||||
@@ -365,8 +372,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
return "[]" + typDecl;
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[string]" + getTypeDeclaration(unaliasSchema(inner));
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[string]" + getTypeDeclaration(unaliasSchema(inner));
|
||||
}
|
||||
|
||||
//return super.getTypeDeclaration(p);
|
||||
@@ -499,7 +506,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
}
|
||||
|
||||
boolean addedOptionalImport = false;
|
||||
boolean addedTimeImport = false;
|
||||
boolean addedOSImport = false;
|
||||
boolean addedReflectImport = false;
|
||||
@@ -516,12 +522,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
addedOSImport = true;
|
||||
}
|
||||
|
||||
// import "time" if the operation has a required time parameter.
|
||||
if (param.required || !usesOptionals) {
|
||||
if (!addedTimeImport && "time.Time".equals(param.dataType)) {
|
||||
imports.add(createMapping("import", "time"));
|
||||
addedTimeImport = true;
|
||||
}
|
||||
// import "time" if the operation has a time parameter.
|
||||
if (!addedTimeImport && "time.Time".equals(param.dataType)) {
|
||||
imports.add(createMapping("import", "time"));
|
||||
addedTimeImport = true;
|
||||
}
|
||||
|
||||
// import "reflect" package if the parameter is collectionFormat=multi
|
||||
@@ -530,23 +534,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
addedReflectImport = true;
|
||||
}
|
||||
|
||||
// import "optionals" package if the parameter is optional
|
||||
if (!param.required && usesOptionals) {
|
||||
if (!addedOptionalImport) {
|
||||
imports.add(createMapping("import", "github.com/antihax/optional"));
|
||||
addedOptionalImport = true;
|
||||
}
|
||||
|
||||
// We need to specially map Time type to the optionals package
|
||||
if ("time.Time".equals(param.dataType)) {
|
||||
param.vendorExtensions.put("x-optional-data-type", "Time");
|
||||
} else {
|
||||
// Map optional type to dataType
|
||||
String optionalType = param.dataType.substring(0, 1).toUpperCase(Locale.ROOT) + param.dataType.substring(1);
|
||||
param.vendorExtensions.put("x-optional-data-type", optionalType);
|
||||
}
|
||||
}
|
||||
|
||||
// set x-exportParamName
|
||||
char nameFirstChar = param.paramName.charAt(0);
|
||||
if (Character.isUpperCase(nameFirstChar)) {
|
||||
@@ -643,7 +630,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
List<CodegenProperty> codegenProperties = new ArrayList<>();
|
||||
if(model.getComposedSchemas() == null || (model.getComposedSchemas() != null && model.getComposedSchemas().getAllOf() != null)) {
|
||||
if (model.getComposedSchemas() == null || (model.getComposedSchemas() != null && model.getComposedSchemas().getAllOf() != null)) {
|
||||
// If the model is an allOf or does not have any composed schemas, then we can use the model's properties.
|
||||
codegenProperties.addAll(model.vars);
|
||||
} else {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user