forked from loafle/openapi-generator-original
Compare commits
112 Commits
v7.4.0
...
devhl-labs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fa075d291 | ||
|
|
d2c48e2999 | ||
|
|
2168851e8a | ||
|
|
6c955da59a | ||
|
|
3d2e38e347 | ||
|
|
b11005b00d | ||
|
|
3bb17efa09 | ||
|
|
ac14e66da1 | ||
|
|
1024c7733e | ||
|
|
90301f932d | ||
|
|
6d10e80916 | ||
|
|
f357be480e | ||
|
|
2a39b29684 | ||
|
|
88204b247a | ||
|
|
2934f5ac51 | ||
|
|
2ce71512d0 | ||
|
|
927768757b | ||
|
|
858499ffdd | ||
|
|
4719d9e55f | ||
|
|
2d7f0496ec | ||
|
|
2fac8e34db | ||
|
|
1704ae1194 | ||
|
|
370eca2889 | ||
|
|
d0f8468651 | ||
|
|
6252dac28e | ||
|
|
807aa5d3ae | ||
|
|
f73db59b0e | ||
|
|
34ebc1c644 | ||
|
|
de680de60e | ||
|
|
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
|
||||
|
||||
37
.github/workflows/samples-dotnet.yaml
vendored
37
.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,17 @@ 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/AnyOfNoCompare
|
||||
- samples/client/petstore/csharp/generichost/net8/FormModels
|
||||
- samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests
|
||||
- samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests
|
||||
- samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
|
||||
- samples/client/petstore/csharp/generichost/net8/OneOf
|
||||
- samples/client/petstore/csharp/generichost/net8/Petstore
|
||||
- samples/client/petstore/csharp/generichost/net8/SourceGeneration
|
||||
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-dotnet@v4.0.0
|
||||
|
||||
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
|
||||
|
||||
|
||||
41
appveyor.yml
41
appveyor.yml
@@ -43,23 +43,30 @@ build_script:
|
||||
#- dotnet build samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\Org.OpenAPITools.sln
|
||||
|
||||
test_script:
|
||||
# test c# API client (multiple frameworks)
|
||||
- dotnet test samples\client\petstore\csharp\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\AnyOfNoCompare\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\FormModels\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualSourceGenerationTests\ManualTests.Latest.UseSourceGeneration\ManualTests.Latest.UseSourceGeneration.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualPetstoreTests\OpenAPIClient-generichost-manual-tests\OpenAPIClient-generichost-manual-tests.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\NullReferenceTypes\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\OneOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\SourceGeneration\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\net8\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\generichost\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
|
||||
- dotnet test samples\client\petstore\csharp\httpclient\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\MultipleFrameworks\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net4.8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net6\ParameterMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\EnumMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\net7\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
|
||||
### TODO: Execute all generators via powershell or other
|
||||
# generate all petstore clients
|
||||
|
||||
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
|
||||
13
bin/configs/csharp-generichost-net8-anyOfNoCompare.yaml
Normal file
13
bin/configs/csharp-generichost-net8-anyOfNoCompare.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: false
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
16
bin/configs/csharp-generichost-net8-formModels.yaml
Normal file
16
bin/configs/csharp-generichost-net8-formModels.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
# for csharp generichost
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/generichost/net8/FormModels
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
library: generichost
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: false
|
||||
equatable: true
|
||||
targetFramework: net8.0
|
||||
skipFormModel: false
|
||||
inlineSchemaOptions:
|
||||
RESOLVE_INLINE_ENUMS: true
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -88,6 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>field</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -401,7 +401,7 @@ class GenerateTaskDslTest : TestBase() {
|
||||
fun `openApiValidate should fail on invalid spec`() {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
|
||||
withProject(defaultBuildGradle, projectFiles)
|
||||
@@ -423,7 +423,7 @@ class GenerateTaskDslTest : TestBase() {
|
||||
fun `openApiValidate should ok skip spec validation`() {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
|
||||
withProject("""
|
||||
|
||||
@@ -113,7 +113,7 @@ class ValidateTaskDslTest : TestBase() {
|
||||
fun `openApiValidate should fail on invalid spec`(gradleVersion: String?) {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
withProject(
|
||||
"""
|
||||
@@ -139,6 +139,50 @@ class ValidateTaskDslTest : TestBase() {
|
||||
result.output.contains("Spec is invalid."),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertTrue(
|
||||
result.output.contains("attribute info is missing"),
|
||||
"Spec validation detail"
|
||||
)
|
||||
assertEquals(
|
||||
FAILED, result.task(":openApiValidate")?.outcome,
|
||||
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}"
|
||||
)
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gradle_version_provider")
|
||||
fun `openApiValidate should fail on invalid spec with duplicate 200 status code`(gradleVersion: String?) {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-duplicate-200-status-code.yaml")
|
||||
)
|
||||
withProject(
|
||||
"""
|
||||
| plugins {
|
||||
| id 'org.openapi.generator'
|
||||
| }
|
||||
|
|
||||
| openApiValidate {
|
||||
| inputSpec = file('spec.yaml').absolutePath
|
||||
| }
|
||||
""".trimMargin(), projectFiles
|
||||
)
|
||||
|
||||
// Act
|
||||
val result = getGradleRunner(gradleVersion)
|
||||
.withProjectDir(temp)
|
||||
.withArguments("openApiValidate")
|
||||
.withPluginClasspath()
|
||||
.buildAndFail()
|
||||
|
||||
// Assert
|
||||
assertTrue(
|
||||
result.output.contains("Spec is invalid."),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertTrue(
|
||||
result.output.contains("Duplicate field 200"),
|
||||
"Spec validation detail"
|
||||
)
|
||||
assertEquals(
|
||||
FAILED, result.task(":openApiValidate")?.outcome,
|
||||
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}"
|
||||
@@ -186,7 +230,7 @@ class ValidateTaskDslTest : TestBase() {
|
||||
fun `validateBadSpec as defined task should fail on invalid spec`(gradleVersion: String?) {
|
||||
// Arrange
|
||||
val projectFiles = mapOf(
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
|
||||
)
|
||||
withProject(
|
||||
"""
|
||||
@@ -212,6 +256,10 @@ class ValidateTaskDslTest : TestBase() {
|
||||
result.output.contains("Spec is invalid."),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertTrue(
|
||||
result.output.contains("attribute info is missing"),
|
||||
"Unexpected/no message presented to the user for an invalid spec."
|
||||
)
|
||||
assertEquals(
|
||||
FAILED, result.task(":validateBadSpec")?.outcome,
|
||||
"Expected a failed run, but found ${result.task(":validateBadSpec")?.outcome}"
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
openapi: "3.0.0"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
license:
|
||||
name: MIT
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/v1
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
summary: List all pets
|
||||
operationId: listPets
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: limit
|
||||
in: query
|
||||
description: How many items to return at one time (max 100)
|
||||
required: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
'200':
|
||||
description: A paged array of pets
|
||||
headers:
|
||||
x-next:
|
||||
description: A link to the next page of responses
|
||||
schema:
|
||||
type: string
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
'200':
|
||||
description: duplicate 200
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
post:
|
||||
summary: Create a pet
|
||||
operationId: createPets
|
||||
tags:
|
||||
- pets
|
||||
responses:
|
||||
'201':
|
||||
description: Null response
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
/pets/{petId}:
|
||||
get:
|
||||
summary: Info for a specific pet
|
||||
operationId: showPetById
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
required: true
|
||||
description: The id of the pet to retrieve
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Expected response to a valid request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
Pets:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
Error:
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
@@ -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())
|
||||
@@ -1088,7 +1092,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addOneOfNameExtension(s, n);
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(s)) {
|
||||
Schema items = ((ArraySchema) s).getItems();
|
||||
Schema items = ModelUtils.getSchemaItems(s);
|
||||
if (ModelUtils.isComposedSchema(items)) {
|
||||
addOneOfNameExtension(items, nOneOf);
|
||||
addOneOfInterfaceModel(items, nOneOf);
|
||||
@@ -2055,10 +2059,13 @@ 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));
|
||||
String inner = getSchemaType(ModelUtils.getSchemaItems(schema));
|
||||
String parentType;
|
||||
if (ModelUtils.isSet(schema)) {
|
||||
parentType = "set";
|
||||
@@ -2364,15 +2371,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
}
|
||||
|
||||
protected Schema<?> getSchemaItems(ArraySchema schema) {
|
||||
Schema<?> items = schema.getItems();
|
||||
if (items == null) {
|
||||
LOGGER.error("Undefined array inner type for `{}`. Default to String.", schema.getName());
|
||||
items = new StringSchema().description("TODO default missing array inner type to string");
|
||||
schema.setItems(items);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
protected Schema<?> getSchemaAdditionalProperties(Schema schema) {
|
||||
Schema<?> inner = ModelUtils.getAdditionalProperties(schema);
|
||||
@@ -2456,6 +2455,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 +2949,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 +3353,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 +3362,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 +3376,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 +3385,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 +3453,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 +3482,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 +3531,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 +3553,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 +3673,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();
|
||||
@@ -3967,7 +3974,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.error("Undefined property/schema for `{}`. Default to type:string.", name);
|
||||
return null;
|
||||
}
|
||||
LOGGER.debug("debugging fromProperty for {} : {}", name, p);
|
||||
LOGGER.debug("debugging fromProperty for {}: {}", name, p);
|
||||
NamedSchema ns = new NamedSchema(name, p, required, schemaIsFromAdditionalProperties);
|
||||
CodegenProperty cpc = schemaCodegenPropertyCache.get(ns);
|
||||
if (cpc != null) {
|
||||
@@ -3975,6 +3982,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 +4024,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();
|
||||
@@ -4166,8 +4181,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// handle inner property
|
||||
String itemName = getItemsName(p, name);
|
||||
ArraySchema arraySchema = (ArraySchema) p;
|
||||
Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema));
|
||||
Schema innerSchema = unaliasSchema(ModelUtils.getSchemaItems(p));
|
||||
CodegenProperty cp = fromProperty(itemName, innerSchema, false);
|
||||
updatePropertyForArray(property, cp);
|
||||
} else if (ModelUtils.isTypeObjectSchema(p)) {
|
||||
@@ -4477,8 +4491,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenProperty cm = fromProperty("response", responseSchema, false);
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) {
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as), false);
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getSchemaItems(responseSchema), false);
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema), false);
|
||||
@@ -4723,13 +4736,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 +4760,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");
|
||||
@@ -5005,8 +5016,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
r.isArray = true;
|
||||
r.containerType = cp.containerType;
|
||||
r.containerTypeMapped = typeMapping.get(cp.containerType);
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
CodegenProperty items = fromProperty("response", getSchemaItems(as), false);
|
||||
CodegenProperty items = fromProperty("response", ModelUtils.getSchemaItems(responseSchema), false);
|
||||
r.setItems(items);
|
||||
CodegenProperty innerCp = items;
|
||||
|
||||
@@ -5382,8 +5392,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
addVarsRequiredVarsAdditionalProps(parameterSchema, codegenParameter);
|
||||
} else if (ModelUtils.isArraySchema(parameterSchema)) {
|
||||
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
Schema inner = ModelUtils.getSchemaItems(parameterSchema);
|
||||
|
||||
collectionFormat = getCollectionFormat(parameter);
|
||||
// default to csv:
|
||||
@@ -5456,6 +5465,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 +6782,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 +6805,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 +6944,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
scopes.add(scope);
|
||||
}
|
||||
codegenSecurity.scopes = scopes;
|
||||
codegenSecurity.hasScopes = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7183,6 +7200,13 @@ 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.isContainer = codegenProperty.isContainer;
|
||||
codegenParameter.containerType = codegenProperty.containerType;
|
||||
codegenParameter.containerTypeMapped = codegenProperty.containerTypeMapped;
|
||||
codegenParameter.dataFormat = codegenProperty.dataFormat;
|
||||
// non-array/map
|
||||
updateCodegenPropertyEnum(codegenProperty);
|
||||
@@ -7249,19 +7273,27 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isTypeObjectSchema(ps)) {
|
||||
if (ModelUtils.isFreeFormObject(ps)) {
|
||||
if (ModelUtils.isMapSchema(ps)) {
|
||||
codegenParameter.isMap = true;
|
||||
codegenParameter.additionalProperties = codegenProperty.additionalProperties;
|
||||
codegenParameter.setAdditionalPropertiesIsAnyType(codegenProperty.getAdditionalPropertiesIsAnyType());
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.isPrimitiveType = false;
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
|
||||
} else if (ModelUtils.isFreeFormObject(ps)) {
|
||||
codegenParameter.isFreeFormObject = true;
|
||||
}
|
||||
} else if (ModelUtils.isNullType(ps)) {
|
||||
} else if (ModelUtils.isAnyType(ps)) {
|
||||
// any schema with no type set, composed schemas often do this
|
||||
} else if (ModelUtils.isArraySchema(ps)) {
|
||||
Schema inner = getSchemaItems((ArraySchema) ps);
|
||||
Schema inner = ModelUtils.getSchemaItems(ps);
|
||||
CodegenProperty arrayInnerProperty = fromProperty("inner", inner, false);
|
||||
codegenParameter.isArray = true;
|
||||
codegenParameter.items = arrayInnerProperty;
|
||||
codegenParameter.mostInnerItems = arrayInnerProperty.mostInnerItems;
|
||||
codegenParameter.isPrimitiveType = false;
|
||||
codegenParameter.isContainer = true;
|
||||
// hoist items data into the array property
|
||||
// TODO this hoisting code is generator specific and should be isolated into updateFormPropertyForArray
|
||||
codegenParameter.baseType = arrayInnerProperty.dataType;
|
||||
@@ -7537,11 +7569,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isGenerateAliasAsModel(schema) && StringUtils.isNotBlank(name)) {
|
||||
this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true);
|
||||
} else {
|
||||
final ArraySchema arraySchema = (ArraySchema) schema;
|
||||
Schema inner = getSchemaItems(arraySchema);
|
||||
CodegenProperty codegenProperty = fromProperty("property", arraySchema, false);
|
||||
Schema inner = ModelUtils.getSchemaItems(schema);
|
||||
CodegenProperty codegenProperty = fromProperty("property", schema, false);
|
||||
if (codegenProperty == null) {
|
||||
throw new RuntimeException("CodegenProperty cannot be null. arraySchema for debugging: " + arraySchema);
|
||||
throw new RuntimeException("CodegenProperty cannot be null. arraySchema for debugging: " + schema);
|
||||
}
|
||||
|
||||
imports.add(codegenProperty.baseType);
|
||||
@@ -7567,9 +7598,14 @@ 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);
|
||||
codegenParameter.dataType = getTypeDeclaration(schema);
|
||||
codegenParameter.baseType = getSchemaType(inner);
|
||||
codegenParameter.isContainer = Boolean.TRUE;
|
||||
codegenParameter.isNullable = codegenProperty.isNullable;
|
||||
@@ -8399,12 +8435,17 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
xOf.add(cp);
|
||||
i += 1;
|
||||
|
||||
if (dataTypeSet.contains(cp.dataType)) {
|
||||
if (dataTypeSet.contains(cp.dataType)
|
||||
|| (isTypeErasedGenerics() && dataTypeSet.contains(cp.baseType))) {
|
||||
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
|
||||
// in other sub-schemas of allOf/anyOf/oneOf
|
||||
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type", true);
|
||||
} else {
|
||||
dataTypeSet.add(cp.dataType);
|
||||
if(isTypeErasedGenerics()) {
|
||||
dataTypeSet.add(cp.baseType);
|
||||
} else {
|
||||
dataTypeSet.add(cp.dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return xOf;
|
||||
@@ -8441,11 +8482,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());
|
||||
|
||||
@@ -338,10 +338,9 @@ public class InlineModelResolver {
|
||||
return;
|
||||
}
|
||||
// Check array items
|
||||
if (schema instanceof ArraySchema) {
|
||||
ArraySchema array = (ArraySchema) schema;
|
||||
Schema items = array.getItems();
|
||||
if (items == null && array.getPrefixItems() == null) {
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
Schema items = ModelUtils.getSchemaItems(schema);
|
||||
if (items == null && schema.getPrefixItems() == null) {
|
||||
LOGGER.debug("Incorrect array schema with no items, prefixItems: {}", schema.toString());
|
||||
return;
|
||||
}
|
||||
@@ -357,7 +356,7 @@ public class InlineModelResolver {
|
||||
|
||||
if (isModelNeeded(items)) {
|
||||
// If this schema should be split into its own model, do so
|
||||
array.setItems(this.makeSchemaInComponents(schemaName, items));
|
||||
schema.setItems(this.makeSchemaInComponents(schemaName, items));
|
||||
}
|
||||
}
|
||||
// Check allOf, anyOf, oneOf for inline models
|
||||
@@ -788,9 +787,8 @@ public class InlineModelResolver {
|
||||
propsToUpdate.put(key, schema);
|
||||
modelsToAdd.put(modelName, model);
|
||||
}
|
||||
} else if (property instanceof ArraySchema) {
|
||||
ArraySchema ap = (ArraySchema) property;
|
||||
Schema inner = ap.getItems();
|
||||
} else if (ModelUtils.isArraySchema(property)) {
|
||||
Schema inner = ModelUtils.getSchemaItems(property);
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
@@ -801,12 +799,12 @@ public class InlineModelResolver {
|
||||
if (existing != null) {
|
||||
Schema schema = new Schema().$ref(existing);
|
||||
schema.setRequired(op.getRequired());
|
||||
ap.setItems(schema);
|
||||
property.setItems(schema);
|
||||
} else {
|
||||
modelName = addSchemas(modelName, innerModel);
|
||||
Schema schema = new Schema().$ref(modelName);
|
||||
schema.setRequired(op.getRequired());
|
||||
ap.setItems(schema);
|
||||
property.setItems(schema);
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isComposedSchema(inner)) {
|
||||
@@ -815,7 +813,7 @@ public class InlineModelResolver {
|
||||
innerModelName = addSchemas(innerModelName, inner);
|
||||
Schema schema = new Schema().$ref(innerModelName);
|
||||
schema.setRequired(inner.getRequired());
|
||||
ap.setItems(schema);
|
||||
property.setItems(schema);
|
||||
} else {
|
||||
LOGGER.debug("Schema not yet handled in model resolver: {}", inner);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,7 +499,7 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(schema.get$ref())) {
|
||||
// not need to process $ref
|
||||
// no need to process $ref
|
||||
return schema;
|
||||
}
|
||||
|
||||
@@ -444,9 +509,12 @@ public class OpenAPINormalizer {
|
||||
visitedSchemas.add(schema);
|
||||
}
|
||||
|
||||
if (schema instanceof ArraySchema) { // array
|
||||
normalizeSchema(schema.getItems(), visitedSchemas);
|
||||
if (ModelUtils.isArraySchema(schema)) { // array
|
||||
Schema result = normalizeArraySchema(schema);
|
||||
normalizeSchema(result.getItems(), visitedSchemas);
|
||||
return result;
|
||||
} else if (schema.getAdditionalProperties() instanceof Schema) { // map
|
||||
normalizeMapSchema(schema);
|
||||
normalizeSchema((Schema) schema.getAdditionalProperties(), visitedSchemas);
|
||||
} else if (ModelUtils.isOneOf(schema)) { // oneOf
|
||||
return normalizeOneOf(schema, visitedSchemas);
|
||||
@@ -498,16 +566,28 @@ public class OpenAPINormalizer {
|
||||
return schema;
|
||||
}
|
||||
|
||||
private Schema normalizeArraySchema(Schema schema) {
|
||||
Schema result = processNormalize31Spec(schema, new HashSet<>());
|
||||
return processSetArraytoNullable(result);
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -516,7 +596,7 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
|
||||
Schema property = propertiesEntry.getValue();
|
||||
Schema newProperty = normalizeSchema(property, visitedSchemas);
|
||||
Schema newProperty = normalizeSchema(property, new HashSet<>());
|
||||
propertiesEntry.setValue(newProperty);
|
||||
}
|
||||
}
|
||||
@@ -818,8 +898,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 +934,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 +971,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 +1059,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);
|
||||
}
|
||||
@@ -1022,7 +1224,7 @@ public class OpenAPINormalizer {
|
||||
// only one item (type) left
|
||||
if (schema.getTypes().size() == 1) {
|
||||
String type = String.valueOf(schema.getTypes().iterator().next());
|
||||
if ("array".equals(type)) {
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema as = new ArraySchema();
|
||||
as.setDescription(schema.getDescription());
|
||||
as.setDefault(schema.getDefault());
|
||||
@@ -1036,6 +1238,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) {
|
||||
@@ -84,10 +84,9 @@ public class ExampleGenerator {
|
||||
}
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) { // array of schema
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
if (as.getItems() != null) { // array of primitive types
|
||||
if (ModelUtils.getSchemaItems(responseSchema) != null) { // array of primitive types
|
||||
return generate((Map<String, Object>) responseSchema.getExample(),
|
||||
new ArrayList<>(producesInfo), as);
|
||||
new ArrayList<>(producesInfo), responseSchema);
|
||||
} else {
|
||||
// TODO log warning message as such case is not handled at the moment
|
||||
return null;
|
||||
@@ -238,7 +237,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)) {
|
||||
@@ -248,9 +247,9 @@ public class ExampleGenerator {
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
} else if (ModelUtils.isArraySchema(property)) {
|
||||
Schema innerType = ((ArraySchema) property).getItems();
|
||||
Schema innerType = ModelUtils.getSchemaItems(property);
|
||||
if (innerType != null) {
|
||||
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
|
||||
int arrayLength = null == property.getMaxItems() ? 2 : property.getMaxItems();
|
||||
// avoid memory issues by limiting to max. 5 items
|
||||
arrayLength = Math.min(arrayLength, 5);
|
||||
Object[] objectProperties = new Object[arrayLength];
|
||||
|
||||
@@ -128,8 +128,7 @@ public class XmlExampleGenerator {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema as = (ArraySchema) schema;
|
||||
Schema inner = as.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(schema);
|
||||
boolean wrapped = false;
|
||||
if (schema.getXml() != null && schema.getXml().getWrapped() != null && schema.getXml().getWrapped()) {
|
||||
wrapped = true;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -532,8 +532,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
String itemType = getTypeDeclaration(inner);
|
||||
if (itemType.startsWith("OpenAPI.")) {
|
||||
return itemType + "_Vector";
|
||||
@@ -650,10 +649,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 +840,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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -188,10 +188,9 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
if (inner == null) {
|
||||
LOGGER.warn("{}(array property) does not have a proper inner type defined", ap.getName());
|
||||
LOGGER.warn("{}(array property) does not have a proper inner type defined", p.getName());
|
||||
// TODO maybe better defaulting to StringProperty than returning null
|
||||
return null;
|
||||
}
|
||||
@@ -220,13 +219,12 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
final ArraySchema ap = (ArraySchema) p;
|
||||
final String pattern = "new ArrayList<%s>()";
|
||||
if (ap.getItems() == null) {
|
||||
if (ModelUtils.getSchemaItems(p) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.format(Locale.ROOT, pattern, getTypeDeclaration(ap.getItems()));
|
||||
return String.format(Locale.ROOT, pattern, getTypeDeclaration(ModelUtils.getSchemaItems(p)));
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
final MapSchema ap = (MapSchema) p;
|
||||
final String pattern = "new HashMap<%s>()";
|
||||
@@ -318,7 +316,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
example = "new " + getTypeDeclaration(p) + "{" + toExampleValue(
|
||||
((ArraySchema) p).getItems()) + "}";
|
||||
ModelUtils.getSchemaItems(p)) + "}";
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
example = String.valueOf(!"false".equals(example));
|
||||
} else if (ModelUtils.isByteArraySchema(p)) {
|
||||
|
||||
@@ -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
|
||||
@@ -582,7 +585,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
List<CodegenProperty> allOf = composedSchemas.getAllOf();
|
||||
if (allOf != null) {
|
||||
for (CodegenProperty property : allOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.name = patchPropertyName(model, camelize(property.baseType));
|
||||
patchPropertyVendorExtensions(property);
|
||||
}
|
||||
}
|
||||
@@ -591,7 +594,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
if (anyOf != null) {
|
||||
removePropertiesDeclaredInComposedTypes(objs, model, anyOf);
|
||||
for (CodegenProperty property : anyOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.name = patchPropertyName(model, camelize(property.baseType));
|
||||
property.isNullable = true;
|
||||
patchPropertyVendorExtensions(property);
|
||||
}
|
||||
@@ -601,7 +604,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
if (oneOf != null) {
|
||||
removePropertiesDeclaredInComposedTypes(objs, model, oneOf);
|
||||
for (CodegenProperty property : oneOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.name = patchPropertyName(model, camelize(property.baseType));
|
||||
property.isNullable = true;
|
||||
patchPropertyVendorExtensions(property);
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
@@ -1430,12 +1433,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
* @param arr The input array property
|
||||
* @return The type declaration when the type is an array of arrays.
|
||||
*/
|
||||
private String getArrayTypeDeclaration(ArraySchema arr) {
|
||||
private String getArrayTypeDeclaration(Schema arr) {
|
||||
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
|
||||
// This supports arrays of arrays.
|
||||
String arrayType = typeMapping.get("array");
|
||||
StringBuilder instantiationType = new StringBuilder(arrayType);
|
||||
Schema items = arr.getItems();
|
||||
Schema items = ModelUtils.getSchemaItems(arr);
|
||||
String nestedType = getTypeDeclaration(items);
|
||||
// TODO: We may want to differentiate here between generics and primitive arrays.
|
||||
instantiationType.append("<").append(nestedType).append(">");
|
||||
@@ -1445,7 +1448,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String toInstantiationType(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
}
|
||||
return super.toInstantiationType(p);
|
||||
}
|
||||
@@ -1453,7 +1456,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
// Should we also support maps of maps?
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -512,7 +512,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
Schema<?> schema = unaliasSchema(p);
|
||||
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
|
||||
if (ModelUtils.isArraySchema(target)) {
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
Schema<?> items = ModelUtils.getSchemaItems(schema);
|
||||
return getSchemaType(target) + "<" + getTypeDeclaration(items) + ">";
|
||||
}
|
||||
if (ModelUtils.isMapSchema(target)) {
|
||||
|
||||
@@ -293,8 +293,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
return "LIST [" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
@@ -578,8 +577,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// String inner = toModelName(getSchemaType(additionalProperties2));
|
||||
// return instantiationTypes.get("map") + " [" + inner + "]";
|
||||
// } else if (ModelUtils.isArraySchema(p)) {
|
||||
// ArraySchema ap = (ArraySchema) p;
|
||||
// String inner = toModelName(getSchemaType(ap.getItems()));
|
||||
// String inner = toModelName(getSchemaType(ModelUtils.getSchemaItems(p)));
|
||||
// return instantiationTypes.get("array") + " [" + inner + "]";
|
||||
// } else {
|
||||
// return null;
|
||||
|
||||
@@ -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
|
||||
@@ -855,12 +855,12 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
* @param arr The input array property
|
||||
* @return The type declaration when the type is an array of arrays.
|
||||
*/
|
||||
private String getArrayTypeDeclaration(ArraySchema arr) {
|
||||
private String getArrayTypeDeclaration(Schema arr) {
|
||||
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
|
||||
// This supports arrays of arrays.
|
||||
String arrayType = typeMapping.get("array");
|
||||
StringBuilder instantiationType = new StringBuilder(arrayType);
|
||||
Schema items = arr.getItems();
|
||||
Schema items = ModelUtils.getSchemaItems(arr);
|
||||
String nestedType = getTypeDeclaration(items);
|
||||
// TODO: We may want to differentiate here between generics and primitive arrays.
|
||||
return nestedType + "[]";
|
||||
@@ -869,7 +869,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String toInstantiationType(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
}
|
||||
return super.toInstantiationType(p);
|
||||
}
|
||||
@@ -877,7 +877,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
return getArrayTypeDeclaration(p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
// Should we also support maps of maps?
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
@@ -360,8 +360,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
// In OAS 3.0.x, the array "items" attribute is required.
|
||||
// In OAS >= 3.1, the array "items" attribute is optional such that the OAS
|
||||
// specification is aligned with the JSON schema specification.
|
||||
|
||||
@@ -273,12 +273,14 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
Schema inner = ModelUtils.getSchemaItems(p);
|
||||
return "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
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;
|
||||
@@ -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
|
||||
@@ -937,7 +946,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
Schema<?> schema = unaliasSchema(p);
|
||||
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
|
||||
if (ModelUtils.isArraySchema(target)) {
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
Schema<?> items = ModelUtils.getSchemaItems(schema);
|
||||
return getSchemaType(target) + "<" + getBeanValidation(items) + getTypeDeclaration(items) + ">";
|
||||
} else if (ModelUtils.isMapSchema(target)) {
|
||||
// Note: ModelUtils.isMapSchema(p) returns true when p is a composed schema that also defines
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user