Compare commits

...

35 Commits

Author SHA1 Message Date
William Cheng
4fa075d291 Merge branch 'property-names-should-be-pascal-case' of https://github.com/devhl-labs/openapi-generator into devhl-labs-property-names-should-be-pascal-case 2024-04-07 16:17:13 +08:00
Samuel Kahn
d2c48e2999 Fix map parameter not a container (#18220)
* Map parameters now carry their container properties when generated from map properties. This solves an issue where a map parameter was not considered a container and induced generation errors.

* Added test specification with fake endpoint for testing map parameters

---------

Co-authored-by: Samuel Kahn <samuel@darewise.com>
2024-04-07 16:12:59 +08:00
William Cheng
2168851e8a Better array handling in 3.1 spec (#18313)
* better array detection in 3.1 spec

* fix
2024-04-07 15:48:19 +08:00
devhl
6c955da59a fixed property naming convention for composed types 2024-04-06 19:33:16 -04:00
William Cheng
3d2e38e347 add tests for query parameter (array of enum) in 3.1 spec (#18310) 2024-04-06 14:36:41 +08:00
martin-mfg
b11005b00d [JAXRS-SPEC] no @Valid annotation on simple fields (#18302)
* fix and test

* whitespace change, generate samples
2024-04-06 11:19:03 +08:00
devhl-labs
3bb17efa09 fixed issue (#18309) 2024-04-06 11:05:43 +08:00
William Cheng
ac14e66da1 skip warning, better code format for jetbrain http client generator (#18299) 2024-04-06 11:01:08 +08:00
William Cheng
1024c7733e update parser to 2.1.19 (#18298) 2024-04-05 16:44:42 +08:00
Michael Brügmann
90301f932d SWIFT5: sort query items alphabetically to allow better server side caching of requests with same URL (#18239)
* sort query items alphabetically to allow better server side caching of requests

* updarted samples
2024-04-05 08:18:53 +01:00
William Cheng
6d10e80916 [normalizer] fix schemas incorrectly skipped (#18297)
* fix circular reference check in normalizer

* add new files

* fix
2024-04-05 13:55:22 +08:00
sullis
f357be480e [gradle-plugin] enhance unit test cases (#18285) 2024-04-03 17:13:18 -07:00
William Cheng
2a39b29684 [python] Add field as a reserved word (#18279)
* add field as a reserved word

* remove tabs

* update
2024-04-03 16:43:51 +08:00
William Cheng
88204b247a [Java] Sync jersey2 jersey3 template (#18281)
* sync jersey2 and 3 templates

* add deprecated

* update samples
2024-04-03 16:32:39 +08:00
William Cheng
2934f5ac51 add logic to simplify any type represented with oneof/anyof (#18268) 2024-04-02 15:08:20 +08:00
dependabot[bot]
2ce71512d0 Bump julia-actions/setup-julia from 1 to 2 (#18270)
Bumps [julia-actions/setup-julia](https://github.com/julia-actions/setup-julia) from 1 to 2.
- [Release notes](https://github.com/julia-actions/setup-julia/releases)
- [Commits](https://github.com/julia-actions/setup-julia/compare/v1...v2)

---
updated-dependencies:
- dependency-name: julia-actions/setup-julia
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-02 08:52:03 +08:00
William Cheng
927768757b Add designli to bronze sponsor (#18269)
* add designli to bronze sponsor

* update link to jpg
2024-04-01 15:46:04 +08:00
devhl-labs
858499ffdd [csharp][generichost] Form models (#18264)
* rename a bin artifact

* add support for form models

* revert sample changes

* revert sample changes

* build samples

* build samples
2024-04-01 13:12:03 +08:00
William Cheng
4719d9e55f update spring-context to newer version (#18266) 2024-04-01 11:56:58 +08:00
William Cheng
2d7f0496ec add rule to set primitive types to nullable (#18258) 2024-04-01 11:54:21 +08:00
devhl-labs
2fac8e34db [csharp][generichost] Updated UseSourceGeneration (#18265)
* updated UseSourceGeneration

* updated UseSourceGeneration

* updated UseSourceGeneration
2024-04-01 11:49:13 +08:00
martin-mfg
1704ae1194 fix issue 17999 (#18259) 2024-03-31 22:47:19 +08:00
devhl-labs
370eca2889 [csharp] Update dependencies (#18263)
* version bump

* updated a workflow
2024-03-31 11:27:57 +08:00
devhl-labs
d0f8468651 [csharp] Rename samples (#18260)
* renamed OpenAPIClient-httpclient to Petstore

* updated bin artifacts

* renamed OpenAPIClientCoreAndNet47 to MultipleFrameworks

* updated bin artifacts

* renamed OpenAPIClient-net47 to Petstore

* renamed OpenAPIClient-net48 to Petstore

* updated bin artifacts

* renamed OpenAPIClient-restsharp-name-parameter-mappings to ParameterMappings

* updated bin artifacts

* renamed OpenAPIClientCore to Petstore

* updated bin artifacts

* renamed OpenAPIClient-net7.0-useDateTimeForDate to UseDateTimeForDate

* updated bin artifacts

* renamed OpenAPIClient-net5.0 to EnumMappings

* updated bin artifacts

* renamed OpenAPIClient-ConditionalSerialization to ConditionalSerialization

* updated bin artifacts

* renamed OpenAPIClient to Petstore

* updated bin artifacts

* renamed OpenAPIClient-unityWebRequest to Petstore

* updated bin artifacts

* updated appveyor

* updated bin artifacts

* updated bin artifacts

* comenting out a sample project with no csproj file

* updated bin artifacts
2024-03-31 10:36:42 +08:00
devhl-labs
6252dac28e [csharp][generichost] Ensure samples are running (#18257)
* ensure samples are running

* ensure samples are running

* ensure samples are running

* ensure samples are running

* ensure samples are running

* ensure samples are running

* revert testing changes

* sorted the array entries
2024-03-30 21:14:51 +08:00
B4ckslash
807aa5d3ae [Java][jersey2] Fix generated client code for oneOf models if datatype includes arrays (#18042)
* Add java-jersey2 sample with mixed oneOf

* [java][jersey2]Fix client generation if oneOf contains an array type

Changes:
* Change jersey2/oneof_model template to use composed schema data
* Change adding of imports in AbstractJavaCodegen to use composed schema data
* Add escapedDataType property to CodegenProperty so that the data type
  may be part of identifiers (e.g. in getters)
* Update samples

* Add sample for multiple array in oneOf

* Fix generation of constructors with same erasures

* Update samples again

* Version bump

* Add new sample folders to CI

* Make primitive handling more explicit

* Replace escapedDataType property with Mustache lambda

* Update samples with new primitive handling and sanitization lambda
2024-03-30 21:08:41 +08:00
timo-a
f73db59b0e Migrate generated tests for java resttemplate generator updateFeature/resttemplate junit5 (#18222)
* update(resttemplate): migrate java resttemplate templates to junit 5

* update(java defaults): migrate java defaults as well because resttemplate uses model_tests from default

* update(samples, java): update samples as described in the contribution guidelines

* fix tests: try double quotes

* fix tests: remaining double quotes

* update(samples): regenerate resttemplate

* update(samples): regenerate resttemplate-jakarta

* update(samples): regenerate resttemplate-swagger1

* update(samples): regenerate resttemplate-swagger2

* update(samples): regenerate resttemplate-withXml

* update(samples again): ./bin/generate-samples.sh ./bin/configs/*.yaml
2024-03-30 21:06:05 +08:00
Yohei Kitamura
34ebc1c644 [ruby] Use Marcel to detect content-type in form-data file upload using faraday (#18243) 2024-03-29 21:58:08 +08:00
martin-mfg
de680de60e fix issue 17895 (#18248) 2024-03-29 21:57:13 +08:00
William Cheng
e78aeb6bc7 Better support for $ref to schema's properties (#18233)
* use once

* add support for reference to schema properties
2024-03-27 11:46:00 +08:00
Dennis Melzer
309918d03e Fix compile error in client properties configuration (#18232)
* Fix config

* Add tests

* Remove unused import

* Sort imports

* Add new workflow
2024-03-26 22:02:19 +08:00
Harry Devane
6690b9f87d Update okhttp3 to 4.12.0 (#18235) 2024-03-26 21:44:43 +08:00
dependabot[bot]
ee69a7983a Bump express from 4.18.2 to 4.19.2 in /website (#18228)
Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-26 10:21:02 +08:00
devhl-labs
204407daf0 Rename samples (#18223)
* moved OpenAPIClient-generichost-net6.0

* moved OpenAPIClient-generichost-netcore-latest-allOf

* moved OpenAPIClient-generichost-netcore-latest-anyOf

* moved OpenAPIClient-generichost-netcore-latest-oneOf

* moved OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration

* moved OpenAPIClient-generichost-net6.0-nrt

* moved OpenAPIClient-generichost-net7.0-useDateTimeForDate

* moved OpenAPIClient-generichost-manual-tests

* moved OpenAPIClient-generichost-netstandard2.0

* moved OpenAPIClient-generichost-net6.0

* deleted abandoned files

* updated bin artifacts

* build samples

* updated workflow

* fix manual tests
2024-03-26 10:19:05 +08:00
devhl-labs
d1860b95cf [csharp] Move samples (#18217)
* moved manual tests

* moved allOf

* moved anyOf

* moved oneOf

* moved OpenAPIClient-generichost-net6.0

* moved OpenAPIClient-generichost-net6.0-nrt

* moved OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration

* moved OpenAPIClient-generichost-net7.0-useDateTimeForDate

* moved OpenAPIClient-generichost-netstandard2.0

* moved OpenAPIClient

* moved OpenAPIClient-ConditionalSerialization

* moved OpenAPIClient-httpclient

* moved OpenAPIClient-net5.0

* moved OpenAPIClient-net7.0-useDateTimeForDate

* moved OpenAPIClient-net47

* moved OpenAPIClient-net48

* moved OpenAPIClient-restsharp-name-parameter-mappings

* moved OpenAPIClient-unityWebRequest

* moved OpenAPIClientCore

* moved OpenAPIClientCoreAndNet47

* renamed standard2 to standard2.0

* renamed standard2 to standard2.0

* fixed workflows

* renamed workflows

* updated bin artifacts

* updated bin artifacts

* pinned the samples to their version

* renamed bin artifacts

* update bin artifact

* update bin artifact

* update bin artifact

* updated appveyor

* reverting changes bc git does not show the rename

* commiting all but the file rename for these two files
2024-03-25 09:14:34 +08:00
5815 changed files with 84739 additions and 11677 deletions

View File

@@ -3,22 +3,16 @@ name: Samples C# .Net Standard Client
on:
push:
paths:
# build C# API client (netstandard)
- samples/client/petstore/csharp/OpenAPIClient/**
- samples/client/petstore/csharp/*netstandard*/**
# build C# API client (netstandard with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
# build C# API client (netstandard httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
- samples/client/petstore/csharp/generichost/standard2.0/**
- samples/client/petstore/csharp/httpclient/standard2.0/**
- samples/client/petstore/csharp/restsharp/standard2.0/**
- samples/client/petstore/csharp/unityWebRequest/standard2.0/**
pull_request:
paths:
# build C# API client (netstandard)
- samples/client/petstore/csharp/OpenAPIClient/**
- samples/client/petstore/csharp/*netstandard*/**
# build C# API client (netstandard with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
# build C# API client (netstandard httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
- samples/client/petstore/csharp/generichost/standard2.0/**
- samples/client/petstore/csharp/httpclient/standard2.0/**
- samples/client/petstore/csharp/restsharp/standard2.0/**
- samples/client/petstore/csharp/unityWebRequest/standard2.0/**
jobs:
build:
name: Build .Net projects
@@ -27,13 +21,11 @@ jobs:
fail-fast: false
matrix:
sample:
# build C# API client (netstandard)
- samples/client/petstore/csharp/OpenAPIClient/
- samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/
# build C# API client (netstandard with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/
# build C# API client (netstandard httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/
- samples/client/petstore/csharp/generichost/standard2.0/Petstore/
- samples/client/petstore/csharp/httpclient/standard2.0/Petstore/
- samples/client/petstore/csharp/restsharp/standard2.0/Petstore/
- samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -3,16 +3,16 @@ name: Samples C# .Net 8 Clients
on:
push:
paths:
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**
- samples/client/petstore/csharp/*net6.0*/**
- samples/client/petstore/csharp/*net7.0*/**
- samples/client/petstore/csharp/OpenAPIClient-*latest*/**
- samples/client/petstore/csharp/generichost/net8/**
- samples/client/petstore/csharp/httpclient/net8/**
- samples/client/petstore/csharp/restsharp/net8/**
- samples/client/petstore/csharp/unityWebRequest/net8/**
pull_request:
paths:
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**
- samples/client/petstore/csharp/*net6.0*/**
- samples/client/petstore/csharp/*net7.0*/**
- samples/client/petstore/csharp/OpenAPIClient-*latest*/**
- samples/client/petstore/csharp/generichost/net8/**
- samples/client/petstore/csharp/httpclient/net8/**
- samples/client/petstore/csharp/restsharp/net8/**
- samples/client/petstore/csharp/unityWebRequest/net8/**
jobs:
build:
name: Build .Net projects
@@ -21,16 +21,17 @@ jobs:
fail-fast: false
matrix:
sample:
# clients
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
- samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
- samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
- samples/client/petstore/csharp/generichost/net8/AllOf
- samples/client/petstore/csharp/generichost/net8/AnyOf
- samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
- samples/client/petstore/csharp/generichost/net8/FormModels
- samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests
- samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests
- samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
- samples/client/petstore/csharp/generichost/net8/OneOf
- samples/client/petstore/csharp/generichost/net8/Petstore
- samples/client/petstore/csharp/generichost/net8/SourceGeneration
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -3,28 +3,10 @@ name: Samples C# .Net 6 Client
on:
push:
paths:
# build C# API client (httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
# build C# API client (.net framework 4.7)
- samples/client/petstore/csharp/OpenAPIClient-net47/**
# build C# API client (.net framework 4.8)
- samples/client/petstore/csharp/OpenAPIClient-net48/**
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/**
# build C# API client (multiple frameworks)
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
- samples/client/petstore/csharp/restsharp/net6/**
pull_request:
paths:
# build C# API client (httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
# build C# API client (.net framework 4.7)
- samples/client/petstore/csharp/OpenAPIClient-net47/**
# build C# API client (.net framework 4.8)
- samples/client/petstore/csharp/OpenAPIClient-net48/**
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/**
# build C# API client (multiple frameworks)
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
- samples/client/petstore/csharp/restsharp/net6/**
jobs:
build:
name: Build .Net clients
@@ -33,16 +15,7 @@ jobs:
fail-fast: false
matrix:
sample:
# build C# API client (httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/
# build C# API client (.net framework 4.7)
- samples/client/petstore/csharp/OpenAPIClient-net47/
# build C# API client (.net framework 4.8)
- samples/client/petstore/csharp/OpenAPIClient-net48/
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/
# build C# API client (multiple frameworks)
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/
- samples/client/petstore/csharp/restsharp/net6/ParameterMappings/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -13,6 +13,8 @@ on:
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
- samples/client/others/java/jersey2-oneOf-Mixed/**
pull_request:
paths:
- 'samples/client/petstore/java/**'
@@ -25,6 +27,8 @@ on:
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
- samples/client/others/java/jersey2-oneOf-Mixed/**
jobs:
build:
name: Build Java Client JDK11
@@ -71,6 +75,8 @@ jobs:
- samples/client/others/java/okhttp-gson-oneOf/
- samples/client/others/java/resttemplate-useAbstractionForFiles/
- samples/client/others/java/webclient-useAbstractionForFiles/
- samples/client/others/java/jersey2-oneOf-duplicates/
- samples/client/others/java/jersey2-oneOf-Mixed/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4

View File

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

View File

@@ -34,6 +34,7 @@ jobs:
- samples/openapi3/client/petstore/spring-cloud-async
- samples/openapi3/client/petstore/spring-cloud-spring-pageable
- samples/client/petstore/spring-cloud-tags
- samples/client/petstore/spring-cloud-auth
- samples/client/petstore/spring-cloud-deprecated
# servers
- samples/server/petstore/springboot

View File

@@ -13,7 +13,7 @@ if [ "$NODE_INDEX" = "1" ]; then
echo "Running node $NODE_INDEX ..."
java -version
sudo apt-get -y install cpanminus libmagic-dev
sudo apt-get -y install cpanminus
(cd samples/client/petstore/perl && /bin/bash ./test.bash)
(cd samples/client/petstore/ruby && mvn integration-test)
@@ -112,5 +112,3 @@ else
(cd samples/client/petstore/java/apache-httpclient && mvn integration-test)
fi

View File

@@ -68,6 +68,7 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
[<img src="https://openapi-generator.tech/img/companies/ssstwitter.png" width="128" height="128">](https://ssstwitter.com/?utm_source=github&utm_medium=referral&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/svix.png" width="128" height="128">](https://www.svix.com/?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
[<img src="https://openapi-generator.tech/img/companies/litslink.png" width="128" height="128">](https://litslink.com/services/artificial-intelligence?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
[<img src="https://openapi-generator.tech/img/companies/designli.jpg" width="128" height="128">](https://designli.co?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS, Checkly for sponsoring the API monitoring and Gradle for sponsoring Develocity

View File

@@ -43,23 +43,30 @@ build_script:
#- dotnet build samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\Org.OpenAPITools.sln
test_script:
# test c# API client (multiple frameworks)
- dotnet test samples\client\petstore\csharp\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (httpclient)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-httpclient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (generichost)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-generichost-netstandard2.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (netcore)
- dotnet test samples\client\petstore\csharp\OpenAPIClientCore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
#- dotnet test samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net framework 4.7)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net framework 4.8)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net 5.0)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API Client using conditional-serialization
- dotnet test samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\AllOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\AnyOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\AnyOfNoCompare\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\FormModels\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualSourceGenerationTests\ManualTests.Latest.UseSourceGeneration\ManualTests.Latest.UseSourceGeneration.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualPetstoreTests\OpenAPIClient-generichost-manual-tests\OpenAPIClient-generichost-manual-tests.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\NullReferenceTypes\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\OneOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\SourceGeneration\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\httpclient\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\MultipleFrameworks\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net6\ParameterMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\EnumMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
### TODO: Execute all generators via powershell or other
# generate all petstore clients

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
outputDir: samples/client/petstore/csharp/generichost/net8/AllOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
@@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
outputDir: samples/client/petstore/csharp/generichost/net8/AnyOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
@@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -0,0 +1,13 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: false
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -0,0 +1,16 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/FormModels
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: false
equatable: true
targetFramework: net8.0
skipFormModel: false
inlineSchemaOptions:
RESOLVE_INLINE_ENUMS: true

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
outputDir: samples/client/petstore/csharp/generichost/net8/SourceGeneration
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
@@ -9,5 +9,5 @@ additionalProperties:
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
useSourceGeneration: true
packageName: UseSourceGeneration
equatable: true
targetFramework: net8.0

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt
outputDir: samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
@@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
outputDir: samples/client/petstore/csharp/generichost/net8/OneOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
@@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -1,9 +1,10 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
outputDir: samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}'
useDateTimeForDate: true
targetFramework: net8.0

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0
outputDir: samples/client/petstore/csharp/generichost/net8/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
@@ -10,3 +10,4 @@ additionalProperties:
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/OpenAPIClient-generichost-netstandard2.0
outputDir: samples/client/petstore/csharp/generichost/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp

View File

@@ -1,6 +1,6 @@
# for .net standard httpclient
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-httpclient
outputDir: samples/client/petstore/csharp/httpclient/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
library: httpclient

View File

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

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-net47
outputDir: samples/client/petstore/csharp/restsharp/net4.7/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-net48
outputDir: samples/client/petstore/csharp/restsharp/net4.8/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

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

View File

@@ -1,5 +1,5 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClientCore
outputDir: samples/client/petstore/csharp/restsharp/net7/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

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

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-net5.0
outputDir: samples/client/petstore/csharp/restsharp/net7/EnumMappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net Unity
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-unityWebRequest
outputDir: samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
library: unityWebRequest

View File

@@ -0,0 +1,7 @@
generatorName: java
outputDir: samples/client/others/java/jersey2-oneOf-duplicates
library: jersey2
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_duplicateArray.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: "true"

View File

@@ -0,0 +1,7 @@
generatorName: java
outputDir: samples/client/others/java/jersey2-oneOf-Mixed
library: jersey2
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_primitiveAndArray.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: "true"

View File

@@ -0,0 +1,9 @@
generatorName: spring
outputDir: samples/client/petstore/spring-cloud-auth
library: spring-cloud
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-auth.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
documentationProvider: none
artifactId: petstore-spring-cloud-auth
hideGenerationTimestamp: "true"

View File

@@ -1,10 +1,10 @@
---
# csharp test files and image for upload
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
sha256: e323c7e646a0ceb6d1d8f34f287175ac666fdbbe057791b45d138de3d9582666
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
sha256: 7dad88554fe630d25c787cae05305d302d5e34ca810aee4fa23f20055f9188e1
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/linux-logo.png"
sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
# java okhttp gson test files
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java"

View File

@@ -605,3 +605,10 @@ Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_CONTAINER_TO_NULLABLE="array|map"
```
- `SET_PRIMITIVE_TYPES_TO_NULLABLE`: When set to `string|integer|number|boolean` (or just `string`) for example, it will set the type to `nullable` (nullable: true)
Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_PRIMITIVE_TYPES_TO_NULLABLE="integer|number"
```

View File

@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>except</li>
<li>exec</li>
<li>false</li>
<li>field</li>
<li>finally</li>
<li>float</li>
<li>for</li>

View File

@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>except</li>
<li>exec</li>
<li>false</li>
<li>field</li>
<li>finally</li>
<li>float</li>
<li>for</li>

View File

@@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>except</li>
<li>exec</li>
<li>false</li>
<li>field</li>
<li>finally</li>
<li>float</li>
<li>for</li>

View File

@@ -88,6 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>except</li>
<li>exec</li>
<li>false</li>
<li>field</li>
<li>finally</li>
<li>float</li>
<li>for</li>

View File

@@ -401,7 +401,7 @@ class GenerateTaskDslTest : TestBase() {
fun `openApiValidate should fail on invalid spec`() {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
)
withProject(defaultBuildGradle, projectFiles)
@@ -423,7 +423,7 @@ class GenerateTaskDslTest : TestBase() {
fun `openApiValidate should ok skip spec validation`() {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
)
withProject("""

View File

@@ -113,7 +113,7 @@ class ValidateTaskDslTest : TestBase() {
fun `openApiValidate should fail on invalid spec`(gradleVersion: String?) {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
)
withProject(
"""
@@ -139,6 +139,50 @@ class ValidateTaskDslTest : TestBase() {
result.output.contains("Spec is invalid."),
"Unexpected/no message presented to the user for an invalid spec."
)
assertTrue(
result.output.contains("attribute info is missing"),
"Spec validation detail"
)
assertEquals(
FAILED, result.task(":openApiValidate")?.outcome,
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}"
)
}
@Test(dataProvider = "gradle_version_provider")
fun `openApiValidate should fail on invalid spec with duplicate 200 status code`(gradleVersion: String?) {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-duplicate-200-status-code.yaml")
)
withProject(
"""
| plugins {
| id 'org.openapi.generator'
| }
|
| openApiValidate {
| inputSpec = file('spec.yaml').absolutePath
| }
""".trimMargin(), projectFiles
)
// Act
val result = getGradleRunner(gradleVersion)
.withProjectDir(temp)
.withArguments("openApiValidate")
.withPluginClasspath()
.buildAndFail()
// Assert
assertTrue(
result.output.contains("Spec is invalid."),
"Unexpected/no message presented to the user for an invalid spec."
)
assertTrue(
result.output.contains("Duplicate field 200"),
"Spec validation detail"
)
assertEquals(
FAILED, result.task(":openApiValidate")?.outcome,
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}"
@@ -186,7 +230,7 @@ class ValidateTaskDslTest : TestBase() {
fun `validateBadSpec as defined task should fail on invalid spec`(gradleVersion: String?) {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid-due-to-missing-info-attribute.yaml")
)
withProject(
"""
@@ -212,6 +256,10 @@ class ValidateTaskDslTest : TestBase() {
result.output.contains("Spec is invalid."),
"Unexpected/no message presented to the user for an invalid spec."
)
assertTrue(
result.output.contains("attribute info is missing"),
"Unexpected/no message presented to the user for an invalid spec."
)
assertEquals(
FAILED, result.task(":validateBadSpec")?.outcome,
"Expected a failed run, but found ${result.task(":validateBadSpec")?.outcome}"

View File

@@ -0,0 +1,111 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
'200':
description: duplicate 200
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

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

View File

@@ -1139,6 +1139,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isEnum = isEnum;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{");

View File

@@ -43,6 +43,8 @@ public class CodegenSecurity {
// Oauth specific
public String flow, authorizationUrl, tokenUrl, refreshUrl;
public List<Map<String, Object>> scopes;
public Boolean hasScopes;
public Boolean isCode, isPassword, isApplication, isImplicit;
// OpenId specific
public String openIdConnectUrl;

View File

@@ -1092,7 +1092,7 @@ public class DefaultCodegen implements CodegenConfig {
addOneOfNameExtension(s, n);
}
} else if (ModelUtils.isArraySchema(s)) {
Schema items = ((ArraySchema) s).getItems();
Schema items = ModelUtils.getSchemaItems(s);
if (ModelUtils.isComposedSchema(items)) {
addOneOfNameExtension(items, nOneOf);
addOneOfInterfaceModel(items, nOneOf);
@@ -2065,8 +2065,7 @@ public class DefaultCodegen implements CodegenConfig {
}
return inner;
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String inner = getSchemaType(getSchemaItems(arraySchema));
String inner = getSchemaType(ModelUtils.getSchemaItems(schema));
String parentType;
if (ModelUtils.isSet(schema)) {
parentType = "set";
@@ -2372,15 +2371,7 @@ public class DefaultCodegen implements CodegenConfig {
}
protected Schema<?> getSchemaItems(ArraySchema schema) {
Schema<?> items = schema.getItems();
if (items == null) {
LOGGER.error("Undefined array inner type for `{}`. Default to String.", schema.getName());
items = new StringSchema().description("TODO default missing array inner type to string");
schema.setItems(items);
}
return items;
}
protected Schema<?> getSchemaAdditionalProperties(Schema schema) {
Schema<?> inner = ModelUtils.getAdditionalProperties(schema);
@@ -2464,6 +2455,14 @@ public class DefaultCodegen implements CodegenConfig {
protected String getSingleSchemaType(Schema schema) {
Schema unaliasSchema = unaliasSchema(schema);
if (ModelUtils.isRefToSchemaWithProperties(unaliasSchema.get$ref())) {
// ref to schema's properties, e.g. #/components/schemas/Pet/properties/category
Schema refSchema = ModelUtils.getReferencedSchema(openAPI, unaliasSchema);
if (refSchema != null) {
return getSingleSchemaType(refSchema);
}
}
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
// get the schema/model name from $ref
String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
@@ -3354,7 +3353,7 @@ public class DefaultCodegen implements CodegenConfig {
String modelName = ModelUtils.getSimpleRef(((Schema) oneOf).get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) oneOf, discPropName, visitedSchemas);
if (thisCp == null) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName);
}
@@ -3363,7 +3362,7 @@ public class DefaultCodegen implements CodegenConfig {
continue;
}
if (cp != thisCp) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the OneOf schema '{}' has a different {} definition than the prior OneOf schema's. Make sure the {} type and required values are the same",
composedSchemaName, discPropName, modelName, discPropName, discPropName);
}
@@ -3377,7 +3376,7 @@ public class DefaultCodegen implements CodegenConfig {
String modelName = ModelUtils.getSimpleRef(((Schema) anyOf).get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) anyOf, discPropName, visitedSchemas);
if (thisCp == null) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName);
}
@@ -3386,7 +3385,7 @@ public class DefaultCodegen implements CodegenConfig {
continue;
}
if (cp != thisCp) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the AnyOf schema '{}' has a different {} definition than the prior AnyOf schema's. Make sure the {} type and required values are the same",
composedSchemaName, discPropName, modelName, discPropName, discPropName);
}
@@ -3454,7 +3453,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if (discriminatorsPropNames.size() > 1) {
LOGGER.warn("The oneOf schemas have conflicting discriminator property names. " +
once(LOGGER).warn("The oneOf schemas have conflicting discriminator property names. " +
"oneOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
}
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getOneOf().size() && discriminatorsPropNames.size() == 1) {
@@ -3483,7 +3482,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if (discriminatorsPropNames.size() > 1) {
LOGGER.warn("The anyOf schemas have conflicting discriminator property names. " +
once(LOGGER).warn("The anyOf schemas have conflicting discriminator property names. " +
"anyOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
}
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getAnyOf().size() && discriminatorsPropNames.size() == 1) {
@@ -3532,7 +3531,7 @@ public class DefaultCodegen implements CodegenConfig {
// schemas also has inline composed schemas
// Note: if it is only inline one level, then the inline model resolver will move it into its own
// schema and make it a $ref schema in the oneOf/anyOf location
LOGGER.warn(
once(LOGGER).warn(
"Invalid inline schema defined in oneOf/anyOf in '{}'. Per the OpenApi spec, for this case when a composed schema defines a discriminator, the oneOf/anyOf schemas must use $ref. Change this inline definition to a $ref definition",
composedSchemaName);
}
@@ -3554,14 +3553,14 @@ public class DefaultCodegen implements CodegenConfig {
msgSuffix += spacer + "invalid optional definition of " + discPropName + ", include it in required";
}
}
LOGGER.warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
once(LOGGER).warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
composedSchemaName, discPropName, modelName, msgSuffix);
}
MappedModel mm = new MappedModel(modelName, toModelName(modelName));
descendentSchemas.add(mm);
Schema cs = ModelUtils.getSchema(openAPI, modelName);
if (cs == null) { // cannot lookup the model based on the name
LOGGER.error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
once(LOGGER).error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
} else {
Map<String, Object> vendorExtensions = cs.getExtensions();
if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) {
@@ -3674,7 +3673,7 @@ public class DefaultCodegen implements CodegenConfig {
if (e.getValue().indexOf('/') >= 0) {
name = ModelUtils.getSimpleRef(e.getValue());
if (ModelUtils.getSchema(openAPI, name) == null) {
LOGGER.error("Failed to lookup the schema '{}' when processing the discriminator mapping of oneOf/anyOf. Please check to ensure it's defined properly.", name);
once(LOGGER).error("Failed to lookup the schema '{}' when processing the discriminator mapping of oneOf/anyOf. Please check to ensure it's defined properly.", name);
}
} else {
name = e.getValue();
@@ -3975,7 +3974,7 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.error("Undefined property/schema for `{}`. Default to type:string.", name);
return null;
}
LOGGER.debug("debugging fromProperty for {} : {}", name, p);
LOGGER.debug("debugging fromProperty for {}: {}", name, p);
NamedSchema ns = new NamedSchema(name, p, required, schemaIsFromAdditionalProperties);
CodegenProperty cpc = schemaCodegenPropertyCache.get(ns);
if (cpc != null) {
@@ -3983,6 +3982,13 @@ public class DefaultCodegen implements CodegenConfig {
return cpc;
}
// if it's ref to schema's properties, get the actual schema defined in the properties
Schema refToPropertiesSchema = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, p.get$ref());
if (refToPropertiesSchema != null) {
p = refToPropertiesSchema;
return fromProperty(name, refToPropertiesSchema, required, schemaIsFromAdditionalProperties);
}
Schema original = null;
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level
if (ModelUtils.isAllOf(p) && p.getAllOf().size() == 1) {
@@ -4175,8 +4181,7 @@ public class DefaultCodegen implements CodegenConfig {
// handle inner property
String itemName = getItemsName(p, name);
ArraySchema arraySchema = (ArraySchema) p;
Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema));
Schema innerSchema = unaliasSchema(ModelUtils.getSchemaItems(p));
CodegenProperty cp = fromProperty(itemName, innerSchema, false);
updatePropertyForArray(property, cp);
} else if (ModelUtils.isTypeObjectSchema(p)) {
@@ -4486,8 +4491,7 @@ public class DefaultCodegen implements CodegenConfig {
CodegenProperty cm = fromProperty("response", responseSchema, false);
if (ModelUtils.isArraySchema(responseSchema)) {
ArraySchema as = (ArraySchema) responseSchema;
CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as), false);
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getSchemaItems(responseSchema), false);
op.returnBaseType = innerProperty.baseType;
} else if (ModelUtils.isMapSchema(responseSchema)) {
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema), false);
@@ -5012,8 +5016,7 @@ public class DefaultCodegen implements CodegenConfig {
r.isArray = true;
r.containerType = cp.containerType;
r.containerTypeMapped = typeMapping.get(cp.containerType);
ArraySchema as = (ArraySchema) responseSchema;
CodegenProperty items = fromProperty("response", getSchemaItems(as), false);
CodegenProperty items = fromProperty("response", ModelUtils.getSchemaItems(responseSchema), false);
r.setItems(items);
CodegenProperty innerCp = items;
@@ -5389,8 +5392,7 @@ public class DefaultCodegen implements CodegenConfig {
}
addVarsRequiredVarsAdditionalProps(parameterSchema, codegenParameter);
} else if (ModelUtils.isArraySchema(parameterSchema)) {
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
Schema inner = getSchemaItems(arraySchema);
Schema inner = ModelUtils.getSchemaItems(parameterSchema);
collectionFormat = getCollectionFormat(parameter);
// default to csv:
@@ -6780,6 +6782,7 @@ public class DefaultCodegen implements CodegenConfig {
enumVar.put("name", finalEnumName);
enumVar.put("value", toEnumValue(String.valueOf(value), dataType));
enumVar.put("isString", isDataTypeString(dataType));
// TODO: add isNumeric
enumVars.add(enumVar);
}
@@ -6802,6 +6805,7 @@ public class DefaultCodegen implements CodegenConfig {
enumVar.put("name", toEnumVarName(enumName, dataType));
enumVar.put("value", toEnumValue(enumValue, dataType));
enumVar.put("isString", isDataTypeString(dataType));
// TODO: add isNumeric
enumVars.add(enumVar);
}
@@ -6940,6 +6944,7 @@ public class DefaultCodegen implements CodegenConfig {
scopes.add(scope);
}
codegenSecurity.scopes = scopes;
codegenSecurity.hasScopes = true;
}
}
@@ -7199,7 +7204,9 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
codegenParameter.isContainer = codegenProperty.isContainer;
codegenParameter.containerType = codegenProperty.containerType;
codegenParameter.containerTypeMapped = codegenProperty.containerTypeMapped;
codegenParameter.dataFormat = codegenProperty.dataFormat;
// non-array/map
updateCodegenPropertyEnum(codegenProperty);
@@ -7266,19 +7273,27 @@ public class DefaultCodegen implements CodegenConfig {
}
}
} else if (ModelUtils.isTypeObjectSchema(ps)) {
if (ModelUtils.isFreeFormObject(ps)) {
if (ModelUtils.isMapSchema(ps)) {
codegenParameter.isMap = true;
codegenParameter.additionalProperties = codegenProperty.additionalProperties;
codegenParameter.setAdditionalPropertiesIsAnyType(codegenProperty.getAdditionalPropertiesIsAnyType());
codegenParameter.items = codegenProperty.items;
codegenParameter.isPrimitiveType = false;
codegenParameter.items = codegenProperty.items;
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
} else if (ModelUtils.isFreeFormObject(ps)) {
codegenParameter.isFreeFormObject = true;
}
} else if (ModelUtils.isNullType(ps)) {
} else if (ModelUtils.isAnyType(ps)) {
// any schema with no type set, composed schemas often do this
} else if (ModelUtils.isArraySchema(ps)) {
Schema inner = getSchemaItems((ArraySchema) ps);
Schema inner = ModelUtils.getSchemaItems(ps);
CodegenProperty arrayInnerProperty = fromProperty("inner", inner, false);
codegenParameter.isArray = true;
codegenParameter.items = arrayInnerProperty;
codegenParameter.mostInnerItems = arrayInnerProperty.mostInnerItems;
codegenParameter.isPrimitiveType = false;
codegenParameter.isContainer = true;
// hoist items data into the array property
// TODO this hoisting code is generator specific and should be isolated into updateFormPropertyForArray
codegenParameter.baseType = arrayInnerProperty.dataType;
@@ -7554,11 +7569,10 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isGenerateAliasAsModel(schema) && StringUtils.isNotBlank(name)) {
this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true);
} else {
final ArraySchema arraySchema = (ArraySchema) schema;
Schema inner = getSchemaItems(arraySchema);
CodegenProperty codegenProperty = fromProperty("property", arraySchema, false);
Schema inner = ModelUtils.getSchemaItems(schema);
CodegenProperty codegenProperty = fromProperty("property", schema, false);
if (codegenProperty == null) {
throw new RuntimeException("CodegenProperty cannot be null. arraySchema for debugging: " + arraySchema);
throw new RuntimeException("CodegenProperty cannot be null. arraySchema for debugging: " + schema);
}
imports.add(codegenProperty.baseType);
@@ -7591,7 +7605,7 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.items = codegenProperty.items;
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
codegenParameter.dataType = getTypeDeclaration(arraySchema);
codegenParameter.dataType = getTypeDeclaration(schema);
codegenParameter.baseType = getSchemaType(inner);
codegenParameter.isContainer = Boolean.TRUE;
codegenParameter.isNullable = codegenProperty.isNullable;
@@ -8421,12 +8435,17 @@ public class DefaultCodegen implements CodegenConfig {
xOf.add(cp);
i += 1;
if (dataTypeSet.contains(cp.dataType)) {
if (dataTypeSet.contains(cp.dataType)
|| (isTypeErasedGenerics() && dataTypeSet.contains(cp.baseType))) {
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
// in other sub-schemas of allOf/anyOf/oneOf
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type", true);
} else {
dataTypeSet.add(cp.dataType);
if(isTypeErasedGenerics()) {
dataTypeSet.add(cp.baseType);
} else {
dataTypeSet.add(cp.dataType);
}
}
}
return xOf;
@@ -8463,11 +8482,16 @@ public class DefaultCodegen implements CodegenConfig {
return openapiGeneratorIgnoreList;
}
@Override
public boolean isTypeErasedGenerics() {
return false;
}
/*
A function to convert yaml or json ingested strings like property names
And convert special characters like newline, tab, carriage return
Into strings that can be rendered in the language that the generator will output to
*/
A function to convert yaml or json ingested strings like property names
And convert special characters like newline, tab, carriage return
Into strings that can be rendered in the language that the generator will output to
*/
protected String handleSpecialCharacters(String name) { return name; }
/**

View File

@@ -338,10 +338,9 @@ public class InlineModelResolver {
return;
}
// Check array items
if (schema instanceof ArraySchema) {
ArraySchema array = (ArraySchema) schema;
Schema items = array.getItems();
if (items == null && array.getPrefixItems() == null) {
if (ModelUtils.isArraySchema(schema)) {
Schema items = ModelUtils.getSchemaItems(schema);
if (items == null && schema.getPrefixItems() == null) {
LOGGER.debug("Incorrect array schema with no items, prefixItems: {}", schema.toString());
return;
}
@@ -357,7 +356,7 @@ public class InlineModelResolver {
if (isModelNeeded(items)) {
// If this schema should be split into its own model, do so
array.setItems(this.makeSchemaInComponents(schemaName, items));
schema.setItems(this.makeSchemaInComponents(schemaName, items));
}
}
// Check allOf, anyOf, oneOf for inline models
@@ -788,9 +787,8 @@ public class InlineModelResolver {
propsToUpdate.put(key, schema);
modelsToAdd.put(modelName, model);
}
} else if (property instanceof ArraySchema) {
ArraySchema ap = (ArraySchema) property;
Schema inner = ap.getItems();
} else if (ModelUtils.isArraySchema(property)) {
Schema inner = ModelUtils.getSchemaItems(property);
if (inner instanceof ObjectSchema) {
ObjectSchema op = (ObjectSchema) inner;
if (op.getProperties() != null && op.getProperties().size() > 0) {
@@ -801,12 +799,12 @@ public class InlineModelResolver {
if (existing != null) {
Schema schema = new Schema().$ref(existing);
schema.setRequired(op.getRequired());
ap.setItems(schema);
property.setItems(schema);
} else {
modelName = addSchemas(modelName, innerModel);
Schema schema = new Schema().$ref(modelName);
schema.setRequired(op.getRequired());
ap.setItems(schema);
property.setItems(schema);
}
}
} else if (ModelUtils.isComposedSchema(inner)) {
@@ -815,7 +813,7 @@ public class InlineModelResolver {
innerModelName = addSchemas(innerModelName, inner);
Schema schema = new Schema().$ref(innerModelName);
schema.setRequired(inner.getRequired());
ap.setItems(schema);
property.setItems(schema);
} else {
LOGGER.debug("Schema not yet handled in model resolver: {}", inner);
}

View File

@@ -38,6 +38,8 @@ public class OpenAPINormalizer {
private Map<String, String> inputRules = new HashMap<>();
private Map<String, Boolean> rules = new HashMap<>();
private TreeSet<String> anyTypeTreeSet = new TreeSet<>();
final Logger LOGGER = LoggerFactory.getLogger(OpenAPINormalizer.class);
Set<String> ruleNames = new TreeSet<>();
@@ -112,6 +114,14 @@ public class OpenAPINormalizer {
boolean updateSetToNullable;
boolean updateMapToNullable;
// when set (e.g. operationId:getPetById|addPet), filter out (or remove) everything else
final String SET_PRIMITIVE_TYPES_TO_NULLABLE = "SET_PRIMITIVE_TYPES_TO_NULLABLE";
HashSet<String> setPrimitiveTypesToNullable = new HashSet<>();
boolean updateStringToNullable;
boolean updateIntegerToNullable;
boolean updateNumberToNullable;
boolean updateBooleanToNullable;
// ============= end of rules =============
/**
@@ -143,12 +153,23 @@ public class OpenAPINormalizer {
ruleNames.add(NORMALIZE_31SPEC);
ruleNames.add(REMOVE_X_INTERNAL);
ruleNames.add(FILTER);
ruleNames.add(SET_CONTAINER_TO_NULLABLE);
ruleNames.add(SET_PRIMITIVE_TYPES_TO_NULLABLE);
// rules that are default to true
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
processRules(inputRules);
// represent any type in tree set
anyTypeTreeSet.add("string");
anyTypeTreeSet.add("number");
anyTypeTreeSet.add("integer");
anyTypeTreeSet.add("boolean");
anyTypeTreeSet.add("object");
anyTypeTreeSet.add("array");
}
/**
@@ -223,6 +244,26 @@ public class OpenAPINormalizer {
LOGGER.error("SET_CONTAINER_TO_NULLABLE rule must be in the form of `array|set|map`, e.g. `set`, `array|map`: {}", inputRules.get(SET_CONTAINER_TO_NULLABLE));
}
}
if (inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE) != null) {
rules.put(SET_PRIMITIVE_TYPES_TO_NULLABLE, true);
setPrimitiveTypesToNullable = new HashSet<>(Arrays.asList(inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE).split("[|]")));
if (setPrimitiveTypesToNullable.contains("string")) {
updateStringToNullable = true;
}
if (setPrimitiveTypesToNullable.contains("integer")) {
updateIntegerToNullable = true;
}
if (setPrimitiveTypesToNullable.contains("number")) {
updateNumberToNullable = true;
}
if (setPrimitiveTypesToNullable.contains("boolean")) {
updateBooleanToNullable = true;
}
if (!updateStringToNullable && !updateIntegerToNullable && !updateNumberToNullable && !updateBooleanToNullable) {
LOGGER.error("SET_PRIMITIVE_TYPES_TO_NULLABLE rule must be in the form of `string|integer|number|boolean`, e.g. `string`, `integer|number`: {}", inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE));
}
}
}
/**
@@ -458,7 +499,7 @@ public class OpenAPINormalizer {
}
if (StringUtils.isNotEmpty(schema.get$ref())) {
// not need to process $ref
// no need to process $ref
return schema;
}
@@ -468,9 +509,10 @@ public class OpenAPINormalizer {
visitedSchemas.add(schema);
}
if (schema instanceof ArraySchema) { // array
normalizeArraySchema(schema);
normalizeSchema(schema.getItems(), visitedSchemas);
if (ModelUtils.isArraySchema(schema)) { // array
Schema result = normalizeArraySchema(schema);
normalizeSchema(result.getItems(), visitedSchemas);
return result;
} else if (schema.getAdditionalProperties() instanceof Schema) { // map
normalizeMapSchema(schema);
normalizeSchema((Schema) schema.getAdditionalProperties(), visitedSchemas);
@@ -525,7 +567,8 @@ public class OpenAPINormalizer {
}
private Schema normalizeArraySchema(Schema schema) {
return processSetArraytoNullable(schema);
Schema result = processNormalize31Spec(schema, new HashSet<>());
return processSetArraytoNullable(result);
}
private Schema normalizeMapSchema(Schema schema) {
@@ -533,15 +576,18 @@ public class OpenAPINormalizer {
}
private Schema normalizeSimpleSchema(Schema schema, Set<Schema> visitedSchemas) {
return processNormalize31Spec(schema, visitedSchemas);
Schema result = processNormalize31Spec(schema, visitedSchemas);
return processSetPrimitiveTypesToNullable(result);
}
private void normalizeBooleanSchema(Schema schema, Set<Schema> visitedSchemas) {
processSimplifyBooleanEnum(schema);
processSetPrimitiveTypesToNullable(schema);
}
private void normalizeIntegerSchema(Schema schema, Set<Schema> visitedSchemas) {
processAddUnsignedToIntegerWithInvalidMaxValue(schema);
processSetPrimitiveTypesToNullable(schema);
}
private void normalizeProperties(Map<String, Schema> properties, Set<Schema> visitedSchemas) {
@@ -550,7 +596,7 @@ public class OpenAPINormalizer {
}
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
Schema property = propertiesEntry.getValue();
Schema newProperty = normalizeSchema(property, visitedSchemas);
Schema newProperty = normalizeSchema(property, new HashSet<>());
propertiesEntry.setValue(newProperty);
}
}
@@ -888,6 +934,27 @@ public class OpenAPINormalizer {
List<Schema> oneOfSchemas = schema.getOneOf();
if (oneOfSchemas != null) {
// simplify any type with 6 sub-schemas (string, integer, etc) in oneOf
if (oneOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: oneOfSchemas) {
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
Schema anyType = new Schema();
anyType.setDescription(schema.getDescription());
anyType.setNullable(schema.getNullable());
anyType.setExtensions(schema.getExtensions());
anyType.setTitle(schema.getTitle());
anyType.setExample(schema.getExample());
anyType.setExamples(schema.getExamples());
anyType.setDefault(schema.getDefault());
anyType.setDeprecated(schema.getDeprecated());
return anyType;
}
}
if (oneOfSchemas.removeIf(oneOf -> isNullTypeSchema(oneOf))) {
schema.setNullable(true);
@@ -917,25 +984,49 @@ public class OpenAPINormalizer {
if (Boolean.TRUE.equals(schema.getUniqueItems())) { // a set
if (updateSetToNullable) {
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
// already set, don't overwrite
return schema;
}
schema.setNullable(true);
return setNullable(schema);
}
} else { // array
if (updateArrayToNullable) {
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
// already set, don't overwrite
return schema;
}
schema.setNullable(true);
return setNullable(schema);
}
}
return schema;
}
/**
* Set nullable to true in primitive types (e.g. string) if needed.
*
* @param schema Schema
* @return Schema
*/
private Schema processSetPrimitiveTypesToNullable(Schema schema) {
if (!getRule(SET_PRIMITIVE_TYPES_TO_NULLABLE)) {
return schema;
}
if (updateStringToNullable && "string".equals(schema.getType())) {
return setNullable(schema);
} else if (updateIntegerToNullable && "integer".equals(schema.getType())) {
return setNullable(schema);
} else if (updateNumberToNullable && "number".equals(schema.getType())) {
return setNullable(schema);
} else if (updateBooleanToNullable && "boolean".equals(schema.getType())) {
return setNullable(schema);
}
return schema;
}
private Schema setNullable(Schema schema) {
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
// already set, don't overwrite
return schema;
}
schema.setNullable(true);
return schema;
}
/**
* Set nullable to true in map if needed.
*
@@ -948,11 +1039,7 @@ public class OpenAPINormalizer {
}
if (updateMapToNullable) {
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
// already set, don't override
return schema;
}
schema.setNullable(true);
return setNullable(schema);
}
return schema;
@@ -972,6 +1059,27 @@ public class OpenAPINormalizer {
List<Schema> anyOfSchemas = schema.getAnyOf();
if (anyOfSchemas != null) {
// simplify any type with 6 sub-schemas (string, integer, etc) in anyOf
if (anyOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: anyOfSchemas) {
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
Schema anyType = new Schema();
anyType.setDescription(schema.getDescription());
anyType.setNullable(schema.getNullable());
anyType.setExtensions(schema.getExtensions());
anyType.setTitle(schema.getTitle());
anyType.setExample(schema.getExample());
anyType.setExamples(schema.getExamples());
anyType.setDefault(schema.getDefault());
anyType.setDeprecated(schema.getDeprecated());
return anyType;
}
}
if (anyOfSchemas.removeIf(anyOf -> isNullTypeSchema(anyOf))) {
schema.setNullable(true);
}
@@ -1116,7 +1224,7 @@ public class OpenAPINormalizer {
// only one item (type) left
if (schema.getTypes().size() == 1) {
String type = String.valueOf(schema.getTypes().iterator().next());
if ("array".equals(type)) {
if (ModelUtils.isArraySchema(schema)) {
ArraySchema as = new ArraySchema();
as.setDescription(schema.getDescription());
as.setDefault(schema.getDefault());

View File

@@ -84,10 +84,9 @@ public class ExampleGenerator {
}
if (ModelUtils.isArraySchema(responseSchema)) { // array of schema
ArraySchema as = (ArraySchema) responseSchema;
if (as.getItems() != null) { // array of primitive types
if (ModelUtils.getSchemaItems(responseSchema) != null) { // array of primitive types
return generate((Map<String, Object>) responseSchema.getExample(),
new ArrayList<>(producesInfo), as);
new ArrayList<>(producesInfo), responseSchema);
} else {
// TODO log warning message as such case is not handled at the moment
return null;
@@ -248,9 +247,9 @@ public class ExampleGenerator {
}
return Boolean.TRUE;
} else if (ModelUtils.isArraySchema(property)) {
Schema innerType = ((ArraySchema) property).getItems();
Schema innerType = ModelUtils.getSchemaItems(property);
if (innerType != null) {
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
int arrayLength = null == property.getMaxItems() ? 2 : property.getMaxItems();
// avoid memory issues by limiting to max. 5 items
arrayLength = Math.min(arrayLength, 5);
Object[] objectProperties = new Object[arrayLength];

View File

@@ -128,8 +128,7 @@ public class XmlExampleGenerator {
StringBuilder sb = new StringBuilder();
if (ModelUtils.isArraySchema(schema)) {
ArraySchema as = (ArraySchema) schema;
Schema inner = as.getItems();
Schema inner = ModelUtils.getSchemaItems(schema);
boolean wrapped = false;
if (schema.getXml() != null && schema.getXml().getWrapped() != null && schema.getXml().getWrapped()) {
wrapped = true;

View File

@@ -532,8 +532,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
}
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
String itemType = getTypeDeclaration(inner);
if (itemType.startsWith("OpenAPI.")) {
return itemType + "_Vector";

View File

@@ -188,10 +188,9 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
if (inner == null) {
LOGGER.warn("{}(array property) does not have a proper inner type defined", ap.getName());
LOGGER.warn("{}(array property) does not have a proper inner type defined", p.getName());
// TODO maybe better defaulting to StringProperty than returning null
return null;
}
@@ -220,13 +219,12 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isArraySchema(p)) {
final ArraySchema ap = (ArraySchema) p;
final String pattern = "new ArrayList<%s>()";
if (ap.getItems() == null) {
if (ModelUtils.getSchemaItems(p) == null) {
return null;
}
return String.format(Locale.ROOT, pattern, getTypeDeclaration(ap.getItems()));
return String.format(Locale.ROOT, pattern, getTypeDeclaration(ModelUtils.getSchemaItems(p)));
} else if (ModelUtils.isMapSchema(p)) {
final MapSchema ap = (MapSchema) p;
final String pattern = "new HashMap<%s>()";
@@ -318,7 +316,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
if (ModelUtils.isArraySchema(p)) {
example = "new " + getTypeDeclaration(p) + "{" + toExampleValue(
((ArraySchema) p).getItems()) + "}";
ModelUtils.getSchemaItems(p)) + "}";
} else if (ModelUtils.isBooleanSchema(p)) {
example = String.valueOf(!"false".equals(example));
} else if (ModelUtils.isByteArraySchema(p)) {

View File

@@ -585,7 +585,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
List<CodegenProperty> allOf = composedSchemas.getAllOf();
if (allOf != null) {
for (CodegenProperty property : allOf) {
property.name = patchPropertyName(model, property.baseType);
property.name = patchPropertyName(model, camelize(property.baseType));
patchPropertyVendorExtensions(property);
}
}
@@ -594,7 +594,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (anyOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, anyOf);
for (CodegenProperty property : anyOf) {
property.name = patchPropertyName(model, property.baseType);
property.name = patchPropertyName(model, camelize(property.baseType));
property.isNullable = true;
patchPropertyVendorExtensions(property);
}
@@ -604,7 +604,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (oneOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, oneOf);
for (CodegenProperty property : oneOf) {
property.name = patchPropertyName(model, property.baseType);
property.name = patchPropertyName(model, camelize(property.baseType));
property.isNullable = true;
patchPropertyVendorExtensions(property);
}
@@ -734,6 +734,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
});
}
String[] numericTypes = {"double", "double?", "decimal", "decimal", "float", "float?", "int", "int?", "long", "long?", "ulong", "ulong?"};
enumVars.forEach((enumVar) -> {
enumVar.put("isNumeric", Arrays.stream(numericTypes).anyMatch(dataType::equals));
});
return enumVars;
}
@@ -1428,12 +1433,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
* @param arr The input array property
* @return The type declaration when the type is an array of arrays.
*/
private String getArrayTypeDeclaration(ArraySchema arr) {
private String getArrayTypeDeclaration(Schema arr) {
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
// This supports arrays of arrays.
String arrayType = typeMapping.get("array");
StringBuilder instantiationType = new StringBuilder(arrayType);
Schema items = arr.getItems();
Schema items = ModelUtils.getSchemaItems(arr);
String nestedType = getTypeDeclaration(items);
// TODO: We may want to differentiate here between generics and primitive arrays.
instantiationType.append("<").append(nestedType).append(">");
@@ -1443,7 +1448,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
@Override
public String toInstantiationType(Schema p) {
if (ModelUtils.isArraySchema(p)) {
return getArrayTypeDeclaration((ArraySchema) p);
return getArrayTypeDeclaration(p);
}
return super.toInstantiationType(p);
}
@@ -1451,7 +1456,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
return getArrayTypeDeclaration((ArraySchema) p);
return getArrayTypeDeclaration(p);
} else if (ModelUtils.isMapSchema(p)) {
// Should we also support maps of maps?
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -512,7 +512,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema);
Schema<?> items = ModelUtils.getSchemaItems(schema);
return getSchemaType(target) + "<" + getTypeDeclaration(items) + ">";
}
if (ModelUtils.isMapSchema(target)) {

View File

@@ -293,8 +293,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "LIST [" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -578,8 +577,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
// String inner = toModelName(getSchemaType(additionalProperties2));
// return instantiationTypes.get("map") + " [" + inner + "]";
// } else if (ModelUtils.isArraySchema(p)) {
// ArraySchema ap = (ArraySchema) p;
// String inner = toModelName(getSchemaType(ap.getItems()));
// String inner = toModelName(getSchemaType(ModelUtils.getSchemaItems(p)));
// return instantiationTypes.get("array") + " [" + inner + "]";
// } else {
// return null;

View File

@@ -855,12 +855,12 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
* @param arr The input array property
* @return The type declaration when the type is an array of arrays.
*/
private String getArrayTypeDeclaration(ArraySchema arr) {
private String getArrayTypeDeclaration(Schema arr) {
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
// This supports arrays of arrays.
String arrayType = typeMapping.get("array");
StringBuilder instantiationType = new StringBuilder(arrayType);
Schema items = arr.getItems();
Schema items = ModelUtils.getSchemaItems(arr);
String nestedType = getTypeDeclaration(items);
// TODO: We may want to differentiate here between generics and primitive arrays.
return nestedType + "[]";
@@ -869,7 +869,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
@Override
public String toInstantiationType(Schema p) {
if (ModelUtils.isArraySchema(p)) {
return getArrayTypeDeclaration((ArraySchema) p);
return getArrayTypeDeclaration(p);
}
return super.toInstantiationType(p);
}
@@ -877,7 +877,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
return getArrayTypeDeclaration((ArraySchema) p);
return getArrayTypeDeclaration(p);
} else if (ModelUtils.isMapSchema(p)) {
// Should we also support maps of maps?
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -360,8 +360,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
// In OAS 3.0.x, the array "items" attribute is required.
// In OAS >= 3.1, the array "items" attribute is optional such that the OAS
// specification is aligned with the JSON schema specification.

View File

@@ -273,8 +273,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Object ap = p.getAdditionalProperties();

View File

@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
@@ -666,6 +667,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.setContainerDefaultToNull(Boolean.parseBoolean(additionalProperties.get(CONTAINER_DEFAULT_TO_NULL).toString()));
}
additionalProperties.put(CONTAINER_DEFAULT_TO_NULL, containerDefaultToNull);
additionalProperties.put("sanitizeGeneric", (Mustache.Lambda) (fragment, writer) -> {
String content = fragment.execute();
for (final String s: List.of("<", ">", ",", " ")) {
content = content.replace(s, "");
}
writer.write(content);
});
}
@Override
@@ -937,7 +946,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema);
Schema<?> items = ModelUtils.getSchemaItems(schema);
return getSchemaType(target) + "<" + getBeanValidation(items) + getTypeDeclaration(items) + ">";
} else if (ModelUtils.isMapSchema(target)) {
// Note: ModelUtils.isMapSchema(p) returns true when p is a composed schema that also defines
@@ -1592,15 +1601,29 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
// additional import for different cases
addAdditionalImports(codegenModel, codegenModel.oneOf);
addAdditionalImports(codegenModel, codegenModel.anyOf);
addAdditionalImports(codegenModel, codegenModel.getComposedSchemas());
return codegenModel;
}
private void addAdditionalImports(CodegenModel model, Set<String> dataTypeSet) {
for (String dataType : dataTypeSet) {
if (null != importMapping().get(dataType)) {
model.imports.add(dataType);
private void addAdditionalImports(CodegenModel model, CodegenComposedSchemas composedSchemas) {
if(composedSchemas == null) {
return;
}
final List<List<CodegenProperty>> propertyLists = Arrays.asList(
composedSchemas.getAnyOf(),
composedSchemas.getOneOf(),
composedSchemas.getAllOf());
for(final List<CodegenProperty> propertyList : propertyLists){
if(propertyList == null)
{
continue;
}
for (CodegenProperty cp : propertyList) {
final String dataType = cp.baseType;
if (null != importMapping().get(dataType)) {
model.imports.add(dataType);
}
}
}
}
@@ -2507,4 +2530,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
imports.add(importsItem);
}
}
@Override
public boolean isTypeErasedGenerics() {
return true;
}
}

View File

@@ -346,8 +346,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
@Override
public String getTypeDeclaration(Schema schema) {
if (ModelUtils.isArraySchema(schema)) {
ArraySchema ap = (ArraySchema) schema;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(schema);
return getSchemaType(schema) + "{" + getTypeDeclaration(inner) + "}";
} else if (ModelUtils.isSet(schema)) {
Schema inner = ModelUtils.getAdditionalProperties(schema);

View File

@@ -359,7 +359,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema);
Schema<?> items = ModelUtils.getSchemaItems( schema);
return getSchemaType(target) + "<" + getTypeDeclaration(items) + ">";
} else if (ModelUtils.isMapSchema(target)) {
// Note: ModelUtils.isMapSchema(p) returns true when p is a composed schema that also defines
@@ -1104,7 +1104,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
StringBuilder defaultContent = new StringBuilder();
Schema<?> itemsSchema = getSchemaItems((ArraySchema) schema);
Schema<?> itemsSchema = ModelUtils.getSchemaItems(schema);
_default.elements().forEachRemaining((element) -> {
String defaultValue = element.asText();
if (defaultValue != null) {

View File

@@ -355,11 +355,10 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
if (inner == null) {
LOGGER.warn("{}(array property) does not have a proper inner type defined.Default to string",
ap.getName());
p.getName());
inner = new StringSchema().description("TODO default missing array inner type to string");
}
return getTypeDeclaration(inner) + "[]";

View File

@@ -105,6 +105,8 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
// from https://docs.python.org/3/reference/lexical_analysis.html#keywords
setReservedWordsLowerCase(
Arrays.asList(
// pydantic
"field",
// local variable name used in API methods (endpoints)
"all_params", "resource_path", "path_params", "query_params",
"header_params", "form_params", "local_var_files", "body_params", "auth_settings",
@@ -489,8 +491,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
includedSchemas.add(schema);
}
ArraySchema arrayschema = (ArraySchema) schema;
example = "[\n" + indentationString + toExampleValueRecursive(arrayschema.getItems(), includedSchemas, indentation + 1) + "\n" + indentationString + "]";
example = "[\n" + indentationString + toExampleValueRecursive(ModelUtils.getSchemaItems(schema), includedSchemas, indentation + 1) + "\n" + indentationString + "]";
} else if (ModelUtils.isMapSchema(schema)) {
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
includedSchemas.add(schema);
@@ -691,8 +692,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
p = ModelUtils.unaliasSchema(openAPI, p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "[" + getCollectionItemTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -351,8 +351,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -454,8 +454,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
includedSchemas.add(schema);
}
ArraySchema arrayschema = (ArraySchema) schema;
example = "[\n" + indentationString + toExampleValueRecursive(arrayschema.getItems(), includedSchemas, indentation + 1) + "\n" + indentationString + "]";
example = "[\n" + indentationString + toExampleValueRecursive(ModelUtils.getSchemaItems(schema), includedSchemas, indentation + 1) + "\n" + indentationString + "]";
} else if (ModelUtils.isMapSchema(schema)) {
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
includedSchemas.add(schema);
@@ -656,8 +655,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
p = ModelUtils.unaliasSchema(openAPI, p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -119,7 +119,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
@Override
public String getTypeDeclaration(Schema schema) {
if (ModelUtils.isArraySchema(schema)) {
Schema inner = ((ArraySchema) schema).getItems();
Schema inner = ModelUtils.getSchemaItems(schema);
return getSchemaType(schema) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(schema)) {
Schema inner = ModelUtils.getAdditionalProperties(schema);

View File

@@ -236,8 +236,7 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
String innerType = getTypeDeclaration(inner);
return typeMapping.get("array") + "<" + innerType + ">";
} else if (ModelUtils.isMapSchema(p)) {

View File

@@ -371,7 +371,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema);
Schema<?> items = ModelUtils.getSchemaItems(schema);
return getSchemaType(target) + "[" + getTypeDeclaration(items) + "]";
} else if (ModelUtils.isMapSchema(target)) {
Schema<?> inner = ModelUtils.getAdditionalProperties(target);
@@ -404,9 +404,8 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return instantiationTypes.get("map") + "[String, " + inner + "]";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
return (ModelUtils.isSet(ap) ? instantiationTypes.get("set") : instantiationTypes.get("array")) + "[" + inner + "]";
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
return (ModelUtils.isSet(p) ? instantiationTypes.get("set") : instantiationTypes.get("array")) + "[" + inner + "]";
} else {
return null;
}
@@ -433,10 +432,9 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "new HashMap[String, " + inner + "]() ";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
String genericType;
if (ModelUtils.isSet(ap)) {
if (ModelUtils.isSet(p)) {
genericType = instantiationTypes.get("set");
} else {
genericType = instantiationTypes.get("array");
@@ -475,8 +473,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
CodegenProperty prop = super.fromProperty(name, p, required);
if (ModelUtils.isArraySchema(p)) {
ArraySchema as = (ArraySchema) p;
if (ModelUtils.isSet(as)) {
if (ModelUtils.isSet(p)) {
prop.containerType = "set";
}
}

View File

@@ -624,7 +624,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
Schema<?> items = getSchemaItems((ArraySchema) p);
Schema<?> items = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<" + getTypeDeclaration(unaliasSchema(items)) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema<?> inner = getSchemaAdditionalProperties(p);
@@ -647,8 +647,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
// handle enums of various data types
Schema inner;
if (ModelUtils.isArraySchema(p)) {
ArraySchema mp1 = (ArraySchema) p;
inner = mp1.getItems();
inner = ModelUtils.getSchemaItems(p);
return this.getSchemaType(p) + "<" + this.getParameterDataType(parameter, inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
inner = ModelUtils.getAdditionalProperties(p);
@@ -1177,8 +1176,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
return filteredSchemas.stream().map(schema -> {
String schemaType = getSchemaType(schema);
if (ModelUtils.isArraySchema(schema)) {
ArraySchema ap = (ArraySchema) schema;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(schema);
schemaType = schemaType + "<" + getSchemaType(inner) + ">";
}
return schemaType;

View File

@@ -221,8 +221,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -223,7 +223,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
public String toDefaultValue(Schema p) {
String out = null;
if (ModelUtils.isArraySchema(p)) {
Schema inner = ((ArraySchema) p).getItems();
Schema inner = ModelUtils.getSchemaItems(p);
out = String.format(
Locale.ROOT,
"new List<%s>()",

View File

@@ -429,8 +429,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -1515,8 +1515,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
}
return instantiationTypes.get("map") + "<String, " + inner + ">";
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String inner = getSchemaType(arraySchema.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(schema));
return instantiationTypes.get("array") + "<" + inner + ">";
} else {
return null;

View File

@@ -1091,8 +1091,7 @@ public class CSharpReducedClientCodegen extends AbstractCSharpCodegen {
}
return instantiationTypes.get("map") + "<String, " + inner + ">";
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String inner = getSchemaType(arraySchema.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(schema));
return instantiationTypes.get("array") + "<" + inner + ">";
} else {
return null;

View File

@@ -165,10 +165,8 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
@Override
public String getTypeDeclaration(Schema p) {
if (p instanceof ArraySchema) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (ModelUtils.isArraySchema(p)) {
Schema inner = ModelUtils.getSchemaItems(p);
return "(s/coll-of " + getTypeDeclaration(inner) + ")";
} else if (ModelUtils.isMapSchema(p)) {
Object ap = p.getAdditionalProperties();

View File

@@ -108,8 +108,7 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -381,8 +381,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
String openAPIType = getSchemaType(p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
}
if (ModelUtils.isMapSchema(p)) {
@@ -474,8 +473,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "std::map<std::string, " + inner + ">()";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
if (!languageSpecificPrimitives.contains(inner)) {
inner = "std::shared_ptr<" + inner + ">";
}

View File

@@ -189,8 +189,7 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
String openAPIType = getSchemaType(p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -232,8 +231,7 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
Schema inner = ModelUtils.getAdditionalProperties(p);
return "QMap<QString, " + getTypeDeclaration(inner) + ">()";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "QList<" + getTypeDeclaration(inner) + ">()";
} else if (ModelUtils.isStringSchema(p)) {
return "QString(\"\")";

View File

@@ -367,8 +367,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
String openAPIType = getSchemaType(p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -407,8 +406,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "std::map<utility::string_t, " + inner + ">()";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
if (!languageSpecificPrimitives.contains(inner)) {
inner = "std::shared_ptr<" + inner + ">";
}

View File

@@ -379,8 +379,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
String openAPIType = getSchemaType(p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -469,12 +468,10 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "std::map<std::string, " + inner + ">()";
} else if (ModelUtils.isSet(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
return "std::set<" + inner + ">()";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
return "std::vector<" + inner + ">()";
} else if (ModelUtils.isModel(p)) {
String modelName = getTypeDeclaration(p);

View File

@@ -351,8 +351,7 @@ public class CppRestbedServerDeprecatedCodegen extends AbstractCppCodegen {
String openAPIType = getSchemaType(p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -433,8 +432,7 @@ public class CppRestbedServerDeprecatedCodegen extends AbstractCppCodegen {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "std::map<std::string, " + inner + ">()";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
if (!languageSpecificPrimitives.contains(inner)) {
inner = "std::shared_ptr<" + inner + ">";
}

View File

@@ -416,8 +416,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
String openAPIType = getSchemaType(p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
return getSchemaType(p) + "<" + getTypeDeclaration(ap.getItems()) + ">";
return getSchemaType(p) + "<" + getTypeDeclaration(ModelUtils.getSchemaItems(p)) + ">";
} else if (ModelUtils.isMapSchema(p)) {
return getSchemaType(p) + "<FString, " + getTypeDeclaration(ModelUtils.getAdditionalProperties(p)) + ">";
}

View File

@@ -814,7 +814,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
@Override
public String getTypeDeclaration(Schema schema) {
if (ModelUtils.isArraySchema(schema)) {
Schema inner = ((ArraySchema) schema).getItems();
Schema inner = ModelUtils.getSchemaItems(schema);
return getSchemaType(schema) + "(" + getTypeDeclaration(inner) + ")";
} else if (ModelUtils.isMapSchema(schema)) {
Schema inner = ModelUtils.getAdditionalProperties(schema);

View File

@@ -557,8 +557,7 @@ public class ElixirClientCodegen extends DefaultCodegen {
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -244,8 +244,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toInstantiationType(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
return instantiationTypes.get("array") + " " + inner;
} else {
return null;
@@ -464,8 +463,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getTypeDeclaration(inner);
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -141,7 +141,7 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
public CodegenModel fromModel(String name, Schema model) {
CodegenModel cm = super.fromModel(name, model);
if(ModelUtils.isArraySchema(model)) {
return new CodegenArrayModel(cm, (ArraySchema) model);
return new CodegenArrayModel(cm, model);
} else {
return cm;
}
@@ -156,12 +156,9 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
public String getTypeDeclaration(Schema schema) {
String typeDeclaration = super.getSchemaType(schema);
if(ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String complexType = getSchemaType(arraySchema.getItems());
String complexType = getSchemaType(ModelUtils.getSchemaItems(schema));
StringBuilder sb = new StringBuilder("list(");
sb.append(complexType);
return sb.append(")").toString();
} else if (typeMapping.containsKey(typeDeclaration)) {
return typeMapping.get(typeDeclaration);
@@ -174,8 +171,7 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
public String getSchemaType(Schema schema) {
String schemaType = super.getSchemaType(schema);
if(ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String complexType = getSchemaType(arraySchema.getItems());
String complexType = getSchemaType(ModelUtils.getSchemaItems(schema));
StringBuilder sb = new StringBuilder("list(");
sb.append(complexType);
@@ -446,7 +442,7 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
Integer minItems;
Integer maxItems;
public CodegenArrayModel(CodegenModel cm, ArraySchema schema) {
public CodegenArrayModel(CodegenModel cm, Schema schema) {
super();
// Copy all fields of CodegenModel

View File

@@ -124,8 +124,7 @@ public class GraphQLNodeJSExpressServerCodegen extends AbstractGraphQLCodegen im
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
// IMPORTANT NOTE we add the braces within template because there we have the possibility to differentiate
// between some specific types for GraphQL:

View File

@@ -653,8 +653,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -687,8 +686,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
String inner = getSchemaType(additionalProperties2);
return "(Map.Map Text " + inner + ")";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
return getSchemaType(ap.getItems());
return getSchemaType(ModelUtils.getSchemaItems(p));
} else {
return null;
}

View File

@@ -372,8 +372,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -419,8 +418,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
String inner = getSchemaType(additionalProperties2);
return "(Map.Map Text " + inner + ")";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
// Return only the inner type; the wrapping with QueryList is done
// somewhere else, where we have access to the collection format.
return inner;

View File

@@ -295,8 +295,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -342,8 +341,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
String inner = getSchemaType(additionalProperties2);
return "(Map.Map Text " + inner + ")";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
// Return only the inner type; the wrapping with QueryList is done
// somewhere else, where we have access to the collection format.
return inner;

View File

@@ -210,8 +210,7 @@ public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -610,8 +610,7 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -872,9 +871,9 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
codegenModel = JavascriptApolloClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
}
if (ModelUtils.isArraySchema(model)) {
ArraySchema am = (ArraySchema) model;
if (codegenModel != null && am.getItems() != null) {
String itemType = getSchemaType(am.getItems());
Schema inner = ModelUtils.getSchemaItems(model);
if (codegenModel != null && inner != null) {
String itemType = getSchemaType(inner);
codegenModel.vendorExtensions.put("x-is-array", true);
codegenModel.vendorExtensions.put("x-item-type", itemType);
}

View File

@@ -610,8 +610,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
@@ -874,9 +873,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
}
}
if (ModelUtils.isArraySchema(model)) {
ArraySchema am = (ArraySchema) model;
if (codegenModel != null && am.getItems() != null) {
String itemType = getSchemaType(am.getItems());
if (codegenModel != null && ModelUtils.getSchemaItems(model) != null) {
String itemType = getSchemaType(ModelUtils.getSchemaItems(model));
codegenModel.vendorExtensions.put("x-is-array", true);
codegenModel.vendorExtensions.put("x-item-type", itemType);
}

View File

@@ -225,8 +225,7 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getSchemaType(p) + "<!" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -109,11 +109,11 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
var additionalProperties = additionalProperties();
if(additionalProperties.containsKey(BODY_VARIABLES)) {
if (additionalProperties.containsKey(BODY_VARIABLES)) {
bodyVariables = Arrays.asList(additionalProperties.get(BODY_VARIABLES).toString().split("-"));
}
if(additionalProperties.containsKey(CUSTOM_HEADERS)) {
if (additionalProperties.containsKey(CUSTOM_HEADERS)) {
customHeaders = Arrays.asList(additionalProperties.get(CUSTOM_HEADERS).toString().split("&"));
}
}
@@ -138,15 +138,15 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationsMap results = super.postProcessOperationsWithModels(objs, allModels);
OperationsMap results = super.postProcessOperationsWithModels(objs, allModels);
OperationMap ops = results.getOperations();
List<CodegenOperation> opList = ops.getOperation();
for(CodegenOperation codegenOperation : opList) {
for (CodegenOperation codegenOperation : opList) {
List<RequestItem> requests = getRequests(codegenOperation);
if(requests != null) {
if (requests != null) {
codegenOperation.vendorExtensions.put("requests", requests);
//Adding to each operation for now, we may be smarter later on
codegenOperation.vendorExtensions.put("customHeaders", customHeaders);
@@ -158,7 +158,7 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
List<RequestItem> getRequests(CodegenOperation codegenOperation) {
List<RequestItem> items = new ArrayList<>();
if(codegenOperation.getHasBodyParam()) {
if (codegenOperation.getHasBodyParam()) {
// operation with bodyParam
if (requestParameterGeneration.equalsIgnoreCase("Schema")) {
// get from schema
@@ -173,7 +173,7 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
// find in components/examples
for (Map.Entry<String, Example> entry : codegenOperation.bodyParam.getContent().get("application/json").getExamples().entrySet()) {
String exampleRef = entry.getValue().get$ref();
if(exampleRef != null){
if (exampleRef != null) {
Example example = this.openAPI.getComponents().getExamples().get(extractExampleByName(exampleRef));
String exampleAsString = getJsonFromExample(example);
items.add(new RequestItem(example.getSummary(), exampleAsString));
@@ -200,11 +200,11 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
}
private List<RequestItem> handleCustomVariablesInRequests(List<RequestItem> items) {
if(!bodyVariables.isEmpty()){
for(var item : items){
for(var customVariable: bodyVariables){
if (!bodyVariables.isEmpty()) {
for (var item : items) {
for (var customVariable : bodyVariables) {
var body = item.getBody();
if(body != null){
if (body != null) {
body = body.replace(customVariable, "{{" + customVariable + "}}");
item.setBody(body);
}
@@ -269,7 +269,7 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + codegenProperty.baseName + JSON_ESCAPE_DOUBLE_QUOTE + ": " +
JSON_ESCAPE_DOUBLE_QUOTE + "<" + getType(codegenProperty) + ">" + JSON_ESCAPE_DOUBLE_QUOTE;
if(counter < numVars) {
if (counter < numVars) {
// add comma unless last attribute
ret = ret + "," + JSON_ESCAPE_NEW_LINE + " ";
}
@@ -283,9 +283,9 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
}
public String getType(CodegenProperty codegenProperty) {
if(codegenProperty.isNumeric) {
if (codegenProperty.isNumeric) {
return "number";
} else if(codegenProperty.isDate) {
} else if (codegenProperty.isDate) {
return "date";
} else {
return "string";
@@ -316,14 +316,14 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
public String getJsonFromExample(Example example) {
String ret = "";
if(example == null) {
if (example == null) {
return ret;
}
if(example.getValue() instanceof ObjectNode) {
ret = convertToJson((ObjectNode)example.getValue());
} else if(example.getValue() instanceof LinkedHashMap) {
ret = convertToJson((LinkedHashMap)example.getValue());
if (example.getValue() instanceof ObjectNode) {
ret = convertToJson((ObjectNode) example.getValue());
} else if (example.getValue() instanceof LinkedHashMap) {
ret = convertToJson((LinkedHashMap) example.getValue());
}
return ret;
@@ -350,9 +350,9 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
String key = mapElement.getKey();
Object value = mapElement.getValue();
if(value instanceof String) {
if (value instanceof String) {
// unescape double quotes already escaped
value = ((String)value).replace("\\\"", "\"");
value = ((String) value).replace("\\\"", "\"");
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " +
JSON_ESCAPE_DOUBLE_QUOTE + value + JSON_ESCAPE_DOUBLE_QUOTE;
@@ -369,20 +369,21 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
for (int i = 0; i < items.size(); i++) {
jsonBuilder.append(JSON_ESCAPE_DOUBLE_QUOTE).append(items.get(i)).append(JSON_ESCAPE_DOUBLE_QUOTE);
if (i < items.size() - 1) {jsonBuilder.append(",");}
if (i < items.size() - 1) {
jsonBuilder.append(",");
}
}
jsonBuilder.append("]");
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " + jsonBuilder ;
}
else {
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " + jsonBuilder;
} else {
LOGGER.warn("Value type unrecognised: " + value.getClass());
//WARNING: here we are undoing what is done in "add comma unless last attribute"
// This is meant to avoid dangling commas if we encounter an unknown type
ret = ret.substring(0, ret.length() - 3);
}
if(counter < numVars ) {
if (counter < numVars) {
// add comma unless last attribute
ret = ret + "," + JSON_ESCAPE_NEW_LINE + " ";
}
@@ -394,4 +395,13 @@ public class JetbrainsHttpClientClientCodegen extends DefaultCodegen implements
return ret;
}
}
@Override
public String escapeUnsafeCharacters(String input) {
return input;
}
@Override
public String escapeQuotationMark(String input) {
return input;
}
}

View File

@@ -383,8 +383,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
return getTypeDeclaration(inner);
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);

View File

@@ -513,7 +513,7 @@ public class N4jsClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
Schema<?> items = getSchemaItems((ArraySchema) p);
Schema<?> items = ModelUtils.getSchemaItems(p);
return getTypeDeclaration(unaliasSchema(items)) + "[]";
} else if (ModelUtils.isMapSchema(p)) {
return "~Object+";
@@ -544,8 +544,7 @@ public class N4jsClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String getParameterDataType(Parameter parameter, Schema p) {
// handle enums of various data types
if (ModelUtils.isArraySchema(p)) {
ArraySchema mp1 = (ArraySchema) p;
Schema<?> inner = mp1.getItems();
Schema<?> inner = ModelUtils.getSchemaItems(p);
return getParameterDataType(parameter, inner) + "[]";
} else if (ModelUtils.isMapSchema(p)) {
return "~Object+";

View File

@@ -275,8 +275,7 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
if (inner == null) {
return null;
}

View File

@@ -279,8 +279,8 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
}
private void collectEnumSchemas(String parentName, String sName, Schema schema) {
if (schema instanceof ArraySchema) {
collectEnumSchemas(parentName, sName, ((ArraySchema) schema).getItems());
if (ModelUtils.isArraySchema(schema)) {
collectEnumSchemas(parentName, sName, ModelUtils.getSchemaItems(schema));
} else if (schema instanceof MapSchema && schema.getAdditionalProperties() instanceof Schema) {
collectEnumSchemas(parentName, sName, (Schema) schema.getAdditionalProperties());
} else if (isEnumSchema(schema)) {
@@ -317,11 +317,10 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
collectEnumSchemas(pName, (Schema) schema.getAdditionalProperties());
}
if (schema instanceof ArraySchema) {
ArraySchema s = (ArraySchema) schema;
if (s.getItems() != null) {
if (ModelUtils.isArraySchema(schema)) {
if (ModelUtils.getSchemaItems(schema) != null) {
String pName = parentName != null ? parentName + "_" + sName : sName;
collectEnumSchemas(pName, s.getItems());
collectEnumSchemas(pName, ModelUtils.getSchemaItems(schema));
}
}
}
@@ -581,11 +580,10 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
Schema inner = ModelUtils.getSchemaItems(p);
if (inner == null) {
LOGGER.warn("{}(array property) does not have a proper inner type defined.Default to string",
ap.getName());
p.getName());
inner = new StringSchema().description("TODO default missing array inner type to string");
}
return getTypeDeclaration(inner) + " list";

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