forked from loafle/openapi-generator-original
Compare commits
92 Commits
devhl-labs
...
timcbaoth-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f37a431e49 | ||
|
|
f362ff1e88 | ||
|
|
ef50215438 | ||
|
|
c7b33c4762 | ||
|
|
1471e7a0d0 | ||
|
|
81f576c9da | ||
|
|
8155d03c38 | ||
|
|
4cde53c3d7 | ||
|
|
24c1968002 | ||
|
|
359ff9e457 | ||
|
|
85c81e84d5 | ||
|
|
86186586c7 | ||
|
|
0b3e6edb98 | ||
|
|
65e74a354d | ||
|
|
b4c315ebce | ||
|
|
03af25ce34 | ||
|
|
ff8fa40808 | ||
|
|
172c4d11b4 | ||
|
|
97c1dc8a1a | ||
|
|
44ae981830 | ||
|
|
a887f6d4bf | ||
|
|
6bcc28d06e | ||
|
|
9351217048 | ||
|
|
2bfc5a3958 | ||
|
|
ef36ea410e | ||
|
|
eb506ee776 | ||
|
|
a651376b18 | ||
|
|
abfeb6e035 | ||
|
|
edd91063b4 | ||
|
|
1a06e3e0fb | ||
|
|
6a2ad134c6 | ||
|
|
d6749f8a0e | ||
|
|
3cb3fc2898 | ||
|
|
a245e86b74 | ||
|
|
b2a7f435c8 | ||
|
|
45a657f59d | ||
|
|
83b45fd1e8 | ||
|
|
b2faf39ac7 | ||
|
|
453facc81c | ||
|
|
2c663561ef | ||
|
|
101b3fcc35 | ||
|
|
79fe176ef2 | ||
|
|
3f143a3b5a | ||
|
|
560089e4c7 | ||
|
|
a91d8e2c57 | ||
|
|
494d74ab82 | ||
|
|
fbc8616a06 | ||
|
|
650e119f22 | ||
|
|
d2c48e2999 | ||
|
|
2168851e8a | ||
|
|
3d2e38e347 | ||
|
|
b11005b00d | ||
|
|
3bb17efa09 | ||
|
|
ac14e66da1 | ||
|
|
1024c7733e | ||
|
|
90301f932d | ||
|
|
6d10e80916 | ||
|
|
f357be480e | ||
|
|
2a39b29684 | ||
|
|
88204b247a | ||
|
|
2934f5ac51 | ||
|
|
2ce71512d0 | ||
|
|
927768757b | ||
|
|
858499ffdd | ||
|
|
4719d9e55f | ||
|
|
2d7f0496ec | ||
|
|
2fac8e34db | ||
|
|
1704ae1194 | ||
|
|
370eca2889 | ||
|
|
d0f8468651 | ||
|
|
6252dac28e | ||
|
|
807aa5d3ae | ||
|
|
f73db59b0e | ||
|
|
34ebc1c644 | ||
|
|
de680de60e | ||
|
|
f10a9939dd | ||
|
|
e1b3dbc683 | ||
|
|
e78aeb6bc7 | ||
|
|
309918d03e | ||
|
|
6690b9f87d | ||
|
|
ee69a7983a | ||
|
|
204407daf0 | ||
|
|
d1860b95cf | ||
|
|
08590cb7f3 | ||
|
|
2cacac8aea | ||
|
|
0596817264 | ||
|
|
5a988d719f | ||
|
|
9714f12d5d | ||
|
|
67a2ccc67f | ||
|
|
a9de1ef614 | ||
|
|
cb1f2dab3a | ||
|
|
80b6dd933f |
10
.github/workflows/samples-dotnet-standard.yaml
vendored
10
.github/workflows/samples-dotnet-standard.yaml
vendored
@@ -21,11 +21,11 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- samples/client/petstore/csharp/generichost/standard2.0/OpenAPIClient-generichost-netstandard2.0/
|
||||
- samples/client/petstore/csharp/httpclient/standard2.0/OpenAPIClient-httpclient/
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient/
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient-ConditionalSerialization/
|
||||
- samples/client/petstore/csharp/unityWebRequest/standard2.0/OpenAPIClient-unityWebRequest/
|
||||
- samples/client/petstore/csharp/generichost/standard2.0/Petstore/
|
||||
- samples/client/petstore/csharp/httpclient/standard2.0/Petstore/
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/Petstore/
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/
|
||||
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-dotnet@v4.0.0
|
||||
|
||||
19
.github/workflows/samples-dotnet.yaml
vendored
19
.github/workflows/samples-dotnet.yaml
vendored
@@ -21,14 +21,17 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-manual-tests
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net6.0
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net6.0-nrt
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net7.0-useDateTimeForDate
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-netcore-latest-allOf
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-netcore-latest-anyOf
|
||||
- samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-netcore-latest-oneOf
|
||||
- samples/client/petstore/csharp/generichost/net8/AllOf
|
||||
- samples/client/petstore/csharp/generichost/net8/AnyOf
|
||||
- samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
|
||||
- samples/client/petstore/csharp/generichost/net8/FormModels
|
||||
- samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests
|
||||
- samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests
|
||||
- samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
|
||||
- samples/client/petstore/csharp/generichost/net8/OneOf
|
||||
- samples/client/petstore/csharp/generichost/net8/Petstore
|
||||
- samples/client/petstore/csharp/generichost/net8/SourceGeneration
|
||||
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-dotnet@v4.0.0
|
||||
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- samples/client/petstore/csharp/restsharp/net6/OpenAPIClient-restsharp-name-parameter-mappings/
|
||||
- samples/client/petstore/csharp/restsharp/net6/ParameterMappings/
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-dotnet@v4.0.0
|
||||
|
||||
@@ -13,6 +13,8 @@ on:
|
||||
- samples/client/others/java/okhttp-gson-oneOf/**
|
||||
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
|
||||
- samples/client/others/java/webclient-useAbstractionForFiles/**
|
||||
- samples/client/others/java/jersey2-oneOf-duplicates/**
|
||||
- samples/client/others/java/jersey2-oneOf-Mixed/**
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/client/petstore/java/**'
|
||||
@@ -25,6 +27,8 @@ on:
|
||||
- samples/client/others/java/okhttp-gson-oneOf/**
|
||||
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
|
||||
- samples/client/others/java/webclient-useAbstractionForFiles/**
|
||||
- samples/client/others/java/jersey2-oneOf-duplicates/**
|
||||
- samples/client/others/java/jersey2-oneOf-Mixed/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build Java Client JDK11
|
||||
@@ -71,6 +75,8 @@ jobs:
|
||||
- samples/client/others/java/okhttp-gson-oneOf/
|
||||
- samples/client/others/java/resttemplate-useAbstractionForFiles/
|
||||
- samples/client/others/java/webclient-useAbstractionForFiles/
|
||||
- samples/client/others/java/jersey2-oneOf-duplicates/
|
||||
- samples/client/others/java/jersey2-oneOf-Mixed/
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
|
||||
2
.github/workflows/samples-julia.yaml
vendored
2
.github/workflows/samples-julia.yaml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: julia-actions/setup-julia@v1
|
||||
- uses: julia-actions/setup-julia@v2
|
||||
with:
|
||||
version: 1.8
|
||||
arch: x64
|
||||
|
||||
1
.github/workflows/samples-scala.yaml
vendored
1
.github/workflows/samples-scala.yaml
vendored
@@ -32,6 +32,7 @@ jobs:
|
||||
- samples/server/petstore/scalatra
|
||||
- samples/server/petstore/scala-finch # cannot be tested with jdk11
|
||||
- samples/server/petstore/scala-http4s-server
|
||||
- samples/server/petstore/scala-cask
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
|
||||
1
.github/workflows/samples-spring.yaml
vendored
1
.github/workflows/samples-spring.yaml
vendored
@@ -34,6 +34,7 @@ jobs:
|
||||
- samples/openapi3/client/petstore/spring-cloud-async
|
||||
- samples/openapi3/client/petstore/spring-cloud-spring-pageable
|
||||
- samples/client/petstore/spring-cloud-tags
|
||||
- samples/client/petstore/spring-cloud-auth
|
||||
- samples/client/petstore/spring-cloud-deprecated
|
||||
# servers
|
||||
- samples/server/petstore/springboot
|
||||
|
||||
@@ -13,7 +13,7 @@ if [ "$NODE_INDEX" = "1" ]; then
|
||||
echo "Running node $NODE_INDEX ..."
|
||||
java -version
|
||||
|
||||
sudo apt-get -y install cpanminus libmagic-dev
|
||||
sudo apt-get -y install cpanminus
|
||||
|
||||
(cd samples/client/petstore/perl && /bin/bash ./test.bash)
|
||||
(cd samples/client/petstore/ruby && mvn integration-test)
|
||||
@@ -112,5 +112,3 @@ else
|
||||
(cd samples/client/petstore/java/apache-httpclient && mvn integration-test)
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -61,13 +61,14 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
|
||||
[<img src="https://openapi-generator.tech/img/companies/bumpsh.png" width="128" height="128">](https://bump.sh/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/bileto.png" width="128" height="128">](https://www.bileto.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/bairesdev.png" width="128" height="128">](https://www.bairesdev.com/sponsoring-open-source-projects/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/dmtech.jpeg" width="128" height="128">](https://www.dm-jobs.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/dmtech.jpeg" width="128" height="128">](https://www.dmtech.de/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/adyen.png" width="128" height="128">](https://adyen.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/fornex.png" width="128" height="128">](https://fornex.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/alloyautomation.png" width="128" height="128">](https://runalloy.com/signup?utm_source=github&utm_medium=referral&utm_campaign=1524_openapigenerator)
|
||||
[<img src="https://openapi-generator.tech/img/companies/ssstwitter.png" width="128" height="128">](https://ssstwitter.com/?utm_source=github&utm_medium=referral&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/svix.png" width="128" height="128">](https://www.svix.com/?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
|
||||
[<img src="https://openapi-generator.tech/img/companies/litslink.png" width="128" height="128">](https://litslink.com/services/artificial-intelligence?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
|
||||
[<img src="https://openapi-generator.tech/img/companies/designli.jpg" width="128" height="128">](https://designli.co?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
|
||||
|
||||
|
||||
#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS, Checkly for sponsoring the API monitoring and Gradle for sponsoring Develocity
|
||||
@@ -84,7 +85,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, 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 - 17.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
|
||||
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
|
||||
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
|
||||
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
|
||||
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
|
||||
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Postman Collection**, **Protocol Buffer**, **WSDL** |
|
||||
@@ -1101,6 +1102,7 @@ Here is a list of template creators:
|
||||
* Ruby on Rails 5: @zlx
|
||||
* Rust (rust-server): @metaswitch
|
||||
* Scala Akka: @Bouillie
|
||||
* Scala Cask: @aaronp
|
||||
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||
* Scala Lagom: @gmkumar2005
|
||||
* Scala Play: @adigerber
|
||||
|
||||
41
appveyor.yml
41
appveyor.yml
@@ -43,23 +43,30 @@ build_script:
|
||||
#- dotnet build samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\Org.OpenAPITools.sln
|
||||
|
||||
test_script:
|
||||
# test c# API client (multiple frameworks)
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test c# API client (httpclient)
|
||||
- dotnet test samples\client\petstore\csharp\httpclient\standard2.0\OpenAPIClient-httpclient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test c# API client (generichost)
|
||||
- dotnet test samples\client\petstore\csharp\generichost\standard2.0\OpenAPIClient-generichost-netstandard2.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test c# API client (netcore)
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\OpenAPIClientCore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
#- dotnet test samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net framework 4.7)
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net framework 4.8)
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.8\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net 5.0)
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API Client using conditional-serialization
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\OpenAPIClient-ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\AllOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\AnyOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\AnyOfNoCompare\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\FormModels\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualSourceGenerationTests\ManualTests.Latest.UseSourceGeneration\ManualTests.Latest.UseSourceGeneration.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualPetstoreTests\OpenAPIClient-generichost-manual-tests\OpenAPIClient-generichost-manual-tests.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\NullReferenceTypes\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\OneOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\SourceGeneration\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
|
||||
- dotnet test samples\client\petstore\csharp\httpclient\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\MultipleFrameworks\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net6\ParameterMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\EnumMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
|
||||
### TODO: Execute all generators via powershell or other
|
||||
# generate all petstore clients
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-netcore-latest-allOf
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/AllOf
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-netcore-latest-anyOf
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/AnyOf
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
|
||||
13
bin/configs/csharp-generichost-net8-anyOfNoCompare.yaml
Normal file
13
bin/configs/csharp-generichost-net8-anyOfNoCompare.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: false
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
16
bin/configs/csharp-generichost-net8-formModels.yaml
Normal file
16
bin/configs/csharp-generichost-net8-formModels.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/FormModels
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: false
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
skipFormModel: false
|
||||
inlineSchemaOptions:
|
||||
RESOLVE_INLINE_ENUMS: true
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/SourceGeneration
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
@@ -9,6 +9,5 @@ additionalProperties:
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useSourceGeneration: true
|
||||
packageName: UseSourceGeneration
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net6.0-nrt
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-netcore-latest-oneOf
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OneOf
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net7.0-useDateTimeForDate
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/OpenAPIClient-generichost-net6.0
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/standard2.0/OpenAPIClient-generichost-netstandard2.0
|
||||
outputDir: samples/client/petstore/csharp/generichost/standard2.0/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard httpclient
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/httpclient/standard2.0/OpenAPIClient-httpclient
|
||||
outputDir: samples/client/petstore/csharp/httpclient/standard2.0/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
library: httpclient
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net4.7/OpenAPIClientCoreAndNet47
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net4.7/OpenAPIClient-net47
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net4.7/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net4.8/OpenAPIClient-net48
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net4.8/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net6/OpenAPIClient-restsharp-name-parameter-mappings
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net6/ParameterMappings
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/name-parameter-mappings.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
nameMappings:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net7/OpenAPIClientCore
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net7/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net7/OpenAPIClient-net7.0-useDateTimeForDate
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net7/OpenAPIClient-net5.0
|
||||
outputDir: samples/client/petstore/csharp/restsharp/net7/EnumMappings
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient-ConditionalSerialization
|
||||
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient
|
||||
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net Unity
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/unityWebRequest/standard2.0/OpenAPIClient-unityWebRequest
|
||||
outputDir: samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
library: unityWebRequest
|
||||
|
||||
7
bin/configs/java-jersey2-8-oneOfDuplicateList.yaml
Normal file
7
bin/configs/java-jersey2-8-oneOfDuplicateList.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/others/java/jersey2-oneOf-duplicates
|
||||
library: jersey2
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_duplicateArray.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
7
bin/configs/java-jersey2-8-oneOfMixed.yaml
Normal file
7
bin/configs/java-jersey2-8-oneOfMixed.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/others/java/jersey2-oneOf-Mixed
|
||||
library: jersey2
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_primitiveAndArray.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -8,4 +8,5 @@ additionalProperties:
|
||||
serializationLibrary: jackson
|
||||
artifactId: microprofile-rest-client-3-jackson-with-xml
|
||||
configKey: petstore
|
||||
microprofileRestClientVersion: "3.0"
|
||||
microprofileRestClientVersion: "3.0"
|
||||
hideGenerationTimestamp: true
|
||||
|
||||
@@ -7,4 +7,5 @@ additionalProperties:
|
||||
serializationLibrary: jackson
|
||||
artifactId: microprofile-rest-client-3-jackson
|
||||
configKey: petstore
|
||||
microprofileRestClientVersion: "3.0"
|
||||
microprofileRestClientVersion: "3.0"
|
||||
hideGenerationTimestamp: true
|
||||
|
||||
@@ -9,4 +9,5 @@ additionalProperties:
|
||||
useOneOfDiscriminatorLookup: "true"
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
annotationLibrary: "swagger1"
|
||||
|
||||
openapiNormalizer:
|
||||
SET_TAGS_FOR_ALL_OPERATIONS: common
|
||||
|
||||
@@ -12,4 +12,4 @@ additionalProperties:
|
||||
enumPropertyNaming: UPPERCASE
|
||||
serializationLibrary: gson
|
||||
openapiNormalizer:
|
||||
SIMPLIFY_ONEOF_ANYOF=false
|
||||
SIMPLIFY_ONEOF_ANYOF: false
|
||||
|
||||
@@ -12,4 +12,4 @@ additionalProperties:
|
||||
enumPropertyNaming: UPPERCASE
|
||||
serializationLibrary: gson
|
||||
openapiNormalizer:
|
||||
SIMPLIFY_ONEOF_ANYOF=false
|
||||
SIMPLIFY_ONEOF_ANYOF: false
|
||||
|
||||
13
bin/configs/scala-cask-petstore-new.yaml
Normal file
13
bin/configs/scala-cask-petstore-new.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
generatorName: scala-cask
|
||||
outputDir: samples/server/petstore/scala-cask
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/scala-cask
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
artifactId: scala-cask-petstore
|
||||
groupId: "cask.groupId"
|
||||
package: "sample.cask"
|
||||
modelPackage: "sample.cask.model"
|
||||
apiPackage: "sample.cask.api"
|
||||
gitRepoId: "sample-cask-repo"
|
||||
gitUserId: "sample-cask-user"
|
||||
9
bin/configs/spring-cloud-auth.yaml
Normal file
9
bin/configs/spring-cloud-auth.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/client/petstore/spring-cloud-auth
|
||||
library: spring-cloud
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-auth.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: none
|
||||
artifactId: petstore-spring-cloud-auth
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -1,16 +1,16 @@
|
||||
---
|
||||
# csharp test files and image for upload
|
||||
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
|
||||
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
|
||||
sha256: e323c7e646a0ceb6d1d8f34f287175ac666fdbbe057791b45d138de3d9582666
|
||||
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
|
||||
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
|
||||
sha256: 7dad88554fe630d25c787cae05305d302d5e34ca810aee4fa23f20055f9188e1
|
||||
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
|
||||
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/linux-logo.png"
|
||||
sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
|
||||
# java okhttp gson test files
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java"
|
||||
sha256: db505f7801fef62c13a08a8e9ca1fc4c5c947ab46b46f12943139d353feacf17
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java"
|
||||
sha256: c479b587cf0d51fa550eb81d33b277081807b87dc28649027d1164224c25ad0a
|
||||
sha256: 8210bdaf06aae8dc46521515a8a0ef10e48c980fadd3efd95313e6c806f409c2
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java"
|
||||
sha256: 0d64cdc11809a7b5b952ccdad2bd91bd0045b3894d6fabf3e368fa0be12b8217
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/PetTest.java"
|
||||
|
||||
@@ -304,6 +304,8 @@ You can use also `config.yml` with following equivalent example:
|
||||
apiPackage: "petstore"
|
||||
```
|
||||
|
||||
Another example of config file can be found in [modules/openapi-generator/src/test/resources/sampleConfig.json](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/sampleConfig.json)
|
||||
|
||||
Supported config options can be different per language. Running `config-help -g {lang}` will show available options.
|
||||
**These options are applied via configuration file (e.g. config.json or config.yml) or by passing them with `-p {optionName}={optionValue}`**. (If `-p {optionName}` does not work, please open a [ticket](https://github.com/openapitools/openapi-generator/issues/new) and we'll look into it)
|
||||
|
||||
@@ -605,3 +607,10 @@ Example:
|
||||
```
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_CONTAINER_TO_NULLABLE="array|map"
|
||||
```
|
||||
|
||||
- `SET_PRIMITIVE_TYPES_TO_NULLABLE`: When set to `string|integer|number|boolean` (or just `string`) for example, it will set the type to `nullable` (nullable: true)
|
||||
|
||||
Example:
|
||||
```
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_PRIMITIVE_TYPES_TO_NULLABLE="integer|number"
|
||||
```
|
||||
|
||||
@@ -134,6 +134,7 @@ The following generators are available:
|
||||
* [rust-axum (beta)](generators/rust-axum.md)
|
||||
* [rust-server](generators/rust-server.md)
|
||||
* [scala-akka-http-server (beta)](generators/scala-akka-http-server.md)
|
||||
* [scala-cask](generators/scala-cask.md)
|
||||
* [scala-finch](generators/scala-finch.md)
|
||||
* [scala-http4s-server](generators/scala-http4s-server.md)
|
||||
* [scala-lagom-server](generators/scala-lagom-server.md)
|
||||
|
||||
@@ -135,6 +135,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -174,6 +174,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -128,6 +128,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -130,6 +130,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -132,6 +132,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -153,6 +153,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -153,6 +153,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -138,6 +138,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -139,6 +139,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -142,6 +142,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -132,6 +132,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -132,6 +132,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -135,6 +135,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -132,6 +132,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -164,6 +164,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -146,6 +146,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -137,6 +137,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -160,6 +160,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -155,6 +155,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -138,6 +138,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -139,6 +139,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -138,6 +138,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -146,6 +146,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -88,6 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
261
docs/generators/scala-cask.md
Normal file
261
docs/generators/scala-cask.md
Normal file
@@ -0,0 +1,261 @@
|
||||
---
|
||||
title: Documentation for the scala-cask Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | scala-cask | pass this to the generate command after -g |
|
||||
| generator stability | STABLE | |
|
||||
| generator type | SERVER | |
|
||||
| generator language | Scala | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a scala-cask server. | |
|
||||
|
||||
## 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|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |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|
|
||||
|gitRepoId|Git repo ID, e.g. openapi-generator.| |null|
|
||||
|gitUserId|Git user ID, e.g. openapitools.| |null|
|
||||
|groupId|groupId in generated pom.xml| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|
||||
|packageName|packageDescription| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|sourceFolder|source folder for generated code| |null|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|Array|java.util.List|
|
||||
|ArrayList|java.util.ArrayList|
|
||||
|Date|java.util.Date|
|
||||
|DateTime|org.joda.time.*|
|
||||
|File|java.io.File|
|
||||
|HashMap|java.util.HashMap|
|
||||
|ListBuffer|scala.collection.mutable.ListBuffer|
|
||||
|ListSet|scala.collection.immutable.ListSet|
|
||||
|LocalDate|org.joda.time.*|
|
||||
|LocalDateTime|org.joda.time.*|
|
||||
|LocalTime|org.joda.time.*|
|
||||
|Seq|scala.collection.immutable.Seq|
|
||||
|Set|scala.collection.immutable.Set|
|
||||
|Timestamp|java.sql.Timestamp|
|
||||
|URI|java.net.URI|
|
||||
|UUID|java.util.UUID|
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|set|Set|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Any</li>
|
||||
<li>Array</li>
|
||||
<li>Boolean</li>
|
||||
<li>Byte</li>
|
||||
<li>Double</li>
|
||||
<li>Float</li>
|
||||
<li>Int</li>
|
||||
<li>List</li>
|
||||
<li>Long</li>
|
||||
<li>Map</li>
|
||||
<li>Object</li>
|
||||
<li>Seq</li>
|
||||
<li>String</li>
|
||||
<li>boolean</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>abstract</li>
|
||||
<li>assert</li>
|
||||
<li>boolean</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>default</li>
|
||||
<li>do</li>
|
||||
<li>double</li>
|
||||
<li>else</li>
|
||||
<li>enum</li>
|
||||
<li>extends</li>
|
||||
<li>final</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
<li>goto</li>
|
||||
<li>if</li>
|
||||
<li>implements</li>
|
||||
<li>import</li>
|
||||
<li>instanceof</li>
|
||||
<li>int</li>
|
||||
<li>interface</li>
|
||||
<li>long</li>
|
||||
<li>native</li>
|
||||
<li>new</li>
|
||||
<li>package</li>
|
||||
<li>private</li>
|
||||
<li>protected</li>
|
||||
<li>public</li>
|
||||
<li>return</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>transient</li>
|
||||
<li>try</li>
|
||||
<li>type</li>
|
||||
<li>void</li>
|
||||
<li>volatile</li>
|
||||
<li>while</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
||||
|
||||
### Client Modification Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasePath|✗|ToolingExtension
|
||||
|Authorizations|✗|ToolingExtension
|
||||
|UserAgent|✗|ToolingExtension
|
||||
|MockServer|✗|ToolingExtension
|
||||
|
||||
### Data Type Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Custom|✗|OAS2,OAS3
|
||||
|Int32|✓|OAS2,OAS3
|
||||
|Int64|✓|OAS2,OAS3
|
||||
|Float|✓|OAS2,OAS3
|
||||
|Double|✓|OAS2,OAS3
|
||||
|Decimal|✓|ToolingExtension
|
||||
|String|✓|OAS2,OAS3
|
||||
|Byte|✓|OAS2,OAS3
|
||||
|Binary|✓|OAS2,OAS3
|
||||
|Boolean|✓|OAS2,OAS3
|
||||
|Date|✓|OAS2,OAS3
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|CollectionFormatMulti|✓|OAS2
|
||||
|Enum|✓|OAS2,OAS3
|
||||
|ArrayOfEnum|✓|ToolingExtension
|
||||
|ArrayOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
||||
|MapOfEnum|✓|ToolingExtension
|
||||
|MapOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|MapOfCollectionOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfEnum|✓|ToolingExtension
|
||||
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✗|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
### Global Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Host|✓|OAS2,OAS3
|
||||
|BasePath|✓|OAS2,OAS3
|
||||
|Info|✓|OAS2,OAS3
|
||||
|Schemes|✗|OAS2,OAS3
|
||||
|PartialSchemes|✓|OAS2,OAS3
|
||||
|Consumes|✓|OAS2
|
||||
|Produces|✓|OAS2
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✓|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✓|OAS2
|
||||
|Cookie|✓|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✓|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✓|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
|
||||
|SignatureAuth|✗|OAS3
|
||||
|AWSV4Signature|✗|ToolingExtension
|
||||
|
||||
### Wire Format Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✓|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✗|OAS2,OAS3
|
||||
@@ -167,6 +167,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>_</li>
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
|
||||
@@ -515,11 +515,11 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
applyModelNameMappingsKvpList(modelNameMappings, configurator);
|
||||
applyEnumNameMappingsKvpList(enumNameMappings, configurator);
|
||||
applyOperationIdNameMappingsKvpList(operationIdNameMappings, configurator);
|
||||
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
|
||||
applyOpenapiNormalizerKvpList(openapiNormalizer, configurator);
|
||||
applyTypeMappingsKvpList(typeMappings, configurator);
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
|
||||
applyOpenAPIGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
|
||||
applyOpenapiGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
|
||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
*
|
||||
* @return a map of rules
|
||||
*/
|
||||
public Map<String, String> getOpenAPINormalizer() {
|
||||
public Map<String, String> getOpenapiNormalizer() {
|
||||
return openapiNormalizer;
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
*
|
||||
* @return the openapi generator ignore list
|
||||
*/
|
||||
public Set<String> getOpenAPIGeneratorIgnoreList() {
|
||||
public Set<String> getOpenapiGeneratorIgnoreList() {
|
||||
return openapiGeneratorIgnoreList;
|
||||
}
|
||||
|
||||
@@ -614,14 +614,14 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (copy.getOperationIdNameMappings() != null) {
|
||||
builder.operationIdNameMappings.putAll(copy.getOperationIdNameMappings());
|
||||
}
|
||||
if (copy.getOpenAPINormalizer() != null) {
|
||||
builder.openapiNormalizer.putAll(copy.getOpenAPINormalizer());
|
||||
if (copy.getOpenapiNormalizer() != null) {
|
||||
builder.openapiNormalizer.putAll(copy.getOpenapiNormalizer());
|
||||
}
|
||||
if (copy.getLanguageSpecificPrimitives() != null) {
|
||||
builder.languageSpecificPrimitives.addAll(copy.getLanguageSpecificPrimitives());
|
||||
}
|
||||
if (copy.getOpenAPIGeneratorIgnoreList() != null) {
|
||||
builder.openapiGeneratorIgnoreList.addAll(copy.getOpenAPIGeneratorIgnoreList());
|
||||
if (copy.getOpenapiGeneratorIgnoreList() != null) {
|
||||
builder.openapiGeneratorIgnoreList.addAll(copy.getOpenapiGeneratorIgnoreList());
|
||||
}
|
||||
if (copy.getReservedWordsMappings() != null) {
|
||||
builder.reservedWordsMappings.putAll(copy.getReservedWordsMappings());
|
||||
@@ -1152,7 +1152,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
* @param openapiNormalizer the {@code openapiNormalizer} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withOpenAPINormalizer(Map<String, String> openapiNormalizer) {
|
||||
public Builder withOpenapiNormalizer(Map<String, String> openapiNormalizer) {
|
||||
this.openapiNormalizer = openapiNormalizer;
|
||||
return this;
|
||||
}
|
||||
@@ -1164,7 +1164,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
* @param value The value of the OpenAPI normalizer rule
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withOpenAPINormalizer(String key, String value) {
|
||||
public Builder withOpenapiNormalizer(String key, String value) {
|
||||
if (this.openapiNormalizer == null) {
|
||||
this.openapiNormalizer = new HashMap<>();
|
||||
}
|
||||
@@ -1203,7 +1203,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
* @param openapiGeneratorIgnoreList the {@code openapiGeneratorIgnoreList} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withOpenAPIGeneratorIgnoreList(Set<String> openapiGeneratorIgnoreList) {
|
||||
public Builder withOpenapiGeneratorIgnoreList(Set<String> openapiGeneratorIgnoreList) {
|
||||
this.openapiGeneratorIgnoreList = openapiGeneratorIgnoreList;
|
||||
return this;
|
||||
}
|
||||
@@ -1214,7 +1214,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
* @param value The value of entry to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withOpenAPIGeneratorIgnoreList(String value) {
|
||||
public Builder withOpenapiGeneratorIgnoreList(String value) {
|
||||
if (this.openapiGeneratorIgnoreList == null) {
|
||||
this.openapiGeneratorIgnoreList = new HashSet<>();
|
||||
}
|
||||
@@ -1390,9 +1390,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getModelNameMappings(), that.getModelNameMappings()) &&
|
||||
Objects.equals(getEnumNameMappings(), that.getEnumNameMappings()) &&
|
||||
Objects.equals(getOperationIdNameMappings(), that.getOperationIdNameMappings()) &&
|
||||
Objects.equals(getOpenAPINormalizer(), that.getOpenAPINormalizer()) &&
|
||||
Objects.equals(getOpenapiNormalizer(), that.getOpenapiNormalizer()) &&
|
||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||
Objects.equals(getOpenAPIGeneratorIgnoreList(), that.getOpenAPIGeneratorIgnoreList()) &&
|
||||
Objects.equals(getOpenapiGeneratorIgnoreList(), that.getOpenapiGeneratorIgnoreList()) &&
|
||||
Objects.equals(getReservedWordsMappings(), that.getReservedWordsMappings()) &&
|
||||
Objects.equals(getGitHost(), that.getGitHost()) &&
|
||||
Objects.equals(getGitUserId(), that.getGitUserId()) &&
|
||||
@@ -1428,9 +1428,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
getModelNameMappings(),
|
||||
getEnumNameMappings(),
|
||||
getOperationIdNameMappings(),
|
||||
getOpenAPINormalizer(),
|
||||
getOpenapiNormalizer(),
|
||||
getLanguageSpecificPrimitives(),
|
||||
getOpenAPIGeneratorIgnoreList(),
|
||||
getOpenapiGeneratorIgnoreList(),
|
||||
getReservedWordsMappings(),
|
||||
getGitHost(),
|
||||
getGitUserId(),
|
||||
|
||||
@@ -887,7 +887,7 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
|
||||
if (openapiNormalizer.isPresent) {
|
||||
openapiNormalizer.get().forEach { entry ->
|
||||
configurator.addOpenAPINormalizer(entry.key, entry.value)
|
||||
configurator.addOpenapiNormalizer(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -917,7 +917,7 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
|
||||
if (openapiGeneratorIgnoreList.isPresent) {
|
||||
openapiGeneratorIgnoreList.get().forEach {
|
||||
configurator.addOpenAPIGeneratorIgnoreList(it)
|
||||
configurator.addOpenapiGeneratorIgnoreList(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ class GenerateTaskDslTest : TestBase() {
|
||||
fun `openApiValidate should fail on invalid spec`() {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
|
||||
withProject(defaultBuildGradle, projectFiles)
|
||||
@@ -423,7 +423,7 @@ class GenerateTaskDslTest : TestBase() {
|
||||
fun `openApiValidate should ok skip spec validation`() {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
|
||||
withProject("""
|
||||
|
||||
@@ -113,7 +113,7 @@ class ValidateTaskDslTest : TestBase() {
|
||||
fun `openApiValidate should fail on invalid spec`(gradleVersion: String?) {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
withProject(
|
||||
"""
|
||||
@@ -139,6 +139,50 @@ class ValidateTaskDslTest : TestBase() {
|
||||
result.output.contains("Spec is invalid."),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertTrue(
|
||||
result.output.contains("attribute info is missing"),
|
||||
"Spec validation detail"
|
||||
)
|
||||
assertEquals(
|
||||
FAILED, result.task(":openApiValidate")?.outcome,
|
||||
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}"
|
||||
)
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gradle_version_provider")
|
||||
fun `openApiValidate should fail on invalid spec with duplicate 200 status code`(gradleVersion: String?) {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-duplicate-200-status-code.yaml")
|
||||
)
|
||||
withProject(
|
||||
"""
|
||||
| plugins {
|
||||
| id 'org.openapi.generator'
|
||||
| }
|
||||
|
|
||||
| openApiValidate {
|
||||
| inputSpec = file('spec.yaml').absolutePath
|
||||
| }
|
||||
""".trimMargin(), projectFiles
|
||||
)
|
||||
|
||||
// Act
|
||||
val result = getGradleRunner(gradleVersion)
|
||||
.withProjectDir(temp)
|
||||
.withArguments("openApiValidate")
|
||||
.withPluginClasspath()
|
||||
.buildAndFail()
|
||||
|
||||
// Assert
|
||||
assertTrue(
|
||||
result.output.contains("Spec is invalid."),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertTrue(
|
||||
result.output.contains("Duplicate field 200"),
|
||||
"Spec validation detail"
|
||||
)
|
||||
assertEquals(
|
||||
FAILED, result.task(":openApiValidate")?.outcome,
|
||||
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}"
|
||||
@@ -186,7 +230,7 @@ class ValidateTaskDslTest : TestBase() {
|
||||
fun `validateBadSpec as defined task should fail on invalid spec`(gradleVersion: String?) {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
withProject(
|
||||
"""
|
||||
@@ -212,6 +256,10 @@ class ValidateTaskDslTest : TestBase() {
|
||||
result.output.contains("Spec is invalid."),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertTrue(
|
||||
result.output.contains("attribute info is missing"),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertEquals(
|
||||
FAILED, result.task(":validateBadSpec")?.outcome,
|
||||
"Expected a failed run, but found ${result.task(":validateBadSpec")?.outcome}"
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
openapi: "3.0.0"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
license:
|
||||
name: MIT
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/v1
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
summary: List all pets
|
||||
operationId: listPets
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: limit
|
||||
in: query
|
||||
description: How many items to return at one time (max 100)
|
||||
required: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
'200':
|
||||
description: A paged array of pets
|
||||
headers:
|
||||
x-next:
|
||||
description: A link to the next page of responses
|
||||
schema:
|
||||
type: string
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
'200':
|
||||
description: duplicate 200
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
post:
|
||||
summary: Create a pet
|
||||
operationId: createPets
|
||||
tags:
|
||||
- pets
|
||||
responses:
|
||||
'201':
|
||||
description: Null response
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
/pets/{petId}:
|
||||
get:
|
||||
summary: Info for a specific pet
|
||||
operationId: showPetById
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
required: true
|
||||
description: The id of the pet to retrieve
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Expected response to a valid request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
Pets:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
Error:
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
@@ -829,7 +829,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
// Retained for backwards-compatibility with configOptions -> openapi-normalizer
|
||||
if (openapiNormalizer == null && configOptions.containsKey("openapi-normalizer")) {
|
||||
applyOpenAPINormalizerKvp(configOptions.get("openapi-normalizer").toString(),
|
||||
applyOpenapiNormalizerKvp(configOptions.get("openapi-normalizer").toString(),
|
||||
configurator);
|
||||
}
|
||||
|
||||
@@ -846,7 +846,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
// Retained for backwards-compatibility with configOptions -> openapi-generator-ignore-list
|
||||
if (openapiGeneratorIgnoreList == null && configOptions.containsKey("openapi-generator-ignore-list")) {
|
||||
applyOpenAPIGeneratorIgnoreListCsv(configOptions
|
||||
applyOpenapiGeneratorIgnoreListCsv(configOptions
|
||||
.get("openapi-generator-ignore-list").toString(), configurator);
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
// Apply OpenAPI normalizer rules
|
||||
if (openapiNormalizer != null && (configOptions == null || !configOptions.containsKey("openapi-normalizer"))) {
|
||||
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
|
||||
applyOpenapiNormalizerKvpList(openapiNormalizer, configurator);
|
||||
}
|
||||
|
||||
// Apply Type Mappings
|
||||
@@ -936,7 +936,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
// Apply Language Specific Primitives
|
||||
if (openapiGeneratorIgnoreList != null
|
||||
&& (configOptions == null || !configOptions.containsKey("openapi-generator-ignore-list"))) {
|
||||
applyOpenAPIGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
|
||||
applyOpenapiGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
|
||||
}
|
||||
|
||||
// Apply Additional Properties
|
||||
|
||||
@@ -350,14 +350,15 @@ public interface CodegenConfig {
|
||||
*/
|
||||
String generatorLanguageVersion();
|
||||
|
||||
boolean isTypeErasedGenerics();
|
||||
|
||||
List<VendorExtension> getSupportedVendorExtensions();
|
||||
|
||||
boolean getUseInlineModelResolver();
|
||||
|
||||
boolean getAddSuffixToDuplicateOperationNicknames();
|
||||
|
||||
boolean getUseOpenAPINormalizer();
|
||||
|
||||
Set<String> getOpenAPIGeneratorIgnoreList();
|
||||
boolean getUseOpenapiNormalizer();
|
||||
|
||||
Set<String> getOpenapiGeneratorIgnoreList();
|
||||
}
|
||||
|
||||
@@ -1139,6 +1139,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
this.isEnum = isEnum;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("CodegenProperty{");
|
||||
|
||||
@@ -43,6 +43,8 @@ public class CodegenSecurity {
|
||||
// Oauth specific
|
||||
public String flow, authorizationUrl, tokenUrl, refreshUrl;
|
||||
public List<Map<String, Object>> scopes;
|
||||
public Boolean hasScopes;
|
||||
|
||||
public Boolean isCode, isPassword, isApplication, isImplicit;
|
||||
// OpenId specific
|
||||
public String openIdConnectUrl;
|
||||
|
||||
@@ -52,7 +52,6 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.languages.PhpNextgenClientCodegen;
|
||||
import org.openapitools.codegen.languages.RustAxumServerCodegen;
|
||||
import org.openapitools.codegen.languages.RustServerCodegen;
|
||||
import org.openapitools.codegen.meta.FeatureSet;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
@@ -707,7 +706,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* Removes importToRemove from the imports of objs, if present.
|
||||
* This is useful to remove imports that are already present in operations-related template files, to avoid importing the same thing twice.
|
||||
*
|
||||
* @param objs imports will be removed from this objs' imports collection
|
||||
* @param objs imports will be removed from this objs' imports collection
|
||||
* @param importToRemove the import statement to be removed
|
||||
*/
|
||||
protected void removeImport(OperationsMap objs, String importToRemove) {
|
||||
@@ -1092,7 +1091,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addOneOfNameExtension(s, n);
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(s)) {
|
||||
Schema items = ((ArraySchema) s).getItems();
|
||||
Schema items = ModelUtils.getSchemaItems(s);
|
||||
if (ModelUtils.isComposedSchema(items)) {
|
||||
addOneOfNameExtension(items, nOneOf);
|
||||
addOneOfInterfaceModel(items, nOneOf);
|
||||
@@ -2065,8 +2064,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
return inner;
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema arraySchema = (ArraySchema) schema;
|
||||
String inner = getSchemaType(getSchemaItems(arraySchema));
|
||||
String inner = getSchemaType(ModelUtils.getSchemaItems(schema));
|
||||
String parentType;
|
||||
if (ModelUtils.isSet(schema)) {
|
||||
parentType = "set";
|
||||
@@ -2303,7 +2301,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* Any non-null value will cause {{#defaultValue} check to pass.
|
||||
*
|
||||
* @param codegenProperty Codegen Property
|
||||
* @param schema Parameter schema
|
||||
* @param schema Parameter schema
|
||||
* @return string presentation of the default value of the parameter
|
||||
*/
|
||||
public String toDefaultParameterValue(CodegenProperty codegenProperty, Schema<?> schema) {
|
||||
@@ -2330,7 +2328,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* Return null if you do NOT want a default value.
|
||||
* Any non-null value will cause {{#defaultValue} check to pass.
|
||||
*
|
||||
* @param schema Property schema
|
||||
* @param schema Property schema
|
||||
* @param codegenProperty Codegen property
|
||||
* @return string presentation of the default value of the property
|
||||
*/
|
||||
@@ -2372,15 +2370,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
}
|
||||
|
||||
protected Schema<?> getSchemaItems(ArraySchema schema) {
|
||||
Schema<?> items = schema.getItems();
|
||||
if (items == null) {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", schema.getName());
|
||||
items = new StringSchema().description("TODO default missing array inner type to string");
|
||||
schema.setItems(items);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
protected Schema<?> getSchemaAdditionalProperties(Schema schema) {
|
||||
Schema<?> inner = ModelUtils.getAdditionalProperties(schema);
|
||||
@@ -2464,6 +2453,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected String getSingleSchemaType(Schema schema) {
|
||||
Schema unaliasSchema = unaliasSchema(schema);
|
||||
|
||||
if (ModelUtils.isRefToSchemaWithProperties(unaliasSchema.get$ref())) {
|
||||
// ref to schema's properties, e.g. #/components/schemas/Pet/properties/category
|
||||
Schema refSchema = ModelUtils.getReferencedSchema(openAPI, unaliasSchema);
|
||||
if (refSchema != null) {
|
||||
return getSingleSchemaType(refSchema);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
|
||||
// get the schema/model name from $ref
|
||||
String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
|
||||
@@ -3010,6 +3007,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* A method that allows generators to pre-process test example payloads
|
||||
* This can be useful if one needs to change how values like null in string are represented
|
||||
*
|
||||
* @param data the test data payload
|
||||
* @return the updated test data payload
|
||||
*/
|
||||
@@ -3020,6 +3018,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Processes any test cases if they exist in the components.x-test-examples vendor extensions
|
||||
* If they exist then cast them to java class instances and return them back in a map
|
||||
*
|
||||
* @param refToTestCases the component schema name that the test cases are for
|
||||
*/
|
||||
private HashMap<String, SchemaTestCase> extractSchemaTestCases(String refToTestCases) {
|
||||
@@ -3056,7 +3055,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Sets the booleans that define the model's type
|
||||
*
|
||||
* @param model the model to update
|
||||
* @param model the model to update
|
||||
* @param schema the model's schema
|
||||
*/
|
||||
protected void updateModelForString(CodegenModel model, Schema schema) {
|
||||
@@ -3314,7 +3313,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param sc The Schema that may contain the discriminator
|
||||
* @param discPropName The String that is the discriminator propertyName in the schema
|
||||
* @param visitedSchemas A set of visited schema names
|
||||
*
|
||||
*/
|
||||
private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc, String discPropName, Set<String> visitedSchemas) {
|
||||
if (visitedSchemas.contains(composedSchemaName)) { // recursive schema definition found
|
||||
@@ -3354,7 +3352,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String modelName = ModelUtils.getSimpleRef(((Schema) oneOf).get$ref());
|
||||
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) oneOf, discPropName, visitedSchemas);
|
||||
if (thisCp == null) {
|
||||
LOGGER.warn(
|
||||
once(LOGGER).warn(
|
||||
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
|
||||
composedSchemaName, discPropName, modelName, discPropName);
|
||||
}
|
||||
@@ -3363,7 +3361,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
continue;
|
||||
}
|
||||
if (cp != thisCp) {
|
||||
LOGGER.warn(
|
||||
once(LOGGER).warn(
|
||||
"'{}' defines discriminator '{}', but the OneOf schema '{}' has a different {} definition than the prior OneOf schema's. Make sure the {} type and required values are the same",
|
||||
composedSchemaName, discPropName, modelName, discPropName, discPropName);
|
||||
}
|
||||
@@ -3377,7 +3375,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String modelName = ModelUtils.getSimpleRef(((Schema) anyOf).get$ref());
|
||||
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) anyOf, discPropName, visitedSchemas);
|
||||
if (thisCp == null) {
|
||||
LOGGER.warn(
|
||||
once(LOGGER).warn(
|
||||
"'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}",
|
||||
composedSchemaName, discPropName, modelName, discPropName);
|
||||
}
|
||||
@@ -3386,7 +3384,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
continue;
|
||||
}
|
||||
if (cp != thisCp) {
|
||||
LOGGER.warn(
|
||||
once(LOGGER).warn(
|
||||
"'{}' defines discriminator '{}', but the AnyOf schema '{}' has a different {} definition than the prior AnyOf schema's. Make sure the {} type and required values are the same",
|
||||
composedSchemaName, discPropName, modelName, discPropName, discPropName);
|
||||
}
|
||||
@@ -3401,7 +3399,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Recursively look in Schema sc for the discriminator and return it
|
||||
*
|
||||
* @param sc The Schema that may contain the discriminator
|
||||
* @param sc The Schema that may contain the discriminator
|
||||
* @param visitedSchemas An array list of visited schemas
|
||||
*/
|
||||
private Discriminator recursiveGetDiscriminator(Schema sc, ArrayList<Schema> visitedSchemas) {
|
||||
@@ -3454,7 +3452,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
if (discriminatorsPropNames.size() > 1) {
|
||||
LOGGER.warn("The oneOf schemas have conflicting discriminator property names. " +
|
||||
once(LOGGER).warn("The oneOf schemas have conflicting discriminator property names. " +
|
||||
"oneOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
|
||||
}
|
||||
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getOneOf().size() && discriminatorsPropNames.size() == 1) {
|
||||
@@ -3483,7 +3481,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
if (discriminatorsPropNames.size() > 1) {
|
||||
LOGGER.warn("The anyOf schemas have conflicting discriminator property names. " +
|
||||
once(LOGGER).warn("The anyOf schemas have conflicting discriminator property names. " +
|
||||
"anyOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
|
||||
}
|
||||
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getAnyOf().size() && discriminatorsPropNames.size() == 1) {
|
||||
@@ -3532,7 +3530,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// schemas also has inline composed schemas
|
||||
// Note: if it is only inline one level, then the inline model resolver will move it into its own
|
||||
// schema and make it a $ref schema in the oneOf/anyOf location
|
||||
LOGGER.warn(
|
||||
once(LOGGER).warn(
|
||||
"Invalid inline schema defined in oneOf/anyOf in '{}'. Per the OpenApi spec, for this case when a composed schema defines a discriminator, the oneOf/anyOf schemas must use $ref. Change this inline definition to a $ref definition",
|
||||
composedSchemaName);
|
||||
}
|
||||
@@ -3554,14 +3552,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
msgSuffix += spacer + "invalid optional definition of " + discPropName + ", include it in required";
|
||||
}
|
||||
}
|
||||
LOGGER.warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
|
||||
once(LOGGER).warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
|
||||
composedSchemaName, discPropName, modelName, msgSuffix);
|
||||
}
|
||||
MappedModel mm = new MappedModel(modelName, toModelName(modelName));
|
||||
descendentSchemas.add(mm);
|
||||
Schema cs = ModelUtils.getSchema(openAPI, modelName);
|
||||
if (cs == null) { // cannot lookup the model based on the name
|
||||
LOGGER.error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
|
||||
once(LOGGER).error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
|
||||
} else {
|
||||
Map<String, Object> vendorExtensions = cs.getExtensions();
|
||||
if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) {
|
||||
@@ -3621,9 +3619,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Map<String, Object> vendorExtensions = cs.getExtensions();
|
||||
String mappingName =
|
||||
Optional.ofNullable(vendorExtensions)
|
||||
.map(ve -> ve.get("x-discriminator-value"))
|
||||
.map(discriminatorValue -> (String) discriminatorValue)
|
||||
.orElse(currentSchemaName);
|
||||
.map(ve -> ve.get("x-discriminator-value"))
|
||||
.map(discriminatorValue -> (String) discriminatorValue)
|
||||
.orElse(currentSchemaName);
|
||||
MappedModel mm = new MappedModel(mappingName, toModelName(currentSchemaName), !mappingName.equals(currentSchemaName));
|
||||
descendentSchemas.add(mm);
|
||||
}
|
||||
@@ -3650,11 +3648,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// the future..
|
||||
String propertyType =
|
||||
Optional.ofNullable(schema.getProperties())
|
||||
.map(p -> (Schema<?>) p.get(discriminatorPropertyName))
|
||||
.map(Schema::get$ref)
|
||||
.map(ModelUtils::getSimpleRef)
|
||||
.map(this::toModelName)
|
||||
.orElseGet(() -> typeMapping.get("string"));
|
||||
.map(p -> (Schema<?>) p.get(discriminatorPropertyName))
|
||||
.map(Schema::get$ref)
|
||||
.map(ModelUtils::getSimpleRef)
|
||||
.map(this::toModelName)
|
||||
.orElseGet(() -> typeMapping.get("string"));
|
||||
discriminator.setPropertyType(propertyType);
|
||||
|
||||
// check to see if the discriminator property is an enum string
|
||||
@@ -3674,7 +3672,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (e.getValue().indexOf('/') >= 0) {
|
||||
name = ModelUtils.getSimpleRef(e.getValue());
|
||||
if (ModelUtils.getSchema(openAPI, name) == null) {
|
||||
LOGGER.error("Failed to lookup the schema '{}' when processing the discriminator mapping of oneOf/anyOf. Please check to ensure it's defined properly.", name);
|
||||
once(LOGGER).error("Failed to lookup the schema '{}' when processing the discriminator mapping of oneOf/anyOf. Please check to ensure it's defined properly.", name);
|
||||
}
|
||||
} else {
|
||||
name = e.getValue();
|
||||
@@ -3945,8 +3943,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* This method was kept when required was added to the fromProperty signature
|
||||
* to ensure that the change was non-breaking
|
||||
*
|
||||
* @param name name of the property
|
||||
* @param p OAS property schema
|
||||
* @param name name of the property
|
||||
* @param p OAS property schema
|
||||
* @return Codegen Property object
|
||||
*/
|
||||
public CodegenProperty fromProperty(String name, Schema p) {
|
||||
@@ -3962,9 +3960,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* Any subsequent processing of the CodegenModel return value must be idempotent
|
||||
* for a given (String name, Schema schema).
|
||||
*
|
||||
* @param name name of the property
|
||||
* @param p OAS property schema
|
||||
* @param required true if the property is required in the next higher object schema, false otherwise
|
||||
* @param name name of the property
|
||||
* @param p OAS property schema
|
||||
* @param required true if the property is required in the next higher object schema, false otherwise
|
||||
* @param schemaIsFromAdditionalProperties true if the property is a required property defined by additional properties schema
|
||||
* If this is the actual additionalProperties schema not defining a required property, then
|
||||
* the value should be false
|
||||
@@ -3975,7 +3973,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.error("Undefined property/schema for `{}`. Default to type:string.", name);
|
||||
return null;
|
||||
}
|
||||
LOGGER.debug("debugging fromProperty for {} : {}", name, p);
|
||||
LOGGER.debug("debugging fromProperty for {}: {}", name, p);
|
||||
NamedSchema ns = new NamedSchema(name, p, required, schemaIsFromAdditionalProperties);
|
||||
CodegenProperty cpc = schemaCodegenPropertyCache.get(ns);
|
||||
if (cpc != null) {
|
||||
@@ -3983,6 +3981,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return cpc;
|
||||
}
|
||||
|
||||
// if it's ref to schema's properties, get the actual schema defined in the properties
|
||||
Schema refToPropertiesSchema = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, p.get$ref());
|
||||
if (refToPropertiesSchema != null) {
|
||||
p = refToPropertiesSchema;
|
||||
return fromProperty(name, refToPropertiesSchema, required, schemaIsFromAdditionalProperties);
|
||||
}
|
||||
|
||||
Schema original = null;
|
||||
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level
|
||||
if (ModelUtils.isAllOf(p) && p.getAllOf().size() == 1) {
|
||||
@@ -4175,8 +4180,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// handle inner property
|
||||
String itemName = getItemsName(p, name);
|
||||
ArraySchema arraySchema = (ArraySchema) p;
|
||||
Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema));
|
||||
Schema innerSchema = unaliasSchema(ModelUtils.getSchemaItems(p));
|
||||
CodegenProperty cp = fromProperty(itemName, innerSchema, false);
|
||||
updatePropertyForArray(property, cp);
|
||||
} else if (ModelUtils.isTypeObjectSchema(p)) {
|
||||
@@ -4486,8 +4490,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenProperty cm = fromProperty("response", responseSchema, false);
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as), false);
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getSchemaItems(responseSchema), false);
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema), false);
|
||||
@@ -4738,7 +4741,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (contentType != null) {
|
||||
contentType = contentType.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
if (!(this instanceof RustAxumServerCodegen) && contentType != null &&
|
||||
if (contentType != null &&
|
||||
(contentType.startsWith("application/x-www-form-urlencoded") ||
|
||||
contentType.startsWith("multipart"))) {
|
||||
// process form parameters
|
||||
@@ -5012,8 +5015,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
r.isArray = true;
|
||||
r.containerType = cp.containerType;
|
||||
r.containerTypeMapped = typeMapping.get(cp.containerType);
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty items = fromProperty("response", getSchemaItems(as), false);
|
||||
CodegenProperty items = fromProperty("response", ModelUtils.getSchemaItems(responseSchema), false);
|
||||
r.setItems(items);
|
||||
CodegenProperty innerCp = items;
|
||||
|
||||
@@ -5389,8 +5391,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
addVarsRequiredVarsAdditionalProps(parameterSchema, codegenParameter);
|
||||
} else if (ModelUtils.isArraySchema(parameterSchema)) {
|
||||
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
Schema inner = ModelUtils.getSchemaItems(parameterSchema);
|
||||
|
||||
collectionFormat = getCollectionFormat(parameter);
|
||||
// default to csv:
|
||||
@@ -5907,10 +5908,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Add the model name of the child schema in a composed schema to the set of imports
|
||||
*
|
||||
* @param composed composed schema
|
||||
* @param composed composed schema
|
||||
* @param childSchema composed schema
|
||||
* @param model codegen model
|
||||
* @param modelName model name
|
||||
* @param model codegen model
|
||||
* @param modelName model name
|
||||
*/
|
||||
protected void addImport(Schema composed, Schema childSchema, CodegenModel model, String modelName) {
|
||||
if (composed == null || childSchema == null) {
|
||||
@@ -6780,6 +6781,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
enumVar.put("name", finalEnumName);
|
||||
enumVar.put("value", toEnumValue(String.valueOf(value), dataType));
|
||||
enumVar.put("isString", isDataTypeString(dataType));
|
||||
// TODO: add isNumeric
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
|
||||
@@ -6792,16 +6794,17 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String enumValue = isDataTypeString(dataType)
|
||||
? enumUnknownDefaultCaseName
|
||||
: // This is a dummy value that attempts to avoid collisions with previously specified cases.
|
||||
// Int.max / 192
|
||||
// The number 192 that is used to calculate this random value, is the Swift Evolution proposal for frozen/non-frozen enums.
|
||||
// [SE-0192](https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md)
|
||||
// Since this functionality was born in the Swift 5 generator and latter on broth to all generators
|
||||
// https://github.com/OpenAPITools/openapi-generator/pull/11013
|
||||
String.valueOf(11184809);
|
||||
// Int.max / 192
|
||||
// The number 192 that is used to calculate this random value, is the Swift Evolution proposal for frozen/non-frozen enums.
|
||||
// [SE-0192](https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md)
|
||||
// Since this functionality was born in the Swift 5 generator and latter on broth to all generators
|
||||
// https://github.com/OpenAPITools/openapi-generator/pull/11013
|
||||
String.valueOf(11184809);
|
||||
|
||||
enumVar.put("name", toEnumVarName(enumName, dataType));
|
||||
enumVar.put("value", toEnumValue(enumValue, dataType));
|
||||
enumVar.put("isString", isDataTypeString(dataType));
|
||||
// TODO: add isNumeric
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
|
||||
@@ -6940,6 +6943,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
scopes.add(scope);
|
||||
}
|
||||
codegenSecurity.scopes = scopes;
|
||||
codegenSecurity.hasScopes = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7199,7 +7203,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
|
||||
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
|
||||
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
|
||||
|
||||
codegenParameter.isContainer = codegenProperty.isContainer;
|
||||
codegenParameter.containerType = codegenProperty.containerType;
|
||||
codegenParameter.containerTypeMapped = codegenProperty.containerTypeMapped;
|
||||
codegenParameter.dataFormat = codegenProperty.dataFormat;
|
||||
// non-array/map
|
||||
updateCodegenPropertyEnum(codegenProperty);
|
||||
@@ -7266,19 +7272,27 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isTypeObjectSchema(ps)) {
|
||||
if (ModelUtils.isFreeFormObject(ps)) {
|
||||
if (ModelUtils.isMapSchema(ps)) {
|
||||
codegenParameter.isMap = true;
|
||||
codegenParameter.additionalProperties = codegenProperty.additionalProperties;
|
||||
codegenParameter.setAdditionalPropertiesIsAnyType(codegenProperty.getAdditionalPropertiesIsAnyType());
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.isPrimitiveType = false;
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
|
||||
} else if (ModelUtils.isFreeFormObject(ps)) {
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
}
|
||||
} else if (ModelUtils.isNullType(ps)) {
|
||||
} else if (ModelUtils.isAnyType(ps)) {
|
||||
// any schema with no type set, composed schemas often do this
|
||||
} else if (ModelUtils.isArraySchema(ps)) {
|
||||
Schema inner = getSchemaItems((ArraySchema) ps);
|
||||
Schema inner = ModelUtils.getSchemaItems(ps);
|
||||
CodegenProperty arrayInnerProperty = fromProperty("inner", inner, false);
|
||||
codegenParameter.isArray = true;
|
||||
codegenParameter.items = arrayInnerProperty;
|
||||
codegenParameter.mostInnerItems = arrayInnerProperty.mostInnerItems;
|
||||
codegenParameter.isPrimitiveType = false;
|
||||
codegenParameter.isContainer = true;
|
||||
// hoist items data into the array property
|
||||
// TODO this hoisting code is generator specific and should be isolated into updateFormPropertyForArray
|
||||
codegenParameter.baseType = arrayInnerProperty.dataType;
|
||||
@@ -7554,11 +7568,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isGenerateAliasAsModel(schema) && StringUtils.isNotBlank(name)) {
|
||||
this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true);
|
||||
} else {
|
||||
final ArraySchema arraySchema = (ArraySchema) schema;
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
CodegenProperty codegenProperty = fromProperty("property", arraySchema, false);
|
||||
Schema inner = ModelUtils.getSchemaItems(schema);
|
||||
CodegenProperty codegenProperty = fromProperty("property", schema, false);
|
||||
if (codegenProperty == null) {
|
||||
throw new RuntimeException("CodegenProperty cannot be null. arraySchema for debugging: " + arraySchema);
|
||||
throw new RuntimeException("CodegenProperty cannot be null. arraySchema for debugging: " + schema);
|
||||
}
|
||||
|
||||
imports.add(codegenProperty.baseType);
|
||||
@@ -7591,7 +7604,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
|
||||
codegenParameter.dataType = getTypeDeclaration(arraySchema);
|
||||
codegenParameter.dataType = getTypeDeclaration(schema);
|
||||
codegenParameter.baseType = getSchemaType(inner);
|
||||
codegenParameter.isContainer = Boolean.TRUE;
|
||||
codegenParameter.isNullable = codegenProperty.isNullable;
|
||||
@@ -7970,6 +7983,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected String getAdditionalPropertiesName() {
|
||||
return "additional_properties";
|
||||
}
|
||||
|
||||
private void addJsonSchemaForBodyRequestInCaseItsNotPresent(CodegenParameter codegenParameter, RequestBody body) {
|
||||
if (codegenParameter.jsonSchema == null)
|
||||
codegenParameter.jsonSchema = Json.pretty(body);
|
||||
@@ -8236,8 +8250,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Add a given ComposedSchema as an interface model to be generated, assuming it has `oneOf` defined
|
||||
*
|
||||
* @param cs ComposedSchema object to create as interface model
|
||||
* @param type name to use for the generated interface model
|
||||
* @param cs ComposedSchema object to create as interface model
|
||||
* @param type name to use for the generated interface model
|
||||
*/
|
||||
public void addOneOfInterfaceModel(Schema cs, String type) {
|
||||
if (cs.getOneOf() == null) {
|
||||
@@ -8421,12 +8435,17 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
xOf.add(cp);
|
||||
i += 1;
|
||||
|
||||
if (dataTypeSet.contains(cp.dataType)) {
|
||||
if (dataTypeSet.contains(cp.dataType)
|
||||
|| (isTypeErasedGenerics() && dataTypeSet.contains(cp.baseType))) {
|
||||
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
|
||||
// in other sub-schemas of allOf/anyOf/oneOf
|
||||
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type", true);
|
||||
} else {
|
||||
dataTypeSet.add(cp.dataType);
|
||||
if (isTypeErasedGenerics()) {
|
||||
dataTypeSet.add(cp.baseType);
|
||||
} else {
|
||||
dataTypeSet.add(cp.dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return xOf;
|
||||
@@ -8453,22 +8472,33 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseInlineModelResolver() { return true; }
|
||||
public boolean getUseInlineModelResolver() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseOpenAPINormalizer() { return true; }
|
||||
public boolean getUseOpenapiNormalizer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getOpenAPIGeneratorIgnoreList() {
|
||||
public Set<String> getOpenapiGeneratorIgnoreList() {
|
||||
return openapiGeneratorIgnoreList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTypeErasedGenerics() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
A function to convert yaml or json ingested strings like property names
|
||||
And convert special characters like newline, tab, carriage return
|
||||
Into strings that can be rendered in the language that the generator will output to
|
||||
*/
|
||||
protected String handleSpecialCharacters(String name) { return name; }
|
||||
A function to convert yaml or json ingested strings like property names
|
||||
And convert special characters like newline, tab, carriage return
|
||||
Into strings that can be rendered in the language that the generator will output to
|
||||
*/
|
||||
protected String handleSpecialCharacters(String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to ensure that null or Schema is returned given an input Boolean/Schema/null
|
||||
|
||||
@@ -257,6 +257,12 @@ public class DefaultGenerator implements Generator {
|
||||
System.out.println(SerializerUtils.toJsonString(openAPI));
|
||||
}
|
||||
|
||||
// check to see if we need to apply camelize fix
|
||||
if (config.additionalProperties().containsKey("applyCamelizeFix")) {
|
||||
org.openapitools.codegen.utils.StringUtils.applyCamelizeFix =
|
||||
Boolean.parseBoolean(String.valueOf(config.additionalProperties().get("applyCamelizeFix")));
|
||||
}
|
||||
|
||||
config.processOpts();
|
||||
if (opts != null && opts.getGeneratorSettings() != null) {
|
||||
config.typeMapping().putAll(opts.getGeneratorSettings().getTypeMappings());
|
||||
@@ -265,7 +271,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
// normalize the spec
|
||||
try {
|
||||
if (config.getUseOpenAPINormalizer()) {
|
||||
if (config.getUseOpenapiNormalizer()) {
|
||||
SemVer version = new SemVer(openAPI.getOpenapi());
|
||||
if (version.atLeast("3.1.0")) {
|
||||
config.openapiNormalizer().put("NORMALIZE_31SPEC", "true");
|
||||
@@ -929,8 +935,8 @@ public class DefaultGenerator implements Generator {
|
||||
/*
|
||||
* Generate .openapi-generator-ignore if the option openapiGeneratorIgnoreFile is enabled.
|
||||
*/
|
||||
private void generateOpenAPIGeneratorIgnoreFile() {
|
||||
if (config.getOpenAPIGeneratorIgnoreList() == null || config.getOpenAPIGeneratorIgnoreList().isEmpty()) {
|
||||
private void generateOpenapiGeneratorIgnoreFile() {
|
||||
if (config.getOpenapiGeneratorIgnoreList() == null || config.getOpenapiGeneratorIgnoreList().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -982,7 +988,7 @@ public class DefaultGenerator implements Generator {
|
||||
Writer fileWriter = Files.newBufferedWriter(ignoreFile.toPath(), StandardCharsets.UTF_8);
|
||||
fileWriter.write(header);
|
||||
// add entries provided by the users
|
||||
for (String entry : config.getOpenAPIGeneratorIgnoreList()) {
|
||||
for (String entry : config.getOpenapiGeneratorIgnoreList()) {
|
||||
fileWriter.write(entry);
|
||||
fileWriter.write("\n");
|
||||
}
|
||||
@@ -1219,7 +1225,7 @@ public class DefaultGenerator implements Generator {
|
||||
processUserDefinedTemplates();
|
||||
|
||||
// generate .openapi-generator-ignore if the option openapiGeneratorIgnoreFile is enabled
|
||||
generateOpenAPIGeneratorIgnoreFile();
|
||||
generateOpenapiGeneratorIgnoreFile();
|
||||
|
||||
List<File> files = new ArrayList<>();
|
||||
// models
|
||||
|
||||
@@ -338,10 +338,9 @@ public class InlineModelResolver {
|
||||
return;
|
||||
}
|
||||
// Check array items
|
||||
if (schema instanceof ArraySchema) {
|
||||
ArraySchema array = (ArraySchema) schema;
|
||||
Schema items = array.getItems();
|
||||
if (items == null && array.getPrefixItems() == null) {
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
Schema items = ModelUtils.getSchemaItems(schema);
|
||||
if (items == null && schema.getPrefixItems() == null) {
|
||||
LOGGER.debug("Incorrect array schema with no items, prefixItems: {}", schema.toString());
|
||||
return;
|
||||
}
|
||||
@@ -357,7 +356,7 @@ public class InlineModelResolver {
|
||||
|
||||
if (isModelNeeded(items)) {
|
||||
// If this schema should be split into its own model, do so
|
||||
array.setItems(this.makeSchemaInComponents(schemaName, items));
|
||||
schema.setItems(this.makeSchemaInComponents(schemaName, items));
|
||||
}
|
||||
}
|
||||
// Check allOf, anyOf, oneOf for inline models
|
||||
@@ -771,9 +770,8 @@ public class InlineModelResolver {
|
||||
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
|
||||
String key = propertiesEntry.getKey();
|
||||
Schema property = propertiesEntry.getValue();
|
||||
if (property instanceof ObjectSchema && ((ObjectSchema) property).getProperties() != null
|
||||
&& ((ObjectSchema) property).getProperties().size() > 0) {
|
||||
ObjectSchema op = (ObjectSchema) property;
|
||||
if (ModelUtils.isObjectSchema(property)) {
|
||||
Schema op = property;
|
||||
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
|
||||
Schema model = modelFromProperty(openAPI, op, modelName);
|
||||
String existing = matchGenerated(model);
|
||||
@@ -788,11 +786,10 @@ public class InlineModelResolver {
|
||||
propsToUpdate.put(key, schema);
|
||||
modelsToAdd.put(modelName, model);
|
||||
}
|
||||
} else if (property instanceof ArraySchema) {
|
||||
ArraySchema ap = (ArraySchema) property;
|
||||
Schema inner = ap.getItems();
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
} else if (ModelUtils.isArraySchema(property)) {
|
||||
Schema inner = ModelUtils.getSchemaItems(property);
|
||||
if (ModelUtils.isObjectSchema(inner)) {
|
||||
Schema op = inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, op.getProperties(), path);
|
||||
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
|
||||
@@ -801,12 +798,12 @@ public class InlineModelResolver {
|
||||
if (existing != null) {
|
||||
Schema schema = new Schema().$ref(existing);
|
||||
schema.setRequired(op.getRequired());
|
||||
ap.setItems(schema);
|
||||
property.setItems(schema);
|
||||
} else {
|
||||
modelName = addSchemas(modelName, innerModel);
|
||||
Schema schema = new Schema().$ref(modelName);
|
||||
schema.setRequired(op.getRequired());
|
||||
ap.setItems(schema);
|
||||
property.setItems(schema);
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isComposedSchema(inner)) {
|
||||
@@ -815,14 +812,14 @@ public class InlineModelResolver {
|
||||
innerModelName = addSchemas(innerModelName, inner);
|
||||
Schema schema = new Schema().$ref(innerModelName);
|
||||
schema.setRequired(inner.getRequired());
|
||||
ap.setItems(schema);
|
||||
property.setItems(schema);
|
||||
} else {
|
||||
LOGGER.debug("Schema not yet handled in model resolver: {}", inner);
|
||||
}
|
||||
} else if (ModelUtils.isMapSchema(property)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(property);
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (ModelUtils.isObjectSchema(inner)) {
|
||||
Schema op = inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, op.getProperties(), path);
|
||||
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
|
||||
|
||||
@@ -38,6 +38,8 @@ public class OpenAPINormalizer {
|
||||
private Map<String, String> inputRules = new HashMap<>();
|
||||
private Map<String, Boolean> rules = new HashMap<>();
|
||||
|
||||
private TreeSet<String> anyTypeTreeSet = new TreeSet<>();
|
||||
|
||||
final Logger LOGGER = LoggerFactory.getLogger(OpenAPINormalizer.class);
|
||||
|
||||
Set<String> ruleNames = new TreeSet<>();
|
||||
@@ -112,6 +114,14 @@ public class OpenAPINormalizer {
|
||||
boolean updateSetToNullable;
|
||||
boolean updateMapToNullable;
|
||||
|
||||
// when set (e.g. operationId:getPetById|addPet), filter out (or remove) everything else
|
||||
final String SET_PRIMITIVE_TYPES_TO_NULLABLE = "SET_PRIMITIVE_TYPES_TO_NULLABLE";
|
||||
HashSet<String> setPrimitiveTypesToNullable = new HashSet<>();
|
||||
boolean updateStringToNullable;
|
||||
boolean updateIntegerToNullable;
|
||||
boolean updateNumberToNullable;
|
||||
boolean updateBooleanToNullable;
|
||||
|
||||
// ============= end of rules =============
|
||||
|
||||
/**
|
||||
@@ -143,12 +153,23 @@ public class OpenAPINormalizer {
|
||||
ruleNames.add(NORMALIZE_31SPEC);
|
||||
ruleNames.add(REMOVE_X_INTERNAL);
|
||||
ruleNames.add(FILTER);
|
||||
ruleNames.add(SET_CONTAINER_TO_NULLABLE);
|
||||
ruleNames.add(SET_PRIMITIVE_TYPES_TO_NULLABLE);
|
||||
|
||||
|
||||
// rules that are default to true
|
||||
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
|
||||
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
|
||||
|
||||
processRules(inputRules);
|
||||
|
||||
// represent any type in tree set
|
||||
anyTypeTreeSet.add("string");
|
||||
anyTypeTreeSet.add("number");
|
||||
anyTypeTreeSet.add("integer");
|
||||
anyTypeTreeSet.add("boolean");
|
||||
anyTypeTreeSet.add("object");
|
||||
anyTypeTreeSet.add("array");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,6 +244,26 @@ public class OpenAPINormalizer {
|
||||
LOGGER.error("SET_CONTAINER_TO_NULLABLE rule must be in the form of `array|set|map`, e.g. `set`, `array|map`: {}", inputRules.get(SET_CONTAINER_TO_NULLABLE));
|
||||
}
|
||||
}
|
||||
|
||||
if (inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE) != null) {
|
||||
rules.put(SET_PRIMITIVE_TYPES_TO_NULLABLE, true);
|
||||
setPrimitiveTypesToNullable = new HashSet<>(Arrays.asList(inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE).split("[|]")));
|
||||
if (setPrimitiveTypesToNullable.contains("string")) {
|
||||
updateStringToNullable = true;
|
||||
}
|
||||
if (setPrimitiveTypesToNullable.contains("integer")) {
|
||||
updateIntegerToNullable = true;
|
||||
}
|
||||
if (setPrimitiveTypesToNullable.contains("number")) {
|
||||
updateNumberToNullable = true;
|
||||
}
|
||||
if (setPrimitiveTypesToNullable.contains("boolean")) {
|
||||
updateBooleanToNullable = true;
|
||||
}
|
||||
if (!updateStringToNullable && !updateIntegerToNullable && !updateNumberToNullable && !updateBooleanToNullable) {
|
||||
LOGGER.error("SET_PRIMITIVE_TYPES_TO_NULLABLE rule must be in the form of `string|integer|number|boolean`, e.g. `string`, `integer|number`: {}", inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,7 +499,7 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(schema.get$ref())) {
|
||||
// not need to process $ref
|
||||
// no need to process $ref
|
||||
return schema;
|
||||
}
|
||||
|
||||
@@ -468,9 +509,10 @@ public class OpenAPINormalizer {
|
||||
visitedSchemas.add(schema);
|
||||
}
|
||||
|
||||
if (schema instanceof ArraySchema) { // array
|
||||
normalizeArraySchema(schema);
|
||||
normalizeSchema(schema.getItems(), visitedSchemas);
|
||||
if (ModelUtils.isArraySchema(schema)) { // array
|
||||
Schema result = normalizeArraySchema(schema);
|
||||
normalizeSchema(result.getItems(), visitedSchemas);
|
||||
return result;
|
||||
} else if (schema.getAdditionalProperties() instanceof Schema) { // map
|
||||
normalizeMapSchema(schema);
|
||||
normalizeSchema((Schema) schema.getAdditionalProperties(), visitedSchemas);
|
||||
@@ -525,7 +567,8 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
private Schema normalizeArraySchema(Schema schema) {
|
||||
return processSetArraytoNullable(schema);
|
||||
Schema result = processNormalize31Spec(schema, new HashSet<>());
|
||||
return processSetArraytoNullable(result);
|
||||
}
|
||||
|
||||
private Schema normalizeMapSchema(Schema schema) {
|
||||
@@ -533,15 +576,18 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
private Schema normalizeSimpleSchema(Schema schema, Set<Schema> visitedSchemas) {
|
||||
return processNormalize31Spec(schema, visitedSchemas);
|
||||
Schema result = processNormalize31Spec(schema, visitedSchemas);
|
||||
return processSetPrimitiveTypesToNullable(result);
|
||||
}
|
||||
|
||||
private void normalizeBooleanSchema(Schema schema, Set<Schema> visitedSchemas) {
|
||||
processSimplifyBooleanEnum(schema);
|
||||
processSetPrimitiveTypesToNullable(schema);
|
||||
}
|
||||
|
||||
private void normalizeIntegerSchema(Schema schema, Set<Schema> visitedSchemas) {
|
||||
processAddUnsignedToIntegerWithInvalidMaxValue(schema);
|
||||
processSetPrimitiveTypesToNullable(schema);
|
||||
}
|
||||
|
||||
private void normalizeProperties(Map<String, Schema> properties, Set<Schema> visitedSchemas) {
|
||||
@@ -550,7 +596,7 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
|
||||
Schema property = propertiesEntry.getValue();
|
||||
Schema newProperty = normalizeSchema(property, visitedSchemas);
|
||||
Schema newProperty = normalizeSchema(property, new HashSet<>());
|
||||
propertiesEntry.setValue(newProperty);
|
||||
}
|
||||
}
|
||||
@@ -844,7 +890,7 @@ public class OpenAPINormalizer {
|
||||
|
||||
if (schema.getTypes() != null && !schema.getTypes().isEmpty()) {
|
||||
// 3.1 spec
|
||||
if (schema.getTypes().size() ==1) { // 1 type only
|
||||
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
|
||||
@@ -856,6 +902,11 @@ public class OpenAPINormalizer {
|
||||
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;
|
||||
@@ -888,6 +939,27 @@ public class OpenAPINormalizer {
|
||||
|
||||
List<Schema> oneOfSchemas = schema.getOneOf();
|
||||
if (oneOfSchemas != null) {
|
||||
// simplify any type with 6 sub-schemas (string, integer, etc) in oneOf
|
||||
if (oneOfSchemas.size() == 6) {
|
||||
TreeSet<String> ts = new TreeSet<>();
|
||||
for (Schema s: oneOfSchemas) {
|
||||
ts.add(ModelUtils.getType(s));
|
||||
}
|
||||
|
||||
if (ts.equals(anyTypeTreeSet)) {
|
||||
Schema anyType = new Schema();
|
||||
anyType.setDescription(schema.getDescription());
|
||||
anyType.setNullable(schema.getNullable());
|
||||
anyType.setExtensions(schema.getExtensions());
|
||||
anyType.setTitle(schema.getTitle());
|
||||
anyType.setExample(schema.getExample());
|
||||
anyType.setExamples(schema.getExamples());
|
||||
anyType.setDefault(schema.getDefault());
|
||||
anyType.setDeprecated(schema.getDeprecated());
|
||||
return anyType;
|
||||
}
|
||||
}
|
||||
|
||||
if (oneOfSchemas.removeIf(oneOf -> isNullTypeSchema(oneOf))) {
|
||||
schema.setNullable(true);
|
||||
|
||||
@@ -917,25 +989,49 @@ public class OpenAPINormalizer {
|
||||
|
||||
if (Boolean.TRUE.equals(schema.getUniqueItems())) { // a set
|
||||
if (updateSetToNullable) {
|
||||
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
|
||||
// already set, don't overwrite
|
||||
return schema;
|
||||
}
|
||||
schema.setNullable(true);
|
||||
return setNullable(schema);
|
||||
}
|
||||
} else { // array
|
||||
if (updateArrayToNullable) {
|
||||
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
|
||||
// already set, don't overwrite
|
||||
return schema;
|
||||
}
|
||||
schema.setNullable(true);
|
||||
return setNullable(schema);
|
||||
}
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set nullable to true in primitive types (e.g. string) if needed.
|
||||
*
|
||||
* @param schema Schema
|
||||
* @return Schema
|
||||
*/
|
||||
private Schema processSetPrimitiveTypesToNullable(Schema schema) {
|
||||
if (!getRule(SET_PRIMITIVE_TYPES_TO_NULLABLE)) {
|
||||
return schema;
|
||||
}
|
||||
|
||||
if (updateStringToNullable && "string".equals(schema.getType())) {
|
||||
return setNullable(schema);
|
||||
} else if (updateIntegerToNullable && "integer".equals(schema.getType())) {
|
||||
return setNullable(schema);
|
||||
} else if (updateNumberToNullable && "number".equals(schema.getType())) {
|
||||
return setNullable(schema);
|
||||
} else if (updateBooleanToNullable && "boolean".equals(schema.getType())) {
|
||||
return setNullable(schema);
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
private Schema setNullable(Schema schema) {
|
||||
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
|
||||
// already set, don't overwrite
|
||||
return schema;
|
||||
}
|
||||
schema.setNullable(true);
|
||||
return schema;
|
||||
}
|
||||
/**
|
||||
* Set nullable to true in map if needed.
|
||||
*
|
||||
@@ -948,11 +1044,7 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
if (updateMapToNullable) {
|
||||
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
|
||||
// already set, don't override
|
||||
return schema;
|
||||
}
|
||||
schema.setNullable(true);
|
||||
return setNullable(schema);
|
||||
}
|
||||
|
||||
return schema;
|
||||
@@ -972,6 +1064,27 @@ public class OpenAPINormalizer {
|
||||
|
||||
List<Schema> anyOfSchemas = schema.getAnyOf();
|
||||
if (anyOfSchemas != null) {
|
||||
// simplify any type with 6 sub-schemas (string, integer, etc) in anyOf
|
||||
if (anyOfSchemas.size() == 6) {
|
||||
TreeSet<String> ts = new TreeSet<>();
|
||||
for (Schema s: anyOfSchemas) {
|
||||
ts.add(ModelUtils.getType(s));
|
||||
}
|
||||
|
||||
if (ts.equals(anyTypeTreeSet)) {
|
||||
Schema anyType = new Schema();
|
||||
anyType.setDescription(schema.getDescription());
|
||||
anyType.setNullable(schema.getNullable());
|
||||
anyType.setExtensions(schema.getExtensions());
|
||||
anyType.setTitle(schema.getTitle());
|
||||
anyType.setExample(schema.getExample());
|
||||
anyType.setExamples(schema.getExamples());
|
||||
anyType.setDefault(schema.getDefault());
|
||||
anyType.setDeprecated(schema.getDeprecated());
|
||||
return anyType;
|
||||
}
|
||||
}
|
||||
|
||||
if (anyOfSchemas.removeIf(anyOf -> isNullTypeSchema(anyOf))) {
|
||||
schema.setNullable(true);
|
||||
}
|
||||
@@ -1116,7 +1229,7 @@ public class OpenAPINormalizer {
|
||||
// only one item (type) left
|
||||
if (schema.getTypes().size() == 1) {
|
||||
String type = String.valueOf(schema.getTypes().iterator().next());
|
||||
if ("array".equals(type)) {
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema as = new ArraySchema();
|
||||
as.setDescription(schema.getDescription());
|
||||
as.setDefault(schema.getDefault());
|
||||
|
||||
@@ -145,14 +145,14 @@ public class CodegenConfigurator {
|
||||
if(generatorSettings.getOperationIdNameMappings() != null) {
|
||||
configurator.operationIdNameMappings.putAll(generatorSettings.getOperationIdNameMappings());
|
||||
}
|
||||
if(generatorSettings.getOpenAPINormalizer() != null) {
|
||||
configurator.openapiNormalizer.putAll(generatorSettings.getOpenAPINormalizer());
|
||||
if(generatorSettings.getOpenapiNormalizer() != null) {
|
||||
configurator.openapiNormalizer.putAll(generatorSettings.getOpenapiNormalizer());
|
||||
}
|
||||
if(generatorSettings.getLanguageSpecificPrimitives() != null) {
|
||||
configurator.languageSpecificPrimitives.addAll(generatorSettings.getLanguageSpecificPrimitives());
|
||||
}
|
||||
if(generatorSettings.getOpenAPIGeneratorIgnoreList() != null) {
|
||||
configurator.openapiGeneratorIgnoreList.addAll(generatorSettings.getOpenAPIGeneratorIgnoreList());
|
||||
if(generatorSettings.getOpenapiGeneratorIgnoreList() != null) {
|
||||
configurator.openapiGeneratorIgnoreList.addAll(generatorSettings.getOpenapiGeneratorIgnoreList());
|
||||
}
|
||||
if(generatorSettings.getReservedWordsMappings() != null) {
|
||||
configurator.reservedWordsMappings.putAll(generatorSettings.getReservedWordsMappings());
|
||||
@@ -268,9 +268,9 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addOpenAPINormalizer(String key, String value) {
|
||||
public CodegenConfigurator addOpenapiNormalizer(String key, String value) {
|
||||
this.openapiNormalizer.put(key, value);
|
||||
generatorSettingsBuilder.withOpenAPINormalizer(key, value);
|
||||
generatorSettingsBuilder.withOpenapiNormalizer(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -286,9 +286,9 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addOpenAPIGeneratorIgnoreList(String value) {
|
||||
public CodegenConfigurator addOpenapiGeneratorIgnoreList(String value) {
|
||||
this.openapiGeneratorIgnoreList.add(value);
|
||||
generatorSettingsBuilder.withOpenAPIGeneratorIgnoreList(value);
|
||||
generatorSettingsBuilder.withOpenapiGeneratorIgnoreList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -482,9 +482,9 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setOpenAPINormalizer(Map<String, String> openapiNormalizer) {
|
||||
public CodegenConfigurator setOpenapiNormalizer(Map<String, String> openapiNormalizer) {
|
||||
this.openapiNormalizer = openapiNormalizer;
|
||||
generatorSettingsBuilder.withOpenAPINormalizer(openapiNormalizer);
|
||||
generatorSettingsBuilder.withOpenapiNormalizer(openapiNormalizer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -515,10 +515,10 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setOpenAPIGeneratorIgnoreList(
|
||||
public CodegenConfigurator setOpenapiGeneratorIgnoreList(
|
||||
Set<String> openapiGeneratorIgnoreList) {
|
||||
this.openapiGeneratorIgnoreList = openapiGeneratorIgnoreList;
|
||||
generatorSettingsBuilder.withOpenAPIGeneratorIgnoreList(openapiGeneratorIgnoreList);
|
||||
generatorSettingsBuilder.withOpenapiGeneratorIgnoreList(openapiGeneratorIgnoreList);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -779,9 +779,9 @@ public class CodegenConfigurator {
|
||||
config.modelNameMapping().putAll(generatorSettings.getModelNameMappings());
|
||||
config.enumNameMapping().putAll(generatorSettings.getEnumNameMappings());
|
||||
config.operationIdNameMapping().putAll(generatorSettings.getOperationIdNameMappings());
|
||||
config.openapiNormalizer().putAll(generatorSettings.getOpenAPINormalizer());
|
||||
config.openapiNormalizer().putAll(generatorSettings.getOpenapiNormalizer());
|
||||
config.languageSpecificPrimitives().addAll(generatorSettings.getLanguageSpecificPrimitives());
|
||||
config.openapiGeneratorIgnoreList().addAll(generatorSettings.getOpenAPIGeneratorIgnoreList());
|
||||
config.openapiGeneratorIgnoreList().addAll(generatorSettings.getOpenapiGeneratorIgnoreList());
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordsMappings());
|
||||
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
|
||||
|
||||
|
||||
@@ -185,16 +185,16 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyOpenAPINormalizerKvpList(List<String> openapiNormalizer, CodegenConfigurator configurator) {
|
||||
public static void applyOpenapiNormalizerKvpList(List<String> openapiNormalizer, CodegenConfigurator configurator) {
|
||||
for (String propString : openapiNormalizer) {
|
||||
applyOpenAPINormalizerKvp(propString, configurator);
|
||||
applyOpenapiNormalizerKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyOpenAPINormalizerKvp(String openapiNormalizer, CodegenConfigurator configurator) {
|
||||
public static void applyOpenapiNormalizerKvp(String openapiNormalizer, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(openapiNormalizer);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addOpenAPINormalizer(entry.getKey().trim(), entry.getValue().trim());
|
||||
configurator.addOpenapiNormalizer(entry.getKey().trim(), entry.getValue().trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,16 +250,16 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyOpenAPIGeneratorIgnoreListCsvList(List<String> openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
|
||||
public static void applyOpenapiGeneratorIgnoreListCsvList(List<String> openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
|
||||
for (String propString : openapiGeneratorIgnoreList) {
|
||||
applyOpenAPIGeneratorIgnoreListCsv(propString, configurator);
|
||||
applyOpenapiGeneratorIgnoreListCsv(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyOpenAPIGeneratorIgnoreListCsv(String openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
|
||||
public static void applyOpenapiGeneratorIgnoreListCsv(String openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
|
||||
final Set<String> set = createSetFromCsvList(openapiGeneratorIgnoreList);
|
||||
for (String item : set) {
|
||||
configurator.addOpenAPIGeneratorIgnoreList(item);
|
||||
configurator.addOpenapiGeneratorIgnoreList(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,10 +84,9 @@ public class ExampleGenerator {
|
||||
}
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) { // array of schema
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
if (as.getItems() != null) { // array of primitive types
|
||||
if (ModelUtils.getSchemaItems(responseSchema) != null) { // array of primitive types
|
||||
return generate((Map<String, Object>) responseSchema.getExample(),
|
||||
new ArrayList<>(producesInfo), as);
|
||||
new ArrayList<>(producesInfo), responseSchema);
|
||||
} else {
|
||||
// TODO log warning message as such case is not handled at the moment
|
||||
return null;
|
||||
@@ -248,9 +247,9 @@ public class ExampleGenerator {
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
} else if (ModelUtils.isArraySchema(property)) {
|
||||
Schema innerType = ((ArraySchema) property).getItems();
|
||||
Schema innerType = ModelUtils.getSchemaItems(property);
|
||||
if (innerType != null) {
|
||||
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
|
||||
int arrayLength = null == property.getMaxItems() ? 2 : property.getMaxItems();
|
||||
// avoid memory issues by limiting to max. 5 items
|
||||
arrayLength = Math.min(arrayLength, 5);
|
||||
Object[] objectProperties = new Object[arrayLength];
|
||||
|
||||
@@ -128,8 +128,7 @@ public class XmlExampleGenerator {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema as = (ArraySchema) schema;
|
||||
Schema inner = as.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(schema);
|
||||
boolean wrapped = false;
|
||||
if (schema.getXml() != null && schema.getXml().getWrapped() != null && schema.getXml().getWrapped()) {
|
||||
wrapped = true;
|
||||
|
||||
@@ -532,8 +532,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
String itemType = getTypeDeclaration(inner);
|
||||
if (itemType.startsWith("OpenAPI.")) {
|
||||
return itemType + "_Vector";
|
||||
|
||||
@@ -188,10 +188,9 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
if (inner == null) {
|
||||
LOGGER.warn("{}(array property) does not have a proper inner type defined", ap.getName());
|
||||
LOGGER.warn("{}(array property) does not have a proper inner type defined", p.getName());
|
||||
// TODO maybe better defaulting to StringProperty than returning null
|
||||
return null;
|
||||
}
|
||||
@@ -220,13 +219,12 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
final ArraySchema ap = (ArraySchema) p;
|
||||
final String pattern = "new ArrayList<%s>()";
|
||||
if (ap.getItems() == null) {
|
||||
if (ModelUtils.getSchemaItems(p) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.format(Locale.ROOT, pattern, getTypeDeclaration(ap.getItems()));
|
||||
return String.format(Locale.ROOT, pattern, getTypeDeclaration(ModelUtils.getSchemaItems(p)));
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
final MapSchema ap = (MapSchema) p;
|
||||
final String pattern = "new HashMap<%s>()";
|
||||
@@ -318,7 +316,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
example = "new " + getTypeDeclaration(p) + "{" + toExampleValue(
|
||||
((ArraySchema) p).getItems()) + "}";
|
||||
ModelUtils.getSchemaItems(p)) + "}";
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
example = String.valueOf(!"false".equals(example));
|
||||
} else if (ModelUtils.isByteArraySchema(p)) {
|
||||
|
||||
@@ -734,6 +734,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
});
|
||||
}
|
||||
|
||||
String[] numericTypes = {"double", "double?", "decimal", "decimal", "float", "float?", "int", "int?", "long", "long?", "ulong", "ulong?"};
|
||||
enumVars.forEach((enumVar) -> {
|
||||
enumVar.put("isNumeric", Arrays.stream(numericTypes).anyMatch(dataType::equals));
|
||||
});
|
||||
|
||||
return enumVars;
|
||||
}
|
||||
|
||||
@@ -1428,12 +1433,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
* @param arr The input array property
|
||||
* @return The type declaration when the type is an array of arrays.
|
||||
*/
|
||||
private String getArrayTypeDeclaration(ArraySchema arr) {
|
||||
private String getArrayTypeDeclaration(Schema arr) {
|
||||
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
|
||||
// This supports arrays of arrays.
|
||||
String arrayType = typeMapping.get("array");
|
||||
StringBuilder instantiationType = new StringBuilder(arrayType);
|
||||
Schema items = arr.getItems();
|
||||
Schema items = ModelUtils.getSchemaItems(arr);
|
||||
String nestedType = getTypeDeclaration(items);
|
||||
// TODO: We may want to differentiate here between generics and primitive arrays.
|
||||
instantiationType.append("<").append(nestedType).append(">");
|
||||
@@ -1443,7 +1448,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String toInstantiationType(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
}
|
||||
return super.toInstantiationType(p);
|
||||
}
|
||||
@@ -1451,7 +1456,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
// Should we also support maps of maps?
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
@@ -512,7 +512,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
Schema<?> schema = unaliasSchema(p);
|
||||
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
|
||||
if (ModelUtils.isArraySchema(target)) {
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
Schema<?> items = ModelUtils.getSchemaItems(schema);
|
||||
return getSchemaType(target) + "<" + getTypeDeclaration(items) + ">";
|
||||
}
|
||||
if (ModelUtils.isMapSchema(target)) {
|
||||
|
||||
@@ -293,8 +293,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
return "LIST [" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
@@ -578,8 +577,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// String inner = toModelName(getSchemaType(additionalProperties2));
|
||||
// return instantiationTypes.get("map") + " [" + inner + "]";
|
||||
// } else if (ModelUtils.isArraySchema(p)) {
|
||||
// ArraySchema ap = (ArraySchema) p;
|
||||
// String inner = toModelName(getSchemaType(ap.getItems()));
|
||||
// String inner = toModelName(getSchemaType(ModelUtils.getSchemaItems(p)));
|
||||
// return instantiationTypes.get("array") + " [" + inner + "]";
|
||||
// } else {
|
||||
// return null;
|
||||
|
||||
@@ -855,12 +855,12 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
* @param arr The input array property
|
||||
* @return The type declaration when the type is an array of arrays.
|
||||
*/
|
||||
private String getArrayTypeDeclaration(ArraySchema arr) {
|
||||
private String getArrayTypeDeclaration(Schema arr) {
|
||||
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
|
||||
// This supports arrays of arrays.
|
||||
String arrayType = typeMapping.get("array");
|
||||
StringBuilder instantiationType = new StringBuilder(arrayType);
|
||||
Schema items = arr.getItems();
|
||||
Schema items = ModelUtils.getSchemaItems(arr);
|
||||
String nestedType = getTypeDeclaration(items);
|
||||
// TODO: We may want to differentiate here between generics and primitive arrays.
|
||||
return nestedType + "[]";
|
||||
@@ -869,7 +869,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String toInstantiationType(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
}
|
||||
return super.toInstantiationType(p);
|
||||
}
|
||||
@@ -877,7 +877,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
// Should we also support maps of maps?
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
@@ -360,8 +360,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
// In OAS 3.0.x, the array "items" attribute is required.
|
||||
// In OAS >= 3.1, the array "items" attribute is optional such that the OAS
|
||||
// specification is aligned with the JSON schema specification.
|
||||
|
||||
@@ -273,8 +273,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
return "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Object ap = p.getAdditionalProperties();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user