Compare commits

..

5 Commits

Author SHA1 Message Date
William Cheng
1bc19c694e fix dir 2024-03-13 15:07:03 +08:00
William Cheng
da2401a520 skip test 2024-03-13 14:59:05 +08:00
William Cheng
474325a9e5 update install 2024-03-11 15:33:40 +08:00
William Cheng
8e8e16e136 fix dir 2024-03-11 14:40:20 +08:00
William Cheng
a450c651b9 test R clients in node4 of circleci 2024-03-11 14:35:04 +08:00
7888 changed files with 157557 additions and 273600 deletions

View File

@@ -192,6 +192,20 @@ jobs:
- checkout
- command_build_and_test:
nodeNo: "3"
node4:
machine:
image: ubuntu-2004:202201-02
working_directory: ~/OpenAPITools/openapi-generator
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
steps:
- checkout
- command_build_and_test:
nodeNo: "4"
workflows:
version: 2
build:
@@ -200,3 +214,4 @@ workflows:
- node1
- node2
- node3
- node4

View File

@@ -4,23 +4,14 @@ 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
@@ -28,7 +19,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y libssl-dev libcurl4-openssl-dev
- name: Build
working-directory: ${{ matrix.sample }}
working-directory: "samples/client/petstore/c"
run: |
mkdir build
cd build

View File

@@ -3,16 +3,22 @@ name: Samples C# .Net Standard Client
on:
push:
paths:
- 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/**
# 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/**
pull_request:
paths:
- 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/**
# 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/**
jobs:
build:
name: Build .Net projects
@@ -21,11 +27,13 @@ jobs:
fail-fast: false
matrix:
sample:
- 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/
# 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/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -3,16 +3,16 @@ name: Samples C# .Net 8 Clients
on:
push:
paths:
- samples/client/petstore/csharp/generichost/net8/**
- samples/client/petstore/csharp/httpclient/net8/**
- samples/client/petstore/csharp/restsharp/net8/**
- samples/client/petstore/csharp/unityWebRequest/net8/**
- 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*/**
pull_request:
paths:
- samples/client/petstore/csharp/generichost/net8/**
- samples/client/petstore/csharp/httpclient/net8/**
- samples/client/petstore/csharp/restsharp/net8/**
- samples/client/petstore/csharp/unityWebRequest/net8/**
- 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*/**
jobs:
build:
name: Build .Net projects
@@ -21,16 +21,16 @@ jobs:
fail-fast: false
matrix:
sample:
- samples/client/petstore/csharp/generichost/net8/AllOf
- samples/client/petstore/csharp/generichost/net8/AnyOf
- samples/client/petstore/csharp/generichost/net8/FormModels
- samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests
- samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests
- samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
- samples/client/petstore/csharp/generichost/net8/OneOf
- samples/client/petstore/csharp/generichost/net8/Petstore
- samples/client/petstore/csharp/generichost/net8/SourceGeneration
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
# 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
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -3,10 +3,28 @@ name: Samples C# .Net 6 Client
on:
push:
paths:
- samples/client/petstore/csharp/restsharp/net6/**
# 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/**
pull_request:
paths:
- samples/client/petstore/csharp/restsharp/net6/**
# 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/**
jobs:
build:
name: Build .Net clients
@@ -15,7 +33,16 @@ jobs:
fail-fast: false
matrix:
sample:
- samples/client/petstore/csharp/restsharp/net6/ParameterMappings/
# 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/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -13,8 +13,6 @@ 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/**'
@@ -27,8 +25,6 @@ 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
@@ -75,8 +71,6 @@ 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

View File

@@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
- uses: julia-actions/setup-julia@v1
with:
version: 1.8
arch: x64

View File

@@ -25,7 +25,6 @@ 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

View File

@@ -19,7 +19,6 @@ 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

View File

@@ -5,14 +5,12 @@ 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/**
@@ -42,7 +40,6 @@ 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

View File

@@ -4,7 +4,6 @@ on:
pull_request:
paths:
- samples/schema/postman-collection/python/**
- samples/schema/postman-collection/postman.json
- .github/workflows/samples-postman.yaml
jobs:
build:

View File

@@ -34,7 +34,6 @@ 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

View File

@@ -41,7 +41,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
- uses: swift-actions/setup-swift@v1
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
swift-version: '5'

View File

@@ -13,7 +13,7 @@ if [ "$NODE_INDEX" = "1" ]; then
echo "Running node $NODE_INDEX ..."
java -version
sudo apt-get -y install cpanminus
sudo apt-get -y install cpanminus libmagic-dev
(cd samples/client/petstore/perl && /bin/bash ./test.bash)
(cd samples/client/petstore/ruby && mvn integration-test)
@@ -93,6 +93,16 @@ elif [ "$NODE_INDEX" = "3" ]; then
(cd samples/client/petstore/javascript-es6 && mvn integration-test)
(cd samples/client/petstore/javascript-promise-es6 && mvn integration-test)
elif [ "$NODE_INDEX" = "4" ]; then
echo "Running node $NODE_INDEX ..."
sudo apt install r-base r-base-dev -y
sudo apt-get install r-base-core libssl-dev libcurl4-openssl-dev -y # for httr
#(cd samples/client/petstore/R && mvn integration-test)
(cd samples/client/petstore/R-httr2 && mvn integration-test)
(cd samples/client/petstore/R-httr2-wrapper && mvn integration-test)
else
echo "Running node $NODE_INDEX ..."
java -version
@@ -112,3 +122,5 @@ else
(cd samples/client/petstore/java/apache-httpclient && mvn integration-test)
fi

View File

@@ -68,7 +68,6 @@ 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
@@ -905,7 +904,6 @@ 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)
@@ -929,8 +927,6 @@ 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)
@@ -1118,9 +1114,8 @@ 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

View File

@@ -43,29 +43,23 @@ build_script:
#- dotnet build samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\Org.OpenAPITools.sln
test_script:
- dotnet test samples\client\petstore\csharp\generichost\net8\AllOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\AnyOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\FormModels\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualSourceGenerationTests\ManualTests.Latest.UseSourceGeneration\ManualTests.Latest.UseSourceGeneration.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualPetstoreTests\OpenAPIClient-generichost-manual-tests\OpenAPIClient-generichost-manual-tests.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\NullReferenceTypes\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\OneOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\SourceGeneration\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\httpclient\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\MultipleFrameworks\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net6\ParameterMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\EnumMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# 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
### TODO: Execute all generators via powershell or other
# generate all petstore clients

View File

@@ -1,9 +0,0 @@
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

View File

@@ -0,0 +1,12 @@
# 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

View File

@@ -0,0 +1,12 @@
# 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

View File

@@ -0,0 +1,13 @@
# 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

View File

@@ -0,0 +1,12 @@
# 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

View File

@@ -0,0 +1,12 @@
# 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

View File

@@ -0,0 +1,12 @@
# 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

View File

@@ -0,0 +1,9 @@
# 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

View File

@@ -1,13 +0,0 @@
# 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

View File

@@ -1,13 +0,0 @@
# 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

View File

@@ -1,16 +0,0 @@
# 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

View File

@@ -1,13 +0,0 @@
# 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

View File

@@ -1,13 +0,0 @@
# 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

View File

@@ -1,13 +0,0 @@
# 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

View File

@@ -1,10 +0,0 @@
# 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

View File

@@ -1,13 +0,0 @@
# 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

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/standard2.0/Petstore
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.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

View File

@@ -1,6 +1,6 @@
# for .net standard httpclient
generatorName: csharp
outputDir: samples/client/petstore/csharp/httpclient/standard2.0/Petstore
outputDir: samples/client/petstore/csharp/OpenAPIClient-httpclient
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

View File

@@ -1,5 +1,5 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks
outputDir: samples/client/petstore/csharp/OpenAPIClientCoreAndNet47
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/net4.7/Petstore
outputDir: samples/client/petstore/csharp/OpenAPIClient-net47
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:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/net4.8/Petstore
outputDir: samples/client/petstore/csharp/OpenAPIClient-net48
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:

View File

@@ -1,5 +1,5 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/net6/ParameterMappings
outputDir: samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/name-parameter-mappings.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
nameMappings:

View File

@@ -1,5 +1,5 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/net7/Petstore
outputDir: samples/client/petstore/csharp/OpenAPIClientCore
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:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate
outputDir: samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/net7/EnumMappings
outputDir: samples/client/petstore/csharp/OpenAPIClient-net5.0
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:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization
outputDir: samples/client/petstore/csharp/OpenAPIClient-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:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/Petstore
outputDir: samples/client/petstore/csharp/OpenAPIClient
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:

View File

@@ -1,6 +1,6 @@
# for .net Unity
generatorName: csharp
outputDir: samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore
outputDir: samples/client/petstore/csharp/OpenAPIClient-unityWebRequest
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

View File

@@ -1,6 +1,6 @@
generatorName: haskell-http-client
outputDir: samples/client/petstore/haskell-http-client
inputSpec: modules/openapi-generator/src/test/resources/3_0/haskell-http-client/petstore-with-fake-endpoints-models-for-testing.yaml
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/haskell-http-client
additionalProperties:
queryExtraUnreserved: ''

View File

@@ -1,7 +0,0 @@
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"

View File

@@ -1,7 +0,0 @@
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"

View File

@@ -4,7 +4,6 @@ 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"

View File

@@ -10,4 +10,3 @@ additionalProperties:
playVersion: play26
artifactId: petstore-java-client-retrofit2-play26
hideGenerationTimestamp: "true"
useJakartaEe: "true"

View File

@@ -1,15 +0,0 @@
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

View File

@@ -1,15 +0,0 @@
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

View File

@@ -1,8 +0,0 @@
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

View File

@@ -1,9 +0,0 @@
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"

View File

@@ -1,10 +1,10 @@
---
# csharp test files and image for upload
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
sha256: e323c7e646a0ceb6d1d8f34f287175ac666fdbbe057791b45d138de3d9582666
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
sha256: 7dad88554fe630d25c787cae05305d302d5e34ca810aee4fa23f20055f9188e1
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/linux-logo.png"
- filename: "samples/client/petstore/csharp/OpenAPIClient/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"

View File

@@ -598,17 +598,3 @@ 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"
```

View File

@@ -27,7 +27,6 @@ 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

View File

@@ -51,9 +51,6 @@ 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)

View File

@@ -822,7 +822,6 @@ 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.

View File

@@ -350,8 +350,6 @@ public interface CodegenConfig {
*/
String generatorLanguageVersion();
boolean isTypeErasedGenerics();
List<VendorExtension> getSupportedVendorExtensions();
boolean getUseInlineModelResolver();

