forked from loafle/openapi-generator-original
Compare commits
99 Commits
v7.4.0
...
fix-bean-v
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56eb5a63bf | ||
|
|
2934f5ac51 | ||
|
|
2ce71512d0 | ||
|
|
927768757b | ||
|
|
858499ffdd | ||
|
|
4719d9e55f | ||
|
|
2d7f0496ec | ||
|
|
2fac8e34db | ||
|
|
1704ae1194 | ||
|
|
370eca2889 | ||
|
|
d0f8468651 | ||
|
|
6252dac28e | ||
|
|
807aa5d3ae | ||
|
|
f73db59b0e | ||
|
|
34ebc1c644 | ||
|
|
de680de60e | ||
|
|
e78aeb6bc7 | ||
|
|
309918d03e | ||
|
|
6690b9f87d | ||
|
|
ee69a7983a | ||
|
|
204407daf0 | ||
|
|
d1860b95cf | ||
|
|
e0b059bcde | ||
|
|
6746be9a50 | ||
|
|
d88023f833 | ||
|
|
8acf9b779d | ||
|
|
9acd620bbb | ||
|
|
e17777044e | ||
|
|
f258ce2cf5 | ||
|
|
5e9546451c | ||
|
|
420e49f258 | ||
|
|
4ca8f9c384 | ||
|
|
aedf571811 | ||
|
|
8288b6fb15 | ||
|
|
a26c87e7a9 | ||
|
|
2916be0fb5 | ||
|
|
716a82f8bb | ||
|
|
84b3cd9962 | ||
|
|
19898646a8 | ||
|
|
7565e365f8 | ||
|
|
1bfe800b9f | ||
|
|
a4508f6817 | ||
|
|
c7e9bd2f29 | ||
|
|
e39b99051c | ||
|
|
894848e550 | ||
|
|
9c26ad4745 | ||
|
|
bcd0bc5de8 | ||
|
|
bf2a251dd6 | ||
|
|
7aeb952565 | ||
|
|
43ca5fcac9 | ||
|
|
0b94817f58 | ||
|
|
fe9ba01bf8 | ||
|
|
2600eb92dc | ||
|
|
ed8b7ec7f6 | ||
|
|
6a1791c8c3 | ||
|
|
c15e267e22 | ||
|
|
e2df0d6154 | ||
|
|
971c3a6059 | ||
|
|
09af44eca3 | ||
|
|
de081e4edf | ||
|
|
1108ce5808 | ||
|
|
783119b687 | ||
|
|
93b76dde37 | ||
|
|
191dc1a6ba | ||
|
|
b7ea139f77 | ||
|
|
e58f19c735 | ||
|
|
815205250a | ||
|
|
5f49a04190 | ||
|
|
ddb5ab4078 | ||
|
|
3155a70c3f | ||
|
|
b59957a095 | ||
|
|
da1187fc8d | ||
|
|
669651fcb2 | ||
|
|
96fad5eb2c | ||
|
|
12849cccbe | ||
|
|
c5ab78575a | ||
|
|
0b4cf0a027 | ||
|
|
ae9598dcfc | ||
|
|
d1ccabbe7e | ||
|
|
3137b3da77 | ||
|
|
fbe81f0735 | ||
|
|
41dbe51575 | ||
|
|
58bdef48c7 | ||
|
|
4f4237393f | ||
|
|
3bd8974583 | ||
|
|
cb75fa0d9e | ||
|
|
5ed2283e01 | ||
|
|
96bf7ac915 | ||
|
|
6075b8a8f1 | ||
|
|
7e8de912a7 | ||
|
|
9824b004f0 | ||
|
|
e41dc1e81b | ||
|
|
1586c698c9 | ||
|
|
5975e6c5b0 | ||
|
|
6251aa17ef | ||
|
|
678db1e4af | ||
|
|
82fcf28a2b | ||
|
|
7f1e79f7d2 | ||
|
|
4ff7e0ec3f |
11
.github/workflows/samples-c-libcurl-client.yaml
vendored
11
.github/workflows/samples-c-libcurl-client.yaml
vendored
@@ -4,14 +4,23 @@ on:
|
||||
push:
|
||||
paths:
|
||||
- 'samples/client/petstore/c/**'
|
||||
- 'samples/client/petstore/c-useJsonUnformatted/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/client/petstore/c/**'
|
||||
- 'samples/client/petstore/c-useJsonUnformatted/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build c libcurl client
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- 'samples/client/petstore/c/'
|
||||
- 'samples/client/petstore/c-useJsonUnformatted/'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Prepare
|
||||
@@ -19,7 +28,7 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libssl-dev libcurl4-openssl-dev
|
||||
- name: Build
|
||||
working-directory: "samples/client/petstore/c"
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
34
.github/workflows/samples-dotnet-standard.yaml
vendored
34
.github/workflows/samples-dotnet-standard.yaml
vendored
@@ -3,22 +3,16 @@ name: Samples C# .Net Standard Client
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
# build C# API client (netstandard)
|
||||
- samples/client/petstore/csharp/OpenAPIClient/**
|
||||
- samples/client/petstore/csharp/*netstandard*/**
|
||||
# build C# API client (netstandard with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (netstandard httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
|
||||
- samples/client/petstore/csharp/generichost/standard2.0/**
|
||||
- samples/client/petstore/csharp/httpclient/standard2.0/**
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/**
|
||||
- samples/client/petstore/csharp/unityWebRequest/standard2.0/**
|
||||
pull_request:
|
||||
paths:
|
||||
# build C# API client (netstandard)
|
||||
- samples/client/petstore/csharp/OpenAPIClient/**
|
||||
- samples/client/petstore/csharp/*netstandard*/**
|
||||
# build C# API client (netstandard with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (netstandard httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
|
||||
- samples/client/petstore/csharp/generichost/standard2.0/**
|
||||
- samples/client/petstore/csharp/httpclient/standard2.0/**
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/**
|
||||
- samples/client/petstore/csharp/unityWebRequest/standard2.0/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build .Net projects
|
||||
@@ -27,13 +21,11 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# build C# API client (netstandard)
|
||||
- samples/client/petstore/csharp/OpenAPIClient/
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/
|
||||
# build C# API client (netstandard with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/
|
||||
# build C# API client (netstandard httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/
|
||||
- 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
|
||||
|
||||
36
.github/workflows/samples-dotnet.yaml
vendored
36
.github/workflows/samples-dotnet.yaml
vendored
@@ -3,16 +3,16 @@ name: Samples C# .Net 8 Clients
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**
|
||||
- samples/client/petstore/csharp/*net6.0*/**
|
||||
- samples/client/petstore/csharp/*net7.0*/**
|
||||
- samples/client/petstore/csharp/OpenAPIClient-*latest*/**
|
||||
- samples/client/petstore/csharp/generichost/net8/**
|
||||
- samples/client/petstore/csharp/httpclient/net8/**
|
||||
- samples/client/petstore/csharp/restsharp/net8/**
|
||||
- samples/client/petstore/csharp/unityWebRequest/net8/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**
|
||||
- samples/client/petstore/csharp/*net6.0*/**
|
||||
- samples/client/petstore/csharp/*net7.0*/**
|
||||
- samples/client/petstore/csharp/OpenAPIClient-*latest*/**
|
||||
- samples/client/petstore/csharp/generichost/net8/**
|
||||
- samples/client/petstore/csharp/httpclient/net8/**
|
||||
- samples/client/petstore/csharp/restsharp/net8/**
|
||||
- samples/client/petstore/csharp/unityWebRequest/net8/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build .Net projects
|
||||
@@ -21,16 +21,16 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
|
||||
- samples/client/petstore/csharp/generichost/net8/AllOf
|
||||
- samples/client/petstore/csharp/generichost/net8/AnyOf
|
||||
- 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
|
||||
|
||||
33
.github/workflows/samples-dotnet6-client.yaml
vendored
33
.github/workflows/samples-dotnet6-client.yaml
vendored
@@ -3,28 +3,10 @@ name: Samples C# .Net 6 Client
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
# build C# API client (httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
|
||||
# build C# API client (.net framework 4.7)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/**
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/**
|
||||
# build C# API client (multiple frameworks)
|
||||
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
|
||||
- samples/client/petstore/csharp/restsharp/net6/**
|
||||
pull_request:
|
||||
paths:
|
||||
# build C# API client (httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
|
||||
# build C# API client (.net framework 4.7)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/**
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/**
|
||||
# build C# API client (multiple frameworks)
|
||||
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
|
||||
- samples/client/petstore/csharp/restsharp/net6/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build .Net clients
|
||||
@@ -33,16 +15,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# build C# API client (httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/
|
||||
# build C# API client (.net framework 4.7)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/
|
||||
# build C# API client (multiple frameworks)
|
||||
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/
|
||||
- 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-kotlin-client.yaml
vendored
1
.github/workflows/samples-kotlin-client.yaml
vendored
@@ -25,6 +25,7 @@ jobs:
|
||||
- samples/client/petstore/kotlin
|
||||
- samples/client/petstore/kotlin-gson
|
||||
- samples/client/petstore/kotlin-jackson
|
||||
- samples/client/petstore/kotlin-model-prefix-type-mappings
|
||||
# needs Android configured
|
||||
#- samples/client/petstore/kotlin-json-request-string
|
||||
- samples/client/petstore/kotlin-jvm-okhttp4-coroutines
|
||||
|
||||
@@ -19,6 +19,7 @@ jobs:
|
||||
sample:
|
||||
# clients
|
||||
- samples/client/echo_api/kotlin-jvm-spring-3-restclient
|
||||
- samples/client/echo_api/kotlin-model-prefix-type-mappings
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
|
||||
3
.github/workflows/samples-kotlin-server.yaml
vendored
3
.github/workflows/samples-kotlin-server.yaml
vendored
@@ -5,12 +5,14 @@ on:
|
||||
branches:
|
||||
- samples/server/others/kotlin-server/jaxrs-spec/**
|
||||
- 'samples/server/petstore/kotlin*/**'
|
||||
- 'samples/server/others/kotlin-server/jaxrs-spec-array-response/**'
|
||||
# comment out due to gradle build failure
|
||||
#- samples/server/petstore/kotlin-spring-default/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/server/others/kotlin-server/jaxrs-spec/**
|
||||
- 'samples/server/petstore/kotlin*/**'
|
||||
- 'samples/server/others/kotlin-server/jaxrs-spec-array-response/**'
|
||||
# comment out due to gradle build failure
|
||||
# - samples/server/petstore/kotlin-spring-default/**
|
||||
|
||||
@@ -40,6 +42,7 @@ jobs:
|
||||
- samples/server/petstore/kotlin-server-modelMutable
|
||||
- samples/server/petstore/kotlin-server/javalin
|
||||
- samples/server/others/kotlin-server/jaxrs-spec
|
||||
- samples/server/others/kotlin-server/jaxrs-spec-array-response
|
||||
# comment out due to gradle build failure
|
||||
#- samples/server/petstore/kotlin-spring-default
|
||||
# no build.gradle file
|
||||
|
||||
1
.github/workflows/samples-postman.yaml
vendored
1
.github/workflows/samples-postman.yaml
vendored
@@ -4,6 +4,7 @@ on:
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/schema/postman-collection/python/**
|
||||
- samples/schema/postman-collection/postman.json
|
||||
- .github/workflows/samples-postman.yaml
|
||||
jobs:
|
||||
build:
|
||||
|
||||
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
|
||||
|
||||
2
.github/workflows/samples-swift.yaml
vendored
2
.github/workflows/samples-swift.yaml
vendored
@@ -41,7 +41,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: swift-actions/setup-swift@v1
|
||||
- uses: swift-actions/setup-swift@v2
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
with:
|
||||
swift-version: '5'
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
19
README.md
19
README.md
@@ -15,7 +15,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.4.0`):
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.5.0`):
|
||||
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
@@ -68,6 +68,7 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
|
||||
[<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
|
||||
@@ -125,8 +126,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
| OpenAPI Generator Version | Release Date | Notes |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||
| 7.4.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.4.0-SNAPSHOT/) | 08.03.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [7.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.3.0) (latest stable release) | 08.02.2024 | Minor release with breaking changes (with fallback) |
|
||||
| 7.5.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.5.0-SNAPSHOT/) | 12.04.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [7.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.4.0) (latest stable release) | 11.03.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 11.05.2023 | Minor release with breaking changes (with fallback) |
|
||||
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | Minor release with breaking changes (with fallback) |
|
||||
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
|
||||
@@ -189,16 +190,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.3.0/openapi-generator-cli-7.3.0.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.3.0/openapi-generator-cli-7.3.0.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.3.0/openapi-generator-cli-7.3.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -904,6 +905,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2022-04-06 - [Effective Software Development using OpenAPI Generator](https://apexlabs.ai/post/openapi-generator) by Ajil Oommen (Senior Flutter Developer)
|
||||
- 2022-05-13 - [A Path From an API To Client Libraries](https://www.youtube.com/watch?v=XC8oVn_efTw) by [Filip Srnec](https://www.devoxx.co.uk/talk/?id=11211) at Infobip
|
||||
- 2022-06-01 - [API First, using OpenAPI and Spring Boot](https://medium.com/xgeeks/api-first-using-openapi-and-spring-boot-2602c04bb0d3) by [Micael Estrázulas Vianna](https://estrazulas.medium.com/)
|
||||
- 2022-06-10 - [Autogenerating Clients with FastAPI and Github Actions](https://www.propelauth.com/post/autogenerating-clients-with-fastapi-and-github-actions) by [Andrew Israel](https://www.propelauth.com/author/andrew)
|
||||
- 2022-06-12 - [Mustache templates with OpenAPI specs](https://medium.com/geekculture/mustache-templates-with-openapi-specs-f24711c67dec) by [Beppe Catanese](https://github.com/gcatanese)
|
||||
- 2022-07-01 - [Generate API contract using OpenAPI Generator Maven plugin](https://huongdanjava.com/generate-api-contract-using-openapi-generator-maven-plugin.html) by [Khanh Nguyen](https://huongdanjava.com/)
|
||||
- 2022-07-22 - [使用OpenAPI Generator Maven plugin开发api优先的java客户端和服务端代码](https://blog.roccoshi.top/2022/java/openapi-generator%E7%9A%84%E4%BD%BF%E7%94%A8/) by [Lincest](https://github.com/Lincest)
|
||||
@@ -927,6 +929,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2023-06-28 - [Generate API contract using OpenAPI Generator Maven plugin](https://huongdanjava.com/generate-api-contract-using-openapi-generator-maven-plugin.html) by [Khanh Nguyen](https://huongdanjava.com/)
|
||||
- 2023-06-30 - [Generate Client SDKs with OpenApi Generator in Springboot](https://medium.com/@ramavathvinayak/generate-client-sdks-with-openapi-generator-in-springboot-f9f012e73c0b) by [Vinayak Ramavath](https://medium.com/@ramavathvinayak)
|
||||
- 2023-12-10 - [UnityでOpenAPI Generatorを使う](https://www.youtube.com/watch?v=CbNwKVV5LRM) by [Soup Tori](https://www.youtube.com/@souptori8417)
|
||||
- 2024-03-04 - [Generating TypeScript Types with OpenAPI for REST API Consumption](https://www.pullrequest.com/blog/generating-typescript-types-with-openapi-for-rest-api-consumption/) by [PullRequest](https://www.pullrequest.com/)
|
||||
- 2024-03-07 - [Fully typed Web Apps with OpenAPI (Part 1)](https://medium.com/@gfox1984/fully-typed-web-apps-with-openapi-part-1-595d55766670) by [Guillaume Renard](https://medium.com/@gfox1984)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -1114,8 +1118,9 @@ Here is a list of template creators:
|
||||
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* Ktorm: @Luiz-Monad
|
||||
* MySQL: [@ybelenko](https://github.com/ybelenko)
|
||||
* Postman Collection: @gcatanese
|
||||
* Protocol Buffer: @wing328
|
||||
* WSDL @adessoDpd
|
||||
* WSDL: @adessoDpd
|
||||
|
||||
:heart: = Link to support the contributor directly
|
||||
|
||||
|
||||
40
appveyor.yml
40
appveyor.yml
@@ -43,23 +43,29 @@ 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\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test c# API client (httpclient)
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-httpclient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test c# API client (generichost)
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-generichost-netstandard2.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test c# API client (netcore)
|
||||
- dotnet test samples\client\petstore\csharp\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\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net framework 4.8)
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net 5.0)
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API Client using conditional-serialization
|
||||
- dotnet test samples\client\petstore\csharp\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\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
|
||||
|
||||
9
bin/configs/c-useJsonUnformatted.yaml
Normal file
9
bin/configs/c-useJsonUnformatted.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
generatorName: c
|
||||
outputDir: samples/client/petstore/c-useJsonUnformatted
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/c/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/C-libcurl
|
||||
additionalProperties:
|
||||
useJsonUnformatted: true
|
||||
modelNameMappings:
|
||||
another_model: MappedModel
|
||||
another_property: mappedProperty
|
||||
@@ -1,12 +0,0 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
@@ -1,12 +0,0 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
|
||||
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: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
@@ -1,13 +0,0 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
|
||||
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
|
||||
useSourceGeneration: true
|
||||
packageName: UseSourceGeneration
|
||||
equatable: true
|
||||
@@ -1,12 +0,0 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt
|
||||
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: true
|
||||
equatable: true
|
||||
@@ -1,12 +0,0 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
@@ -1,12 +0,0 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0
|
||||
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
|
||||
@@ -1,9 +0,0 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}'
|
||||
useDateTimeForDate: true
|
||||
13
bin/configs/csharp-generichost-net8-allOf.yaml
Normal file
13
bin/configs/csharp-generichost-net8-allOf.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
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
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
13
bin/configs/csharp-generichost-net8-anyOf.yaml
Normal file
13
bin/configs/csharp-generichost-net8-anyOf.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
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
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
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
|
||||
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
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
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useSourceGeneration: true
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
13
bin/configs/csharp-generichost-net8-nrt.yaml
Normal file
13
bin/configs/csharp-generichost-net8-nrt.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
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
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
13
bin/configs/csharp-generichost-net8-oneOf.yaml
Normal file
13
bin/configs/csharp-generichost-net8-oneOf.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
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
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
10
bin/configs/csharp-generichost-net8-useDateTimeForDate.yaml
Normal file
10
bin/configs/csharp-generichost-net8-useDateTimeForDate.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
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
|
||||
additionalProperties:
|
||||
packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}'
|
||||
useDateTimeForDate: true
|
||||
targetFramework: net8.0
|
||||
13
bin/configs/csharp-generichost-net8.yaml
Normal file
13
bin/configs/csharp-generichost-net8.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
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
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: false
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
@@ -1,6 +1,6 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/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/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/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/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/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/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/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/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/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/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/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/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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: haskell-http-client
|
||||
outputDir: samples/client/petstore/haskell-http-client
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/haskell-http-client/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/haskell-http-client
|
||||
additionalProperties:
|
||||
queryExtraUnreserved: ''
|
||||
|
||||
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"
|
||||
@@ -4,6 +4,7 @@ library: jersey3
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
useBeanValidation: true
|
||||
artifactId: petstore-jersey3
|
||||
hideGenerationTimestamp: true
|
||||
serverPort: "8082"
|
||||
|
||||
@@ -8,3 +8,4 @@ additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useSingleRequestParameter: true
|
||||
useBeanValidation: true
|
||||
|
||||
@@ -10,3 +10,4 @@ additionalProperties:
|
||||
playVersion: play26
|
||||
artifactId: petstore-java-client-retrofit2-play26
|
||||
hideGenerationTimestamp: "true"
|
||||
useJakartaEe: "true"
|
||||
|
||||
15
bin/configs/kotlin-model-prefix-type-mapping-echo-api.yaml
Normal file
15
bin/configs/kotlin-model-prefix-type-mapping-echo-api.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: kotlin
|
||||
outputDir: samples/client/echo_api/kotlin-model-prefix-type-mappings
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/echo_api.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||
typeMappings:
|
||||
java.io.File: RequestBody
|
||||
modelNamePrefix: Api
|
||||
additionalProperties:
|
||||
artifactId: kotlin-client-prefix-mapping
|
||||
useCoroutines: true
|
||||
library: jvm-retrofit2
|
||||
enumPropertyNaming: UPPERCASE
|
||||
serializationLibrary: gson
|
||||
openapiNormalizer:
|
||||
SIMPLIFY_ONEOF_ANYOF=false
|
||||
15
bin/configs/kotlin-model-prefix-type-mapping.yaml
Normal file
15
bin/configs/kotlin-model-prefix-type-mapping.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: kotlin
|
||||
outputDir: samples/client/petstore/kotlin-model-prefix-type-mappings
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||
typeMappings:
|
||||
java.io.File: RequestBody
|
||||
modelNamePrefix: Api
|
||||
additionalProperties:
|
||||
artifactId: kotlin-client-prefix-mapping
|
||||
useCoroutines: true
|
||||
library: jvm-retrofit2
|
||||
enumPropertyNaming: UPPERCASE
|
||||
serializationLibrary: gson
|
||||
openapiNormalizer:
|
||||
SIMPLIFY_ONEOF_ANYOF=false
|
||||
8
bin/configs/kotlin-server-jaxrs-spec-array-response.yaml
Normal file
8
bin/configs/kotlin-server-jaxrs-spec-array-response.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: kotlin-server
|
||||
outputDir: samples/server/others/kotlin-server/jaxrs-spec-array-response
|
||||
library: jaxrs-spec
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/issue18177-array.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-server
|
||||
additionalProperties:
|
||||
interfaceOnly: "true"
|
||||
useJakartaEe: true
|
||||
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,10 +1,10 @@
|
||||
---
|
||||
# csharp test files and image for upload
|
||||
- filename: "samples/client/petstore/csharp/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/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/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"
|
||||
|
||||
@@ -598,3 +598,17 @@ 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 FILTER="operationId:addPet|getPetById"
|
||||
```
|
||||
|
||||
- `SET_CONTAINER_TO_NULLABLE`: When set to `array|set|map` (or just `array`) for example, it will set `nullable` in array, set and map to 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_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"
|
||||
```
|
||||
|
||||
@@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|useJsonUnformatted|Use cJSON_PrintUnformatted instead of cJSON_Print when creating the JSON string.| |false|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ To push the auto-generated SDK to GitHub, we provide `git_push.sh` to streamline
|
||||
cd /var/tmp/perl/petstore
|
||||
/bin/sh ./git_push.sh
|
||||
```
|
||||
|
||||
To use openapi-generator as part of Github workflows, the blog post ["Autogenerating Clients with FastAPI and Github Actions"](https://www.propelauth.com/post/autogenerating-clients-with-fastapi-and-github-actions) by Andrew Israel is a good starting point.
|
||||
|
||||
### CI/CD
|
||||
|
||||
Some generators also generate CI/CD configuration files (.travis.yml) so that the output will be ready to be tested by the CI (e.g. Travis)
|
||||
|
||||
@@ -822,6 +822,7 @@ Many generators (*those extending DefaultCodegen*) come with a small set of lamb
|
||||
- `uppercase` - Converts all of the characters in this fragment to upper case using the rules of the `ROOT` locale.
|
||||
- `titlecase` - Converts text in a fragment to title case. For example `once upon a time` to `Once Upon A Time`.
|
||||
- `camelcase` - Converts text in a fragment to camelCase. For example `Input-text` to `inputText`.
|
||||
- `uncamelize` - Converts text in a fragment from camelCase or PascalCase to a string of words separated by whitespaces. For example `inputText` to `Input Text`.
|
||||
- `indented` - Prepends 4 spaces indention from second line of a fragment on. First line will be indented by Mustache.
|
||||
- `indented_8` - Prepends 8 spaces indention from second line of a fragment on. First line will be indented by Mustache.
|
||||
- `indented_12` - Prepends 12 spaces indention from second line of a fragment on. First line will be indented by Mustache.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.4.0
|
||||
openApiGeneratorVersion=7.5.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.4.0
|
||||
openApiGeneratorVersion=7.5.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.4.0</version>
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -350,6 +350,8 @@ public interface CodegenConfig {
|
||||
*/
|
||||
String generatorLanguageVersion();
|
||||
|
||||
boolean isTypeErasedGenerics();
|
||||
|
||||
List<VendorExtension> getSupportedVendorExtensions();
|
||||
|
||||
boolean getUseInlineModelResolver();
|
||||
|
||||
@@ -39,6 +39,9 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumDefaultValue, enumName, style;
|
||||
|
||||
public String nameInLowerCase; // property name in lower case
|
||||
public String nameInCamelCase; // property name in camel case (e.g. modifiedDate)
|
||||
public String nameInPascalCase; // property name in pascal case (e.g. ModifiedDate)
|
||||
public String nameInSnakeCase; // property name in upper snake case
|
||||
public String example; // example value (x-example)
|
||||
public Map<String, Example> examples;
|
||||
public String jsonSchema;
|
||||
@@ -184,6 +187,11 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
output.additionalProperties = this.additionalProperties;
|
||||
output.isNull = this.isNull;
|
||||
output.isVoid = this.isVoid;
|
||||
output.nameInPascalCase = this.nameInPascalCase;
|
||||
output.nameInCamelCase = this.nameInCamelCase;
|
||||
output.nameInLowerCase = this.nameInLowerCase;
|
||||
output.nameInSnakeCase = this.nameInSnakeCase;
|
||||
|
||||
output.setAdditionalPropertiesIsAnyType(this.getAdditionalPropertiesIsAnyType());
|
||||
output.setHasVars(this.hasVars);
|
||||
output.setHasRequired(this.hasRequired);
|
||||
@@ -265,7 +273,22 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, containerType, containerTypeMapped, defaultValue, enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, isVoid, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content, requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties);
|
||||
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam,
|
||||
isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName,
|
||||
paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description,
|
||||
unescapedDescription, baseType, containerType, containerTypeMapped, defaultValue,
|
||||
enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples,
|
||||
jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal,
|
||||
isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword,
|
||||
isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues,
|
||||
items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation,
|
||||
getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(),
|
||||
getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(),
|
||||
getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull,isVoid,
|
||||
additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger,
|
||||
hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content,
|
||||
requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties,
|
||||
nameInPascalCase, nameInCamelCase, nameInLowerCase, nameInSnakeCase);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -182,8 +182,10 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
public boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
||||
public boolean isInherited;
|
||||
public String discriminatorValue;
|
||||
|
||||
public String nameInLowerCase; // property name in lower case
|
||||
public String nameInCamelCase; // property name in camel case
|
||||
public String nameInCamelCase; // property name in camel case (e.g. modifiedDate)
|
||||
public String nameInPascalCase; // property name in pascal case (e.g. ModifiedDate)
|
||||
public String nameInSnakeCase; // property name in upper snake case
|
||||
// enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
|
||||
public String enumName;
|
||||
@@ -697,6 +699,14 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
this.nameInCamelCase = nameInCamelCase;
|
||||
}
|
||||
|
||||
public String getNameInPascalCase() {
|
||||
return nameInPascalCase;
|
||||
}
|
||||
|
||||
public void setNameInPascalCase(String nameInPascalCase) {
|
||||
this.nameInPascalCase = nameInPascalCase;
|
||||
}
|
||||
|
||||
public String getNameInSnakeCase() {
|
||||
return nameInSnakeCase;
|
||||
}
|
||||
@@ -1129,6 +1139,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
this.isEnum = isEnum;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("CodegenProperty{");
|
||||
@@ -1213,6 +1224,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
sb.append(", isInherited=").append(isInherited);
|
||||
sb.append(", discriminatorValue='").append(discriminatorValue).append('\'');
|
||||
sb.append(", nameInCamelCase='").append(nameInCamelCase).append('\'');
|
||||
sb.append(", nameInPascalCase='").append(nameInPascalCase).append('\'');
|
||||
sb.append(", nameInSnakeCase='").append(nameInSnakeCase).append('\'');
|
||||
sb.append(", enumName='").append(enumName).append('\'');
|
||||
sb.append(", maxItems=").append(maxItems);
|
||||
@@ -1352,6 +1364,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
Objects.equals(vendorExtensions, that.vendorExtensions) &&
|
||||
Objects.equals(discriminatorValue, that.discriminatorValue) &&
|
||||
Objects.equals(nameInCamelCase, that.nameInCamelCase) &&
|
||||
Objects.equals(nameInPascalCase, that.nameInPascalCase) &&
|
||||
Objects.equals(nameInSnakeCase, that.nameInSnakeCase) &&
|
||||
Objects.equals(enumName, that.enumName) &&
|
||||
Objects.equals(maxItems, that.maxItems) &&
|
||||
@@ -1376,7 +1389,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
isArray, isMap, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
|
||||
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, isOverridden, _enum,
|
||||
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
|
||||
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
|
||||
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInPascalCase, nameInCamelCase,
|
||||
nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
|
||||
xmlNamespace, isXmlWrapped, isNull, isVoid, additionalPropertiesIsAnyType, hasVars, hasRequired,
|
||||
hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, requiredVarsMap,
|
||||
|
||||
@@ -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,6 +52,7 @@ 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;
|
||||
@@ -64,6 +65,7 @@ import org.openapitools.codegen.model.WebhooksMap;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.templating.MustacheEngineAdapter;
|
||||
import org.openapitools.codegen.templating.mustache.*;
|
||||
import org.openapitools.codegen.utils.CamelizeOption;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.OneOfImplementorAdditionalData;
|
||||
import org.slf4j.Logger;
|
||||
@@ -81,6 +83,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.openapitools.codegen.CodegenConstants.UNSUPPORTED_V310_SPEC_MSG;
|
||||
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
|
||||
import static org.openapitools.codegen.utils.OnceLogger.once;
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
|
||||
@@ -462,8 +465,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
.put("snakecase", new SnakecaseLambda())
|
||||
.put("titlecase", new TitlecaseLambda())
|
||||
.put("kebabcase", new KebabCaseLambda())
|
||||
.put("camelcase", new CamelCaseLambda(true).generator(this))
|
||||
.put("pascalcase", new CamelCaseLambda(false).generator(this))
|
||||
.put("camelcase", new CamelCaseAndSanitizeLambda(true).generator(this))
|
||||
.put("pascalcase", new CamelCaseAndSanitizeLambda(false).generator(this))
|
||||
.put("uncamelize", new UncamelizeLambda())
|
||||
.put("forwardslash", new ForwardSlashLambda())
|
||||
.put("backslash", new BackSlashLambda())
|
||||
.put("doublequote", new DoubleQuoteLambda())
|
||||
@@ -2055,7 +2059,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
|
||||
String inner = getSchemaType(additionalProperties);
|
||||
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
||||
String mapInstantion = instantiationTypes.get("map");
|
||||
if (mapInstantion != null) {
|
||||
return mapInstantion + "<String, " + inner + ">";
|
||||
}
|
||||
return inner;
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema arraySchema = (ArraySchema) schema;
|
||||
String inner = getSchemaType(getSchemaItems(arraySchema));
|
||||
@@ -2456,6 +2464,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());
|
||||
@@ -2942,7 +2958,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
newProperties.forEach((key, value) ->
|
||||
existingProperties.put(
|
||||
key,
|
||||
AnnotationsUtils.clone(value, specVersionGreaterThanOrEqualTo310(openAPI))
|
||||
ModelUtils.cloneSchema(value, specVersionGreaterThanOrEqualTo310(openAPI))
|
||||
));
|
||||
if (null != existingType && null != newType && null != newType.getEnum() && !newType.getEnum().isEmpty()) {
|
||||
for (Object e : newType.getEnum()) {
|
||||
@@ -3346,7 +3362,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);
|
||||
}
|
||||
@@ -3355,7 +3371,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);
|
||||
}
|
||||
@@ -3369,7 +3385,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);
|
||||
}
|
||||
@@ -3378,7 +3394,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);
|
||||
}
|
||||
@@ -3446,7 +3462,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) {
|
||||
@@ -3475,7 +3491,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) {
|
||||
@@ -3524,7 +3540,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);
|
||||
}
|
||||
@@ -3546,14 +3562,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")) {
|
||||
@@ -3666,7 +3682,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();
|
||||
@@ -3975,6 +3991,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) {
|
||||
@@ -4010,8 +4033,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else {
|
||||
property.openApiType = p.getType();
|
||||
}
|
||||
property.nameInCamelCase = camelize(property.name);
|
||||
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
|
||||
property.nameInPascalCase = camelize(property.name);
|
||||
property.nameInCamelCase = camelize(property.name, LOWERCASE_FIRST_LETTER);
|
||||
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInPascalCase);
|
||||
property.description = escapeText(p.getDescription());
|
||||
property.unescapedDescription = p.getDescription();
|
||||
property.title = p.getTitle();
|
||||
@@ -4723,13 +4747,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
List<CodegenParameter> notNullableParams = new ArrayList<>();
|
||||
|
||||
CodegenParameter bodyParam = null;
|
||||
RequestBody requestBody = operation.getRequestBody();
|
||||
RequestBody requestBody = ModelUtils.getReferencedRequestBody(this.openAPI, operation.getRequestBody());
|
||||
if (requestBody != null) {
|
||||
String contentType = getContentType(requestBody);
|
||||
if (contentType != null) {
|
||||
contentType = contentType.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
if (contentType != null &&
|
||||
if (!(this instanceof RustAxumServerCodegen) && contentType != null &&
|
||||
(contentType.startsWith("application/x-www-form-urlencoded") ||
|
||||
contentType.startsWith("multipart"))) {
|
||||
// process form parameters
|
||||
@@ -4747,8 +4771,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
} else {
|
||||
// process body parameter
|
||||
requestBody = ModelUtils.getReferencedRequestBody(this.openAPI, requestBody);
|
||||
|
||||
String bodyParameterName = "";
|
||||
if (op.vendorExtensions != null && op.vendorExtensions.containsKey("x-codegen-request-body-name")) {
|
||||
bodyParameterName = (String) op.vendorExtensions.get("x-codegen-request-body-name");
|
||||
@@ -5456,6 +5478,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isCollectionFormatMulti = true;
|
||||
}
|
||||
codegenParameter.paramName = toParamName(parameter.getName());
|
||||
codegenParameter.nameInCamelCase = camelize(codegenParameter.paramName, LOWERCASE_FIRST_LETTER);
|
||||
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
|
||||
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
|
||||
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
|
||||
|
||||
// import
|
||||
if (codegenProperty.complexType != null) {
|
||||
imports.add(codegenProperty.complexType);
|
||||
@@ -6768,6 +6795,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);
|
||||
}
|
||||
|
||||
@@ -6790,6 +6818,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
enumVar.put("name", toEnumVarName(enumName, dataType));
|
||||
enumVar.put("value", toEnumValue(enumValue, dataType));
|
||||
enumVar.put("isString", isDataTypeString(dataType));
|
||||
// TODO: add isNumeric
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
|
||||
@@ -6928,6 +6957,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
scopes.add(scope);
|
||||
}
|
||||
codegenSecurity.scopes = scopes;
|
||||
codegenSecurity.hasScopes = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7183,6 +7213,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.dataType = codegenProperty.dataType;
|
||||
codegenParameter.baseName = codegenProperty.baseName;
|
||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||
codegenParameter.nameInCamelCase = camelize(codegenParameter.paramName, LOWERCASE_FIRST_LETTER);
|
||||
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
|
||||
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
|
||||
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
|
||||
|
||||
codegenParameter.dataFormat = codegenProperty.dataFormat;
|
||||
// non-array/map
|
||||
updateCodegenPropertyEnum(codegenProperty);
|
||||
@@ -7567,6 +7602,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.baseName = bodyParameterName;
|
||||
}
|
||||
codegenParameter.paramName = toArrayModelParamName(codegenParameter.baseName);
|
||||
codegenParameter.nameInCamelCase = camelize(codegenParameter.paramName, LOWERCASE_FIRST_LETTER);
|
||||
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
|
||||
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
|
||||
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
|
||||
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
|
||||
codegenParameter.dataType = getTypeDeclaration(arraySchema);
|
||||
@@ -8399,12 +8439,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;
|
||||
@@ -8441,11 +8486,16 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
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
|
||||
*/
|
||||
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; }
|
||||
|
||||
/**
|
||||
|
||||
@@ -292,7 +292,9 @@ public class DefaultGenerator implements Generator {
|
||||
// set OpenAPI to make these available to all methods
|
||||
config.setOpenAPI(openAPI);
|
||||
|
||||
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
|
||||
if (!config.additionalProperties().containsKey("generatorVersion")) {
|
||||
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
|
||||
}
|
||||
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
|
||||
config.additionalProperties().put("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
|
||||
config.additionalProperties().put("generatorClass", config.getClass().getName());
|
||||
|
||||
@@ -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<>();
|
||||
@@ -101,10 +103,25 @@ public class OpenAPINormalizer {
|
||||
final String X_INTERNAL = "x-internal";
|
||||
boolean removeXInternal;
|
||||
|
||||
// when set (e.g. operationId:getPetById, addPet), filter out (or remove) everything else
|
||||
// when set (e.g. operationId:getPetById|addPet), filter out (or remove) everything else
|
||||
final String FILTER = "FILTER";
|
||||
HashSet<String> operationIdFilters = new HashSet<>();
|
||||
|
||||
// when set (e.g. operationId:getPetById|addPet), filter out (or remove) everything else
|
||||
final String SET_CONTAINER_TO_NULLABLE = "SET_CONTAINER_TO_NULLABLE";
|
||||
HashSet<String> setContainerToNullable = new HashSet<>();
|
||||
boolean updateArrayToNullable;
|
||||
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 =============
|
||||
|
||||
/**
|
||||
@@ -136,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");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,6 +227,43 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inputRules.get(SET_CONTAINER_TO_NULLABLE) != null) {
|
||||
rules.put(SET_CONTAINER_TO_NULLABLE, true);
|
||||
setContainerToNullable = new HashSet<>(Arrays.asList(inputRules.get(SET_CONTAINER_TO_NULLABLE).split("[|]")));
|
||||
if (setContainerToNullable.contains("array")) {
|
||||
updateArrayToNullable = true;
|
||||
}
|
||||
if (setContainerToNullable.contains("set")) {
|
||||
updateSetToNullable = true;
|
||||
}
|
||||
if (setContainerToNullable.contains("map")) {
|
||||
updateMapToNullable = true;
|
||||
}
|
||||
if (!updateArrayToNullable && !updateSetToNullable && !updateMapToNullable) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,8 +510,10 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
if (schema instanceof ArraySchema) { // array
|
||||
normalizeArraySchema(schema);
|
||||
normalizeSchema(schema.getItems(), visitedSchemas);
|
||||
} else if (schema.getAdditionalProperties() instanceof Schema) { // map
|
||||
normalizeMapSchema(schema);
|
||||
normalizeSchema((Schema) schema.getAdditionalProperties(), visitedSchemas);
|
||||
} else if (ModelUtils.isOneOf(schema)) { // oneOf
|
||||
return normalizeOneOf(schema, visitedSchemas);
|
||||
@@ -498,16 +565,27 @@ public class OpenAPINormalizer {
|
||||
return schema;
|
||||
}
|
||||
|
||||
private Schema normalizeArraySchema(Schema schema) {
|
||||
return processSetArraytoNullable(schema);
|
||||
}
|
||||
|
||||
private Schema normalizeMapSchema(Schema schema) {
|
||||
return processSetMapToNullable(schema);
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -818,8 +896,14 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
|
||||
if (!(schema instanceof JsonSchema) && (schema.getType() == null || schema.getType().equals("null")) && schema.get$ref() == null) {
|
||||
return true;
|
||||
if (schema instanceof JsonSchema) { // 3.1 spec
|
||||
if (Boolean.TRUE.equals(schema.getNullable())) {
|
||||
return true;
|
||||
}
|
||||
} else { // 3.0.x or 2.x spec
|
||||
if ((schema.getType() == null || schema.getType().equals("null")) && schema.get$ref() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// convert referenced enum of null only to `nullable:true`
|
||||
@@ -848,6 +932,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(s.getType());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -864,6 +969,80 @@ public class OpenAPINormalizer {
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set nullable to true in array/set if needed.
|
||||
*
|
||||
* @param schema Schema
|
||||
* @return Schema
|
||||
*/
|
||||
private Schema processSetArraytoNullable(Schema schema) {
|
||||
if (!getRule(SET_CONTAINER_TO_NULLABLE)) {
|
||||
return schema;
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(schema.getUniqueItems())) { // a set
|
||||
if (updateSetToNullable) {
|
||||
return setNullable(schema);
|
||||
}
|
||||
} else { // array
|
||||
if (updateArrayToNullable) {
|
||||
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.
|
||||
*
|
||||
* @param schema Schema
|
||||
* @return Schema
|
||||
*/
|
||||
private Schema processSetMapToNullable(Schema schema) {
|
||||
if (!getRule(SET_CONTAINER_TO_NULLABLE)) {
|
||||
return schema;
|
||||
}
|
||||
|
||||
if (updateMapToNullable) {
|
||||
return setNullable(schema);
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the schema is anyOf and the sub-schemas is null, set `nullable: true` instead.
|
||||
* If there's only one sub-schema, simply return the sub-schema directly.
|
||||
@@ -878,6 +1057,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(s.getType());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1036,6 +1236,7 @@ public class OpenAPINormalizer {
|
||||
as.setMaxItems(schema.getMaxItems());
|
||||
as.setExtensions(schema.getExtensions());
|
||||
as.setXml(schema.getXml());
|
||||
as.setUniqueItems(schema.getUniqueItems());
|
||||
if (schema.getItems() != null) {
|
||||
// `items` is also a json schema
|
||||
if (StringUtils.isNotEmpty(schema.getItems().get$ref())) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ExampleGenerator {
|
||||
private static final String MIME_TYPE_JSON = "application/json";
|
||||
private static final String MIME_TYPE_XML = "application/xml";
|
||||
|
||||
protected final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
|
||||
protected final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
|
||||
|
||||
private static final String EXAMPLE = "example";
|
||||
private static final String CONTENT_TYPE = "contentType";
|
||||
@@ -57,7 +57,7 @@ public class ExampleGenerator {
|
||||
this.openAPI = openAPI;
|
||||
// use a fixed seed to make the "random" numbers reproducible.
|
||||
this.random = new Random("ExampleGenerator".hashCode());
|
||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public List<Map<String, String>> generateFromResponseSchema(String statusCode, Schema responseSchema, Set<String> producesInfo) {
|
||||
@@ -238,7 +238,7 @@ public class ExampleGenerator {
|
||||
// When a property is of type Date, we want to ensure that we're returning a formatted Date.
|
||||
// And not returning the Date object directly.
|
||||
if (property.getExample() instanceof Date) {
|
||||
return DATE_FORMAT.format(property.getExample());
|
||||
return dateFormat.format(property.getExample());
|
||||
}
|
||||
return property.getExample();
|
||||
} else if (ModelUtils.isBooleanSchema(property)) {
|
||||
|
||||
@@ -469,9 +469,9 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
|
||||
CodegenProperty property = super.fromProperty(name, p, required);
|
||||
if (property != null) {
|
||||
String nameInCamelCase = property.nameInCamelCase;
|
||||
nameInCamelCase = sanitizeName(nameInCamelCase);
|
||||
property.nameInCamelCase = nameInCamelCase;
|
||||
String nameInPascalCase = property.nameInPascalCase;
|
||||
nameInPascalCase = sanitizeName(nameInPascalCase);
|
||||
property.nameInPascalCase = nameInPascalCase;
|
||||
}
|
||||
return property;
|
||||
}
|
||||
@@ -650,10 +650,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodegenProperty header : rsp.headers) {
|
||||
header.nameInCamelCase = toModelName(header.baseName);
|
||||
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
return op;
|
||||
@@ -845,10 +841,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodegenProperty header : rsp.headers) {
|
||||
header.nameInCamelCase = toModelName(header.baseName);
|
||||
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -85,7 +85,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
protected String enumValueSuffix = "Enum";
|
||||
|
||||
protected String sourceFolder = "src";
|
||||
protected String invalidNamePrefix = "var";
|
||||
protected static final String invalidParameterNamePrefix = "var";
|
||||
protected static final String invalidPropertyNamePrefix = "Var";
|
||||
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.PascalCase;
|
||||
|
||||
// TODO: Add option for test folder output location. Nice to allow e.g. ./test instead of ./src.
|
||||
@@ -441,7 +442,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
CopyLambda copyLambda = new CopyLambda();
|
||||
|
||||
return super.addMustacheLambdas()
|
||||
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
|
||||
.put("camelcase_sanitize_param", new CamelCaseAndSanitizeLambda().generator(this).escapeAsParamName(true))
|
||||
.put("required", new RequiredParameterLambda())
|
||||
.put("optional", new OptionalParameterLambda().generator(this))
|
||||
.put("joinWithComma", new JoinWithCommaLambda())
|
||||
@@ -461,7 +462,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
.put("pasteOnce", new PasteLambda(copyLambda, true, true, true, true))
|
||||
.put("pasteLine", new PasteLambda(copyLambda, true, true, false, false))
|
||||
.put("uniqueLines", new UniqueLambda("\n", false))
|
||||
.put("unique", new UniqueLambda("\n", true));
|
||||
.put("unique", new UniqueLambda("\n", true))
|
||||
.put("camel_case", new CamelCaseLambda())
|
||||
.put("escape_reserved_word", new EscapeKeywordLambda((val) -> this.escapeKeyword(val)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -664,18 +667,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
private String patchPropertyName(CodegenModel model, String value) {
|
||||
// the casing will be wrong if we just set the name to escapeReservedWord
|
||||
// if we try to fix it with camelize, underscores get stripped out
|
||||
// so test if the name was escaped and then replace var with Var
|
||||
String tmpPropertyName = escapeReservedWord(model, value);
|
||||
if (!value.equals(tmpPropertyName) || value.startsWith(this.invalidNamePrefix)) {
|
||||
value = tmpPropertyName;
|
||||
String firstCharacter = value.substring(0, 1);
|
||||
value = value.substring(1);
|
||||
value = firstCharacter.toUpperCase(Locale.ROOT) + value;
|
||||
String name = escapeReservedWord(model, value);
|
||||
|
||||
if (name.startsWith(AbstractCSharpCodegen.invalidParameterNamePrefix)) {
|
||||
name = AbstractCSharpCodegen.invalidPropertyNamePrefix + name.substring(AbstractCSharpCodegen.invalidParameterNamePrefix.length());
|
||||
}
|
||||
|
||||
return value;
|
||||
return name;
|
||||
}
|
||||
|
||||
private void patchPropertyVendorExtensions(CodegenProperty property) {
|
||||
@@ -700,7 +698,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
patchPropertyVendorExtensions(property);
|
||||
|
||||
String tmpPropertyName = escapeReservedWord(model, property.name);
|
||||
property.name = patchPropertyName(model, property.name);
|
||||
|
||||
String[] nestedTypes = { "List", "Collection", "ICollection", "Dictionary" };
|
||||
@@ -737,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;
|
||||
}
|
||||
|
||||
@@ -794,6 +796,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
additionalProperties.put("x-http-statuses-with-return", httpStatusesWithReturn);
|
||||
|
||||
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
|
||||
|
||||
if (objs != null) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
@@ -1044,57 +1048,57 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.allParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.bodyParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.cookieParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.formParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.headerParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.implicitHeadersParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.optionalParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.pathParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.queryParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.notNullableParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
for (CodegenParameter parameter : operation.requiredParams) {
|
||||
CodegenModel model = getModelFromParameter(allModels, parameter);
|
||||
CodegenModel model = getModelFromParameter(modelMaps, parameter);
|
||||
patchParameter(model, parameter);
|
||||
}
|
||||
|
||||
@@ -1121,10 +1125,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
/**
|
||||
* Returns the model related to the given parameter
|
||||
*/
|
||||
private CodegenModel getModelFromParameter(List<ModelMap> allModels, CodegenParameter parameter) {
|
||||
return parameter.isModel
|
||||
? allModels.stream().map(m -> m.getModel()).filter(m -> m.getClassname().equals(parameter.dataType)).findFirst().orElse(null)
|
||||
: null;
|
||||
private CodegenModel getModelFromParameter(HashMap<String, CodegenModel> allModels, CodegenParameter parameter) {
|
||||
return allModels.getOrDefault(parameter.dataType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1308,23 +1310,24 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
public String escapeReservedWord(CodegenModel model, String name) {
|
||||
name = this.escapeReservedWord(name);
|
||||
|
||||
return name.equalsIgnoreCase(model.getClassname())
|
||||
? this.invalidNamePrefix + camelize(name)
|
||||
return name.equals(model.getClassname())
|
||||
? AbstractCSharpCodegen.invalidParameterNamePrefix + camelize(name)
|
||||
: name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (reservedWords().contains(name) ||
|
||||
reservedWords().contains(name.toLowerCase(Locale.ROOT)) ||
|
||||
reservedWords().contains(camelize(sanitizeName(name))) ||
|
||||
isReservedWord(name) ||
|
||||
if (isReservedWord(name) ||
|
||||
name.matches("^\\d.*")) {
|
||||
name = this.invalidNamePrefix + camelize(name);
|
||||
name = AbstractCSharpCodegen.invalidParameterNamePrefix + camelize(name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public String escapeKeyword(String value) {
|
||||
return isReservedWord(value) ? "@" + value : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the example value of the property
|
||||
*
|
||||
|
||||
@@ -280,7 +280,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
@Override
|
||||
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
|
||||
CodegenProperty property = super.fromProperty(name, p, required);
|
||||
String nameInCamelCase = property.nameInCamelCase;
|
||||
String nameInCamelCase = property.nameInPascalCase;
|
||||
if (nameInCamelCase.length() > 1) {
|
||||
nameInCamelCase = sanitizeName(Character.toLowerCase(nameInCamelCase.charAt(0)) + nameInCamelCase.substring(1));
|
||||
} else {
|
||||
|
||||
@@ -313,7 +313,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
|
||||
return super.addMustacheLambdas()
|
||||
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true));
|
||||
.put("camelcase_param", new CamelCaseAndSanitizeLambda().generator(this).escapeAsParamName(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -277,8 +277,11 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
|
||||
Schema inner = ap.getItems();
|
||||
return "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
return getTypeDeclaration(inner);
|
||||
Object ap = p.getAdditionalProperties();
|
||||
// additionalProperties is either a Schema or a Boolean
|
||||
if (ap instanceof Schema) {
|
||||
return getTypeDeclaration((Schema) ap);
|
||||
}
|
||||
}
|
||||
|
||||
// Not using the supertype invocation, because we want to UpperCamelize
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
@@ -139,7 +140,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected boolean implicitHeaders = false;
|
||||
protected String implicitHeadersRegex = null;
|
||||
protected boolean camelCaseDollarSign = false;
|
||||
protected boolean useJakartaEe = false;
|
||||
protected boolean useJakartaEe = true;
|
||||
protected boolean containerDefaultToNull = false;
|
||||
|
||||
private Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
|
||||
@@ -666,6 +667,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.setContainerDefaultToNull(Boolean.parseBoolean(additionalProperties.get(CONTAINER_DEFAULT_TO_NULL).toString()));
|
||||
}
|
||||
additionalProperties.put(CONTAINER_DEFAULT_TO_NULL, containerDefaultToNull);
|
||||
|
||||
additionalProperties.put("sanitizeGeneric", (Mustache.Lambda) (fragment, writer) -> {
|
||||
String content = fragment.execute();
|
||||
for (final String s: List.of("<", ">", ",", " ")) {
|
||||
content = content.replace(s, "");
|
||||
}
|
||||
writer.write(content);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1038,7 +1047,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
private String getStringBeanValidation(Schema<?> items) {
|
||||
String validations = "";
|
||||
if (ModelUtils.isByteArraySchema(items) || ModelUtils.isBinarySchema(items)) {
|
||||
if (ModelUtils.shouldIgnoreBeanValidation(items)) {
|
||||
return validations;
|
||||
}
|
||||
|
||||
@@ -1103,13 +1112,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
*/
|
||||
public String toArrayDefaultValue(CodegenProperty cp, Schema schema) {
|
||||
if (schema.getDefault() != null) { // has default value
|
||||
if (cp.isArray && !cp.getUniqueItems()) { // array
|
||||
if (cp.isArray) {
|
||||
List<String> _values = new ArrayList<>();
|
||||
|
||||
if (schema.getDefault() instanceof ArrayNode) { // array of default values
|
||||
ArrayNode _default = (ArrayNode) schema.getDefault();
|
||||
if (_default.isEmpty()) { // e.g. default: []
|
||||
return "new ArrayList<>()";
|
||||
return getDefaultCollectionType(schema);
|
||||
}
|
||||
|
||||
List<String> final_values = _values;
|
||||
@@ -1155,14 +1164,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
defaultValue = StringUtils.join(_values, ", ");
|
||||
}
|
||||
} else {
|
||||
return "new ArrayList<>()";
|
||||
return getDefaultCollectionType(schema);
|
||||
}
|
||||
|
||||
return String.format(Locale.ROOT, "new ArrayList<>(Arrays.asList(%s))", defaultValue);
|
||||
} else if (cp.isArray && cp.getUniqueItems()) { // set
|
||||
// TODO
|
||||
return null;
|
||||
} else if (cp.isMap) { // map
|
||||
return getDefaultCollectionType(schema, defaultValue);
|
||||
}
|
||||
if (cp.isMap) { // map
|
||||
// TODO
|
||||
return null;
|
||||
} else {
|
||||
@@ -1178,21 +1185,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
if (schema.getDefault() == null) {
|
||||
// nullable, optional or containerDefaultToNull set to true
|
||||
if (cp.isNullable || !cp.required || containerDefaultToNull) {
|
||||
// nullable or containerDefaultToNull set to true
|
||||
if (cp.isNullable || containerDefaultToNull) {
|
||||
return null;
|
||||
} else {
|
||||
if (ModelUtils.isSet(schema)) {
|
||||
return String.format(Locale.ROOT, "new %s<>()",
|
||||
instantiationTypes().getOrDefault("set", "LinkedHashSet"));
|
||||
} else {
|
||||
return String.format(Locale.ROOT, "new %s<>()",
|
||||
instantiationTypes().getOrDefault("array", "ArrayList"));
|
||||
}
|
||||
}
|
||||
} else { // has default value
|
||||
return toArrayDefaultValue(cp, schema);
|
||||
return getDefaultCollectionType(schema);
|
||||
}
|
||||
return toArrayDefaultValue(cp, schema);
|
||||
} else if (ModelUtils.isMapSchema(schema) && !(ModelUtils.isComposedSchema(schema))) {
|
||||
if (schema.getProperties() != null && schema.getProperties().size() > 0) {
|
||||
// object is complex object with free-form additional properties
|
||||
@@ -1202,7 +1201,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
|
||||
// nullable or containerDefaultToNull set to true
|
||||
if (cp.isNullable || containerDefaultToNull) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1290,6 +1290,24 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return super.toDefaultValue(schema);
|
||||
}
|
||||
|
||||
private String getDefaultCollectionType(Schema schema) {
|
||||
return getDefaultCollectionType(schema, null);
|
||||
}
|
||||
|
||||
private String getDefaultCollectionType(Schema schema, String defaultValues) {
|
||||
String arrayFormat = "new %s<>(Arrays.asList(%s))";
|
||||
if(defaultValues == null || defaultValues.isEmpty()){
|
||||
defaultValues = "";
|
||||
arrayFormat = "new %s<>()";
|
||||
}
|
||||
|
||||
if (ModelUtils.isSet(schema)) {
|
||||
return String.format(Locale.ROOT, arrayFormat,
|
||||
instantiationTypes().getOrDefault("set", "LinkedHashSet"),defaultValues);
|
||||
}
|
||||
return String.format(Locale.ROOT, arrayFormat, instantiationTypes().getOrDefault("array", "ArrayList"),defaultValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultParameterValue(final Schema<?> schema) {
|
||||
Object defaultValue = schema.get$ref() != null ? ModelUtils.getReferencedSchema(openAPI, schema).getDefault() : schema.getDefault();
|
||||
@@ -1583,15 +1601,29 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
// additional import for different cases
|
||||
addAdditionalImports(codegenModel, codegenModel.oneOf);
|
||||
addAdditionalImports(codegenModel, codegenModel.anyOf);
|
||||
addAdditionalImports(codegenModel, codegenModel.getComposedSchemas());
|
||||
return codegenModel;
|
||||
}
|
||||
|
||||
private void addAdditionalImports(CodegenModel model, Set<String> dataTypeSet) {
|
||||
for (String dataType : dataTypeSet) {
|
||||
if (null != importMapping().get(dataType)) {
|
||||
model.imports.add(dataType);
|
||||
private void addAdditionalImports(CodegenModel model, CodegenComposedSchemas composedSchemas) {
|
||||
if(composedSchemas == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<List<CodegenProperty>> propertyLists = Arrays.asList(
|
||||
composedSchemas.getAnyOf(),
|
||||
composedSchemas.getOneOf(),
|
||||
composedSchemas.getAllOf());
|
||||
for(final List<CodegenProperty> propertyList : propertyLists){
|
||||
if(propertyList == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (CodegenProperty cp : propertyList) {
|
||||
final String dataType = cp.baseType;
|
||||
if (null != importMapping().get(dataType)) {
|
||||
model.imports.add(dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1775,7 +1807,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
String contentType = consumes.isEmpty() ? defaultContentType : consumes.get(0);
|
||||
operation.addExtension("x-content-type", contentType);
|
||||
}
|
||||
String accepts = getAccepts(openAPI, operation);
|
||||
String[] accepts = getAccepts(openAPI, operation);
|
||||
operation.addExtension("x-accepts", accepts);
|
||||
}
|
||||
}
|
||||
@@ -1826,19 +1858,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
private static String getAccepts(OpenAPI openAPIArg, Operation operation) {
|
||||
private static String[] getAccepts(OpenAPI openAPIArg, Operation operation) {
|
||||
final Set<String> producesInfo = getProducesInfo(openAPIArg, operation);
|
||||
if (producesInfo != null && !producesInfo.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String produce : producesInfo) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(produce);
|
||||
}
|
||||
return sb.toString();
|
||||
return producesInfo.toArray(new String[] {});
|
||||
}
|
||||
return "application/json"; // default media type
|
||||
return new String[] { "application/json" }; // default media type
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2505,4 +2530,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
imports.add(importsItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTypeErasedGenerics() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.ComposedSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
@@ -30,7 +29,6 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.templating.mustache.EscapeChar;
|
||||
import org.openapitools.codegen.templating.mustache.JoinWithCommaLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -524,7 +522,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_JAKARTA_EE)) {
|
||||
setUseJakartaEe(Boolean.TRUE.equals(additionalProperties.get(USE_JAKARTA_EE)));
|
||||
setUseJakartaEe(Boolean.parseBoolean(additionalProperties.get(USE_JAKARTA_EE).toString()));
|
||||
}
|
||||
additionalProperties.put(USE_JAKARTA_EE, useJakartaEe);
|
||||
|
||||
@@ -648,7 +646,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return property.nameInCamelCase;
|
||||
return property.nameInPascalCase;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1056,8 +1056,8 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
Set<String> exampleImports,
|
||||
Set<String> postponedModelImports,
|
||||
Set<String> postponedExampleImports,
|
||||
PythonImports moduleImports,
|
||||
String classname) {
|
||||
PythonImports moduleImports = new PythonImports();
|
||||
PydanticType pt = new PydanticType(
|
||||
modelImports,
|
||||
exampleImports,
|
||||
@@ -1250,6 +1250,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
exampleImports,
|
||||
postponedModelImports,
|
||||
postponedExampleImports,
|
||||
moduleImports,
|
||||
null
|
||||
);
|
||||
}
|
||||
@@ -2062,7 +2063,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
values.add((String) enumVar.get("value"));
|
||||
}
|
||||
}
|
||||
return String.format(Locale.ROOT, "%sEnum", cp.nameInCamelCase);
|
||||
return String.format(Locale.ROOT, "%sEnum", cp.nameInPascalCase);
|
||||
} else*/
|
||||
|
||||
if (result == null) {
|
||||
@@ -2171,7 +2172,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
// TODO process the first one only at the moment
|
||||
if (cmt != null)
|
||||
// TODO: don't loop back to the deprecated getPydanticType method
|
||||
return getPydanticType(cmt.getSchema(), modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname);
|
||||
return getPydanticType(cmt.getSchema(), modelImports, exampleImports, postponedModelImports, postponedExampleImports, moduleImports, classname);
|
||||
}
|
||||
throw new RuntimeException("Error! Failed to process getPydanticType when getting the content: " + cp);
|
||||
} else {
|
||||
|
||||
@@ -956,7 +956,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
|
||||
}
|
||||
|
||||
if (!fields.isEmpty()) {
|
||||
fields.add(0, fieldCustomization);
|
||||
fields.add(0, "default=" + fieldCustomization);
|
||||
pydanticImports.add("Field");
|
||||
fieldCustomization = String.format(Locale.ROOT, "Field(%s)", StringUtils.join(fields, ", "));
|
||||
}
|
||||
@@ -1351,7 +1351,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
|
||||
values.add((String) enumVar.get("value"));
|
||||
}
|
||||
}
|
||||
return String.format(Locale.ROOT, "%sEnum", cp.nameInCamelCase);
|
||||
return String.format(Locale.ROOT, "%sEnum", cp.nameInPascalCase);
|
||||
} else*/
|
||||
if (cp.isArray) {
|
||||
String constraints = "";
|
||||
|
||||
@@ -436,4 +436,12 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
|
||||
public String addRegularExpressionDelimiter(String pattern) {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return "r#"+ name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(CLibcurlClientCodegen.class);
|
||||
|
||||
public static final String USE_JSON_UNFORMATTED = "useJsonUnformatted";
|
||||
public static final String USE_JSON_UNFORMATTED_DESC = "Use cJSON_PrintUnformatted instead of cJSON_Print when creating the JSON string.";
|
||||
|
||||
public static final String PROJECT_NAME = "projectName";
|
||||
protected String moduleName;
|
||||
protected String projectName;
|
||||
@@ -47,6 +50,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
|
||||
protected String libFolder = "lib";
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
protected boolean useJsonUnformatted = false;
|
||||
|
||||
protected static int emptyMethodNameCounter = 0;
|
||||
|
||||
@@ -306,6 +310,8 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).
|
||||
defaultValue(Boolean.TRUE.toString()));
|
||||
|
||||
cliOptions.add(new CliOption(USE_JSON_UNFORMATTED, USE_JSON_UNFORMATTED_DESC).
|
||||
defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,6 +322,15 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
|
||||
LOGGER.info("Environment variable C_POST_PROCESS_FILE not defined so the C code may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To define it, try `export C_POST_PROCESS_FILE=\"/usr/local/bin/uncrustify --no-backup\" && export UNCRUSTIFY_CONFIG=/path/to/uncrustify-rules.cfg` (Linux/Mac). Note: replace /path/to with the location of uncrustify-rules.cfg");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_JSON_UNFORMATTED)) {
|
||||
useJsonUnformatted = Boolean.parseBoolean(additionalProperties.get(USE_JSON_UNFORMATTED).toString());
|
||||
}
|
||||
if (useJsonUnformatted) {
|
||||
additionalProperties.put("cJSONPrint", "cJSON_PrintUnformatted");
|
||||
} else {
|
||||
additionalProperties.put("cJSONPrint", "cJSON_Print");
|
||||
}
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
@@ -171,9 +171,13 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
|
||||
return "(s/coll-of " + getTypeDeclaration(inner) + ")";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
|
||||
return "(s/map-of string? " + getTypeDeclaration(inner) + ")";
|
||||
Object ap = p.getAdditionalProperties();
|
||||
// additionalProperties is either a Schema or a Boolean
|
||||
if (ap instanceof Schema) {
|
||||
Schema inner = (Schema) ap;
|
||||
return "(s/map-of string? " + getTypeDeclaration(inner) + ")";
|
||||
}
|
||||
return "(s/map-of string? s/any?)";
|
||||
}
|
||||
|
||||
// If it's a type we defined, we want to append the spec suffix
|
||||
|
||||
@@ -20,6 +20,10 @@ import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenResponse;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
@@ -246,6 +250,34 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
||||
this.optionalProjectFileFlag = flag;
|
||||
}
|
||||
|
||||
// override to post-process any model properties
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
// Nullable will be handled as optional
|
||||
property.required = !property.notRequiredOrIsNullable();
|
||||
}
|
||||
|
||||
// override to post-process any response
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void postProcessResponseWithProperty(CodegenResponse response, CodegenProperty property) {
|
||||
super.postProcessResponseWithProperty(response, property);
|
||||
// Nullable will be handled as optional
|
||||
property.required = !property.notRequiredOrIsNullable();
|
||||
}
|
||||
|
||||
// override to post-process any parameters
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
// Nullable will be handled as optional
|
||||
parameter.required = !parameter.notRequiredOrIsNullable();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configures the type of generator.
|
||||
*
|
||||
|
||||
@@ -599,14 +599,9 @@ public class CrystalClientCodegen extends DefaultCodegen {
|
||||
return objs;
|
||||
}
|
||||
OperationMap operations = objs.getOperations();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
|
||||
HashMap<String, Integer> processedModelMaps = new HashMap<>();
|
||||
|
||||
for (ModelMap modelMap : allModels) {
|
||||
CodegenModel m = modelMap.getModel();
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
|
||||
@@ -453,7 +453,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
CodegenProperty prop = super.fromProperty(name, p, required);
|
||||
String cc = camelize(prop.name, LOWERCASE_FIRST_LETTER);
|
||||
if (isReservedWord(cc)) {
|
||||
cc = escapeReservedWord(cc);
|
||||
cc = escapeReservedWord(cc); // e.g. byte => byte_
|
||||
}
|
||||
prop.nameInCamelCase = cc;
|
||||
return prop;
|
||||
@@ -533,14 +533,9 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
OperationMap operations = objs.getOperations();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
|
||||
HashMap<String, ArrayList<Integer>> processedModelMaps = new HashMap<>();
|
||||
|
||||
for (ModelMap modelMap : allModels) {
|
||||
CodegenModel m = modelMap.getModel();
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
|
||||
@@ -132,9 +132,10 @@ public class GraphQLNodeJSExpressServerCodegen extends AbstractGraphQLCodegen im
|
||||
// return "[" + getTypeDeclaration(inner) + "]";
|
||||
return getTypeDeclaration(inner);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
|
||||
return getTypeDeclaration(inner);
|
||||
Object ap = p.getAdditionalProperties();
|
||||
if (ap instanceof Schema) {
|
||||
return getTypeDeclaration((Schema) ap);
|
||||
}
|
||||
}
|
||||
|
||||
// IMPORTANT NOTE Not using the supertype invocation, because we want to UpperCamelize the type:
|
||||
|
||||
@@ -745,10 +745,15 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
param.vendorExtensions.put(VENDOR_EXTENSION_X_IS_BODY_OR_FORM_PARAM, param.isBodyParam || param.isFormParam);
|
||||
if (!StringUtils.isBlank(param.collectionFormat)) {
|
||||
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
|
||||
} else if (!param.isBodyParam && (param.isArray || param.dataType.startsWith("["))) { // param.isArray is sometimes false for list types
|
||||
// defaulting due to https://github.com/wing328/openapi-generator/issues/72
|
||||
param.collectionFormat = "csv";
|
||||
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
|
||||
} else if (!param.isBodyParam) {
|
||||
if (param.isArray || param.dataType.startsWith("[")) { // param.isArray is sometimes false for list types
|
||||
// defaulting due to https://github.com/wing328/openapi-generator/issues/72
|
||||
param.collectionFormat = "csv";
|
||||
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
|
||||
}
|
||||
}
|
||||
if (param.isQueryParam && (isJsonMimeType(param.contentType) || ContainsJsonMimeType(param.contentType))) {
|
||||
param.vendorExtensions.put(X_MEDIA_IS_JSON, "true");
|
||||
}
|
||||
if (!param.required) {
|
||||
op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_OPTIONAL_PARAMS, true);
|
||||
|
||||
@@ -514,6 +514,13 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
// Query parameters appended to routes
|
||||
for (CodegenParameter param : op.queryParams) {
|
||||
String paramType = param.dataType;
|
||||
if (param.contentType == "application/json") {
|
||||
if (param.isArray) {
|
||||
paramType = "[JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + "]";
|
||||
} else {
|
||||
paramType = "(JSONQueryParam " + paramType + ")";
|
||||
}
|
||||
}
|
||||
if (param.isArray) {
|
||||
if (StringUtils.isEmpty(param.collectionFormat)) {
|
||||
param.collectionFormat = "csv";
|
||||
@@ -549,6 +556,13 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
path.add("Header \"" + param.baseName + "\" " + param.dataType);
|
||||
|
||||
String paramType = param.dataType;
|
||||
if (param.contentType == "application/json") {
|
||||
if (param.isArray) {
|
||||
paramType = "(JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + ")";
|
||||
} else {
|
||||
paramType = "(JSONQueryParam " + paramType + ")";
|
||||
}
|
||||
}
|
||||
if (param.isArray) {
|
||||
if (StringUtils.isEmpty(param.collectionFormat)) {
|
||||
param.collectionFormat = "csv";
|
||||
|
||||
@@ -569,6 +569,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
}
|
||||
|
||||
if (APACHE.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("BaseApi.mustache", invokerFolder, "BaseApi.java"));
|
||||
}
|
||||
|
||||
if (FEIGN.equals(getLibrary())) {
|
||||
if (getSerializationLibrary() == null) {
|
||||
LOGGER.info("No serializationLibrary configured, using '{}' as fallback", SERIALIZATION_LIBRARY_JACKSON);
|
||||
|
||||
@@ -953,6 +953,12 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (Boolean.TRUE.equals(param.isFile)) {
|
||||
operations.put("x-kotlin-multipart-import", true);
|
||||
}
|
||||
|
||||
if (param.isQueryParam && "form".equals(param.style) && param.isExplode && param.isModel) {
|
||||
// query parameter (style: form, explode) referencing models need to import
|
||||
// models defined in the properties of the models
|
||||
operations.put("x-koltin-import-models", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user