mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-09 08:19:01 +00:00
Compare commits
141 Commits
kotin-spri
...
update-mus
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
277b43bcea | ||
|
|
38dac13c26 | ||
|
|
0a39a1760e | ||
|
|
ca032113f2 | ||
|
|
65b1859161 | ||
|
|
8f7d9f7467 | ||
|
|
c487a6ea18 | ||
|
|
21a8e4e623 | ||
|
|
b1dd6b262e | ||
|
|
1214ad7492 | ||
|
|
4ddfb6fc41 | ||
|
|
3b3f9a770a | ||
|
|
2354d402a8 | ||
|
|
b5b760a8a2 | ||
|
|
8849156d29 | ||
|
|
2838b9584b | ||
|
|
d1ca82cb8b | ||
|
|
462f450366 | ||
|
|
185c0639c0 | ||
|
|
715f6b634e | ||
|
|
7f899dff97 | ||
|
|
368b9b7e37 | ||
|
|
a84946bdb3 | ||
|
|
d9cdecf3c3 | ||
|
|
b357744048 | ||
|
|
45fa4384e7 | ||
|
|
ea4b17c32f | ||
|
|
b730e36937 | ||
|
|
43fd18935c | ||
|
|
30e6612558 | ||
|
|
d14eab8446 | ||
|
|
627c0f43cd | ||
|
|
31be9b9207 | ||
|
|
d60200de38 | ||
|
|
22b8c47b93 | ||
|
|
ba169342a1 | ||
|
|
b3b3f46ee2 | ||
|
|
25b834131c | ||
|
|
7c84177e65 | ||
|
|
e2c458b9ea | ||
|
|
4145000dfe | ||
|
|
a82475ed4e | ||
|
|
7cf84e2daf | ||
|
|
4ff8c3aaef | ||
|
|
7d1e9997d0 | ||
|
|
9a0fc5900f | ||
|
|
4c81563708 | ||
|
|
5902af4e75 | ||
|
|
39fb51062b | ||
|
|
77e8346fd7 | ||
|
|
9163e00932 | ||
|
|
2f3f25dee2 | ||
|
|
28ae69dafd | ||
|
|
6745340c64 | ||
|
|
c7d9857c8d | ||
|
|
fce8bb9604 | ||
|
|
c8fad42324 | ||
|
|
2f73582d82 | ||
|
|
899ddecdbd | ||
|
|
98468aba5c | ||
|
|
fbebfeb774 | ||
|
|
9791e6f537 | ||
|
|
e5dee54797 | ||
|
|
77eb192414 | ||
|
|
5e7cf1cfdd | ||
|
|
ad6c2dd2b7 | ||
|
|
8e10dd7be7 | ||
|
|
66cde8b5f4 | ||
|
|
cfe6520283 | ||
|
|
817da39124 | ||
|
|
67942aa478 | ||
|
|
06d914dd0f | ||
|
|
5f345c0213 | ||
|
|
c9a9ae0aa8 | ||
|
|
2437d7fa97 | ||
|
|
d521cddc3b | ||
|
|
c48ef148c0 | ||
|
|
74100e44cb | ||
|
|
577483c2e2 | ||
|
|
d193050a35 | ||
|
|
9f2bd313ff | ||
|
|
6686c4d02f | ||
|
|
c84af35e7b | ||
|
|
171b98e06c | ||
|
|
83f6d592a2 | ||
|
|
619e4d9653 | ||
|
|
0371799857 | ||
|
|
2111713117 | ||
|
|
fad33dfebf | ||
|
|
673cd15e72 | ||
|
|
43ce2a8e10 | ||
|
|
168a1d5d1f | ||
|
|
90bc1000bd | ||
|
|
f409bf1440 | ||
|
|
1cdd7b7ff2 | ||
|
|
c5060a2318 | ||
|
|
c6eb9e0e09 | ||
|
|
2544fa2928 | ||
|
|
d7ac1e4337 | ||
|
|
60d0888898 | ||
|
|
2322a99bba | ||
|
|
5f39bd230e | ||
|
|
8ef3118005 | ||
|
|
7e1ebe6404 | ||
|
|
2551689ec6 | ||
|
|
241f51c56b | ||
|
|
849b3e8e17 | ||
|
|
af2ed1c7a6 | ||
|
|
df22ca6dcc | ||
|
|
d68a186c5e | ||
|
|
2d57255817 | ||
|
|
ea6b1c6612 | ||
|
|
9300a68ad7 | ||
|
|
fb5e69f83a | ||
|
|
0b32c5025e | ||
|
|
4223be77f8 | ||
|
|
b01dd41ce3 | ||
|
|
36367e79e7 | ||
|
|
5e2af7203a | ||
|
|
1b247e75a9 | ||
|
|
911455d206 | ||
|
|
76aca6618f | ||
|
|
645626d2f5 | ||
|
|
29c3b020e6 | ||
|
|
a6581e8e4c | ||
|
|
9147e998ff | ||
|
|
7f6b1306ed | ||
|
|
17e0b7ca71 | ||
|
|
e370b8130a | ||
|
|
5732e2758f | ||
|
|
7d8eacc197 | ||
|
|
78f2f7010f | ||
|
|
98783f8161 | ||
|
|
565af33e24 | ||
|
|
b42027da5d | ||
|
|
fb36272358 | ||
|
|
8821cf095e | ||
|
|
e1a1d7ab5a | ||
|
|
b4edca5ad4 | ||
|
|
eebecc8646 | ||
|
|
3240c5baf0 |
1
.ddev/web-build/Dockerfile.maven
Normal file
1
.ddev/web-build/Dockerfile.maven
Normal file
@@ -0,0 +1 @@
|
||||
RUN apt update && apt install -y maven
|
||||
4
.github/workflows/linux.yaml
vendored
4
.github/workflows/linux.yaml
vendored
@@ -45,7 +45,7 @@ jobs:
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- name: Setup Maven
|
||||
uses: s4u/setup-maven-action@v1.14.0
|
||||
uses: s4u/setup-maven-action@v1.15.0
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
maven-version: 3.8.8
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Maven
|
||||
uses: s4u/setup-maven-action@v1.14.0
|
||||
uses: s4u/setup-maven-action@v1.15.0
|
||||
with:
|
||||
java-version: 11
|
||||
maven-version: 3.8.8
|
||||
|
||||
2
.github/workflows/openapi-generator.yaml
vendored
2
.github/workflows/openapi-generator.yaml
vendored
@@ -142,6 +142,8 @@ jobs:
|
||||
path: modules/openapi-generator-cli/target
|
||||
- name: Delete samples that are entirely generated
|
||||
run: |
|
||||
rm -rf samples/client/petstore/csharp/generichost/latest/Tags
|
||||
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/AllOf
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
|
||||
|
||||
3
.github/workflows/samples-dotnet.yaml
vendored
3
.github/workflows/samples-dotnet.yaml
vendored
@@ -3,12 +3,14 @@ name: Samples C# .Net 8 Clients
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/client/petstore/csharp/generichost/latest/**
|
||||
- samples/client/petstore/csharp/generichost/net8/**
|
||||
- samples/client/petstore/csharp/httpclient/net8/**
|
||||
- samples/client/petstore/csharp/restsharp/net8/**
|
||||
- samples/client/petstore/csharp/unityWebRequest/net8/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/petstore/csharp/generichost/latest/**
|
||||
- samples/client/petstore/csharp/generichost/net8/**
|
||||
- samples/client/petstore/csharp/httpclient/net8/**
|
||||
- samples/client/petstore/csharp/restsharp/net8/**
|
||||
@@ -21,6 +23,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- samples/client/petstore/csharp/generichost/latest/Tags
|
||||
- samples/client/petstore/csharp/generichost/net8/AllOf
|
||||
- samples/client/petstore/csharp/generichost/net8/AnyOf
|
||||
- samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
|
||||
|
||||
@@ -11,6 +11,7 @@ on:
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/**
|
||||
- samples/openapi3/client/petstore/java/native**
|
||||
- samples/client/others/java/okhttp-gson-oneOf/**
|
||||
- samples/client/others/java/okhttp-gson-oneOf-array/**
|
||||
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
|
||||
- samples/client/others/java/webclient-useAbstractionForFiles/**
|
||||
- samples/client/others/java/jersey2-oneOf-duplicates/**
|
||||
@@ -26,6 +27,7 @@ on:
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/**
|
||||
- samples/openapi3/client/petstore/java/native**
|
||||
- samples/client/others/java/okhttp-gson-oneOf/**
|
||||
- samples/client/others/java/okhttp-gson-oneOf-array/**
|
||||
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
|
||||
- samples/client/others/java/webclient-useAbstractionForFiles/**
|
||||
- samples/client/others/java/jersey2-oneOf-duplicates/**
|
||||
@@ -75,6 +77,7 @@ jobs:
|
||||
- samples/client/petstore/java/resttemplate-swagger2/
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/
|
||||
- samples/client/others/java/okhttp-gson-oneOf/
|
||||
- samples/client/others/java/okhttp-gson-oneOf-array/
|
||||
- samples/client/echo_api/java/okhttp-gson-user-defined-templates/
|
||||
- samples/client/others/java/resttemplate-useAbstractionForFiles/
|
||||
- samples/client/others/java/webclient-useAbstractionForFiles/
|
||||
|
||||
2
.github/workflows/samples-kotlin-server.yaml
vendored
2
.github/workflows/samples-kotlin-server.yaml
vendored
@@ -17,7 +17,7 @@ on:
|
||||
# - samples/server/petstore/kotlin-spring-default/**
|
||||
|
||||
env:
|
||||
GRADLE_VERSION: 6.9
|
||||
GRADLE_VERSION: 7.6.4
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
1
.github/workflows/samples-scala.yaml
vendored
1
.github/workflows/samples-scala.yaml
vendored
@@ -23,6 +23,7 @@ jobs:
|
||||
- 'samples/client/petstore/java/okhttp-gson'
|
||||
- samples/client/petstore/scalaz
|
||||
- samples/client/petstore/scala-pekko
|
||||
- samples/client/petstore/scala-http4s
|
||||
#- samples/client/petstore/scala-sttp # won't pass while the same tests in circleci pass
|
||||
# servers
|
||||
- samples/server/petstore/scala-lagom-server
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Samples Swift
|
||||
name: Samples Swift 5
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -16,24 +16,18 @@ jobs:
|
||||
os: [macos-latest]
|
||||
sample:
|
||||
- samples/client/petstore/swift5/alamofireLibrary
|
||||
- samples/client/petstore/swift5/anycodableLibrary
|
||||
- samples/client/petstore/swift5/asyncAwaitLibrary
|
||||
- samples/client/petstore/swift5/combineLibrary
|
||||
- samples/client/petstore/swift5/default
|
||||
- samples/client/petstore/swift5/deprecated
|
||||
- samples/client/petstore/swift5/frozenEnums
|
||||
- samples/client/petstore/swift5/nonPublicApi
|
||||
- samples/client/petstore/swift5/objcCompatible
|
||||
- samples/client/petstore/swift5/oneOf
|
||||
- samples/client/petstore/swift5/promisekitLibrary
|
||||
- samples/client/petstore/swift5/readonlyProperties
|
||||
- samples/client/petstore/swift5/resultLibrary
|
||||
- samples/client/petstore/swift5/rxswiftLibrary
|
||||
- samples/client/petstore/swift5/urlsessionLibrary
|
||||
- samples/client/petstore/swift5/validation
|
||||
# NOTE: disabled as vaporLibrary doesnt build when adding this CI config
|
||||
#- samples/client/petstore/swift5/vaporLibrary
|
||||
- samples/client/petstore/swift5/x-swift-hashable
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
sample: samples/client/petstore/swift5/alamofireLibrary
|
||||
37
.github/workflows/samples-typescript-encode-decode.yaml
vendored
Normal file
37
.github/workflows/samples-typescript-encode-decode.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: TypeScript Client (Encoding / Decoding Test)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/others/typescript/encode-decode/**
|
||||
- .github/workflows/samples-typescript-encode-decode.yaml
|
||||
jobs:
|
||||
build:
|
||||
name: Test TypeScript Encoding / Decoding
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/client/others/typescript/encode-decode/test
|
||||
node-version:
|
||||
- 16
|
||||
- 18
|
||||
- 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: |
|
||||
npm run preinstall
|
||||
npm i
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: npm test
|
||||
37
.github/workflows/samples-typescript-node-encode-decode.yaml
vendored
Normal file
37
.github/workflows/samples-typescript-node-encode-decode.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: TypeScript Node Client (Encoding / Decoding Test)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/others/typescript-node/encode-decode/**
|
||||
- .github/workflows/samples-typescript-node-encode-decode.yaml
|
||||
jobs:
|
||||
build:
|
||||
name: Test TypeScript Node Encoding / Decoding
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/client/others/typescript-node/encode-decode/test
|
||||
node-version:
|
||||
- 16
|
||||
- 18
|
||||
- 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: |
|
||||
npm run preinstall
|
||||
npm i
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: npm test
|
||||
2
.github/workflows/windows.yaml
vendored
2
.github/workflows/windows.yaml
vendored
@@ -39,7 +39,7 @@ jobs:
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
- name: Setup Maven
|
||||
uses: s4u/setup-maven-action@v1.14.0
|
||||
uses: s4u/setup-maven-action@v1.15.0
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
maven-version: 3.8.8
|
||||
|
||||
23
.travis.yml
23
.travis.yml
@@ -201,16 +201,19 @@ after_success:
|
||||
echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME";
|
||||
fi;
|
||||
fi;
|
||||
# publish latest website, variables below are secure environment variables which are unavailable to PRs from forks.
|
||||
#- if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
# cd website;
|
||||
# git config --global user.name "${GH_NAME}";
|
||||
# git config --global user.email "${GH_EMAIL}";
|
||||
# echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
|
||||
# yarn install;
|
||||
# GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
|
||||
# fi;
|
||||
|
||||
## NOTE; we will do the followign manually instead as the page doesn't need to be updated in every single travis build
|
||||
## publish latest website, variables below are secure environment variables which are unavailable to PRs from forks.
|
||||
# - if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
# sed -i "s/Vector{UInt8}/Vector\{UInt8\}/g" docs/generators/julia-client.md;
|
||||
# sed -i "s/Vector{UInt8}/Vector\{UInt8\}/g" docs/generators/julia-server.md;
|
||||
# cd website;
|
||||
# git config --global user.name "${GH_NAME}";
|
||||
# git config --global user.email "${GH_EMAIL}";
|
||||
# echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
|
||||
# yarn install;
|
||||
# GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
|
||||
# fi;
|
||||
#
|
||||
env:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ elif [ "$NODE_INDEX" = "3" ]; then
|
||||
#(cd samples/openapi3/client/petstore/typescript/tests/deno && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/builds/browser && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/tests/browser && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/builds/nullable-enum && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-fetch/builds/default && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-fetch/builds/es6-target && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-fetch/builds/with-npm-version && mvn integration-test)
|
||||
@@ -114,6 +115,7 @@ else
|
||||
(cd samples/client/petstore/java/jersey2-java8 && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/java/jersey2-java8 && mvn integration-test)
|
||||
(cd samples/client/petstore/java/jersey3 && mvn integration-test)
|
||||
(cd samples/client/petstore/java/jersey3-oneOf && mvn integration-test)
|
||||
(cd samples/client/others/java/okhttp-gson-streaming && mvn integration-test)
|
||||
(cd samples/client/petstore/java/okhttp-gson && mvn integration-test)
|
||||
(cd samples/client/petstore/java/okhttp-gson-3.1 && mvn integration-test)
|
||||
|
||||
23
README.md
23
README.md
@@ -15,7 +15,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.9.0`):
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.10.0`):
|
||||
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
@@ -87,7 +87,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, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, Spring 6 RestClient, 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, pekko), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (9.x - 18.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
|
||||
| **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, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, Spring 6 RestClient, 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, pekko), **Swift** (2.x, 3.x, 4.x, 5.x, 6.x), **Typescript** (AngularJS, Angular (9.x - 18.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** ([Flight](https://docs.flightphp.com/), 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/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
|
||||
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
|
||||
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
|
||||
@@ -129,7 +129,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
| OpenAPI Generator Version | Release Date | Notes |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||
| 7.9.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.9.0-SNAPSHOT/) | 23.09.2024 | Minor release with breaking changes (with fallback) |
|
||||
| 7.10.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.10.0-SNAPSHOT/) | 07.11.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [7.9.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.9.0) (latest stable release) | 07.10.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [7.8.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.8.0) (latest stable release) | 19.08.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 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) |
|
||||
@@ -193,16 +194,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -437,7 +438,7 @@ openapi-generator-cli version
|
||||
To use a specific version of "openapi-generator-cli"
|
||||
|
||||
```sh
|
||||
openapi-generator-cli version-manager set 7.8.0
|
||||
openapi-generator-cli version-manager set 7.9.0
|
||||
```
|
||||
|
||||
Or install it as dev-dependency:
|
||||
@@ -464,7 +465,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php -o c:\temp\php_api_client`)
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar)
|
||||
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar)
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||
@@ -1045,10 +1046,12 @@ Here is a list of template creators:
|
||||
* Scala (sttp): @chameleon82
|
||||
* Scala (sttp4): @flsh86
|
||||
* Scala (Pekko): @mickaelmagniez
|
||||
* Scala (http4s): @JennyLeahy
|
||||
* Swift: @tkqubo
|
||||
* Swift 3: @hexelon
|
||||
* Swift 4: @ehyche
|
||||
* Swift 5: @4brunu
|
||||
* Swift 6: @4brunu
|
||||
* Swift Combine: @dydus0x14
|
||||
* TypeScript (Angular1): @mhardorf
|
||||
* TypeScript (Angular2): @roni-frantchi
|
||||
@@ -1196,7 +1199,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| JMeter | @kannkyo (2021/01) |
|
||||
| Jetbrains HTTP Client | @jlengrand (2023/01) |
|
||||
| Julia | @tanmaykm (2023/01) |
|
||||
| Kotlin | @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) |
|
||||
| Kotlin | @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10) |
|
||||
| Lua | @daurnimator (2017/08) |
|
||||
| N4JS | @mmews-n4 (2023/03) |
|
||||
| Nim | |
|
||||
@@ -1212,7 +1215,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Rust | @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) |
|
||||
| Scala | @clasnake (2017/07), @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) @fish86 (2023/06) |
|
||||
| Swift | @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @4brunu (2019/11) @dydus0x14 (2023/06) |
|
||||
| TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) |
|
||||
| TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10) |
|
||||
| Xojo | @Topheee (2023/04) |
|
||||
|
||||
|
||||
|
||||
10
bin/configs/csharp-generichost-tags-latest.yaml
Normal file
10
bin/configs/csharp-generichost-tags-latest.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/latest/Tags
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/tags.json
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
modelPropertySorting: alphabetical
|
||||
operationParameterSorting: alphabetical
|
||||
@@ -2,6 +2,7 @@ generatorName: java-helidon-client
|
||||
library: mp
|
||||
outputDir: samples/client/petstore/java-helidon-client/v3/mp
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/java-helidon/client
|
||||
additionalProperties:
|
||||
helidonVersion: 3.2.7
|
||||
artifactId: petstore-helidon-client-mp
|
||||
|
||||
@@ -2,6 +2,7 @@ generatorName: java-helidon-client
|
||||
library: mp
|
||||
outputDir: samples/client/petstore/java-helidon-client/v4/mp
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/java-helidon/client
|
||||
additionalProperties:
|
||||
helidonVersion: 4.0.11
|
||||
artifactId: petstore-helidon-client-mp
|
||||
|
||||
@@ -2,6 +2,7 @@ generatorName: java-helidon-client
|
||||
library: se
|
||||
outputDir: samples/client/petstore/java-helidon-client/v3/se
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/java-helidon/client
|
||||
additionalProperties:
|
||||
helidonVersion: 3.2.7
|
||||
artifactId: petstore-helidon-client-se
|
||||
|
||||
@@ -2,6 +2,7 @@ generatorName: java-helidon-client
|
||||
library: se
|
||||
outputDir: samples/client/petstore/java-helidon-client/v4/se
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/java-helidon/client
|
||||
additionalProperties:
|
||||
helidonVersion: 4.0.11
|
||||
artifactId: petstore-helidon-client-se
|
||||
|
||||
@@ -10,4 +10,4 @@ additionalProperties:
|
||||
build: "all"
|
||||
test: "spock"
|
||||
useAuth: "false"
|
||||
fullProject: "true"
|
||||
fullProject: "true"
|
||||
|
||||
@@ -7,4 +7,4 @@ additionalProperties:
|
||||
helidonVersion: 3.2.7
|
||||
artifactId: format-helidon-server-mp
|
||||
hideGenerationTimestamp: "true"
|
||||
fullProject: "true"
|
||||
fullProject: "true"
|
||||
|
||||
7
bin/configs/java-jersey3-oneOf.yaml
Normal file
7
bin/configs/java-jersey3-oneOf.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/jersey3-oneOf
|
||||
library: jersey3
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_additionalProperties.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: true
|
||||
@@ -1,6 +1,7 @@
|
||||
generatorName: java-micronaut-client
|
||||
outputDir: samples/client/petstore/java-micronaut-client/
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/java-micronaut/
|
||||
additionalProperties:
|
||||
artifactId: petstore-micronaut
|
||||
hideGenerationTimestamp: "true"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
generatorName: java-micronaut-server
|
||||
outputDir: samples/server/petstore/java-micronaut-server/
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/java-micronaut/
|
||||
additionalProperties:
|
||||
artifactId: petstore-micronaut-server
|
||||
hideGenerationTimestamp: "true"
|
||||
|
||||
8
bin/configs/java-okhttp-gson-oneOf-array.yaml
Normal file
8
bin/configs/java-okhttp-gson-oneOf-array.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/others/java/okhttp-gson-oneOf-array
|
||||
library: okhttp-gson
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_array.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
useBeanValidation: "true"
|
||||
@@ -5,6 +5,7 @@ templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||
additionalProperties:
|
||||
artifactId: kotlin-petstore-string
|
||||
serializableModel: "true"
|
||||
mapFileBinaryToByteArray: "true"
|
||||
sortModelPropertiesByRequiredFlag: "false"
|
||||
sortParamsByRequiredFlag: "false"
|
||||
dateLibrary: string
|
||||
|
||||
11
bin/configs/rust-reqwest-petstore-async-tokensource.yaml
Normal file
11
bin/configs/rust-reqwest-petstore-async-tokensource.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/petstore/rust/reqwest/petstore-async-tokensource
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: true
|
||||
supportTokenSource: true
|
||||
supportMultipleResponses: true
|
||||
packageName: petstore-reqwest-async-tokensource
|
||||
useSingleRequestParameter: true
|
||||
6
bin/configs/scala-http4s.yaml
Normal file
6
bin/configs/scala-http4s.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
generatorName: scala-http4s
|
||||
outputDir: samples/client/petstore/scala-http4s
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/scala-http4s/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/scala-http4s
|
||||
additionalProperties:
|
||||
artifactId: scala-http4s-client
|
||||
@@ -1,10 +0,0 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/anycodableLibrary
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/any_codable.yaml
|
||||
modelNamePrefix: Prefix
|
||||
modelNameSuffix: Suffix
|
||||
additionalProperties:
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
@@ -1,10 +0,0 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/deprecated
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-deprecated-fields.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift5
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
@@ -7,5 +7,19 @@ additionalProperties:
|
||||
responseAs: Result
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
sortParamsByRequiredFlag: false
|
||||
enumUnknownDefaultCase: true
|
||||
nonPublicApi: true
|
||||
readonlyProperties: true
|
||||
hashableModels: false
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
nameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
-type: dashType
|
||||
parameterNameMappings:
|
||||
_type: underscoreType
|
||||
type_: typeWithUnderscore
|
||||
-type: dashType
|
||||
|
||||
|
||||
13
bin/configs/swift6-alamofireLibrary.yaml
Normal file
13
bin/configs/swift6-alamofireLibrary.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/alamofireLibrary
|
||||
library: alamofire
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
useCustomDateWithoutTime: true
|
||||
additionalProperties:
|
||||
responseAs: ObjcBlock
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
13
bin/configs/swift6-api-non-static-method.yaml
Normal file
13
bin/configs/swift6-api-non-static-method.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/apiNonStaticMethod
|
||||
library: alamofire
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
additionalProperties:
|
||||
responseAs: AsyncAwait,Combine,Result,PromiseKit,RxSwift,ObjcBlock
|
||||
apiStaticMethod: false
|
||||
mapFileBinaryToData: true
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
@@ -1,11 +1,11 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/x-swift-hashable
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/asyncAwaitLibrary
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift5
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: AsyncAwait
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
hashableModels: false
|
||||
@@ -1,12 +1,12 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/frozenEnums
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/combineDeferredLibrary
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift5
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: Combine
|
||||
useSPMFileStructure: false
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
sortParamsByRequiredFlag: false
|
||||
enumUnknownDefaultCase: true
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
13
bin/configs/swift6-combineLibrary.yaml
Normal file
13
bin/configs/swift6-combineLibrary.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/combineLibrary
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: Combine
|
||||
combineDeferred: false
|
||||
swiftPackagePath: "Sources/CombineLibrary"
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
12
bin/configs/swift6-default.yaml
Normal file
12
bin/configs/swift6-default.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
enumNameMappings:
|
||||
delivered: shipped
|
||||
@@ -1,11 +1,12 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/readonlyProperties
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/objcCompatible
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift5
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: ObjcBlock
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
readonlyProperties: true
|
||||
objcCompatible: true
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
12
bin/configs/swift6-oneOf.yaml
Normal file
12
bin/configs/swift6-oneOf.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/oneOf
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: ObjcBlock
|
||||
useSPMFileStructure: false
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
12
bin/configs/swift6-promisekitLibrary.yaml
Normal file
12
bin/configs/swift6-promisekitLibrary.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/promisekitLibrary
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
useSPMFileStructure: false
|
||||
responseAs: PromiseKit
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
@@ -1,13 +1,18 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/nonPublicApi
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/resultLibrary
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift5
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: Result
|
||||
useSPMFileStructure: false
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
sortParamsByRequiredFlag: false
|
||||
enumUnknownDefaultCase: true
|
||||
nonPublicApi: true
|
||||
readonlyProperties: true
|
||||
hashableModels: false
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
nameMappings:
|
||||
14
bin/configs/swift6-rxswiftLibrary.yaml
Normal file
14
bin/configs/swift6-rxswiftLibrary.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/rxswiftLibrary
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: RxSwift
|
||||
useSPMFileStructure: false
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
useBacktickEscapes: true
|
||||
generateModelAdditionalProperties: false
|
||||
16
bin/configs/swift6-urlsessionLibrary.yaml
Normal file
16
bin/configs/swift6-urlsessionLibrary.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/urlsessionLibrary
|
||||
library: urlsession
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
responseAs: ObjcBlock
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
useSPMFileStructure: true
|
||||
mapFileBinaryToData: true
|
||||
useClasses: true
|
||||
swiftUseApiNamespace: true
|
||||
11
bin/configs/swift6-validation.yaml
Normal file
11
bin/configs/swift6-validation.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/validation
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/validation.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
useSPMFileStructure: false
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
12
bin/configs/swift6-vapor.yaml
Normal file
12
bin/configs/swift6-vapor.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
generatorName: swift6
|
||||
outputDir: samples/client/petstore/swift6/vaporLibrary
|
||||
library: vapor
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
projectName: PetstoreClient
|
||||
useSPMFileStructure: true
|
||||
useClasses: true
|
||||
useBacktickEscapes: true
|
||||
mapFileBinaryToData: true
|
||||
4
bin/configs/typescript-consolidated-nullable-enum.yaml
Normal file
4
bin/configs/typescript-consolidated-nullable-enum.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/openapi3/client/petstore/typescript/builds/nullable-enum
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript/19027-regression.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript
|
||||
4
bin/configs/typescript-consolidated-nullable.yaml
Normal file
4
bin/configs/typescript-consolidated-nullable.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/client/others/typescript/builds/null-types-simple
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_1/null-types-simple.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript
|
||||
@@ -0,0 +1,4 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/client/others/typescript/builds/enum-single-value
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_1/enum-single-value.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript
|
||||
11
bin/configs/typescript-encode-decode.yaml
Normal file
11
bin/configs/typescript-encode-decode.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: typescript
|
||||
outputDir: samples/client/others/typescript/encode-decode/build
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_1/encode-decode.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript
|
||||
additionalProperties:
|
||||
artifactId: encode-decode-typescript
|
||||
hideGenerationTimestamp: "true"
|
||||
npmVersion: 1.0.0
|
||||
npmName: '@openapitools/typescript-encode-decode'
|
||||
nullSafeAdditionalProps: true
|
||||
platform: node
|
||||
4
bin/configs/typescript-node-3.0.yaml
Normal file
4
bin/configs/typescript-node-3.0.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
generatorName: typescript-node
|
||||
outputDir: samples/client/petstore/typescript-node/3_0
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-node/SampleProject.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-node
|
||||
10
bin/configs/typescript-node-encode-decode.yaml
Normal file
10
bin/configs/typescript-node-encode-decode.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
generatorName: typescript-node
|
||||
outputDir: samples/client/others/typescript-node/encode-decode/build
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_1/encode-decode.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-node
|
||||
additionalProperties:
|
||||
artifactId: encode-decode-typescript-node
|
||||
hideGenerationTimestamp: "true"
|
||||
npmVersion: 1.0.0
|
||||
npmName: '@openapitools/typescript-node-encode-decode'
|
||||
nullSafeAdditionalProps: true
|
||||
11
bitrise.yml
11
bitrise.yml
@@ -18,6 +18,15 @@ workflows:
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sudo gem install cocoapods
|
||||
- script@1.2.0:
|
||||
title: Run Swift6 tests
|
||||
inputs:
|
||||
- content: |
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
./samples/client/petstore/swift6/swift6_test_all.sh
|
||||
- script@1.2.0:
|
||||
title: Run Swift5 tests
|
||||
inputs:
|
||||
@@ -39,4 +48,4 @@ workflows:
|
||||
|
||||
meta:
|
||||
bitrise.io:
|
||||
stack: osx-xcode-14.3.x-ventura
|
||||
stack: osx-xcode-16.0.x
|
||||
|
||||
@@ -92,16 +92,401 @@ git clone https://github.com/openapitools/openapi-generator.git
|
||||
cd openapi-generator/samples/client/petstore/swift/default/OpenAPIClientTests
|
||||
mvn integration-test
|
||||
```
|
||||
Besides `default` (folder), there's another folder `promisekit` for Swift API client with [PromiseKit support](https://github.com/mxcl/PromiseKit)
|
||||
|
||||
### Which Swift generator is still actively maintained?
|
||||
|
||||
Please use `swift5` generator because Swift 4.x is deprecated.
|
||||
There is a new `swift6` generator, that is currently in beta, try it and give us your feedback.
|
||||
|
||||
### How do I implement bearer token authentication with URLSession on the Swift 5 API client?
|
||||
|
||||
First you subclass RequestBuilderFactory
|
||||
|
||||
```
|
||||
git clone https://github.com/openapitools/openapi-generator.git
|
||||
cd openapi-generator/samples/client/petstore/swift/promisekit/OpenAPIClientTests
|
||||
mvn integration-test
|
||||
class BearerRequestBuilderFactory: RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
BearerRequestBuilder<T>.self
|
||||
}
|
||||
|
||||
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type {
|
||||
BearerDecodableRequestBuilder<T>.self
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Is Swift (2.x) generator still actively maintained?
|
||||
Then you subclass URLSessionRequestBuilder and URLSessionDecodableRequestBuilder
|
||||
```
|
||||
class BearerRequestBuilder<T>: URLSessionRequestBuilder<T> {
|
||||
@discardableResult
|
||||
override func execute(_ apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, _ completion: @escaping (Result<Response<T>, ErrorResponse>) -> Void) -> RequestTask {
|
||||
|
||||
// Before making the request, we can validate if we have a bearer token to be able to make a request
|
||||
BearerTokenHandler.refreshTokenIfDoesntExist {
|
||||
|
||||
// Here we make the request
|
||||
super.execute(apiResponseQueue) { result in
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
// If we got a successful response, we send the response to the completion block
|
||||
completion(result)
|
||||
|
||||
case let .failure(error):
|
||||
|
||||
// If we got a failure response, we will analyse the error to see what we should do with it
|
||||
if case let ErrorResponse.error(_, data, response, error) = error {
|
||||
|
||||
// If the error is an ErrorResponse.error() we will analyse it to see if it's a 401, and if it's a 401, we will refresh the token and retry the request
|
||||
BearerTokenHandler.refreshTokenIfUnauthorizedRequestResponse(
|
||||
data: data,
|
||||
response: response,
|
||||
error: error
|
||||
) { wasTokenRefreshed in
|
||||
|
||||
if wasTokenRefreshed {
|
||||
// If the token was refreshed, it's because it was a 401 error, so we refreshed the token, and we are going to retry the request by calling self.execute()
|
||||
self.execute(apiResponseQueue, completion)
|
||||
} else {
|
||||
// If the token was not refreshed, it's because it was not a 401 error, so we send the response to the completion block
|
||||
completion(result)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If it's an unknown error, we send the response to the completion block
|
||||
completion(result)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requestTask
|
||||
}
|
||||
}
|
||||
|
||||
class BearerDecodableRequestBuilder<T: Decodable>: URLSessionDecodableRequestBuilder<T> {
|
||||
@discardableResult
|
||||
override func execute(_ apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, _ completion: @escaping (Result<Response<T>, ErrorResponse>) -> Void) -> RequestTask {
|
||||
// Before making the request, we can validate if we have a bearer token to be able to make a request
|
||||
BearerTokenHandler.refreshTokenIfDoesntExist {
|
||||
|
||||
// Here we make the request
|
||||
super.execute(apiResponseQueue) { result in
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
// If we got a successful response, we send the response to the completion block
|
||||
completion(result)
|
||||
|
||||
case let .failure(error):
|
||||
|
||||
// If we got a failure response, we will analyse the error to see what we should do with it
|
||||
if case let ErrorResponse.error(_, data, response, error) = error {
|
||||
|
||||
// If the error is an ErrorResponse.error() we will analyse it to see if it's a 401, and if it's a 401, we will refresh the token and retry the request
|
||||
BearerTokenHandler.refreshTokenIfUnauthorizedRequestResponse(
|
||||
data: data,
|
||||
response: response,
|
||||
error: error
|
||||
) { wasTokenRefreshed in
|
||||
|
||||
if wasTokenRefreshed {
|
||||
// If the token was refreshed, it's because it was a 401 error, so we refreshed the token, and we are going to retry the request by calling self.execute()
|
||||
self.execute(apiResponseQueue, completion)
|
||||
} else {
|
||||
// If the token was not refreshed, it's because it was not a 401 error, so we send the response to the completion block
|
||||
completion(result)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If it's an unknown error, we send the response to the completion block
|
||||
completion(result)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requestTask
|
||||
}
|
||||
}
|
||||
|
||||
class BearerTokenHandler {
|
||||
private static var bearerToken: String? = nil
|
||||
|
||||
static func refreshTokenIfDoesntExist(completionHandler: @escaping () -> Void) {
|
||||
if bearerToken != nil {
|
||||
completionHandler()
|
||||
} else {
|
||||
startRefreshingToken {
|
||||
completionHandler()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func refreshTokenIfUnauthorizedRequestResponse(data: Data?, response: URLResponse?, error: Error?, completionHandler: @escaping (Bool) -> Void) {
|
||||
if let response = response as? HTTPURLResponse, response.statusCode == 401 {
|
||||
startRefreshingToken {
|
||||
completionHandler(true)
|
||||
}
|
||||
} else {
|
||||
completionHandler(false)
|
||||
}
|
||||
}
|
||||
|
||||
private static func startRefreshingToken(completionHandler: @escaping () -> Void) {
|
||||
// Get a bearer token
|
||||
let dummyBearerToken = "..."
|
||||
|
||||
bearerToken = dummyBearerToken
|
||||
PetstoreClientAPI.customHeaders["Authorization"] = "Bearer \(dummyBearerToken)"
|
||||
|
||||
completionHandler()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
No, please use `swift3` or `swift4` generator instead as we want to focus on Swift 3.x, 4.x.
|
||||
Then you assign the `BearerRequestBuilderFactory` to the property `requestBuilderFactory`.
|
||||
|
||||
`PetstoreClientAPI.requestBuilderFactory = BearerRequestBuilderFactory()`
|
||||
|
||||
The name `PetstoreClientAPI.requestBuilderFactory` will change depending on your project name.
|
||||
|
||||
Here is a working sample that put's together all of this.
|
||||
[AppDelegate.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift5/urlsessionLibrary/SwaggerClientTests/SwaggerClient/AppDelegate.swift)
|
||||
[BearerDecodableRequestBuilder.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift5/urlsessionLibrary/SwaggerClientTests/SwaggerClient/BearerDecodableRequestBuilder.swift)
|
||||
|
||||
### How do I implement bearer token authentication with Alamofire on the Swift 5 API client?
|
||||
|
||||
First you subclass RequestBuilderFactory
|
||||
|
||||
```
|
||||
class BearerRequestBuilderFactory: RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
BearerRequestBuilder<T>.self
|
||||
}
|
||||
|
||||
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type {
|
||||
BearerDecodableRequestBuilder<T>.self
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then you subclass AlamofireRequestBuilder and AlamofireDecodableRequestBuilder
|
||||
```
|
||||
class BearerRequestBuilder<T>: AlamofireRequestBuilder<T> {
|
||||
override func createSessionManager() -> SessionManager {
|
||||
let sessionManager = super.createSessionManager()
|
||||
|
||||
let bearerTokenHandler = BearerTokenHandler()
|
||||
sessionManager.adapter = bearerTokenHandler
|
||||
sessionManager.retrier = bearerTokenHandler
|
||||
|
||||
return sessionManager
|
||||
}
|
||||
}
|
||||
|
||||
class BearerDecodableRequestBuilder<T: Decodable>: AlamofireDecodableRequestBuilder<T> {
|
||||
override func createSessionManager() -> SessionManager {
|
||||
let sessionManager = super.createSessionManager()
|
||||
|
||||
let bearerTokenHandler = BearerTokenHandler()
|
||||
sessionManager.adapter = bearerTokenHandler
|
||||
sessionManager.retrier = bearerTokenHandler
|
||||
|
||||
return sessionManager
|
||||
}
|
||||
}
|
||||
|
||||
class BearerTokenHandler: RequestAdapter, RequestRetrier {
|
||||
private static var bearerToken: String? = nil
|
||||
|
||||
func adapt(_ urlRequest: URLRequest) throws -> URLRequest {
|
||||
if let bearerToken = Self.bearerToken {
|
||||
var urlRequest = urlRequest
|
||||
urlRequest.setValue("Bearer \(bearerToken)", forHTTPHeaderField: "Authorization")
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
func should(_: SessionManager, retry request: Request, with _: Error, completion: @escaping RequestRetryCompletion) {
|
||||
if let response = request.task?.response as? HTTPURLResponse, response.statusCode == 401 {
|
||||
Self.startRefreshingToken { isTokenRefreshed in
|
||||
completion(isTokenRefreshed, 0.0)
|
||||
}
|
||||
} else {
|
||||
completion(false, 0.0)
|
||||
}
|
||||
}
|
||||
|
||||
private static func startRefreshingToken(completionHandler: @escaping (Bool) -> Void) {
|
||||
// Get a bearer token
|
||||
let dummyBearerToken = "..."
|
||||
|
||||
bearerToken = dummyBearerToken
|
||||
PetstoreClientAPI.customHeaders["Authorization"] = "Bearer \(dummyBearerToken)"
|
||||
|
||||
completionHandler(true)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then you assign the `BearerRequestBuilderFactory` to the property `requestBuilderFactory`.
|
||||
|
||||
`PetstoreClientAPI.requestBuilderFactory = BearerRequestBuilderFactory()`
|
||||
|
||||
The name `PetstoreClientAPI.requestBuilderFactory` will change depending on your project name.
|
||||
|
||||
Here is a working sample that put's together all of this.
|
||||
[AppDelegate.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift5/alamofireLibrary/SwaggerClientTests/SwaggerClient/AppDelegate.swift)
|
||||
[BearerTokenHandler.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift5/alamofireLibrary/SwaggerClientTests/SwaggerClient/BearerDecodableRequestBuilder.swift)
|
||||
|
||||
### How do I implement bearer token authentication with URLSession on the Swift 6 API client?
|
||||
|
||||
First you implement the `OpenAPIInterceptor` protocol.
|
||||
```
|
||||
public class BearerOpenAPIInterceptor: OpenAPIInterceptor {
|
||||
public init() {}
|
||||
|
||||
public func intercept(urlRequest: URLRequest, urlSession: URLSessionProtocol, openAPIClient: OpenAPIClient, completion: @escaping (Result<URLRequest, any Error>) -> Void) {
|
||||
refreshTokenIfDoesntExist { token in
|
||||
|
||||
// Change the current url request
|
||||
var newUrlRequest = urlRequest
|
||||
newUrlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
|
||||
|
||||
// Change the global headers
|
||||
openAPIClient.customHeaders["Authorization"] = "Bearer \(token)"
|
||||
|
||||
completion(.success(newUrlRequest))
|
||||
}
|
||||
}
|
||||
|
||||
public func retry(urlRequest: URLRequest, urlSession: URLSessionProtocol, openAPIClient: OpenAPIClient, data: Data?, response: URLResponse, error: Error, completion: @escaping (OpenAPIInterceptorRetry) -> Void) {
|
||||
// We will analyse the response to see if it's a 401, and if it's a 401, we will refresh the token and retry the request
|
||||
refreshTokenIfUnauthorizedRequestResponse(
|
||||
data: data,
|
||||
response: response,
|
||||
error: error
|
||||
) { (wasTokenRefreshed, newToken) in
|
||||
|
||||
if wasTokenRefreshed, let newToken = newToken {
|
||||
|
||||
// Change the global headers
|
||||
openAPIClient.customHeaders["Authorization"] = "Bearer \(newToken)"
|
||||
|
||||
completion(.retry)
|
||||
} else {
|
||||
// If the token was not refreshed, it's because it was not a 401 error, so we send the response to the completion block
|
||||
completion(.dontRetry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var bearerToken: String? = nil
|
||||
|
||||
func refreshTokenIfDoesntExist(completionHandler: @escaping (String) -> Void) {
|
||||
if let bearerToken = bearerToken {
|
||||
completionHandler(bearerToken)
|
||||
} else {
|
||||
startRefreshingToken { token in
|
||||
completionHandler(token)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func refreshTokenIfUnauthorizedRequestResponse(data: Data?, response: URLResponse, error: Error, completionHandler: @escaping (Bool, String?) -> Void) {
|
||||
if let response = response as? HTTPURLResponse, response.statusCode == 401 {
|
||||
startRefreshingToken { token in
|
||||
completionHandler(true, token)
|
||||
}
|
||||
} else {
|
||||
completionHandler(false, nil)
|
||||
}
|
||||
}
|
||||
|
||||
private func startRefreshingToken(completionHandler: @escaping (String) -> Void) {
|
||||
// Get a bearer token
|
||||
let dummyBearerToken = "..."
|
||||
|
||||
bearerToken = dummyBearerToken
|
||||
|
||||
completionHandler(dummyBearerToken)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then you assign the `BearerOpenAPIInterceptor` to the property `OpenAPIClient.shared.interceptor`.
|
||||
|
||||
`OpenAPIClient.shared.interceptor = BearerOpenAPIInterceptor()`
|
||||
|
||||
Here is a working sample that put's together all of this.
|
||||
[AppDelegate.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift6/urlsessionLibrary/SwaggerClientTests/SwaggerClient/AppDelegate.swift)
|
||||
[BearerTokenHandler.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift5/urlsessionLibrary/SwaggerClientTests/SwaggerClient/BearerDecodableRequestBuilder.swift)
|
||||
|
||||
### How do I implement bearer token authentication with Alamofire on the Swift 6 API client?
|
||||
|
||||
First implement the `Alamofire` `RequestInterceptor` protocol.
|
||||
```
|
||||
class BearerTokenHandler: RequestInterceptor, @unchecked Sendable {
|
||||
private var bearerToken: String? = nil
|
||||
|
||||
func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Result<URLRequest, Error>) -> Void) {
|
||||
if let bearerToken = bearerToken {
|
||||
var urlRequest = urlRequest
|
||||
urlRequest.setValue("Bearer \(bearerToken)", forHTTPHeaderField: "Authorization")
|
||||
|
||||
completion(.success(urlRequest))
|
||||
return
|
||||
}
|
||||
|
||||
completion(.success(urlRequest))
|
||||
}
|
||||
|
||||
func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void) {
|
||||
if let response = request.task?.response as? HTTPURLResponse, response.statusCode == 401 {
|
||||
startRefreshingToken { isTokenRefreshed in
|
||||
completion(.retry)
|
||||
}
|
||||
} else {
|
||||
completion(.doNotRetryWithError(error))
|
||||
}
|
||||
}
|
||||
|
||||
private func startRefreshingToken(completionHandler: @escaping (Bool) -> Void) {
|
||||
// Get a bearer token
|
||||
let dummyBearerToken = "..."
|
||||
|
||||
bearerToken = dummyBearerToken
|
||||
OpenAPIClient.shared.customHeaders["Authorization"] = "Bearer \(dummyBearerToken)"
|
||||
|
||||
completionHandler(true)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then you assign the `BearerTokenHandler` to the property `OpenAPIClient.shared.interceptor`.
|
||||
|
||||
`OpenAPIClient.shared.interceptor = BearerTokenHandler()`
|
||||
|
||||
Here is a working sample that put's together all of this.
|
||||
[AppDelegate.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift6/alamofireLibrary/SwaggerClientTests/SwaggerClient/AppDelegate.swift)
|
||||
[BearerTokenHandler.swift](https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift6/alamofireLibrary/SwaggerClientTests/SwaggerClient/BearerTokenHandler.swift)
|
||||
|
||||
### How do I migrate from the Swift 5 generator to the swift 6 generator?
|
||||
|
||||
- Change the generator to the new `swift6` generator, e.g. `openapi-generator generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g swift6 -o /tmp/test/`
|
||||
- Check the `swift6` [URLSession](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/swift6/urlsessionLibrary) and [Alamofire](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/swift6/alamofireLibrary) samples.
|
||||
- The infrastructure files have been moved to a new directory called `Infrastructure`. Please delete the old ones.
|
||||
- The `AnyCodable` dependency has been removed and replaced with a new enum called `JSONValue`, allowing you to use this generator without external dependencies.
|
||||
- The `Combine` response is now deferred by default, meaning the request will only start when you begin listening to it. To restore the previous behavior, set the `combineDeferred` flag to `false`.
|
||||
- A new configuration, `apiStaticMethod`, allows you to use instance methods instead of class methods for API calls. For more information, check the sample project [apiNonStaticMethod](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/swift6/apiNonStaticMethod).
|
||||
- The new default response is based on async/await. To revert to the previous behavior, set the `responseAs` flag to `ObjcBlock`.
|
||||
- The default project structure now follows the SPM (Swift Package Manager) structure. To revert to the old structure, set the `useSPMFileStructure` flag to `false`.
|
||||
- The former `{{projectName}}API` is now called `OpenAPIClient`.
|
||||
- You can now set a request interceptor and retrier by configuring `OpenAPIClient.shared.interceptor`, making authenticated requests easier to manage.
|
||||
|
||||
## TypeScript
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ Also refer to the relevant documentation for [CLI](./usage.md), [Maven Plugin](h
|
||||
The following environment variables are supported by their respective generators:
|
||||
<!-- query with: grep -Rn '_POST_PROCESS_FILE"' modules | grep -Eo '[^"]+_POST_PROCESS_FILE' | sort -u -->
|
||||
|
||||
* `AVRO_POST_PROCESS_FILE`
|
||||
* `CPP_POST_PROCESS_FILE`
|
||||
* `CSHARP_POST_PROCESS_FILE`
|
||||
* `C_POST_PROCESS_FILE`
|
||||
|
||||
@@ -59,12 +59,14 @@ The following generators are available:
|
||||
* [rust](generators/rust.md)
|
||||
* [scala-akka](generators/scala-akka.md)
|
||||
* [scala-gatling](generators/scala-gatling.md)
|
||||
* [scala-http4s](generators/scala-http4s.md)
|
||||
* [scala-pekko](generators/scala-pekko.md)
|
||||
* [scala-sttp](generators/scala-sttp.md)
|
||||
* [scala-sttp4 (beta)](generators/scala-sttp4.md)
|
||||
* [scalaz](generators/scalaz.md)
|
||||
* [swift-combine](generators/swift-combine.md)
|
||||
* [swift5](generators/swift5.md)
|
||||
* [swift6 (beta)](generators/swift6.md)
|
||||
* [typescript (experimental)](generators/typescript.md)
|
||||
* [typescript-angular](generators/typescript-angular.md)
|
||||
* [typescript-aurelia](generators/typescript-aurelia.md)
|
||||
|
||||
@@ -120,6 +120,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>if</li>
|
||||
<li>inline</li>
|
||||
<li>int</li>
|
||||
<li>linux</li>
|
||||
<li>long</li>
|
||||
<li>mutable</li>
|
||||
<li>namespace</li>
|
||||
|
||||
@@ -26,6 +26,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|
|
||||
|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|
|
||||
|makeOperationsVirtual|Make all operations methods virtual. This makes it easy to mock the generated API class for testing purposes.| |true|
|
||||
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|
|
||||
|optionalProjectFile|Generate client.pri.| |true|
|
||||
|packageName|C++ package (library) name.| |QtOpenAPIClient|
|
||||
|
||||
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|
||||
|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false|
|
||||
|library|Library template (sub-template) to use|<dl><dt>**jvm-ktor**</dt><dd>Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).</dd><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-spring-webclient**</dt><dd>Platform: Java Virtual Machine. HTTP: Spring 5 (or 6 with useSpringBoot3 enabled) WebClient. JSON processing: Jackson.</dd><dt>**jvm-spring-restclient**</dt><dd>Platform: Java Virtual Machine. HTTP: Spring 6 RestClient. JSON processing: Jackson.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd><dt>**jvm-vertx**</dt><dd>Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.</dd></dl>|jvm-okhttp4|
|
||||
|mapFileBinaryToByteArray|Map File and Binary to ByteArray (default: false)| |false|
|
||||
|modelMutable|Create mutable models| |false|
|
||||
|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|
||||
|nullableReturnType|Nullable return type| |false|
|
||||
|
||||
@@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|supportAsync|If set, generate async function call instead. This option is for 'reqwest' library only| |true|
|
||||
|supportMiddleware|If set, add support for reqwest-middleware. This option is for 'reqwest' library only| |false|
|
||||
|supportMultipleResponses|If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only| |false|
|
||||
|supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' library only and requires the 'supportAsync' option| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|
||||
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
|
||||
|
||||
|
||||
273
docs/generators/scala-http4s.md
Normal file
273
docs/generators/scala-http4s.md
Normal file
@@ -0,0 +1,273 @@
|
||||
---
|
||||
title: Documentation for the scala-http4s Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | scala-http4s | pass this to the generate command after -g |
|
||||
| generator stability | STABLE | |
|
||||
| generator type | CLIENT | |
|
||||
| generator language | Scala | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a scala-http4s 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.
|
||||
|
||||
| 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|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for JDK 1.8+)</dd></dl>|java8|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<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|
|
||||
|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|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|
||||
|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|
|
||||
|sourceFolder|source folder for generated code| |null|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|ArrayBuffer|scala.collection.mutable.ArrayBuffer|
|
||||
|Date|java.util.Date|
|
||||
|File|java.io.File|
|
||||
|HashMap|scala.collection.immutable.HashMap|
|
||||
|Instant|java.time.Instant|
|
||||
|Json|io.circe.Json|
|
||||
|LocalDate|java.time.LocalDate|
|
||||
|LocalDateTime|java.time.LocalDateTime|
|
||||
|LocalTime|java.time.LocalTime|
|
||||
|Map|scala.collection.immutable.Map|
|
||||
|OffsetDateTime|java.time.OffsetDateTime|
|
||||
|Seq|scala.collection.immutable.Seq|
|
||||
|Timestamp|java.sql.Timestamp|
|
||||
|URI|java.net.URI|
|
||||
|UUID|java.util.UUID|
|
||||
|ZonedDateTime|java.time.ZonedDateTime|
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|array|Seq|
|
||||
|list|List|
|
||||
|map|Map|
|
||||
|seq|Seq|
|
||||
|set|Set|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Any</li>
|
||||
<li>AnyRef</li>
|
||||
<li>AnyVal</li>
|
||||
<li>BigDecimal</li>
|
||||
<li>Boolean</li>
|
||||
<li>Double</li>
|
||||
<li>Float</li>
|
||||
<li>Int</li>
|
||||
<li>Integer</li>
|
||||
<li>Long</li>
|
||||
<li>Object</li>
|
||||
<li>String</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>abstract</li>
|
||||
<li>assert</li>
|
||||
<li>break</li>
|
||||
<li>byte</li>
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>char</li>
|
||||
<li>class</li>
|
||||
<li>const</li>
|
||||
<li>continue</li>
|
||||
<li>def</li>
|
||||
<li>default</li>
|
||||
<li>do</li>
|
||||
<li>double</li>
|
||||
<li>else</li>
|
||||
<li>enum</li>
|
||||
<li>extends</li>
|
||||
<li>false</li>
|
||||
<li>final</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
<li>forsome</li>
|
||||
<li>goto</li>
|
||||
<li>if</li>
|
||||
<li>implements</li>
|
||||
<li>implicit</li>
|
||||
<li>import</li>
|
||||
<li>instanceof</li>
|
||||
<li>int</li>
|
||||
<li>interface</li>
|
||||
<li>lazy</li>
|
||||
<li>long</li>
|
||||
<li>match</li>
|
||||
<li>native</li>
|
||||
<li>new</li>
|
||||
<li>null</li>
|
||||
<li>object</li>
|
||||
<li>override</li>
|
||||
<li>package</li>
|
||||
<li>private</li>
|
||||
<li>protected</li>
|
||||
<li>public</li>
|
||||
<li>return</li>
|
||||
<li>sealed</li>
|
||||
<li>short</li>
|
||||
<li>static</li>
|
||||
<li>strictfp</li>
|
||||
<li>super</li>
|
||||
<li>switch</li>
|
||||
<li>synchronized</li>
|
||||
<li>this</li>
|
||||
<li>throw</li>
|
||||
<li>throws</li>
|
||||
<li>trait</li>
|
||||
<li>transient</li>
|
||||
<li>true</li>
|
||||
<li>try</li>
|
||||
<li>type</li>
|
||||
<li>val</li>
|
||||
<li>var</li>
|
||||
<li>void</li>
|
||||
<li>volatile</li>
|
||||
<li>while</li>
|
||||
<li>with</li>
|
||||
<li>yield</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
||||
|
||||
### Client Modification Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasePath|✗|ToolingExtension
|
||||
|Authorizations|✗|ToolingExtension
|
||||
|UserAgent|✗|ToolingExtension
|
||||
|MockServer|✗|ToolingExtension
|
||||
|
||||
### Data Type Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Custom|✗|OAS2,OAS3
|
||||
|Int32|✓|OAS2,OAS3
|
||||
|Int64|✓|OAS2,OAS3
|
||||
|Float|✓|OAS2,OAS3
|
||||
|Double|✓|OAS2,OAS3
|
||||
|Decimal|✓|ToolingExtension
|
||||
|String|✓|OAS2,OAS3
|
||||
|Byte|✓|OAS2,OAS3
|
||||
|Binary|✓|OAS2,OAS3
|
||||
|Boolean|✓|OAS2,OAS3
|
||||
|Date|✓|OAS2,OAS3
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|CollectionFormatMulti|✓|OAS2
|
||||
|Enum|✓|OAS2,OAS3
|
||||
|ArrayOfEnum|✓|ToolingExtension
|
||||
|ArrayOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
||||
|MapOfEnum|✓|ToolingExtension
|
||||
|MapOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|MapOfCollectionOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfEnum|✓|ToolingExtension
|
||||
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✗|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
### Global Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Host|✓|OAS2,OAS3
|
||||
|BasePath|✓|OAS2,OAS3
|
||||
|Info|✓|OAS2,OAS3
|
||||
|Schemes|✗|OAS2,OAS3
|
||||
|PartialSchemes|✓|OAS2,OAS3
|
||||
|Consumes|✓|OAS2
|
||||
|Produces|✓|OAS2
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✗|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✗|OAS2
|
||||
|Cookie|✗|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✗|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✗|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
||||
|SignatureAuth|✗|OAS3
|
||||
|AWSV4Signature|✗|ToolingExtension
|
||||
|
||||
### Wire Format Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✓|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✓|OAS2,OAS3
|
||||
@@ -27,11 +27,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|hashableModels|Make hashable models (default: true)| |true|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<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|
|
||||
|lenientTypeCast|Accept and cast values for simple types (string->bool, string->int, int->string)| |false|
|
||||
|library|Library template (sub-template) to use|<dl><dt>**urlsession**</dt><dd>[DEFAULT] HTTP client: URLSession</dd><dt>**alamofire**</dt><dd>HTTP client: Alamofire</dd><dt>**vapor**</dt><dd>HTTP client: Vapor</dd></dl>|urlsession|
|
||||
|mapFileBinaryToData|[WARNING] This option will be removed and enabled by default in the future once we've enhanced the code to work with `Data` in all the different situations. Map File and Binary to Data (default: false)| |false|
|
||||
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null|
|
||||
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
|
||||
|oneOfUnknownDefaultCase|Add unknownDefault case to oneOf enum (default: false)| |false|
|
||||
|podAuthors|Authors used for Podspec| |null|
|
||||
|podDescription|Description used for Podspec| |null|
|
||||
|podDocumentationURL|Documentation URL used for Podspec| |null|
|
||||
|
||||
358
docs/generators/swift6.md
Normal file
358
docs/generators/swift6.md
Normal file
@@ -0,0 +1,358 @@
|
||||
---
|
||||
title: Documentation for the swift6 Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | swift6 | pass this to the generate command after -g |
|
||||
| generator stability | BETA | |
|
||||
| generator type | CLIENT | |
|
||||
| generator language | Swift | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a Swift 6.x client library. | |
|
||||
|
||||
## CONFIG OPTIONS
|
||||
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiNamePrefix|Prefix that will be appended to all API names ('tags'). Default: empty string. e.g. Pet => Pet.| |null|
|
||||
|apiStaticMethod|Make api calls using a static method (default: true)| |true|
|
||||
|combineDeferred|Make combine usages deferred (default: true)| |true|
|
||||
|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|
|
||||
|generateModelAdditionalProperties|Generate model additional properties (default: true)| |true|
|
||||
|hashableModels|Make hashable models (default: true)| |true|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<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|
|
||||
|library|Library template (sub-template) to use|<dl><dt>**urlsession**</dt><dd>[DEFAULT] HTTP client: URLSession</dd><dt>**alamofire**</dt><dd>HTTP client: Alamofire</dd><dt>**vapor**</dt><dd>HTTP client: Vapor</dd></dl>|urlsession|
|
||||
|mapFileBinaryToData|Map File and Binary to Data (default: false)| |false|
|
||||
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null|
|
||||
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
|
||||
|oneOfUnknownDefaultCase|Add unknownDefault case to oneOf enum (default: false)| |false|
|
||||
|podAuthors|Authors used for Podspec| |null|
|
||||
|podDescription|Description used for Podspec| |null|
|
||||
|podDocumentationURL|Documentation URL used for Podspec| |null|
|
||||
|podHomepage|Homepage used for Podspec| |null|
|
||||
|podLicense|License used for Podspec| |null|
|
||||
|podScreenshots|Screenshots used for Podspec| |null|
|
||||
|podSocialMediaURL|Social Media URL used for Podspec| |null|
|
||||
|podSource|Source information used for Podspec| |null|
|
||||
|podSummary|Summary used for Podspec| |null|
|
||||
|podVersion|Version used for Podspec| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|projectName|Project name in Xcode| |null|
|
||||
|readonlyProperties|Make properties readonly (default: false)| |null|
|
||||
|responseAs|Optionally use libraries to manage response. Currently AsyncAwait, Combine, Result, RxSwift, ObjcBlock, PromiseKit are available.| |null|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|swiftPackagePath|Set a custom source path instead of Sources/{{projectName}}.| |null|
|
||||
|swiftUseApiNamespace|Flag to make all the API classes inner-class of {{projectName}}API| |null|
|
||||
|useBacktickEscapes|Escape reserved words using backticks (default: false)| |false|
|
||||
|useClasses|Use final classes for models instead of structs (default: false)| |false|
|
||||
|useCustomDateWithoutTime|Uses a custom type to decode and encode dates without time information to support OpenAPIs date format (default: false)| |false|
|
||||
|useJsonEncodable|Make models conform to JSONEncodable protocol (default: true)| |true|
|
||||
|useSPMFileStructure|Use SPM file structure and set the source path to Sources/{{projectName}} (default: true).| |null|
|
||||
|validatable|Make validation rules and validator for model properies (default: true)| |true|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Any</li>
|
||||
<li>AnyObject</li>
|
||||
<li>Bool</li>
|
||||
<li>Character</li>
|
||||
<li>Data</li>
|
||||
<li>Date</li>
|
||||
<li>Decimal</li>
|
||||
<li>Double</li>
|
||||
<li>Float</li>
|
||||
<li>Int</li>
|
||||
<li>Int32</li>
|
||||
<li>Int64</li>
|
||||
<li>JSONValue</li>
|
||||
<li>OpenAPIDateWithoutTime</li>
|
||||
<li>String</li>
|
||||
<li>URL</li>
|
||||
<li>UUID</li>
|
||||
<li>Void</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>#available</li>
|
||||
<li>#colorLiteral</li>
|
||||
<li>#column</li>
|
||||
<li>#else</li>
|
||||
<li>#elseif</li>
|
||||
<li>#endif</li>
|
||||
<li>#file</li>
|
||||
<li>#fileLiteral</li>
|
||||
<li>#function</li>
|
||||
<li>#if</li>
|
||||
<li>#imageLiteral</li>
|
||||
<li>#line</li>
|
||||
<li>#selector</li>
|
||||
<li>#sourceLocation</li>
|
||||
<li>Any</li>
|
||||
<li>AnyObject</li>
|
||||
<li>Array</li>
|
||||
<li>Bool</li>
|
||||
<li>COLUMN</li>
|
||||
<li>Character</li>
|
||||
<li>Class</li>
|
||||
<li>ClosedRange</li>
|
||||
<li>Codable</li>
|
||||
<li>CountableClosedRange</li>
|
||||
<li>CountableRange</li>
|
||||
<li>Data</li>
|
||||
<li>Decodable</li>
|
||||
<li>Dictionary</li>
|
||||
<li>Double</li>
|
||||
<li>Encodable</li>
|
||||
<li>Error</li>
|
||||
<li>ErrorResponse</li>
|
||||
<li>FILE</li>
|
||||
<li>FUNCTION</li>
|
||||
<li>Float</li>
|
||||
<li>Float32</li>
|
||||
<li>Float64</li>
|
||||
<li>Float80</li>
|
||||
<li>Int</li>
|
||||
<li>Int16</li>
|
||||
<li>Int32</li>
|
||||
<li>Int64</li>
|
||||
<li>Int8</li>
|
||||
<li>LINE</li>
|
||||
<li>OptionSet</li>
|
||||
<li>Optional</li>
|
||||
<li>Protocol</li>
|
||||
<li>Range</li>
|
||||
<li>Response</li>
|
||||
<li>Self</li>
|
||||
<li>Set</li>
|
||||
<li>StaticString</li>
|
||||
<li>String</li>
|
||||
<li>Type</li>
|
||||
<li>UInt</li>
|
||||
<li>UInt16</li>
|
||||
<li>UInt32</li>
|
||||
<li>UInt64</li>
|
||||
<li>UInt8</li>
|
||||
<li>URL</li>
|
||||
<li>Unicode</li>
|
||||
<li>Void</li>
|
||||
<li>_</li>
|
||||
<li>as</li>
|
||||
<li>associatedtype</li>
|
||||
<li>associativity</li>
|
||||
<li>break</li>
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>class</li>
|
||||
<li>continue</li>
|
||||
<li>convenience</li>
|
||||
<li>default</li>
|
||||
<li>defer</li>
|
||||
<li>deinit</li>
|
||||
<li>didSet</li>
|
||||
<li>do</li>
|
||||
<li>dynamic</li>
|
||||
<li>dynamicType</li>
|
||||
<li>else</li>
|
||||
<li>enum</li>
|
||||
<li>extension</li>
|
||||
<li>fallthrough</li>
|
||||
<li>false</li>
|
||||
<li>fileprivate</li>
|
||||
<li>final</li>
|
||||
<li>for</li>
|
||||
<li>func</li>
|
||||
<li>get</li>
|
||||
<li>guard</li>
|
||||
<li>if</li>
|
||||
<li>import</li>
|
||||
<li>in</li>
|
||||
<li>indirect</li>
|
||||
<li>infix</li>
|
||||
<li>init</li>
|
||||
<li>inout</li>
|
||||
<li>internal</li>
|
||||
<li>is</li>
|
||||
<li>lazy</li>
|
||||
<li>left</li>
|
||||
<li>let</li>
|
||||
<li>mutating</li>
|
||||
<li>nil</li>
|
||||
<li>none</li>
|
||||
<li>nonmutating</li>
|
||||
<li>open</li>
|
||||
<li>operator</li>
|
||||
<li>optional</li>
|
||||
<li>override</li>
|
||||
<li>postfix</li>
|
||||
<li>precedence</li>
|
||||
<li>prefix</li>
|
||||
<li>private</li>
|
||||
<li>protocol</li>
|
||||
<li>public</li>
|
||||
<li>repeat</li>
|
||||
<li>required</li>
|
||||
<li>rethrows</li>
|
||||
<li>return</li>
|
||||
<li>right</li>
|
||||
<li>self</li>
|
||||
<li>set</li>
|
||||
<li>static</li>
|
||||
<li>struct</li>
|
||||
<li>subscript</li>
|
||||
<li>super</li>
|
||||
<li>switch</li>
|
||||
<li>throw</li>
|
||||
<li>throws</li>
|
||||
<li>true</li>
|
||||
<li>try</li>
|
||||
<li>typealias</li>
|
||||
<li>unowned</li>
|
||||
<li>var</li>
|
||||
<li>weak</li>
|
||||
<li>where</li>
|
||||
<li>while</li>
|
||||
<li>willSet</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
||||
|
||||
### Client Modification Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasePath|✗|ToolingExtension
|
||||
|Authorizations|✗|ToolingExtension
|
||||
|UserAgent|✗|ToolingExtension
|
||||
|MockServer|✗|ToolingExtension
|
||||
|
||||
### Data Type Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Custom|✗|OAS2,OAS3
|
||||
|Int32|✓|OAS2,OAS3
|
||||
|Int64|✓|OAS2,OAS3
|
||||
|Float|✓|OAS2,OAS3
|
||||
|Double|✓|OAS2,OAS3
|
||||
|Decimal|✓|ToolingExtension
|
||||
|String|✓|OAS2,OAS3
|
||||
|Byte|✓|OAS2,OAS3
|
||||
|Binary|✓|OAS2,OAS3
|
||||
|Boolean|✓|OAS2,OAS3
|
||||
|Date|✓|OAS2,OAS3
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|CollectionFormatMulti|✓|OAS2
|
||||
|Enum|✓|OAS2,OAS3
|
||||
|ArrayOfEnum|✓|ToolingExtension
|
||||
|ArrayOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
||||
|MapOfEnum|✓|ToolingExtension
|
||||
|MapOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|MapOfCollectionOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfEnum|✓|ToolingExtension
|
||||
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✗|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
### Global Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Host|✓|OAS2,OAS3
|
||||
|BasePath|✓|OAS2,OAS3
|
||||
|Info|✓|OAS2,OAS3
|
||||
|Schemes|✗|OAS2,OAS3
|
||||
|PartialSchemes|✓|OAS2,OAS3
|
||||
|Consumes|✓|OAS2
|
||||
|Produces|✓|OAS2
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✓|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✓|OAS2
|
||||
|Cookie|✓|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✓|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✓|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
|
||||
|SignatureAuth|✗|OAS3
|
||||
|AWSV4Signature|✗|ToolingExtension
|
||||
|
||||
### Wire Format Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✓|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✗|OAS2,OAS3
|
||||
@@ -22,7 +22,7 @@ npm install @openapitools/openapi-generator-cli -g
|
||||
To install a specific version of the tool, pass the version during installation:
|
||||
<!-- RELEASE_VERSION -->
|
||||
```bash
|
||||
openapi-generator-cli version-manager set 7.8.0
|
||||
openapi-generator-cli version-manager set 7.9.0
|
||||
```
|
||||
<!-- /RELEASE_VERSION -->
|
||||
To install the tool as a dev dependency in your current project:
|
||||
@@ -103,18 +103,18 @@ docker run --rm \
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
|
||||
```bash
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
|
||||
```powershell
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar
|
||||
```
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>7.8.0</version>
|
||||
<version>7.9.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.9.0-SNAPSHOT</version>
|
||||
<version>7.10.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.9.0-SNAPSHOT</version>
|
||||
<version>7.10.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.9.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.10.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.9.0-SNAPSHOT</version>
|
||||
<version>7.10.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.9.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.10.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -80,6 +80,15 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
@Input
|
||||
val generatorName = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* This is the configuration for reference paths where schemas for openapi generation are stored
|
||||
* The directory which contains the additional schema files
|
||||
*/
|
||||
@Optional
|
||||
@InputDirectory
|
||||
@PathSensitive(PathSensitivity.ABSOLUTE)
|
||||
val schemaLocation = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* The output target directory into which code will be generated.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.9.0-SNAPSHOT</version>
|
||||
<version>7.10.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.9.0-SNAPSHOT</version>
|
||||
<version>7.10.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.9.0-SNAPSHOT</version>
|
||||
<version>7.10.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.9.0-SNAPSHOT</version>
|
||||
<version>7.10.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.9.0-SNAPSHOT</version>
|
||||
<version>7.10.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.9.0-SNAPSHOT</version>
|
||||
<version>7.10.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.9.0-SNAPSHOT</version>
|
||||
<version>7.10.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.9.0-SNAPSHOT</version>
|
||||
<version>7.10.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.9.0-SNAPSHOT</version>
|
||||
<version>7.10.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CodegenOperation {
|
||||
hasVersionHeaders = false, hasVersionQueryParams = false,
|
||||
isResponseBinary = false, isResponseFile = false, isResponseOptional = false, hasReference = false, defaultReturnType = false,
|
||||
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
isRestful, isDeprecated, isCallbackRequest, uniqueItems, hasDefaultResponse = false, hasConstantParams = false,
|
||||
isRestful, isDeprecated, isCallbackRequest, uniqueItems, hasDefaultResponse = false, hasOnlyDefaultResponse = false, hasConstantParams = false,
|
||||
hasErrorResponseObject, // if 4xx, 5xx responses have at least one error object defined
|
||||
hasSingleParam = false; // if the operation has only one parameter;
|
||||
public CodegenProperty returnProperty;
|
||||
@@ -215,6 +215,13 @@ public class CodegenOperation {
|
||||
return responses.stream().anyMatch(response -> response.isDefault);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the responses contain only 1 entry and it's default
|
||||
*
|
||||
* @return true if responses contain only 1 entry and it's a default response, false otherwise
|
||||
*/
|
||||
public boolean getHasOnlyDefaultResponse() { return responses.size() == 1 && getHasDefaultResponse(); }
|
||||
|
||||
public boolean getAllResponsesAreErrors() {
|
||||
return responses.stream().allMatch(response -> response.is4xx || response.is5xx);
|
||||
}
|
||||
@@ -351,6 +358,7 @@ public class CodegenOperation {
|
||||
sb.append(", isResponseOptional=").append(isResponseOptional);
|
||||
sb.append(", hasReference=").append(hasReference);
|
||||
sb.append(", hasDefaultResponse=").append(hasDefaultResponse);
|
||||
sb.append(", hasOnlyDefaultResponse=").append(hasOnlyDefaultResponse);
|
||||
sb.append(", hasErrorResponseObject=").append(hasErrorResponseObject);
|
||||
sb.append(", hasSingleParam=").append(hasSingleParam);
|
||||
sb.append(", isRestfulIndex=").append(isRestfulIndex);
|
||||
@@ -432,6 +440,7 @@ public class CodegenOperation {
|
||||
isResponseOptional == that.isResponseOptional &&
|
||||
hasReference == that.hasReference &&
|
||||
hasDefaultResponse == that.hasDefaultResponse &&
|
||||
hasOnlyDefaultResponse == that.hasOnlyDefaultResponse &&
|
||||
hasErrorResponseObject == that.hasErrorResponseObject &&
|
||||
hasSingleParam == that.hasSingleParam &&
|
||||
isRestfulIndex == that.isRestfulIndex &&
|
||||
@@ -496,7 +505,7 @@ public class CodegenOperation {
|
||||
return Objects.hash(responseHeaders, hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
|
||||
hasRequiredParams, returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMap,
|
||||
isArray, isMultipart, isVoid, isResponseBinary, isResponseFile, isResponseOptional, hasReference,
|
||||
hasDefaultResponse, isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
hasDefaultResponse, hasOnlyDefaultResponse, isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
isRestful, isDeprecated, isCallbackRequest, uniqueItems, path, operationId, returnType, httpMethod,
|
||||
returnBaseType, returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse,
|
||||
discriminator, consumes, produces, prioritizedContentTypes, servers, bodyParam, allParams, bodyParams,
|
||||
|
||||
@@ -71,6 +71,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
@@ -1452,7 +1456,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the file name of the Api Test
|
||||
* Return the file name of the Api
|
||||
*
|
||||
* @param name the file name of the Api
|
||||
* @return the file name of the Api
|
||||
@@ -2424,7 +2428,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return schema.getFormat();
|
||||
}
|
||||
return "string";
|
||||
} else if (ModelUtils.isFreeFormObject(schema)) {
|
||||
} else if (ModelUtils.isFreeFormObject(schema, openAPI)) {
|
||||
// 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";
|
||||
@@ -2649,11 +2653,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.xmlName = ((Schema) innerSchema).getXml().getName();
|
||||
}
|
||||
if (modelDiscriminators > 1) {
|
||||
LOGGER.error("Allof composed schema is inheriting >1 discriminator. Only use one discriminator: {}", composed);
|
||||
LOGGER.debug("Allof composed schema is inheriting >1 discriminator. Only use one discriminator: {}", composed);
|
||||
}
|
||||
|
||||
if (modelImplCnt++ > 1) {
|
||||
LOGGER.warn("More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored.");
|
||||
LOGGER.debug("More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored.");
|
||||
break; // only one schema with discriminator allowed in allOf
|
||||
}
|
||||
}
|
||||
@@ -2833,7 +2837,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(schema)) {
|
||||
} else if (ModelUtils.isFreeFormObject(schema, openAPI)) {
|
||||
// non-composed object type with no properties + additionalProperties
|
||||
// additionalProperties must be null, ObjectSchema, or empty Schema
|
||||
addAdditionPropertiesToCodeGenModel(m, schema);
|
||||
@@ -3039,7 +3043,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.isNullable = Boolean.TRUE;
|
||||
}
|
||||
|
||||
m.setTypeProperties(schema);
|
||||
m.setTypeProperties(schema, openAPI);
|
||||
m.setFormat(schema.getFormat());
|
||||
m.setComposedSchemas(getComposedSchemas(schema));
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
@@ -3154,7 +3158,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
additionalPropertiesIsAnyType = true;
|
||||
}
|
||||
} else {
|
||||
// if additioanl properties is set (e.g. free form object, any type, string, etc)
|
||||
// if additional properties is set (e.g. free form object, any type, string, etc)
|
||||
addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false);
|
||||
additionalPropertiesIsAnyType = true;
|
||||
}
|
||||
@@ -3698,7 +3702,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
protected void updatePropertyForObject(CodegenProperty property, Schema p) {
|
||||
if (ModelUtils.isFreeFormObject(p)) {
|
||||
if (ModelUtils.isFreeFormObject(p, openAPI)) {
|
||||
// non-composed object type with no properties + additionalProperties
|
||||
// additionalProperties must be null, ObjectSchema, or empty Schema
|
||||
property.isFreeFormObject = true;
|
||||
@@ -3949,6 +3953,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
List<Object> _enum = p.getEnum();
|
||||
property._enum = new ArrayList<>();
|
||||
for (Object i : _enum) {
|
||||
// raw null values in enums are unions for nullable
|
||||
// atttributes, not actual enum values, so we remove them here
|
||||
if (i == null) {
|
||||
property.isNullable = true;
|
||||
continue;
|
||||
}
|
||||
property._enum.add(String.valueOf(i));
|
||||
}
|
||||
property.isEnum = true;
|
||||
@@ -4022,7 +4032,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.datatypeWithEnum = property.dataType;
|
||||
}
|
||||
|
||||
property.setTypeProperties(p);
|
||||
property.setTypeProperties(p, openAPI);
|
||||
property.setComposedSchemas(getComposedSchemas(p));
|
||||
if (ModelUtils.isIntegerSchema(p)) { // integer type
|
||||
updatePropertyForInteger(property, p);
|
||||
@@ -4068,7 +4078,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) && !ModelUtils.isFreeFormObject(p) && !isAnyTypeWithNothingElseSet) {
|
||||
if (!ModelUtils.isArraySchema(p) && !ModelUtils.isMapSchema(p) && !ModelUtils.isFreeFormObject(p, openAPI) && !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
|
||||
*/
|
||||
@@ -4865,7 +4875,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
r.setTypeProperties(responseSchema);
|
||||
r.setTypeProperties(responseSchema, openAPI);
|
||||
r.setComposedSchemas(getComposedSchemas(responseSchema));
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
r.simpleType = false;
|
||||
@@ -4925,7 +4935,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
r.isDouble = Boolean.TRUE;
|
||||
}
|
||||
} else if (ModelUtils.isTypeObjectSchema(responseSchema)) {
|
||||
if (ModelUtils.isFreeFormObject(responseSchema)) {
|
||||
if (ModelUtils.isFreeFormObject(responseSchema, openAPI)) {
|
||||
r.isFreeFormObject = true;
|
||||
} else {
|
||||
r.isModel = true;
|
||||
@@ -5189,7 +5199,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
ModelUtils.syncValidationProperties(parameterSchema, codegenParameter);
|
||||
codegenParameter.setTypeProperties(parameterSchema);
|
||||
codegenParameter.setTypeProperties(parameterSchema, openAPI);
|
||||
codegenParameter.setComposedSchemas(getComposedSchemas(parameterSchema));
|
||||
|
||||
if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec
|
||||
@@ -5239,7 +5249,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isMapSchema(parameterSchema)) { // for map parameter
|
||||
updateParameterForMap(codegenParameter, parameterSchema, imports);
|
||||
}
|
||||
if (ModelUtils.isFreeFormObject(parameterSchema)) {
|
||||
if (ModelUtils.isFreeFormObject(parameterSchema, openAPI)) {
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
}
|
||||
addVarsRequiredVarsAdditionalProps(parameterSchema, codegenParameter);
|
||||
@@ -5668,6 +5678,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<String, Integer> seenOperationIds = new HashMap<String, Integer>();
|
||||
|
||||
/**
|
||||
* Add operation to group
|
||||
*
|
||||
@@ -5688,13 +5700,18 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
// check for operationId uniqueness
|
||||
String uniqueName = co.operationId;
|
||||
int counter = 0;
|
||||
int counter = seenOperationIds.getOrDefault(uniqueName, 0);
|
||||
while(seenOperationIds.containsKey(uniqueName)) {
|
||||
uniqueName = co.operationId + "_" + counter;
|
||||
counter++;
|
||||
}
|
||||
for (CodegenOperation op : opList) {
|
||||
if (uniqueName.equals(op.operationId)) {
|
||||
uniqueName = co.operationId + "_" + counter;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
seenOperationIds.put(co.operationId, counter);
|
||||
if (!co.operationId.equals(uniqueName)) {
|
||||
LOGGER.warn("generated unique operationId `{}`", uniqueName);
|
||||
}
|
||||
@@ -6070,30 +6087,68 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a value that is unique, suffixed with _index to make it unique
|
||||
* Ensures generated files are unique when compared case-insensitive
|
||||
* Not all operating systems support case-sensitive paths
|
||||
*/
|
||||
private String uniqueCaseInsensitiveString(String value, Map<String, String> seenValues) {
|
||||
if (seenValues.keySet().contains(value)) {
|
||||
return seenValues.get(value);
|
||||
}
|
||||
|
||||
Optional<Entry<String,String>> foundEntry = seenValues.entrySet().stream().filter(v -> v.getValue().toLowerCase(Locale.ROOT).equals(value.toLowerCase(Locale.ROOT))).findAny();
|
||||
if (foundEntry.isPresent()) {
|
||||
int counter = 0;
|
||||
String uniqueValue = value + "_" + counter;
|
||||
|
||||
while (seenValues.values().stream().map(v -> v.toLowerCase(Locale.ROOT)).collect(Collectors.toList()).contains(uniqueValue.toLowerCase(Locale.ROOT))) {
|
||||
counter++;
|
||||
uniqueValue = value + "_" + counter;
|
||||
}
|
||||
|
||||
seenValues.put(value, uniqueValue);
|
||||
return uniqueValue;
|
||||
}
|
||||
|
||||
seenValues.put(value, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private final Map<String, String> seenApiFilenames = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String apiFilename(String templateName, String tag) {
|
||||
String uniqueTag = uniqueCaseInsensitiveString(tag, seenApiFilenames);
|
||||
String suffix = apiTemplateFiles().get(templateName);
|
||||
return apiFileFolder() + File.separator + toApiFilename(tag) + suffix;
|
||||
return apiFileFolder() + File.separator + toApiFilename(uniqueTag) + suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFilename(String templateName, String tag, String outputDir) {
|
||||
String uniqueTag = uniqueCaseInsensitiveString(tag, seenApiFilenames);
|
||||
String suffix = apiTemplateFiles().get(templateName);
|
||||
return outputDir + File.separator + toApiFilename(tag) + suffix;
|
||||
return outputDir + File.separator + toApiFilename(uniqueTag) + suffix;
|
||||
}
|
||||
|
||||
private final Map<String, String> seenModelFilenames = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String modelFilename(String templateName, String modelName) {
|
||||
String uniqueModelName = uniqueCaseInsensitiveString(modelName, seenModelFilenames);
|
||||
String suffix = modelTemplateFiles().get(templateName);
|
||||
return modelFileFolder() + File.separator + toModelFilename(modelName) + suffix;
|
||||
return modelFileFolder() + File.separator + toModelFilename(uniqueModelName) + suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFilename(String templateName, String modelName, String outputDir) {
|
||||
String uniqueModelName = uniqueCaseInsensitiveString(modelName, seenModelFilenames);
|
||||
String suffix = modelTemplateFiles().get(templateName);
|
||||
return outputDir + File.separator + toModelFilename(modelName) + suffix;
|
||||
return outputDir + File.separator + toModelFilename(uniqueModelName) + suffix;
|
||||
}
|
||||
|
||||
private final Map<String, String> seenApiDocFilenames = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Return the full path and API documentation file
|
||||
*
|
||||
@@ -6103,11 +6158,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
@Override
|
||||
public String apiDocFilename(String templateName, String tag) {
|
||||
String uniqueTag = uniqueCaseInsensitiveString(tag, seenApiDocFilenames);
|
||||
String docExtension = getDocExtension();
|
||||
String suffix = docExtension != null ? docExtension : apiDocTemplateFiles().get(templateName);
|
||||
return apiDocFileFolder() + File.separator + toApiDocFilename(tag) + suffix;
|
||||
return apiDocFileFolder() + File.separator + toApiDocFilename(uniqueTag) + suffix;
|
||||
}
|
||||
|
||||
private final Map<String, String> seenApiTestFilenames = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Return the full path and API test file
|
||||
*
|
||||
@@ -6117,8 +6175,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
@Override
|
||||
public String apiTestFilename(String templateName, String tag) {
|
||||
String uniqueTag = uniqueCaseInsensitiveString(tag, seenApiTestFilenames);
|
||||
String suffix = apiTestTemplateFiles().get(templateName);
|
||||
return apiTestFileFolder() + File.separator + toApiTestFilename(tag) + suffix;
|
||||
return apiTestFileFolder() + File.separator + toApiTestFilename(uniqueTag) + suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -6640,6 +6699,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
: 0;
|
||||
|
||||
for (Object value : values) {
|
||||
if (value == null) {
|
||||
// raw null values in enums are unions for nullable
|
||||
// attributes, not actual enum values, so we remove them here
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> enumVar = new HashMap<>();
|
||||
String enumName = truncateIdx == 0
|
||||
? String.valueOf(value)
|
||||
@@ -7115,7 +7179,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
Schema ps = unaliasSchema(propertySchema);
|
||||
ModelUtils.syncValidationProperties(ps, codegenParameter);
|
||||
codegenParameter.setTypeProperties(ps);
|
||||
codegenParameter.setTypeProperties(ps, openAPI);
|
||||
codegenParameter.setComposedSchemas(getComposedSchemas(ps));
|
||||
if (ps.getPattern() != null) {
|
||||
codegenParameter.pattern = toRegularExpression(ps.getPattern());
|
||||
@@ -7206,7 +7270,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isPrimitiveType = false;
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
|
||||
} else if (ModelUtils.isFreeFormObject(ps)) {
|
||||
} else if (ModelUtils.isFreeFormObject(ps, openAPI)) {
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
}
|
||||
} else if (ModelUtils.isNullType(ps)) {
|
||||
@@ -7382,7 +7446,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
useModel = false;
|
||||
} else {
|
||||
if (ModelUtils.isFreeFormObject(schema)) {
|
||||
if (ModelUtils.isFreeFormObject(schema, openAPI)) {
|
||||
useModel = ModelUtils.shouldGenerateFreeFormObjectModel(name, this);
|
||||
} else if (ModelUtils.isMapSchema(schema)) {
|
||||
useModel = ModelUtils.shouldGenerateMapModel(schema);
|
||||
@@ -7461,7 +7525,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 (ModelUtils.isFreeFormObject(schema)) {
|
||||
} else if (ModelUtils.isFreeFormObject(schema, openAPI)) {
|
||||
// non-composed object type with no properties + additionalProperties
|
||||
// additionalProperties must be null, ObjectSchema, or empty Schema
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
@@ -7724,7 +7788,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
|
||||
|
||||
ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter);
|
||||
codegenParameter.setTypeProperties(unaliasedSchema);
|
||||
codegenParameter.setTypeProperties(unaliasedSchema, openAPI);
|
||||
codegenParameter.setComposedSchemas(getComposedSchemas(unaliasedSchema));
|
||||
// TODO in the future switch al the below schema usages to unaliasedSchema
|
||||
// because it keeps models as refs and will not get their referenced schemas
|
||||
@@ -8077,6 +8141,43 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.debug("Post processing file {} ({})", file, fileType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes an external command for file post processing.
|
||||
*
|
||||
* @param commandArr an array of commands and arguments. They will be concatenated with space and tokenized again.
|
||||
* @return Whether the execution passed (true) or failed (false)
|
||||
*/
|
||||
protected boolean executePostProcessor(String[] commandArr) {
|
||||
final String command = String.join(" ", commandArr);
|
||||
try {
|
||||
// we don't use the array variant here, because the command passed in by the user is often not only a single binary
|
||||
// but a combination of binary + parameters, e.g. `/etc/bin prettier -w`, which would then not be found, as the
|
||||
// first array item would be expected to be the binary only. The exec method is tokenizing the command for us.
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
int exitValue = p.exitValue();
|
||||
if (exitValue != 0) {
|
||||
try (InputStreamReader inputStreamReader = new InputStreamReader(p.getErrorStream(), StandardCharsets.UTF_8);
|
||||
BufferedReader br = new BufferedReader(inputStreamReader)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb);
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
return true;
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boolean value indicating the state of the option for post-processing file using environment variables.
|
||||
*
|
||||
@@ -8343,6 +8444,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
List<CodegenProperty> xOf = new ArrayList<>();
|
||||
Set<String> dataTypeSet = new HashSet<>(); // to keep track of dataType
|
||||
Set<String> dataTypeSetIgnoringErasure = new HashSet<>();
|
||||
int i = 0;
|
||||
for (Schema xOfSchema : xOfCollection) {
|
||||
CodegenProperty cp = fromProperty(collectionName + "_" + i, xOfSchema, false);
|
||||
@@ -8351,7 +8453,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (dataTypeSet.contains(cp.dataType)
|
||||
|| (isTypeErasedGenerics() && dataTypeSet.contains(cp.baseType))) {
|
||||
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
|
||||
// add "x-duplicated-data-type" to indicate if the (base) dataType already occurs before
|
||||
// in other sub-schemas of allOf/anyOf/oneOf
|
||||
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type", true);
|
||||
} else {
|
||||
@@ -8361,6 +8463,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
dataTypeSet.add(cp.dataType);
|
||||
}
|
||||
}
|
||||
if (dataTypeSetIgnoringErasure.contains(cp.dataType)) {
|
||||
// add "x-duplicated-data-type-ignoring-erasure" to indicate if the dataType already occurs before
|
||||
// in other sub-schemas of allOf/anyOf/oneOf
|
||||
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type-ignoring-erasure", true);
|
||||
} else {
|
||||
dataTypeSetIgnoringErasure.add(cp.dataType);
|
||||
}
|
||||
}
|
||||
return xOf;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
import io.swagger.v3.oas.models.Paths;
|
||||
import io.swagger.v3.oas.models.SpecVersion;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
@@ -31,7 +32,7 @@ import io.swagger.v3.oas.models.security.*;
|
||||
import io.swagger.v3.oas.models.tags.Tag;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.comparator.PathFileComparator;
|
||||
import org.apache.commons.io.IOCase;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.api.TemplateDefinition;
|
||||
@@ -343,6 +344,12 @@ public class DefaultGenerator implements Generator {
|
||||
config.additionalProperties().put("unescapedAppDescription", info.getDescription());
|
||||
}
|
||||
|
||||
if (this.openAPI.getSpecVersion().equals(SpecVersion.V31) && !StringUtils.isEmpty(info.getSummary())) {
|
||||
config.additionalProperties().put("appSummary", config.escapeText(info.getSummary()));
|
||||
config.additionalProperties().put("appSummaryWithNewLines", config.escapeTextWhileAllowingNewLines(info.getSummary()));
|
||||
config.additionalProperties().put("unescapedAppSummary", info.getSummary());
|
||||
}
|
||||
|
||||
if (info.getContact() != null) {
|
||||
Contact contact = info.getContact();
|
||||
if (contact.getEmail() != null) {
|
||||
@@ -492,7 +499,7 @@ public class DefaultGenerator implements Generator {
|
||||
if (schema.getExtensions() != null && Boolean.TRUE.equals(schema.getExtensions().get("x-internal"))) {
|
||||
LOGGER.info("Model {} not generated since x-internal is set to true", name);
|
||||
continue;
|
||||
} else if (ModelUtils.isFreeFormObject(schema)) { // check to see if it's a free-form object
|
||||
} else if (ModelUtils.isFreeFormObject(schema, openAPI)) { // check to see if it's a free-form object
|
||||
if (!ModelUtils.shouldGenerateFreeFormObjectModel(name, config)) {
|
||||
LOGGER.info("Model {} not generated since it's a free-form object", name);
|
||||
continue;
|
||||
@@ -1434,6 +1441,8 @@ public class DefaultGenerator implements Generator {
|
||||
return processTemplateToFile(templateData, templateName, outputFilename, shouldGenerate, skippedByOption, this.config.getOutputDir());
|
||||
}
|
||||
|
||||
private final Set<String> seenFiles = new HashSet<>();
|
||||
|
||||
private File processTemplateToFile(Map<String, Object> templateData, String templateName, String outputFilename, boolean shouldGenerate, String skippedByOption, String intendedOutputDir) throws IOException {
|
||||
String adjustedOutputFilename = outputFilename.replaceAll("//", "/").replace('/', File.separatorChar);
|
||||
File target = new File(adjustedOutputFilename);
|
||||
@@ -1444,6 +1453,11 @@ public class DefaultGenerator implements Generator {
|
||||
if (!absoluteTarget.startsWith(outDir)) {
|
||||
throw new RuntimeException(String.format(Locale.ROOT, "Target files must be generated within the output directory; absoluteTarget=%s outDir=%s", absoluteTarget, outDir));
|
||||
}
|
||||
|
||||
if (seenFiles.stream().filter(f -> f.toLowerCase(Locale.ROOT).equals(absoluteTarget.toString().toLowerCase(Locale.ROOT))).findAny().isPresent()) {
|
||||
LOGGER.warn("Duplicate file path detected. Not all operating systems can handle case sensitive file paths. path={}", absoluteTarget.toString());
|
||||
}
|
||||
seenFiles.add(absoluteTarget.toString());
|
||||
return this.templateProcessor.write(templateData, templateName, target);
|
||||
} else {
|
||||
this.templateProcessor.skip(target.toPath(), String.format(Locale.ROOT, "Skipped by %s options supplied by user.", skippedByOption));
|
||||
@@ -1981,7 +1995,8 @@ public class DefaultGenerator implements Generator {
|
||||
// NOTE: Don't use File.separator here as we write linux-style paths to FILES, and File.separator will
|
||||
// result in incorrect match on Windows machines.
|
||||
String relativeMeta = METADATA_DIR + "/VERSION";
|
||||
filesToSort.sort(PathFileComparator.PATH_COMPARATOR);
|
||||
|
||||
final List<String> relativePaths = new ArrayList<>(filesToSort.size());
|
||||
filesToSort.forEach(f -> {
|
||||
// some Java implementations don't honor .relativize documentation fully.
|
||||
// When outDir is /a/b and the input is /a/b/c/d, the result should be c/d.
|
||||
@@ -1994,10 +2009,15 @@ public class DefaultGenerator implements Generator {
|
||||
relativePath = relativePath.replace(File.separator, "/");
|
||||
}
|
||||
if (!relativePath.equals(relativeMeta)) {
|
||||
sb.append(relativePath).append(System.lineSeparator());
|
||||
relativePaths.add(relativePath);
|
||||
}
|
||||
});
|
||||
|
||||
Collections.sort(relativePaths, (a, b) -> IOCase.SENSITIVE.checkCompareTo(a,b));
|
||||
relativePaths.forEach(relativePath -> {
|
||||
sb.append(relativePath).append(System.lineSeparator());
|
||||
});
|
||||
|
||||
String targetFile = config.outputFolder() + File.separator + METADATA_DIR + File.separator + config.getFilesMetadataFilename();
|
||||
|
||||
File filesFile = this.templateProcessor.writeToFile(targetFile, sb.toString().getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.openapitools.codegen.meta.FeatureSet;
|
||||
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
public interface IJsonSchemaValidationProperties {
|
||||
@@ -283,7 +284,7 @@ public interface IJsonSchemaValidationProperties {
|
||||
*
|
||||
* @param p the schema which contains the type info
|
||||
*/
|
||||
default void setTypeProperties(Schema p) {
|
||||
default void setTypeProperties(Schema p, OpenAPI openAPI) {
|
||||
if (ModelUtils.isModelWithPropertiesOnly(p)) {
|
||||
setIsModel(true);
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
@@ -336,7 +337,7 @@ public interface IJsonSchemaValidationProperties {
|
||||
setIsNull(true);
|
||||
} else if (ModelUtils.isAnyType(p)) {
|
||||
setIsAnyType(true);
|
||||
} else if (ModelUtils.isFreeFormObject(p)) {
|
||||
} else if (ModelUtils.isFreeFormObject(p, openAPI)) {
|
||||
setIsFreeFormObject(true);
|
||||
// TODO: remove below later after updating generators to properly use isFreeFormObject
|
||||
setIsMap(true);
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.openapitools.codegen;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.callbacks.Callback;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
@@ -283,10 +284,24 @@ public class OpenAPINormalizer {
|
||||
this.openAPI.getComponents().setSchemas(new HashMap<String, Schema>());
|
||||
}
|
||||
|
||||
normalizeInfo();
|
||||
normalizePaths();
|
||||
normalizeComponentsSchemas();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-populate info if it's not defined.
|
||||
*/
|
||||
private void normalizeInfo() {
|
||||
if (this.openAPI.getInfo() == null) {
|
||||
Info info = new Info();
|
||||
info.setTitle("OpenAPI");
|
||||
info.setVersion("0.0.1");
|
||||
info.setDescription("OpenAPI");
|
||||
this.openAPI.setInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes inline models in Paths
|
||||
*/
|
||||
@@ -478,12 +493,64 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
|
||||
// auto fix self reference schema to avoid stack overflow
|
||||
fixSelfReferenceSchema(schemaName, schema);
|
||||
|
||||
// normalize the schemas
|
||||
schemas.put(schemaName, normalizeSchema(schema, new HashSet<>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto fix a self referencing schema using any type to replace the self-referencing sub-item.
|
||||
*
|
||||
* @param name Schema name
|
||||
* @param schema Schema
|
||||
*/
|
||||
public void fixSelfReferenceSchema(String name, Schema schema) {
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
if (isSelfReference(name, schema.getItems())) {
|
||||
LOGGER.error("Array schema {} has a sub-item referencing itself. Worked around the self-reference schema using any type instead.", name);
|
||||
schema.setItems(new Schema<>());
|
||||
}
|
||||
}
|
||||
|
||||
if (ModelUtils.isOneOf(schema)) {
|
||||
for (int i = 0; i < schema.getOneOf().size(); i++) {
|
||||
if (isSelfReference(name, (Schema) schema.getOneOf().get(i))) {
|
||||
LOGGER.error("oneOf schema {} has a sub-item referencing itself. Worked around the self-reference schema by removing it.", name);
|
||||
schema.getOneOf().remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ModelUtils.isAnyOf(schema)) {
|
||||
for (int i = 0; i < schema.getAnyOf().size(); i++) {
|
||||
if (isSelfReference(name, (Schema) schema.getAnyOf().get(i))) {
|
||||
LOGGER.error("anyOf schema {} has a sub-item referencing itself. Worked around the self-reference schema by removing it.", name);
|
||||
schema.getAnyOf().remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (schema.getAdditionalProperties() != null && schema.getAdditionalProperties() instanceof Schema) {
|
||||
if (isSelfReference(name, (Schema) schema.getAdditionalProperties())) {
|
||||
LOGGER.error("Schema {} (with additional properties) has a sub-item referencing itself. Worked around the self-reference schema using any type instead.", name);
|
||||
schema.setAdditionalProperties(new Schema<>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isSelfReference(String name, Schema subSchema) {
|
||||
if (subSchema != null && name.equals(ModelUtils.getSimpleRef(subSchema.get$ref()))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a schema
|
||||
*
|
||||
@@ -501,7 +568,7 @@ public class OpenAPINormalizer {
|
||||
return schema;
|
||||
}
|
||||
|
||||
if ((visitedSchemas.contains(schema))) {
|
||||
if (visitedSchemas.contains(schema)) {
|
||||
return schema; // skip due to circular reference
|
||||
} else {
|
||||
visitedSchemas.add(schema);
|
||||
@@ -520,7 +587,6 @@ public class OpenAPINormalizer {
|
||||
return normalizeAnyOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isAllOfWithProperties(schema)) { // allOf with properties
|
||||
schema = normalizeAllOfWithProperties(schema, visitedSchemas);
|
||||
normalizeSchema(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isAllOf(schema)) { // allOf
|
||||
return normalizeAllOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isComposedSchema(schema)) { // composed schema
|
||||
@@ -628,24 +694,38 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
private Schema normalizeOneOf(Schema schema, Set<Schema> visitedSchemas) {
|
||||
for (Object item : schema.getOneOf()) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(item instanceof Schema)) {
|
||||
throw new RuntimeException("Error! oneOf schema is not of the type Schema: " + item);
|
||||
}
|
||||
// normalize oenOf sub schemas one by one
|
||||
normalizeSchema((Schema) item, visitedSchemas);
|
||||
}
|
||||
// process rules here
|
||||
// simplify first as the schema may no longer be a oneOf after processing the rule below
|
||||
schema = processSimplifyOneOf(schema);
|
||||
|
||||
// if it's still a oneOf, loop through the sub-schemas
|
||||
if (schema.getOneOf() != null) {
|
||||
for (int i = 0; i < schema.getOneOf().size(); i++) {
|
||||
// normalize oneOf sub schemas one by one
|
||||
Object item = schema.getOneOf().get(i);
|
||||
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(item instanceof Schema)) {
|
||||
throw new RuntimeException("Error! oneOf schema is not of the type Schema: " + item);
|
||||
}
|
||||
|
||||
// update sub-schema with the updated schema
|
||||
schema.getOneOf().set(i, normalizeSchema((Schema) item, visitedSchemas));
|
||||
}
|
||||
} else {
|
||||
// normalize it as it's no longer an oneOf
|
||||
schema = normalizeSchema(schema, visitedSchemas);
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
private Schema normalizeAnyOf(Schema schema, Set<Schema> visitedSchemas) {
|
||||
for (Object item : schema.getAnyOf()) {
|
||||
for (int i = 0; i < schema.getAnyOf().size(); i++) {
|
||||
// normalize anyOf sub schemas one by one
|
||||
Object item = schema.getAnyOf().get(i);
|
||||
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -653,15 +733,16 @@ public class OpenAPINormalizer {
|
||||
if (!(item instanceof Schema)) {
|
||||
throw new RuntimeException("Error! anyOf schema is not of the type Schema: " + item);
|
||||
}
|
||||
// normalize anyOf sub schemas one by one
|
||||
normalizeSchema((Schema) item, visitedSchemas);
|
||||
|
||||
// update sub-schema with the updated schema
|
||||
schema.getAnyOf().set(i, normalizeSchema((Schema) item, visitedSchemas));
|
||||
}
|
||||
|
||||
// process rules here
|
||||
schema = processSimplifyAnyOf(schema);
|
||||
|
||||
// last rule to process as the schema may become String schema (not "anyOf") after the completion
|
||||
return processSimplifyAnyOfStringAndEnumString(schema);
|
||||
return normalizeSchema(processSimplifyAnyOfStringAndEnumString(schema), visitedSchemas);
|
||||
}
|
||||
|
||||
private Schema normalizeComplexComposedSchema(Schema schema, Set<Schema> visitedSchemas) {
|
||||
@@ -672,7 +753,7 @@ public class OpenAPINormalizer {
|
||||
|
||||
processRemoveAnyOfOneOfAndKeepPropertiesOnly(schema);
|
||||
|
||||
return schema;
|
||||
return normalizeSchema(schema, visitedSchemas);
|
||||
}
|
||||
|
||||
// ===================== a list of rules =====================
|
||||
@@ -870,57 +951,7 @@ public class OpenAPINormalizer {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the schema is of type 'null'
|
||||
* <p>
|
||||
* Return true if the schema's type is 'null' or not specified
|
||||
*
|
||||
* @param schema Schema
|
||||
*/
|
||||
public boolean isNullTypeSchema(Schema schema) {
|
||||
if (schema == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ModelUtils.hasAllOf(schema) || ModelUtils.hasOneOf(schema) || ModelUtils.hasAnyOf(schema)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (schema.getTypes() != null && !schema.getTypes().isEmpty()) {
|
||||
// 3.1 spec
|
||||
if (schema.getTypes().size() == 1) { // 1 type only
|
||||
String type = (String) schema.getTypes().iterator().next();
|
||||
return type == null || "null".equals(type);
|
||||
} else { // more than 1 type so must not be just null
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (schema instanceof JsonSchema) { // 3.1 spec
|
||||
if (Boolean.TRUE.equals(schema.getNullable())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// for `type: null`
|
||||
if (schema.getTypes() == null && schema.get$ref() == null) {
|
||||
return true;
|
||||
}
|
||||
} else { // 3.0.x or 2.x spec
|
||||
if ((schema.getType() == null || schema.getType().equals("null")) && schema.get$ref() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// convert referenced enum of null only to `nullable:true`
|
||||
Schema referencedSchema = ModelUtils.getReferencedSchema(openAPI, schema);
|
||||
if (referencedSchema.getEnum() != null && referencedSchema.getEnum().size() == 1) {
|
||||
if ("null".equals(String.valueOf(referencedSchema.getEnum().get(0)))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the schema is oneOf and the sub-schemas is null, set `nullable: true`
|
||||
@@ -964,7 +995,7 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
|
||||
if (oneOfSchemas.removeIf(oneOf -> isNullTypeSchema(oneOf))) {
|
||||
if (oneOfSchemas.removeIf(oneOf -> ModelUtils.isNullTypeSchema(openAPI, oneOf))) {
|
||||
schema.setNullable(true);
|
||||
|
||||
// if only one element left, simplify to just the element (schema)
|
||||
@@ -975,6 +1006,11 @@ public class OpenAPINormalizer {
|
||||
return (Schema) oneOfSchemas.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModelUtils.isIntegerSchema(schema) || ModelUtils.isNumberSchema(schema) || ModelUtils.isStringSchema(schema)) {
|
||||
// TODO convert oneOf const to enum
|
||||
schema.setOneOf(null);
|
||||
}
|
||||
}
|
||||
|
||||
return schema;
|
||||
@@ -1095,7 +1131,7 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
|
||||
if (anyOfSchemas.removeIf(anyOf -> isNullTypeSchema(anyOf))) {
|
||||
if (anyOfSchemas.removeIf(anyOf -> ModelUtils.isNullTypeSchema(openAPI, anyOf))) {
|
||||
schema.setNullable(true);
|
||||
}
|
||||
|
||||
@@ -1236,6 +1272,12 @@ public class OpenAPINormalizer {
|
||||
schema.getTypes().remove("null");
|
||||
}
|
||||
|
||||
// process const
|
||||
if (schema.getConst() != null) {
|
||||
schema.setEnum(Arrays.asList(schema.getConst()));
|
||||
schema.setConst(null);
|
||||
}
|
||||
|
||||
// only one item (type) left
|
||||
if (schema.getTypes().size() == 1) {
|
||||
String type = String.valueOf(schema.getTypes().iterator().next());
|
||||
@@ -1253,6 +1295,7 @@ public class OpenAPINormalizer {
|
||||
as.setMaxItems(schema.getMaxItems());
|
||||
as.setExtensions(schema.getExtensions());
|
||||
as.setXml(schema.getXml());
|
||||
as.setNullable(schema.getNullable());
|
||||
as.setUniqueItems(schema.getUniqueItems());
|
||||
if (schema.getItems() != null) {
|
||||
// `items` is also a json schema
|
||||
@@ -1264,6 +1307,9 @@ public class OpenAPINormalizer {
|
||||
Schema updatedItems = normalizeSchema(schema.getItems(), visitedSchemas);
|
||||
as.setItems(updatedItems);
|
||||
}
|
||||
} else {
|
||||
// when items is not defined, default to any type
|
||||
as.setItems(new Schema());
|
||||
}
|
||||
|
||||
return as;
|
||||
|
||||
@@ -42,7 +42,6 @@ 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;
|
||||
@@ -1065,20 +1064,8 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
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();
|
||||
}
|
||||
String[] commandArr = new String[]{commandPrefix, "--no-compact", "--quiet", file.toString()};
|
||||
this.executePostProcessor(commandArr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,6 +242,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
|
||||
if (StringUtils.isEmpty(System.getenv("CSHARP_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable CSHARP_POST_PROCESS_FILE not defined so the C# code may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To define it, try `export CSHARP_POST_PROCESS_FILE=\"/usr/local/bin/uncrustify --no-backup\" && export UNCRUSTIFY_CONFIG=/path/to/uncrustify-rules.cfg` (Linux/Mac). Note: replace /path/to with the location of uncrustify-rules.cfg");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'CSHARP_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
// License info
|
||||
@@ -450,7 +452,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
|
||||
.put("uniqueLines", new UniqueLambda("\n", false))
|
||||
.put("unique", new UniqueLambda("\n", true))
|
||||
.put("camel_case", new CamelCaseLambda())
|
||||
.put("escape_reserved_word", new EscapeKeywordLambda(this::escapeKeyword));
|
||||
.put("escape_reserved_word", new EscapeKeywordLambda(this::escapeKeyword))
|
||||
.put("alphabet_or_underscore", new ReplaceAllLambda("[^A-Za-z]", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1878,6 +1881,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1889,20 +1893,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
|
||||
|
||||
// only process files with .cs extension
|
||||
if ("cs".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = csharpPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {csharpPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -315,6 +314,8 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
if (StringUtils.isEmpty(System.getenv("CPP_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable CPP_POST_PROCESS_FILE not defined so the C++ code may not be properly formatted. To define it, try 'export CPP_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'CPP_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(RESERVED_WORD_PREFIX_OPTION)) {
|
||||
@@ -337,6 +338,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -346,21 +348,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
// only process files with cpp extension
|
||||
if ("cpp".equals(FilenameUtils.getExtension(file.toString())) || "h".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = cppPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
int exitValue = p.exitValue();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {cppPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
@@ -229,6 +228,8 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'DART_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||
@@ -805,20 +806,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
// process all files with dart extension
|
||||
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
// currently supported is "dartfmt -w" and "dart format"
|
||||
String command = dartPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {dartPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ 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;
|
||||
@@ -1039,6 +1038,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1050,20 +1050,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// only process files with .fs extension
|
||||
if ("fs".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = fsharpPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {fsharpPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ 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;
|
||||
@@ -173,6 +172,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
if (StringUtils.isEmpty(System.getenv("GO_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable GO_POST_PROCESS_FILE not defined so Go code may not be properly formatted. To define it, try `export GO_POST_PROCESS_FILE=\"/usr/local/bin/gofmt -w\"` (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'GO_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -982,6 +983,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1007,20 +1009,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
if ("go".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
// e.g. "gofmt -w yourcode.go"
|
||||
// e.g. "go fmt path/to/your/package"
|
||||
String command = goPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {goPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
@@ -409,6 +408,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (StringUtils.isEmpty(System.getenv("JAVA_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'JAVA_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
convertPropertyToBooleanAndWriteBack(BeanValidationFeatures.USE_BEANVALIDATION, this::setUseBeanValidation);
|
||||
@@ -641,7 +642,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
convertPropertyToBooleanAndWriteBack(CONTAINER_DEFAULT_TO_NULL, this::setContainerDefaultToNull);
|
||||
|
||||
additionalProperties.put("sanitizeGeneric", (Mustache.Lambda) (fragment, writer) -> {
|
||||
String content = fragment.execute();
|
||||
String content = removeAnnotations(fragment.execute());
|
||||
for (final String s: List.of("<", ">", ",", " ")) {
|
||||
content = content.replace(s, "");
|
||||
}
|
||||
@@ -1492,7 +1493,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
MediaType mediaType = content.values().iterator().next();
|
||||
if (mediaType.getExample() != null) {
|
||||
if (isModel) {
|
||||
LOGGER.warn("Ignoring complex example on request body");
|
||||
once(LOGGER).warn("Ignoring complex example on request body");
|
||||
} else {
|
||||
codegenParameter.example = mediaType.getExample().toString();
|
||||
return;
|
||||
@@ -1503,7 +1504,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
Example example = mediaType.getExamples().values().iterator().next();
|
||||
if (example.getValue() != null) {
|
||||
if (isModel) {
|
||||
LOGGER.warn("Ignoring complex example on request body");
|
||||
once(LOGGER).warn("Ignoring complex example on request body");
|
||||
} else {
|
||||
codegenParameter.example = example.getValue().toString();
|
||||
return;
|
||||
@@ -1792,16 +1793,20 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return;
|
||||
}
|
||||
|
||||
// the response data types should not contains a bean validation annotation.
|
||||
// the response data types should not contain a bean validation annotation.
|
||||
if (property.dataType.contains("@")) {
|
||||
property.dataType = property.dataType.replaceAll("(?:(?i)@[a-z0-9]*+([(].*[)]|\\s*))*+", "");
|
||||
property.dataType = removeAnnotations(property.dataType);
|
||||
}
|
||||
// the response data types should not contains a bean validation annotation.
|
||||
// the response data types should not contain a bean validation annotation.
|
||||
if (response.dataType.contains("@")) {
|
||||
response.dataType = response.dataType.replaceAll("(?:(?i)@[a-z0-9]*+([(].*[)]|\\s*))*+", "");
|
||||
response.dataType = removeAnnotations(response.dataType);
|
||||
}
|
||||
}
|
||||
|
||||
private String removeAnnotations(String type) {
|
||||
return type.replaceAll("(?:(?i)@[a-z0-9]*+([(].*[)]|\\s*))*+", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
// recursively add import for mapping one type to multiple imports
|
||||
@@ -2226,6 +2231,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -2237,21 +2243,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// only process files with java extension
|
||||
if ("java".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = javaPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
int exitValue = p.exitValue();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {javaPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -432,6 +431,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
if (StringUtils.isEmpty(System.getenv("KOTLIN_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable KOTLIN_POST_PROCESS_FILE not defined so the Kotlin code may not be properly formatted. To define it, try 'export KOTLIN_POST_PROCESS_FILE=\"/usr/local/bin/ktlint -F\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'KOTLIN_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(MODEL_MUTABLE)) {
|
||||
@@ -964,6 +965,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -975,21 +977,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// only process files with kt extension
|
||||
if ("kt".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = kotlinPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
int exitValue = p.exitValue();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {kotlinPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,7 +1105,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
addAdditionPropertiesToCodeGenModel(m, schema);
|
||||
} else {
|
||||
m.setIsMap(false);
|
||||
if (ModelUtils.isFreeFormObject(schema)) {
|
||||
if (ModelUtils.isFreeFormObject(schema, openAPI)) {
|
||||
// non-composed object type with no properties + additionalProperties
|
||||
// additionalProperties must be null, ObjectSchema, or empty Schema
|
||||
addAdditionPropertiesToCodeGenModel(m, schema);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
@@ -32,7 +33,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -168,6 +168,8 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
if (StringUtils.isEmpty(System.getenv("PHP_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable PHP_POST_PROCESS_FILE not defined so the PHP code may not be properly formatted. To define it, try 'export PHP_POST_PROCESS_FILE=\"/usr/local/bin/prettier --write\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'PHP_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PACKAGE_NAME)) {
|
||||
@@ -384,6 +386,11 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
return super.getTypeDeclaration(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getParameterDataType(Parameter parameter, Schema schema) {
|
||||
return getTypeDeclaration(schema);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
@@ -850,6 +857,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -859,21 +867,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
// only process files with php extension
|
||||
if ("php".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = phpPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
int exitValue = p.exitValue();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {phpPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -51,6 +50,7 @@ import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenResponse;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.GeneratorLanguage;
|
||||
import org.openapitools.codegen.IJsonSchemaValidationProperties;
|
||||
@@ -178,6 +178,8 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
if (StringUtils.isEmpty(System.getenv("PYTHON_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE=\"/usr/local/bin/yapf -i\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'PYTHON_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +353,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -361,20 +364,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// only process files with py extension
|
||||
if ("py".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = pythonPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {pythonPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,6 +1265,23 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
);
|
||||
}
|
||||
|
||||
// update typing import for operation responses type
|
||||
// only python-fastapi needs this at the moment
|
||||
if (this instanceof PythonFastAPIServerCodegen) {
|
||||
for (CodegenResponse response : operation.responses) {
|
||||
// Not interested in the result, only in the update of the imports
|
||||
getPydanticType(
|
||||
response.returnProperty,
|
||||
modelImports,
|
||||
exampleImports,
|
||||
postponedModelImports,
|
||||
postponedExampleImports,
|
||||
moduleImports,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// add import for code samples
|
||||
// import models one by one
|
||||
if (!exampleImports.isEmpty()) {
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -142,6 +141,8 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
|
||||
if (StringUtils.isEmpty(System.getenv("PYTHON_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE=\"/usr/local/bin/yapf -i\"' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'PYTHON_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +297,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -306,20 +308,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
|
||||
|
||||
// only process files with py extension
|
||||
if ("py".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = pythonPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {pythonPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,7 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Arrays;
|
||||
@@ -104,6 +100,8 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("RUBY_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Hint: Environment variable 'RUBY_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export RUBY_POST_PROCESS_FILE=\"/usr/local/bin/rubocop -a\"' (Linux/Mac)");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'RUBY_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +251,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -262,28 +261,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
// only process files with rb extension
|
||||
if ("rb".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = rubyPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
try (InputStreamReader inputStreamReader = new InputStreamReader(p.getErrorStream(), StandardCharsets.UTF_8);
|
||||
BufferedReader br = new BufferedReader(inputStreamReader)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb);
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: `{}`", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {rubyPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,8 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
if (StringUtils.isEmpty(System.getenv("SCALA_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable SCALA_POST_PROCESS_FILE not defined so the Scala code may not be properly formatted. To define it, try 'export SCALA_POST_PROCESS_FILE=/usr/local/bin/scalafmt' (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'SCALA_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
this.appName = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getTitle()).filter(t -> t != null).orElse(this.appName);
|
||||
@@ -547,6 +549,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -558,20 +561,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
|
||||
// only process files with scala extension
|
||||
if ("scala".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = scalaPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {scalaPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1092,20 +1092,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
}
|
||||
// only process files with ts extension
|
||||
if ("ts".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = tsPostProcessFile + " " + file;
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
this.executePostProcessor(new String[] {tsPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
@@ -132,6 +134,14 @@ public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("AVRO_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable AVRO_POST_PROCESS_FILE not defined so the Avro schemas may not be properly formatted. To define it, try `export AVRO_POST_PROCESS_FILE=\"/usr/local/bin/prettier -w\"` (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
} else if (!this.isEnablePostProcessFile()) {
|
||||
LOGGER.info("Warning: Environment variable 'AVRO_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME);
|
||||
|
||||
@@ -177,6 +187,22 @@ public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
String avroPostProcessFile = System.getenv("AVRO_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(avroPostProcessFile)) {
|
||||
return; // skip if AVRO_POST_PROCESS_FILE env variable is not defined
|
||||
}
|
||||
// only process files with avsc extension
|
||||
if ("avsc".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
this.executePostProcessor(new String[] {avroPostProcessFile, file.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||
super.setNonArrayMapProperty(property, type);
|
||||
@@ -199,8 +225,11 @@ public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
protected List<Map<String, Object>> buildEnumVars(List<Object> values, String dataType) {
|
||||
List<Object> sanitizedValues = values.stream().map(Object::toString).map(this::sanitizeEnumValue)
|
||||
.collect(Collectors.toList());
|
||||
List<Object> sanitizedValues = values.stream()
|
||||
.filter(x -> x != null)
|
||||
.map(Object::toString)
|
||||
.map(this::sanitizeEnumValue)
|
||||
.collect(Collectors.toList());
|
||||
removeEnumValueCollisions(sanitizedValues);
|
||||
return super.buildEnumVars(sanitizedValues, dataType);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user