View File

@@ -39,9 +39,6 @@ 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;
@@ -187,11 +184,6 @@ 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);
@@ -273,22 +265,7 @@ 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,
nameInPascalCase, nameInCamelCase, nameInLowerCase, nameInSnakeCase);
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);
}
@Override

View File

@@ -182,10 +182,8 @@ 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 (e.g. modifiedDate)
public String nameInPascalCase; // property name in pascal case (e.g. ModifiedDate)
public String nameInCamelCase; // property name in camel case
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;
@@ -699,14 +697,6 @@ 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;
}
@@ -1139,7 +1129,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isEnum = isEnum;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{");
@@ -1224,7 +1213,6 @@ 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);
@@ -1364,7 +1352,6 @@ 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) &&
@@ -1389,7 +1376,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, nameInPascalCase, nameInCamelCase,
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
xmlNamespace, isXmlWrapped, isNull, isVoid, additionalPropertiesIsAnyType, hasVars, hasRequired,
hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, requiredVarsMap,

View File

@@ -43,8 +43,6 @@ 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;

View File

@@ -52,7 +52,6 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.examples.ExampleGenerator;
import org.openapitools.codegen.languages.PhpNextgenClientCodegen;
import org.openapitools.codegen.languages.RustAxumServerCodegen;
import org.openapitools.codegen.languages.RustServerCodegen;
import org.openapitools.codegen.meta.FeatureSet;
import org.openapitools.codegen.meta.GeneratorMetadata;
@@ -65,7 +64,6 @@ 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;
@@ -83,7 +81,6 @@ 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.*;
@@ -97,6 +94,8 @@ public class DefaultCodegen implements CodegenConfig {
private static final Cache<SanitizeNameOptions, String> sanitizedNameCache;
private static final String xSchemaTestExamplesKey = "x-schema-test-examples";
private static final String xSchemaTestExamplesRefPrefix = "#/components/x-schema-test-examples/";
protected static Schema falseSchema;
protected static Schema trueSchema = new Schema();
static {
DefaultFeatureSet = FeatureSet.newBuilder()
@@ -149,6 +148,8 @@ public class DefaultCodegen implements CodegenConfig {
.expireAfterAccess(cacheExpiry, TimeUnit.SECONDS)
.ticker(Ticker.systemTicker())
.build();
falseSchema = new Schema();
falseSchema.setNot(new Schema());
}
protected GeneratorMetadata generatorMetadata;
@@ -300,6 +301,8 @@ public class DefaultCodegen implements CodegenConfig {
// A cache to efficiently lookup schema `toModelName()` based on the schema Key
private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
protected boolean loadDeepObjectIntoItems = true;
// if true then baseTypes will be imported
protected boolean importBaseType = true;
@@ -459,9 +462,8 @@ public class DefaultCodegen implements CodegenConfig {
.put("snakecase", new SnakecaseLambda())
.put("titlecase", new TitlecaseLambda())
.put("kebabcase", new KebabCaseLambda())
.put("camelcase", new CamelCaseAndSanitizeLambda(true).generator(this))
.put("pascalcase", new CamelCaseAndSanitizeLambda(false).generator(this))
.put("uncamelize", new UncamelizeLambda())
.put("camelcase", new CamelCaseLambda(true).generator(this))
.put("pascalcase", new CamelCaseLambda(false).generator(this))
.put("forwardslash", new ForwardSlashLambda())
.put("backslash", new BackSlashLambda())
.put("doublequote", new DoubleQuoteLambda())
@@ -2053,11 +2055,7 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isMapSchema(schema)) {
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
String inner = getSchemaType(additionalProperties);
String mapInstantion = instantiationTypes.get("map");
if (mapInstantion != null) {
return mapInstantion + "<String, " + inner + ">";
}
return inner;
return instantiationTypes.get("map") + "<String, " + inner + ">";
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String inner = getSchemaType(getSchemaItems(arraySchema));
@@ -2458,14 +2456,6 @@ 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());
@@ -2952,7 +2942,7 @@ public class DefaultCodegen implements CodegenConfig {
newProperties.forEach((key, value) ->
existingProperties.put(
key,
ModelUtils.cloneSchema(value, specVersionGreaterThanOrEqualTo310(openAPI))
AnnotationsUtils.clone(value, specVersionGreaterThanOrEqualTo310(openAPI))
));
if (null != existingType && null != newType && null != newType.getEnum() && !newType.getEnum().isEmpty()) {
for (Object e : newType.getEnum()) {
@@ -3116,6 +3106,11 @@ public class DefaultCodegen implements CodegenConfig {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL);
if (schema.equals(trueSchema)) {
m.setIsBooleanSchemaTrue(true);
} else if (schema.equals(falseSchema)) {
m.setIsBooleanSchemaFalse(true);
}
// unalias schema
schema = unaliasSchema(schema);
if (schema == null) {
@@ -3351,7 +3346,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) {
once(LOGGER).warn(
LOGGER.warn(
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName);
}
@@ -3360,7 +3355,7 @@ public class DefaultCodegen implements CodegenConfig {
continue;
}
if (cp != thisCp) {
once(LOGGER).warn(
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);
}
@@ -3374,7 +3369,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) {
once(LOGGER).warn(
LOGGER.warn(
"'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName);
}
@@ -3383,7 +3378,7 @@ public class DefaultCodegen implements CodegenConfig {
continue;
}
if (cp != thisCp) {
once(LOGGER).warn(
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);
}
@@ -3451,7 +3446,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if (discriminatorsPropNames.size() > 1) {
once(LOGGER).warn("The oneOf schemas have conflicting discriminator property names. " +
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) {
@@ -3480,7 +3475,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if (discriminatorsPropNames.size() > 1) {
once(LOGGER).warn("The anyOf schemas have conflicting discriminator property names. " +
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) {
@@ -3529,7 +3524,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
once(LOGGER).warn(
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);
}
@@ -3551,14 +3546,14 @@ public class DefaultCodegen implements CodegenConfig {
msgSuffix += spacer + "invalid optional definition of " + discPropName + ", include it in required";
}
}
once(LOGGER).warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
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
once(LOGGER).error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
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")) {
@@ -3671,7 +3666,7 @@ public class DefaultCodegen implements CodegenConfig {
if (e.getValue().indexOf('/') >= 0) {
name = ModelUtils.getSimpleRef(e.getValue());
if (ModelUtils.getSchema(openAPI, name) == null) {
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);
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();
@@ -3980,13 +3975,6 @@ 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) {
@@ -4001,6 +3989,11 @@ public class DefaultCodegen implements CodegenConfig {
}
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
if (p.equals(trueSchema)) {
property.setIsBooleanSchemaTrue(true);
} else if (p.equals(falseSchema)) {
property.setIsBooleanSchemaFalse(true);
}
// unalias schema
p = unaliasSchema(p);
@@ -4017,9 +4010,8 @@ public class DefaultCodegen implements CodegenConfig {
} else {
property.openApiType = p.getType();
}
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.nameInCamelCase = camelize(property.name);
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
property.description = escapeText(p.getDescription());
property.unescapedDescription = p.getDescription();
property.title = p.getTitle();
@@ -4731,13 +4723,13 @@ public class DefaultCodegen implements CodegenConfig {
List<CodegenParameter> notNullableParams = new ArrayList<>();
CodegenParameter bodyParam = null;
RequestBody requestBody = ModelUtils.getReferencedRequestBody(this.openAPI, operation.getRequestBody());
RequestBody requestBody = operation.getRequestBody();
if (requestBody != null) {
String contentType = getContentType(requestBody);
if (contentType != null) {
contentType = contentType.toLowerCase(Locale.ROOT);
}
if (!(this instanceof RustAxumServerCodegen) && contentType != null &&
if (contentType != null &&
(contentType.startsWith("application/x-www-form-urlencoded") ||
contentType.startsWith("multipart"))) {
// process form parameters
@@ -4755,6 +4747,8 @@ 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");
@@ -5462,11 +5456,6 @@ 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);
@@ -5474,7 +5463,7 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern());
if (codegenParameter.isQueryParam && codegenParameter.isDeepObject) {
if (codegenParameter.isQueryParam && codegenParameter.isDeepObject && loadDeepObjectIntoItems) {
Schema schema = parameterSchema;
if (schema.get$ref() != null) {
schema = ModelUtils.getReferencedSchema(openAPI, schema);
@@ -6779,7 +6768,6 @@ 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);
}
@@ -6802,7 +6790,6 @@ 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);
}
@@ -6941,7 +6928,6 @@ public class DefaultCodegen implements CodegenConfig {
scopes.add(scope);
}
codegenSecurity.scopes = scopes;
codegenSecurity.hasScopes = true;
}
}
@@ -7197,11 +7183,6 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.dataType = codegenProperty.dataType;
codegenParameter.baseName = codegenProperty.baseName;
codegenParameter.paramName = toParamName(codegenParameter.baseName);
codegenParameter.nameInCamelCase = camelize(codegenParameter.paramName, LOWERCASE_FIRST_LETTER);
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
codegenParameter.dataFormat = codegenProperty.dataFormat;
// non-array/map
updateCodegenPropertyEnum(codegenProperty);
@@ -7586,11 +7567,6 @@ 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);
@@ -8423,17 +8399,12 @@ public class DefaultCodegen implements CodegenConfig {
xOf.add(cp);
i += 1;
if (dataTypeSet.contains(cp.dataType)
|| (isTypeErasedGenerics() && dataTypeSet.contains(cp.baseType))) {
if (dataTypeSet.contains(cp.dataType)) {
// 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 {
if(isTypeErasedGenerics()) {
dataTypeSet.add(cp.baseType);
} else {
dataTypeSet.add(cp.dataType);
}
dataTypeSet.add(cp.dataType);
}
}
return xOf;
@@ -8470,18 +8441,41 @@ 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; }
/**
* Used to ensure that null or Schema is returned given an input Boolean/Schema/null
* This will be used in openapi 3.1.0 spec processing to ensure that Booleans become Schemas
* Because our generators only understand Schemas
* Note: use getIsBooleanSchemaTrue or getIsBooleanSchemaFalse on the IJsonSchemaValidationProperties
* if you need to be able to detect if the original schema's value was true or false
*
* @param schema the input Boolean or Schema data to convert to a Schema
* @return Schema the input data converted to a Schema if possible
*/
protected Schema getSchemaFromBooleanOrSchema(Object schema) {
if (schema == null) {
return null;
} else if (schema instanceof Boolean) {
if (Boolean.TRUE.equals(schema)) {
return trueSchema;
} else if (Boolean.FALSE.equals(schema)) {
return falseSchema;
}
// null case
return null;
} else if (schema instanceof Schema) {
return (Schema) schema;
} else {
throw new IllegalArgumentException("Invalid schema type; type must be Boolean or Schema");
}
}
public void setAutosetConstants(boolean autosetConstants) {
this.autosetConstants = autosetConstants;
}

View File

@@ -292,9 +292,7 @@ public class DefaultGenerator implements Generator {
// set OpenAPI to make these available to all methods
config.setOpenAPI(openAPI);
if (!config.additionalProperties().containsKey("generatorVersion")) {
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
}
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());

View File

@@ -38,8 +38,6 @@ 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<>();
@@ -103,25 +101,10 @@ 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 =============
/**
@@ -153,23 +136,12 @@ 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");
}
/**
@@ -227,43 +199,6 @@ 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));
}
}
}
/**
@@ -510,10 +445,8 @@ public class OpenAPINormalizer {
}
if (schema instanceof ArraySchema) { // array
normalizeArraySchema(schema);
normalizeSchema(schema.getItems(), visitedSchemas);
} else if (schema.getAdditionalProperties() instanceof Schema) { // map
normalizeMapSchema(schema);
normalizeSchema((Schema) schema.getAdditionalProperties(), visitedSchemas);
} else if (ModelUtils.isOneOf(schema)) { // oneOf
return normalizeOneOf(schema, visitedSchemas);
@@ -565,27 +498,16 @@ public class OpenAPINormalizer {
return schema;
}
private Schema normalizeArraySchema(Schema schema) {
return processSetArraytoNullable(schema);
}
private Schema normalizeMapSchema(Schema schema) {
return processSetMapToNullable(schema);
}
private Schema normalizeSimpleSchema(Schema schema, Set<Schema> visitedSchemas) {
Schema result = processNormalize31Spec(schema, visitedSchemas);
return processSetPrimitiveTypesToNullable(result);
return processNormalize31Spec(schema, visitedSchemas);
}
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) {
@@ -896,14 +818,8 @@ public class OpenAPINormalizer {
}
}
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;
}
if (!(schema instanceof JsonSchema) && (schema.getType() == null || schema.getType().equals("null")) && schema.get$ref() == null) {
return true;
}
// convert referenced enum of null only to `nullable:true`
@@ -932,27 +848,6 @@ 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);
@@ -969,80 +864,6 @@ 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.
@@ -1057,27 +878,6 @@ 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);
}
@@ -1236,7 +1036,6 @@ 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())) {

View File

@@ -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 dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
protected final SimpleDateFormat DATE_FORMAT = 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());
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
}
public List<Map<String, String>> generateFromResponseSchema(String statusCode, Schema responseSchema, Set<String> producesInfo) {
@@ -238,7 +238,7 @@ public class ExampleGenerator {
// When a property is of type Date, we want to ensure that we're returning a formatted Date.
// And not returning the Date object directly.
if (property.getExample() instanceof Date) {
return dateFormat.format(property.getExample());
return DATE_FORMAT.format(property.getExample());
}
return property.getExample();
} else if (ModelUtils.isBooleanSchema(property)) {

View File

@@ -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 nameInPascalCase = property.nameInPascalCase;
nameInPascalCase = sanitizeName(nameInPascalCase);
property.nameInPascalCase = nameInPascalCase;
String nameInCamelCase = property.nameInCamelCase;
nameInCamelCase = sanitizeName(nameInCamelCase);
property.nameInCamelCase = nameInCamelCase;
}
return property;
}
@@ -650,6 +650,10 @@ 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;
@@ -841,6 +845,10 @@ 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);
}
}
/*

View File

@@ -85,8 +85,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
protected String enumValueSuffix = "Enum";
protected String sourceFolder = "src";
protected static final String invalidParameterNamePrefix = "var";
protected static final String invalidPropertyNamePrefix = "Var";
protected String invalidNamePrefix = "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.
@@ -442,7 +441,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
CopyLambda copyLambda = new CopyLambda();
return super.addMustacheLambdas()
.put("camelcase_sanitize_param", new CamelCaseAndSanitizeLambda().generator(this).escapeAsParamName(true))
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
.put("required", new RequiredParameterLambda())
.put("optional", new OptionalParameterLambda().generator(this))
.put("joinWithComma", new JoinWithCommaLambda())
@@ -462,9 +461,7 @@ 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("camel_case", new CamelCaseLambda())
.put("escape_reserved_word", new EscapeKeywordLambda((val) -> this.escapeKeyword(val)));
.put("unique", new UniqueLambda("\n", true));
}
@Override
@@ -667,13 +664,18 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
private String patchPropertyName(CodegenModel model, String value) {
String name = escapeReservedWord(model, value);
if (name.startsWith(AbstractCSharpCodegen.invalidParameterNamePrefix)) {
name = AbstractCSharpCodegen.invalidPropertyNamePrefix + name.substring(AbstractCSharpCodegen.invalidParameterNamePrefix.length());
// 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;
}
return name;
return value;
}
private void patchPropertyVendorExtensions(CodegenProperty property) {
@@ -698,6 +700,7 @@ 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" };
@@ -734,11 +737,6 @@ 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;
}
@@ -796,8 +794,6 @@ 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) {
@@ -1048,57 +1044,57 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
for (CodegenParameter parameter : operation.allParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.bodyParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.cookieParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.formParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.headerParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.implicitHeadersParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.optionalParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.pathParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.queryParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.notNullableParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.requiredParams) {
CodegenModel model = getModelFromParameter(modelMaps, parameter);
CodegenModel model = getModelFromParameter(allModels, parameter);
patchParameter(model, parameter);
}
@@ -1125,8 +1121,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
/**
* Returns the model related to the given parameter
*/
private CodegenModel getModelFromParameter(HashMap<String, CodegenModel> allModels, CodegenParameter parameter) {
return allModels.getOrDefault(parameter.dataType, null);
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;
}
/**
@@ -1310,24 +1308,23 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
public String escapeReservedWord(CodegenModel model, String name) {
name = this.escapeReservedWord(name);
return name.equals(model.getClassname())
? AbstractCSharpCodegen.invalidParameterNamePrefix + camelize(name)
return name.equalsIgnoreCase(model.getClassname())
? this.invalidNamePrefix + camelize(name)
: name;
}
@Override
public String escapeReservedWord(String name) {
if (isReservedWord(name) ||
if (reservedWords().contains(name) ||
reservedWords().contains(name.toLowerCase(Locale.ROOT)) ||
reservedWords().contains(camelize(sanitizeName(name))) ||
isReservedWord(name) ||
name.matches("^\\d.*")) {
name = AbstractCSharpCodegen.invalidParameterNamePrefix + camelize(name);
name = this.invalidNamePrefix + camelize(name);
}
return name;
}
public String escapeKeyword(String value) {
return isReservedWord(value) ? "@" + value : value;
}
/**
* Return the example value of the property
*

View File

@@ -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.nameInPascalCase;
String nameInCamelCase = property.nameInCamelCase;
if (nameInCamelCase.length() > 1) {
nameInCamelCase = sanitizeName(Character.toLowerCase(nameInCamelCase.charAt(0)) + nameInCamelCase.substring(1));
} else {

View File

@@ -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 CamelCaseAndSanitizeLambda().generator(this).escapeAsParamName(true));
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true));
}
@Override

View File

@@ -277,11 +277,8 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
Schema inner = ap.getItems();
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Object ap = p.getAdditionalProperties();
// additionalProperties is either a Schema or a Boolean
if (ap instanceof Schema) {
return getTypeDeclaration((Schema) ap);
}
Schema inner = (Schema) p.getAdditionalProperties();
return getTypeDeclaration(inner);
}
// Not using the supertype invocation, because we want to UpperCamelize

View File

@@ -21,7 +21,6 @@ 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;
@@ -667,14 +666,6 @@ 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
@@ -1047,7 +1038,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
private String getStringBeanValidation(Schema<?> items) {
String validations = "";
if (ModelUtils.shouldIgnoreBeanValidation(items)) {
if (ModelUtils.isByteArraySchema(items) || ModelUtils.isBinarySchema(items)) {
return validations;
}
@@ -1112,13 +1103,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) {
if (cp.isArray && !cp.getUniqueItems()) { // array
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 getDefaultCollectionType(schema);
return "new ArrayList<>()";
}
List<String> final_values = _values;
@@ -1164,12 +1155,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
defaultValue = StringUtils.join(_values, ", ");
}
} else {
return getDefaultCollectionType(schema);
return "new ArrayList<>()";
}
return getDefaultCollectionType(schema, defaultValue);
}
if (cp.isMap) { // map
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
// TODO
return null;
} else {
@@ -1185,13 +1178,21 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
if (ModelUtils.isArraySchema(schema)) {
if (schema.getDefault() == null) {
// nullable or containerDefaultToNull set to true
if (cp.isNullable || containerDefaultToNull) {
// nullable, optional or containerDefaultToNull set to true
if (cp.isNullable || !cp.required || 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"));
}
}
return getDefaultCollectionType(schema);
} else { // has default value
return toArrayDefaultValue(cp, 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
@@ -1201,8 +1202,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return null;
}
// nullable or containerDefaultToNull set to true
if (cp.isNullable || containerDefaultToNull) {
if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
return null;
}
@@ -1290,24 +1290,6 @@ 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();
@@ -1601,29 +1583,15 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
// additional import for different cases
addAdditionalImports(codegenModel, codegenModel.getComposedSchemas());
addAdditionalImports(codegenModel, codegenModel.oneOf);
addAdditionalImports(codegenModel, codegenModel.anyOf);
return codegenModel;
}
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);
}
private void addAdditionalImports(CodegenModel model, Set<String> dataTypeSet) {
for (String dataType : dataTypeSet) {
if (null != importMapping().get(dataType)) {
model.imports.add(dataType);
}
}
}
@@ -1807,7 +1775,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);
}
}
@@ -1858,12 +1826,19 @@ 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()) {
return producesInfo.toArray(new String[] {});
StringBuilder sb = new StringBuilder();
for (String produce : producesInfo) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(produce);
}
return sb.toString();
}
return new String[] { "application/json" }; // default media type
return "application/json"; // default media type
}
@Override
@@ -2530,9 +2505,4 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
imports.add(importsItem);
}
}
@Override
public boolean isTypeErasedGenerics() {
return true;
}
}

View File

@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import org.apache.commons.io.FilenameUtils;
@@ -29,6 +30,7 @@ import org.openapitools.codegen.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.templating.mustache.EscapeChar;
import org.openapitools.codegen.templating.mustache.JoinWithCommaLambda;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -522,7 +524,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
if (additionalProperties.containsKey(USE_JAKARTA_EE)) {
setUseJakartaEe(Boolean.parseBoolean(additionalProperties.get(USE_JAKARTA_EE).toString()));
setUseJakartaEe(Boolean.TRUE.equals(additionalProperties.get(USE_JAKARTA_EE)));
}
additionalProperties.put(USE_JAKARTA_EE, useJakartaEe);
@@ -646,7 +648,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toEnumName(CodegenProperty property) {
return property.nameInPascalCase;
return property.nameInCamelCase;
}
@Override

View File

@@ -1056,8 +1056,8 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
Set<String> exampleImports,
Set<String> postponedModelImports,
Set<String> postponedExampleImports,
PythonImports moduleImports,
String classname) {
PythonImports moduleImports = new PythonImports();
PydanticType pt = new PydanticType(
modelImports,
exampleImports,
@@ -1250,7 +1250,6 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
exampleImports,
postponedModelImports,
postponedExampleImports,
moduleImports,
null
);
}
@@ -2063,7 +2062,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
values.add((String) enumVar.get("value"));
}
}
return String.format(Locale.ROOT, "%sEnum", cp.nameInPascalCase);
return String.format(Locale.ROOT, "%sEnum", cp.nameInCamelCase);
} else*/
if (result == null) {
@@ -2172,7 +2171,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
// TODO process the first one only at the moment
if (cmt != null)
// TODO: don't loop back to the deprecated getPydanticType method
return getPydanticType(cmt.getSchema(), modelImports, exampleImports, postponedModelImports, postponedExampleImports, moduleImports, classname);
return getPydanticType(cmt.getSchema(), modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname);
}
throw new RuntimeException("Error! Failed to process getPydanticType when getting the content: " + cp);
} else {

View File

@@ -956,7 +956,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
}
if (!fields.isEmpty()) {
fields.add(0, "default=" + fieldCustomization);
fields.add(0, fieldCustomization);
pydanticImports.add("Field");
fieldCustomization = String.format(Locale.ROOT, "Field(%s)", StringUtils.join(fields, ", "));
}
@@ -1351,7 +1351,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
values.add((String) enumVar.get("value"));
}
}
return String.format(Locale.ROOT, "%sEnum", cp.nameInPascalCase);
return String.format(Locale.ROOT, "%sEnum", cp.nameInCamelCase);
} else*/
if (cp.isArray) {
String constraints = "";

View File

@@ -436,12 +436,4 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
public String addRegularExpressionDelimiter(String pattern) {
return pattern;
}
@Override
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "r#"+ name;
}
}

View File

@@ -39,9 +39,6 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(CLibcurlClientCodegen.class);
public static final String USE_JSON_UNFORMATTED = "useJsonUnformatted";
public static final String USE_JSON_UNFORMATTED_DESC = "Use cJSON_PrintUnformatted instead of cJSON_Print when creating the JSON string.";
public static final String PROJECT_NAME = "projectName";
protected String moduleName;
protected String projectName;
@@ -50,7 +47,6 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
protected String libFolder = "lib";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected boolean useJsonUnformatted = false;
protected static int emptyMethodNameCounter = 0;
@@ -310,8 +306,6 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).
defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(USE_JSON_UNFORMATTED, USE_JSON_UNFORMATTED_DESC).
defaultValue(Boolean.FALSE.toString()));
}
@Override
@@ -322,15 +316,6 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
LOGGER.info("Environment variable C_POST_PROCESS_FILE not defined so the C code may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To define it, try `export C_POST_PROCESS_FILE=\"/usr/local/bin/uncrustify --no-backup\" && export UNCRUSTIFY_CONFIG=/path/to/uncrustify-rules.cfg` (Linux/Mac). Note: replace /path/to with the location of uncrustify-rules.cfg");
}
if (additionalProperties.containsKey(USE_JSON_UNFORMATTED)) {
useJsonUnformatted = Boolean.parseBoolean(additionalProperties.get(USE_JSON_UNFORMATTED).toString());
}
if (useJsonUnformatted) {
additionalProperties.put("cJSONPrint", "cJSON_PrintUnformatted");
} else {
additionalProperties.put("cJSONPrint", "cJSON_Print");
}
// make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);

View File

@@ -171,13 +171,9 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
return "(s/coll-of " + getTypeDeclaration(inner) + ")";
} else if (ModelUtils.isMapSchema(p)) {
Object ap = p.getAdditionalProperties();
// additionalProperties is either a Schema or a Boolean
if (ap instanceof Schema) {
Schema inner = (Schema) ap;
return "(s/map-of string? " + getTypeDeclaration(inner) + ")";
}
return "(s/map-of string? s/any?)";
Schema inner = (Schema) p.getAdditionalProperties();
return "(s/map-of string? " + getTypeDeclaration(inner) + ")";
}
// If it's a type we defined, we want to append the spec suffix

View File

@@ -20,10 +20,6 @@ import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenResponse;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
@@ -250,34 +246,6 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
this.optionalProjectFileFlag = flag;
}
// override to post-process any model properties
@Override
@SuppressWarnings("unused")
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
// Nullable will be handled as optional
property.required = !property.notRequiredOrIsNullable();
}
// override to post-process any response
@Override
@SuppressWarnings("unused")
public void postProcessResponseWithProperty(CodegenResponse response, CodegenProperty property) {
super.postProcessResponseWithProperty(response, property);
// Nullable will be handled as optional
property.required = !property.notRequiredOrIsNullable();
}
// override to post-process any parameters
@Override
@SuppressWarnings("unused")
public void postProcessParameter(CodegenParameter parameter) {
super.postProcessParameter(parameter);
// Nullable will be handled as optional
parameter.required = !parameter.notRequiredOrIsNullable();
}
/**
* Configures the type of generator.
*

View File

@@ -599,9 +599,14 @@ public class CrystalClientCodegen extends DefaultCodegen {
return objs;
}
OperationMap operations = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, Integer> processedModelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operationList = operations.getOperation();
for (CodegenOperation op : operationList) {
for (CodegenParameter p : op.allParams) {

View File

@@ -453,7 +453,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
CodegenProperty prop = super.fromProperty(name, p, required);
String cc = camelize(prop.name, LOWERCASE_FIRST_LETTER);
if (isReservedWord(cc)) {
cc = escapeReservedWord(cc); // e.g. byte => byte_
cc = escapeReservedWord(cc);
}
prop.nameInCamelCase = cc;
return prop;
@@ -533,9 +533,14 @@ public class GoClientCodegen extends AbstractGoCodegen {
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
OperationMap operations = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, ArrayList<Integer>> processedModelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operationList = operations.getOperation();
for (CodegenOperation op : operationList) {
for (CodegenParameter p : op.allParams) {

View File

@@ -132,10 +132,9 @@ public class GraphQLNodeJSExpressServerCodegen extends AbstractGraphQLCodegen im
// return "[" + getTypeDeclaration(inner) + "]";
return getTypeDeclaration(inner);
} else if (ModelUtils.isMapSchema(p)) {
Object ap = p.getAdditionalProperties();
if (ap instanceof Schema) {
return getTypeDeclaration((Schema) ap);
}
Schema inner = (Schema) p.getAdditionalProperties();
return getTypeDeclaration(inner);
}
// IMPORTANT NOTE Not using the supertype invocation, because we want to UpperCamelize the type:

View File

@@ -745,15 +745,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
param.vendorExtensions.put(VENDOR_EXTENSION_X_IS_BODY_OR_FORM_PARAM, param.isBodyParam || param.isFormParam);
if (!StringUtils.isBlank(param.collectionFormat)) {
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
} else if (!param.isBodyParam) {
if (param.isArray || param.dataType.startsWith("[")) { // param.isArray is sometimes false for list types
// defaulting due to https://github.com/wing328/openapi-generator/issues/72
param.collectionFormat = "csv";
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
}
}
if (param.isQueryParam && (isJsonMimeType(param.contentType) || ContainsJsonMimeType(param.contentType))) {
param.vendorExtensions.put(X_MEDIA_IS_JSON, "true");
} else if (!param.isBodyParam && (param.isArray || param.dataType.startsWith("["))) { // param.isArray is sometimes false for list types
// defaulting due to https://github.com/wing328/openapi-generator/issues/72
param.collectionFormat = "csv";
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
}
if (!param.required) {
op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_OPTIONAL_PARAMS, true);

View File

@@ -514,13 +514,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// Query parameters appended to routes
for (CodegenParameter param : op.queryParams) {
String paramType = param.dataType;
if (param.contentType == "application/json") {
if (param.isArray) {
paramType = "[JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + "]";
} else {
paramType = "(JSONQueryParam " + paramType + ")";
}
}
if (param.isArray) {
if (StringUtils.isEmpty(param.collectionFormat)) {
param.collectionFormat = "csv";
@@ -556,13 +549,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
path.add("Header \"" + param.baseName + "\" " + param.dataType);
String paramType = param.dataType;
if (param.contentType == "application/json") {
if (param.isArray) {
paramType = "(JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + ")";
} else {
paramType = "(JSONQueryParam " + paramType + ")";
}
}
if (param.isArray) {
if (StringUtils.isEmpty(param.collectionFormat)) {
param.collectionFormat = "csv";

View File

@@ -569,10 +569,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
}
if (APACHE.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("BaseApi.mustache", invokerFolder, "BaseApi.java"));
}
if (FEIGN.equals(getLibrary())) {
if (getSerializationLibrary() == null) {
LOGGER.info("No serializationLibrary configured, using '{}' as fallback", SERIALIZATION_LIBRARY_JACKSON);

View File

@@ -953,12 +953,6 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
if (Boolean.TRUE.equals(param.isFile)) {
operations.put("x-kotlin-multipart-import", true);
}
if (param.isQueryParam && "form".equals(param.style) && param.isExplode && param.isModel) {
// query parameter (style: form, explode) referencing models need to import
// models defined in the properties of the models
operations.put("x-koltin-import-models", true);
}
}
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {

View File

@@ -30,7 +30,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanValidationFeatures {
@@ -409,8 +412,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap operations = objs.getOperations();
// The following processing breaks the JAX-RS spec, so we only do this for the other libs.
if (operations != null && !Objects.equals(library, Constants.JAXRS_SPEC)) {
if (operations != null) {
List<CodegenOperation> ops = operations.getOperation();
ops.forEach(operation -> {
List<CodegenResponse> responses = operation.responses;

View File

@@ -374,25 +374,19 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
items.add(new PostmanRequestItem(codegenOperation.summary, getJsonFromSchema(codegenOperation.bodyParam)));
} else {
// get from examples
if (codegenOperation.bodyParam.getContent().get("application/json") != null &&
codegenOperation.bodyParam.getContent().get("application/json").getExamples() != null) {
for (Map.Entry<String, Example> entry : codegenOperation.bodyParam.getContent().get("application/json").getExamples().entrySet()) {
if(entry.getValue().get$ref() != null) {
// find in components/examples
String exampleRef = entry.getValue().get$ref();
Example example = this.openAPI.getComponents().getExamples().get(extractExampleByName(exampleRef));
String exampleAsString = getJsonFromExample(example);
items.add(new PostmanRequestItem(example.getSummary(), exampleAsString));
} else if (entry.getValue().getValue() != null && entry.getValue().getValue() instanceof ObjectNode) {
// find inline
String exampleAsString = convertToJson((ObjectNode) entry.getValue().getValue());
items.add(new PostmanRequestItem(entry.getKey(), exampleAsString));
}
}
} else if (codegenOperation.bodyParam.example != null) {
if (codegenOperation.bodyParam.example != null) {
// find in bodyParam example
items.add(new PostmanRequestItem(codegenOperation.summary, formatJson(codegenOperation.bodyParam.example)));
} else if (codegenOperation.bodyParam.getContent().get("application/json") != null &&
codegenOperation.bodyParam.getContent().get("application/json").getExamples() != null) {
// find in components/examples
for (Map.Entry<String, Example> entry : codegenOperation.bodyParam.getContent().get("application/json").getExamples().entrySet()) {
String exampleRef = entry.getValue().get$ref();
Example example = this.openAPI.getComponents().getExamples().get(extractExampleByName(exampleRef));
String exampleAsString = getJsonFromExample(example);
items.add(new PostmanRequestItem(example.getSummary(), exampleAsString));
}
} else if (codegenOperation.bodyParam.getSchema() != null) {
// find in schema example
String exampleAsString = formatJson(codegenOperation.bodyParam.getSchema().getExample());
@@ -756,8 +750,6 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
} else if (value instanceof LinkedHashMap) {
String in = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": ";
ret = traverseMap(((LinkedHashMap<String, Object>) value), in);
} else if (value instanceof ArrayList<?>) {
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " + getJsonArray((ArrayList<Object>) value);
} else {
LOGGER.warn("Value type unrecognised: " + value.getClass());
}
@@ -774,38 +766,6 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
return ret;
}
String getJsonArray(ArrayList<Object> list) {
String ret = "";
for(Object element: list) {
if(element instanceof String) {
ret = ret + getStringArrayElement((String) element) + ", ";
} else if(element instanceof LinkedHashMap) {
ret = traverseMap((LinkedHashMap<String, Object>) element, ret) + ", ";
}
}
if(ret.endsWith(", ")) {
ret = ret.substring(0, ret.length() - 2);
}
return "[" + ret + "]";
}
String getStringArrayElement(String element) {
String ret = "";
if(element.startsWith("{")) {
// isJson (escape all double quotes)
ret = ret + element.replace("\"", JSON_ESCAPE_DOUBLE_QUOTE);
} else {
// string element (add escaped double quotes)
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + element + JSON_ESCAPE_DOUBLE_QUOTE;
}
return ret;
}
public String getPostmanType(CodegenProperty codegenProperty) {
if(codegenProperty.isNumeric) {
return "number";

View File

@@ -1043,9 +1043,14 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap operations = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, Integer> processedModelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operationList = operations.getOperation();
for (CodegenOperation op : operationList) {
int index = 0;

View File

@@ -911,7 +911,13 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap objectMap = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operations = objectMap.getOperation();
for (CodegenOperation operation : operations) {
for (CodegenParameter cp : operation.allParams) {

View File

@@ -651,9 +651,14 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
OperationMap operations = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, Integer> processedModelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operationList = operations.getOperation();
for (CodegenOperation op : operationList) {
for (CodegenParameter p : op.allParams) {

View File

@@ -550,6 +550,20 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
}
}
}
for (CodegenProperty header : rsp.headers) {
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
}
for (CodegenParameter header : op.headerParams) {
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
for (CodegenProperty header : op.responseHeaders) {
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
return op;
@@ -622,6 +636,15 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
param.vendorExtensions.put("x-consumes-json", true);
}
}
for (CodegenParameter header : op.headerParams) {
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
for (CodegenProperty header : op.responseHeaders) {
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
}
@Override

View File

@@ -392,13 +392,6 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
// remove v or V
content = content.trim().replace("v", "");
content = content.replace("V", "");
// convert 5.2 to 5.2.0 for example
String[] contents = content.split("[.]");
if (contents.length == 2) {
content += ".0";
}
writer.write(content);
}
});

View File

@@ -773,7 +773,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
if (uuidType.equals(header.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
header.nameInPascalCase = toModelName(header.baseName);
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
}
@@ -786,7 +786,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
if (uuidType.equals(header.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
header.nameInPascalCase = toModelName(header.baseName);
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
@@ -881,7 +881,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
if (uuidType.equals(header.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
header.nameInPascalCase = toModelName(header.baseName);
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}

View File

@@ -615,6 +615,10 @@ public class SpringCodegen extends AbstractJavaCodegen
additionalProperties.put(USE_FEIGN_CLIENT, "true");
} else if (SPRING_BOOT.equals(library)) {
apiTemplateFiles.put("apiController.mustache", "Controller.java");
if (containsEnums()) {
supportingFiles.add(new SupportingFile("converter.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "EnumConverterConfiguration.java"));
}
supportingFiles.add(new SupportingFile("application.mustache",
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
supportingFiles.add(new SupportingFile("homeController.mustache",
@@ -782,12 +786,6 @@ public class SpringCodegen extends AbstractJavaCodegen
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
super.preprocessOpenAPI(openAPI);
if (!interfaceOnly && SPRING_BOOT.equals(library) && containsEnums()) {
supportingFiles.add(new SupportingFile("converter.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "EnumConverterConfiguration.java"));
}
/*
* TODO the following logic should not need anymore in OAS 3.0 if
* ("/".equals(swagger.getBasePath())) { swagger.setBasePath(""); }

View File

@@ -1256,7 +1256,11 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap objectMap = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operations = objectMap.getOperation();
for (CodegenOperation operation : operations) {

View File

@@ -729,7 +729,12 @@ public class SwiftCombineClientCodegen extends DefaultCodegen implements Codegen
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
for (Object o : allModels) {
HashMap<String, Object> h = (HashMap<String, Object>) o;
CodegenModel m = (CodegenModel) h.get("model");
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
for (CodegenOperation operation : operations) {

View File

@@ -26,12 +26,12 @@ import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import java.util.stream.Collectors;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.templating.mustache.IndentedLambda;
import org.openapitools.codegen.utils.ModelUtils;
@@ -986,8 +986,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
class ExtendedCodegenParameter extends CodegenParameter {
public String dataTypeAlternate;
public boolean isUniqueId; // this parameter represents a unique id (x-isUniqueId: true)
public List<CodegenProperty> readOnlyVars; // a list of read-only properties
public boolean hasReadOnly = false; // indicates the type has at least one read-only property
public boolean itemsAreUniqueId() {
return TypeScriptFetchClientCodegen.itemsAreUniqueId(this.items);
@@ -1083,11 +1081,8 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.minItems = cp.minItems;
this.uniqueItems = cp.uniqueItems;
this.multipleOf = cp.multipleOf;
this.setHasVars(cp.getHasVars());
this.setHasRequired(cp.getHasRequired());
this.setMaxProperties(cp.getMaxProperties());
this.setMinProperties(cp.getMinProperties());
setReadOnlyVars();
}
@Override
@@ -1128,11 +1123,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
sb.append(", dataTypeAlternate='").append(dataTypeAlternate).append('\'');
return sb.toString();
}
private void setReadOnlyVars() {
readOnlyVars = vars.stream().filter(v -> v.isReadOnly).collect(Collectors.toList());
hasReadOnly = !readOnlyVars.isEmpty();
}
}
class ExtendedCodegenProperty extends CodegenProperty {
@@ -1239,7 +1229,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.isInherited = cp.isInherited;
this.discriminatorValue = cp.discriminatorValue;
this.nameInLowerCase = cp.nameInLowerCase;
this.nameInPascalCase = cp.nameInPascalCase;
this.nameInCamelCase = cp.nameInCamelCase;
this.nameInSnakeCase = cp.nameInSnakeCase;
this.enumName = cp.enumName;
this.maxItems = cp.maxItems;

View File

@@ -1,7 +1,6 @@
package org.openapitools.codegen.model;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openapitools.codegen.CodegenModel;
@@ -23,21 +22,4 @@ public class ModelMap extends HashMap<String, Object> {
public CodegenModel getModel() {
return (CodegenModel) get("model");
}
/**
* Convert a list of ModelMap to map of CodegenModel.
*
* @param allModels list of model map
* @return map of Codegen Model
*/
static public HashMap<String, CodegenModel> toCodegenModelMap(List<ModelMap> allModels) {
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
return modelMaps;
}
}

View File

@@ -1,88 +0,0 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
* Copyright 2018 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.templating.mustache;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.utils.CamelizeOption;
import java.io.IOException;
import java.io.Writer;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
/**
* Converts text in a fragment to camelCase.
*
* Register:
* <pre>
* additionalProperties.put("camelcase", new CamelCaseAndSanitizeLambda());
* </pre>
*
* Use:
* <pre>
* {{#camelcase}}{{name}}{{/camelcase}}
* </pre>
*/
public class CamelCaseAndSanitizeLambda implements Mustache.Lambda {
private CodegenConfig generator = null;
private Boolean escapeParam = false;
private CamelizeOption option = LOWERCASE_FIRST_LETTER;
public CamelCaseAndSanitizeLambda(boolean lowercaseFirstLetter) {
if (lowercaseFirstLetter) {
option = LOWERCASE_FIRST_LETTER;
} else {
option = UPPERCASE_FIRST_CHAR;
}
}
public CamelCaseAndSanitizeLambda() {}
public CamelCaseAndSanitizeLambda generator(final CodegenConfig generator) {
this.generator = generator;
return this;
}
public CamelCaseAndSanitizeLambda escapeAsParamName(final Boolean escape) {
this.escapeParam = escape;
return this;
}
@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String text = camelize(fragment.execute().replace(" ", "_"), option);
if (generator != null) {
text = generator.sanitizeName(text);
if (generator.reservedWords().contains(text)) {
// Escaping must be done *after* camelize, because generators may escape using characters removed by camelize function.
text = generator.escapeReservedWord(text);
}
if (escapeParam) {
// NOTE: many generators call escapeReservedWord in toParamName, but we can't assume that's always the case.
// Here, we'll have to accept that we may be duplicating some work.
text = generator.toParamName(text);
}
}
writer.write(text);
}
}

Some files were not shown because too many files have changed in this diff Show More