Compare commits

...

23 Commits

Author SHA1 Message Date
William Cheng
d4cccf386d clean up 2024-04-03 14:11:38 +08:00
William Cheng
326f46baa3 code clean up/refacotring 2024-04-03 13:50:16 +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
5360 changed files with 75550 additions and 9608 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,16 @@ jobs:
fail-fast: false
matrix:
sample:
# clients
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
- samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
- samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
- samples/client/petstore/csharp/generichost/net8/AllOf
- samples/client/petstore/csharp/generichost/net8/AnyOf
- samples/client/petstore/csharp/generichost/net8/FormModels
- samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests
- samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests
- samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
- samples/client/petstore/csharp/generichost/net8/OneOf
- samples/client/petstore/csharp/generichost/net8/Petstore
- samples/client/petstore/csharp/generichost/net8/SourceGeneration
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

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

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,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

@@ -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

@@ -97,8 +97,6 @@ public class DefaultCodegen implements CodegenConfig {
private static final Cache<SanitizeNameOptions, String> sanitizedNameCache;
private static final String xSchemaTestExamplesKey = "x-schema-test-examples";
private static final String xSchemaTestExamplesRefPrefix = "#/components/x-schema-test-examples/";
protected static Schema falseSchema;
protected static Schema trueSchema = new Schema();
static {
DefaultFeatureSet = FeatureSet.newBuilder()
@@ -151,8 +149,6 @@ public class DefaultCodegen implements CodegenConfig {
.expireAfterAccess(cacheExpiry, TimeUnit.SECONDS)
.ticker(Ticker.systemTicker())
.build();
falseSchema = new Schema();
falseSchema.setNot(new Schema());
}
protected GeneratorMetadata generatorMetadata;
@@ -304,8 +300,6 @@ public class DefaultCodegen implements CodegenConfig {
// A cache to efficiently lookup schema `toModelName()` based on the schema Key
private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
protected boolean loadDeepObjectIntoItems = true;
// if true then baseTypes will be imported
protected boolean importBaseType = true;
@@ -2464,6 +2458,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());
@@ -3114,11 +3116,6 @@ public class DefaultCodegen implements CodegenConfig {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL);
if (schema.equals(trueSchema)) {
m.setIsBooleanSchemaTrue(true);
} else if (schema.equals(falseSchema)) {
m.setIsBooleanSchemaFalse(true);
}
// unalias schema
schema = unaliasSchema(schema);
if (schema == null) {
@@ -3354,7 +3351,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 +3360,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 +3374,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 +3383,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 +3451,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 +3480,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 +3529,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 +3551,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 +3671,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();
@@ -3983,6 +3980,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) {
@@ -3997,11 +4001,6 @@ public class DefaultCodegen implements CodegenConfig {
}
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
if (p.equals(trueSchema)) {
property.setIsBooleanSchemaTrue(true);
} else if (p.equals(falseSchema)) {
property.setIsBooleanSchemaFalse(true);
}
// unalias schema
p = unaliasSchema(p);
@@ -5475,7 +5474,7 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern());
if (codegenParameter.isQueryParam && codegenParameter.isDeepObject && loadDeepObjectIntoItems) {
if (codegenParameter.isQueryParam && codegenParameter.isDeepObject) {
Schema schema = parameterSchema;
if (schema.get$ref() != null) {
schema = ModelUtils.getReferencedSchema(openAPI, schema);
@@ -6780,6 +6779,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 +6802,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 +6941,7 @@ public class DefaultCodegen implements CodegenConfig {
scopes.add(scope);
}
codegenSecurity.scopes = scopes;
codegenSecurity.hasScopes = true;
}
}
@@ -8421,12 +8423,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,41 +8470,18 @@ public class DefaultCodegen implements CodegenConfig {
return openapiGeneratorIgnoreList;
}
/*
A function to convert yaml or json ingested strings like property names
And convert special characters like newline, tab, carriage return
Into strings that can be rendered in the language that the generator will output to
*/
protected String handleSpecialCharacters(String name) { return name; }
/**
* Used to ensure that null or Schema is returned given an input Boolean/Schema/null
* This will be used in openapi 3.1.0 spec processing to ensure that Booleans become Schemas
* Because our generators only understand Schemas
* Note: use getIsBooleanSchemaTrue or getIsBooleanSchemaFalse on the IJsonSchemaValidationProperties
* if you need to be able to detect if the original schema's value was true or false
*
* @param schema the input Boolean or Schema data to convert to a Schema
* @return Schema the input data converted to a Schema if possible
*/
protected Schema getSchemaFromBooleanOrSchema(Object schema) {
if (schema == null) {
return null;
} else if (schema instanceof Boolean) {
if (Boolean.TRUE.equals(schema)) {
return trueSchema;
} else if (Boolean.FALSE.equals(schema)) {
return falseSchema;
}
// null case
return null;
} else if (schema instanceof Schema) {
return (Schema) schema;
} else {
throw new IllegalArgumentException("Invalid schema type; type must be Boolean or Schema");
}
@Override
public boolean isTypeErasedGenerics() {
return false;
}
/*
A function to convert yaml or json ingested strings like property names
And convert special characters like newline, tab, carriage return
Into strings that can be rendered in the language that the generator will output to
*/
protected String handleSpecialCharacters(String name) { return name; }
public void setAutosetConstants(boolean autosetConstants) {
this.autosetConstants = autosetConstants;
}

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));
}
}
}
/**
@@ -533,15 +574,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) {
@@ -888,6 +932,27 @@ public class OpenAPINormalizer {
List<Schema> oneOfSchemas = schema.getOneOf();
if (oneOfSchemas != null) {
// simplify any type with 6 sub-schemas (string, integer, etc) in oneOf
if (oneOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: oneOfSchemas) {
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
Schema anyType = new Schema();
anyType.setDescription(schema.getDescription());
anyType.setNullable(schema.getNullable());
anyType.setExtensions(schema.getExtensions());
anyType.setTitle(schema.getTitle());
anyType.setExample(schema.getExample());
anyType.setExamples(schema.getExamples());
anyType.setDefault(schema.getDefault());
anyType.setDeprecated(schema.getDeprecated());
return anyType;
}
}
if (oneOfSchemas.removeIf(oneOf -> isNullTypeSchema(oneOf))) {
schema.setNullable(true);
@@ -917,25 +982,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 +1037,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 +1057,27 @@ public class OpenAPINormalizer {
List<Schema> anyOfSchemas = schema.getAnyOf();
if (anyOfSchemas != null) {
// simplify any type with 6 sub-schemas (string, integer, etc) in anyOf
if (anyOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: anyOfSchemas) {
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
Schema anyType = new Schema();
anyType.setDescription(schema.getDescription());
anyType.setNullable(schema.getNullable());
anyType.setExtensions(schema.getExtensions());
anyType.setTitle(schema.getTitle());
anyType.setExample(schema.getExample());
anyType.setExamples(schema.getExamples());
anyType.setDefault(schema.getDefault());
anyType.setDeprecated(schema.getDeprecated());
return anyType;
}
}
if (anyOfSchemas.removeIf(anyOf -> isNullTypeSchema(anyOf))) {
schema.setNullable(true);
}

View File

@@ -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;
}

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
@@ -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

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

View File

@@ -929,16 +929,76 @@ public class ModelUtils {
* @return schema without '$ref'
*/
public static Schema getReferencedSchema(OpenAPI openAPI, Schema schema) {
if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) {
String name = getSimpleRef(schema.get$ref());
Schema referencedSchema = getSchema(openAPI, name);
if (referencedSchema != null) {
return referencedSchema;
}
if (schema == null) {
return null;
}
if (StringUtils.isEmpty(schema.get$ref())) {
return schema;
}
try {
Schema refSchema = getSchemaFromRefToSchemaWithProperties(openAPI, schema.get$ref());
if (refSchema != null) {
// it's ref to schema's properties, #/components/schemas/Pet/properties/category for example
return refSchema;
}
} catch (Exception e) {
LOGGER.warn("Failed to parse $ref {}. Please report the issue to openapi-generator GitHub repo.", schema.get$ref());
}
// a simple ref, e.g. #/components/schemas/Pet
String name = getSimpleRef(schema.get$ref());
Schema referencedSchema = getSchema(openAPI, name);
if (referencedSchema != null) {
return referencedSchema;
}
return schema;
}
/**
* Get the schema referenced by $ref to schema's properties, e.g. #/components/schemas/Pet/properties/category.
*
* @param openAPI specification being checked
* @param refString schema reference
* @return schema
*/
public static Schema getSchemaFromRefToSchemaWithProperties(OpenAPI openAPI, String refString) {
if (refString == null) {
return null;
}
String[] parts = refString.split("/");
// #/components/schemas/Pet/properties/category
if (parts.length == 6 && "properties".equals(parts[4])) {
Schema referencedSchema = getSchema(openAPI, parts[3]); // parts[3] is Pet
return (Schema) referencedSchema.getProperties().get(parts[5]); // parts[5] is category
} else {
return null;
}
}
/**
* Returns true if $ref to a reference to schema's properties, e.g. #/components/schemas/Pet/properties/category.
*
* @param refString schema reference
* @return true if $ref to a reference to schema's properties
*/
public static boolean isRefToSchemaWithProperties(String refString) {
if (refString == null) {
return false;
}
String[] parts = refString.split("/");
// #/components/schemas/Pet/properties/category
if (parts.length == 6 && "properties".equals(parts[4])) {
return true;
} else {
return false;
}
}
public static Schema getSchema(OpenAPI openAPI, String name) {
if (name == null) {
return null;
@@ -1272,7 +1332,9 @@ public class ModelUtils {
}
Schema ref = allSchemas.get(simpleRef);
if (ref == null) {
once(LOGGER).warn("{} is not defined", schema.get$ref());
if (!isRefToSchemaWithProperties(schema.get$ref())) {
once(LOGGER).warn("{} is not defined", schema.get$ref());
}
return schema;
} else if (ref.getEnum() != null && !ref.getEnum().isEmpty()) {
// top-level enum class

View File

@@ -5,9 +5,9 @@ package {{package}};
import {{invokerPackage}}.ApiException;
{{#imports}}import {{import}};
{{/imports}}
import org.junit.Test;
import org.junit.Ignore;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@@ -19,7 +19,7 @@ import java.util.Map;
/**
* API tests for {{classname}}
*/
public class {{classname}}Test {
class {{classname}}Test {
private final {{classname}} api = new {{classname}}();
@@ -38,7 +38,7 @@ public class {{classname}}Test {
* if the Api call fails
*/
@Test
public void {{operationId}}Test() throws ApiException {
void {{operationId}}Test() throws ApiException {
//{{#allParams}}
//{{{dataType}}} {{paramName}} = null;
//{{/allParams}}

View File

@@ -125,7 +125,7 @@ ext {
{{/useBeanValidation}}
jersey_version = "1.19.4"
jodatime_version = "2.9.9"
junit_version = "4.13.2"
junit_version = "5.10.2"
}
dependencies {
@@ -149,4 +149,20 @@ dependencies {
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
{{/useBeanValidation}}
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
test {
// Enable JUnit 5 (Gradle 4.6+).
useJUnitPlatform()
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
// Show test results.
testLogging {
events "passed", "skipped", "failed"
}
}

View File

@@ -78,37 +78,74 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
int match = 0;
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
{{#composedSchemas}}
{{#oneOf}}
// deserialize {{{.}}}
// deserialize {{{dataType}}}{{#isNullable}} (nullable){{/isNullable}}
try {
{{^isArray}}
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if ({{{.}}}.class.equals(Integer.class) || {{{.}}}.class.equals(Long.class) || {{{.}}}.class.equals(Float.class) || {{{.}}}.class.equals(Double.class) || {{{.}}}.class.equals(Boolean.class) || {{{.}}}.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |= (({{{.}}}.class.equals(Integer.class) || {{{.}}}.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |= (({{{.}}}.class.equals(Float.class) || {{{.}}}.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |= ({{{.}}}.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= ({{{.}}}.class.equals(String.class) && token == JsonToken.VALUE_STRING);
{{#isNullable}}
attemptParsing |= (token == JsonToken.VALUE_NULL);
{{/isNullable}}
}
{{#isPrimitiveType}}
attemptParsing = typeCoercion; //respect type coercion setting
if (!attemptParsing) {
{{#isString}}
attemptParsing |= (token == JsonToken.VALUE_STRING);
{{/isString}}
{{#isInteger}}
attemptParsing |= (token == JsonToken.VALUE_NUMBER_INT);
{{/isInteger}}
{{#isLong}}
attemptParsing |= (token == JsonToken.VALUE_NUMBER_INT);
{{/isLong}}
{{#isShort}}
attemptParsing |= (token == JsonToken.VALUE_NUMBER_INT);
{{/isShort}}
{{#isFloat}}
attemptParsing |= (token == JsonToken.VALUE_NUMBER_FLOAT);
{{/isFloat}}
{{#isDouble}}
attemptParsing |= (token == JsonToken.VALUE_NUMBER_FLOAT);
{{/isDouble}}
{{#isNumber}}
attemptParsing |= (token == JsonToken.VALUE_NUMBER_FLOAT);
{{/isNumber}}
{{#isDecimal}}
attemptParsing |= (token == JsonToken.VALUE_NUMBER_FLOAT);
{{/isDecimal}}
{{#isBoolean}}
attemptParsing |= (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
{{/isBoolean}}
{{#isNullable}}
attemptParsing |= (token == JsonToken.VALUE_NULL);
{{/isNullable}}
}
{{/isPrimitiveType}}
if (attemptParsing) {
deserialized = tree.traverse(jp.getCodec()).readValueAs({{{.}}}.class);
deserialized = tree.traverse(jp.getCodec()).readValueAs({{{dataType}}}.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
match++;
log.log(Level.FINER, "Input data matches schema '{{{.}}}'");
log.log(Level.FINER, "Input data matches schema '{{{dataType}}}'");
}
{{/isArray}}
{{#isArray}}
if (token == JsonToken.START_ARRAY) {
final TypeReference<{{{dataType}}}> ref = new TypeReference<{{{dataType}}}>(){};
deserialized = tree.traverse(jp.getCodec()).readValueAs(ref);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
match++;
log.log(Level.FINER, "Input data matches schema '{{{dataType}}}'");
}
{{/isArray}}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema '{{{.}}}'", e);
log.log(Level.FINER, "Input data does not match schema '{{{dataType}}}'", e);
}
{{/oneOf}}
{{/composedSchemas}}
if (match == 1) {
{{classname}} ret = new {{classname}}();
ret.setActualInstance(deserialized);
@@ -152,13 +189,17 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties);
}
{{/additionalPropertiesType}}
{{#composedSchemas}}
{{#oneOf}}
public {{classname}}({{{.}}} o) {
{{^vendorExtensions.x-duplicated-data-type}}
public {{classname}}({{{baseType}}} o) {
super("oneOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
setActualInstance(o);
}
{{/vendorExtensions.x-duplicated-data-type}}
{{/oneOf}}
{{/composedSchemas}}
static {
{{#oneOf}}
schemas.put("{{{.}}}", new GenericType<{{{.}}}>() {
@@ -198,13 +239,17 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
}
{{/isNullable}}
{{#composedSchemas}}
{{#oneOf}}
if (JSON.isInstanceOf({{{.}}}.class, instance, new HashSet<>())) {
{{^vendorExtensions.x-duplicated-data-type}}
if (JSON.isInstanceOf({{{baseType}}}.class, instance, new HashSet<>())) {
super.setActualInstance(instance);
return;
}
{{/vendorExtensions.x-duplicated-data-type}}
{{/oneOf}}
{{/composedSchemas}}
throw new RuntimeException("Invalid instance type. Must be {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}");
}
@@ -219,17 +264,26 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
return super.getActualInstance();
}
{{#composedSchemas}}
{{#oneOf}}
/**
* Get the actual instance of `{{{.}}}`. If the actual instance is not `{{{.}}}`,
* Get the actual instance of `{{{dataType}}}`. If the actual instance is not `{{{dataType}}}`,
* the ClassCastException will be thrown.
*
* @return The actual instance of `{{{.}}}`
* @throws ClassCastException if the instance is not `{{{.}}}`
* @return The actual instance of `{{{dataType}}}`
* @throws ClassCastException if the instance is not `{{{dataType}}}`
*/
public {{{.}}} get{{{.}}}() throws ClassCastException {
return ({{{.}}})super.getActualInstance();
{{^isArray}}
public {{{dataType}}} get{{{dataType}}}() throws ClassCastException {
return ({{{dataType}}})super.getActualInstance();
}
{{/isArray}}
{{#isArray}}
public {{{dataType}}} get{{#sanitizeGeneric}}{{{dataType}}}{{/sanitizeGeneric}}() throws ClassCastException {
return ({{{dataType}}})super.getActualInstance();
}
{{/isArray}}
{{/oneOf}}
{{/composedSchemas}}
}

View File

@@ -21,7 +21,7 @@ import {{invokerPackage}}.JSON;
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{>xmlAnnotation}}
@JsonDeserialize(using={{classname}}.{{classname}}Deserializer.class)
@JsonSerialize(using = {{classname}}.{{classname}}Serializer.class)
public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-implements}}, {{{.}}}{{/vendorExtensions.x-implements}} {
public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-implements}} implements {{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-implements}} {
private static final Logger log = Logger.getLogger({{classname}}.class.getName());
public static class {{classname}}Serializer extends StdSerializer<{{classname}}> {

View File

@@ -23,7 +23,7 @@ import {{invokerPackage}}.JSON;
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{>xmlAnnotation}}
@JsonDeserialize(using = {{classname}}.{{classname}}Deserializer.class)
@JsonSerialize(using = {{classname}}.{{classname}}Serializer.class)
public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-implements}}, {{{.}}}{{/vendorExtensions.x-implements}} {
public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-implements}} implements {{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-implements}} {
private static final Logger log = Logger.getLogger({{classname}}.class.getName());
public static class {{classname}}Serializer extends StdSerializer<{{classname}}> {

View File

@@ -112,8 +112,8 @@ ext {
dependencies {
implementation 'io.swagger:swagger-annotations:1.6.8'
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'javax.ws.rs:jsr311-api:1.1.1'

View File

@@ -10,8 +10,8 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.6.5",
"com.squareup.okhttp3" % "okhttp" % "4.10.0",
"com.squareup.okhttp3" % "logging-interceptor" % "4.10.0",
"com.squareup.okhttp3" % "okhttp" % "4.12.0",
"com.squareup.okhttp3" % "logging-interceptor" % "4.12.0",
"com.google.code.gson" % "gson" % "2.9.1",
"org.apache.commons" % "commons-lang3" % "3.12.0",
"javax.ws.rs" % "jsr311-api" % "1.1.1",

View File

@@ -4,8 +4,9 @@ package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import org.junit.Test;
import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestClientException;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@@ -17,8 +18,8 @@ import java.util.Map;
/**
* API tests for {{classname}}
*/
@Ignore
public class {{classname}}Test {
@Disabled
class {{classname}}Test {
private final {{classname}} api = new {{classname}}();
@@ -28,11 +29,11 @@ public class {{classname}}Test {
*
* {{notes}}
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void {{operationId}}Test() {
void {{operationId}}Test() {
{{#allParams}}
{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.Resource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}} = null;
{{/allParams}}

View File

@@ -121,15 +121,15 @@ ext {
jackson_databind_nullable_version = "0.2.6"
{{/openApiNullable}}
{{#useJakartaEe}}
spring_web_version = "6.0.17"
spring_web_version = "6.1.5"
jakarta_annotation_version = "2.1.1"
{{/useJakartaEe}}
{{^useJakartaEe}}
spring_web_version = "5.3.32"
spring_web_version = "5.3.33"
jakarta_annotation_version = "1.3.5"
{{/useJakartaEe}}
jodatime_version = "2.9.9"
junit_version = "4.13.2"
junit_version = "5.10.2"
}
dependencies {
@@ -158,5 +158,20 @@ dependencies {
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version"
{{/withXml}}
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
test {
// Enable JUnit 5 (Gradle 4.6+).
useJUnitPlatform()
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
// Show test results.
testLogging {
events "passed", "skipped", "failed"
}
}

View File

@@ -76,6 +76,14 @@
<forkMode>pertest</forkMode>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
<dependencies>
<!--Custom provider and engine for Junit 5 to surefire-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -339,11 +347,17 @@
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit-platform-runner.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -354,10 +368,10 @@
<swagger-annotations-version>2.2.15</swagger-annotations-version>
{{/swagger2AnnotationLibrary}}
{{#useJakartaEe}}
<spring-web-version>6.0.17</spring-web-version>
<spring-web-version>6.1.5</spring-web-version>
{{/useJakartaEe}}
{{^useJakartaEe}}
<spring-web-version>5.3.32</spring-web-version>
<spring-web-version>5.3.33</spring-web-version>
{{/useJakartaEe}}
<jackson-version>2.15.2</jackson-version>
<jackson-databind-version>2.15.2</jackson-databind-version>
@@ -379,6 +393,7 @@
{{#performBeanValidation}}
<hibernate-validator-version>5.4.3.Final</hibernate-validator-version>
{{/performBeanValidation}}
<junit-version>4.13.2</junit-version>
<junit-version>5.10.2</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
</properties>
</project>

View File

@@ -4,14 +4,14 @@ package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for {{classname}}
*/
public class {{classname}}Test {
class {{classname}}Test {
{{#models}}
{{#model}}
{{^vendorExtensions.x-is-one-of-interface}}
@@ -23,7 +23,7 @@ public class {{classname}}Test {
* Model tests for {{classname}}
*/
@Test
public void test{{classname}}() {
void test{{classname}}() {
// TODO: test {{classname}}
}
@@ -32,7 +32,7 @@ public class {{classname}}Test {
* Test the property '{{name}}'
*/
@Test
public void {{name}}Test() {
void {{name}}Test() {
// TODO: test {{name}}
}

View File

@@ -92,6 +92,14 @@
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
</configuration>
<dependencies>
<!--Custom provider and engine for Junit 5 to surefire-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -335,11 +343,17 @@
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit-platform-runner.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -362,6 +376,7 @@
<beanvalidation-version>3.0.2</beanvalidation-version>
{{/useBeanValidation}}
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.13.2</junit-version>
<junit-version>5.10.2</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
</properties>
</project>

View File

@@ -1,7 +1,6 @@
package {{configPackage}};
{{#authMethods}}
{{#isOAuth}}
import java.util.Properties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;
@@ -11,31 +10,34 @@ import org.springframework.core.env.PropertiesPropertySource;
public class ClientPropertiesConfiguration {
public ClientPropertiesConfiguration( final ConfigurableEnvironment configurableEnvironment ) {
final Properties properties = new Properties();
properties.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.client-id", "set-{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}-client-id" );
properties.put("{{#scopes}}{{#-first}}spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.scope", "{{/-first}}{{scope}}{{^-last}},{{/-last}}{{/scopes}}" );
{{#authMethods}}
{{#isOAuth}}
final Properties {{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}} = new Properties();
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.client-id", "set-{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}-client-id" );
{{#hasScopes}}
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("{{#scopes}}{{#-first}}spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.scope", "{{/-first}}{{scope}}{{^-last}},{{/-last}}{{/scopes}}" );
{{/hasScopes}}
{{#isCode}}
properties.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "authorization_code" );
properties.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.redirect-uri", "set-{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}-redirect-uri" );
properties.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.token-uri", "{{{tokenUrl}}}" );
properties.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-uri", "{{{authorizationUrl}}}" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "authorization_code" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.redirect-uri", "set-{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}-redirect-uri" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.token-uri", "{{{tokenUrl}}}" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-uri", "{{{authorizationUrl}}}" );
{{/isCode}}
{{#isPassword}}
properties.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "password" );
properties.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.token-uri", "{{{tokenUrl}}}" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "password" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.token-uri", "{{{tokenUrl}}}" );
{{/isPassword}}
{{#isApplication}}
properties.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "client_credentials" );
properties.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.token-uri", "{{{tokenUrl}}}" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "client_credentials" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.token-uri", "{{{tokenUrl}}}" );
{{/isApplication}}
{{#isImplicit}}
properties.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "implicit" );
properties.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-uri", "{{{authorizationUrl}}}" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.registration.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-grant-type", "implicit" );
{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.put("spring.security.oauth2.client.provider.{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}.authorization-uri", "{{{authorizationUrl}}}" );
{{/isImplicit}}
final PropertiesPropertySource propertiesPropertySource = new PropertiesPropertySource("{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}", properties );
configurableEnvironment.getPropertySources().addLast( propertiesPropertySource );
configurableEnvironment.getPropertySources().addLast( new PropertiesPropertySource("{{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}}", {{{name}}}{{#lambda.pascalcase}}{{{flow}}}{{/lambda.pascalcase}} ) );
{{/isOAuth}}
{{/authMethods}}
}
}
{{/isOAuth}}
{{/authMethods}}

View File

@@ -459,7 +459,7 @@
{{/isInnerEnum}}
{{^isInnerEnum}}
{{#lambda.copy}}
{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}RawValue
{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}
{{/lambda.copy}}
{{#required}}
{{#isNullable}}
@@ -472,7 +472,7 @@
{{#enumVars}}
{{#-first}}
{{#isString}}
if ({{#lambda.pasteLine}}{{/lambda.pasteLine}} != null){{! we cant use name here because enumVar also has a name property, so use the paste lambda instead }}
if ({{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue != null){{! we cant use name here because enumVar also has a name property, so use the paste lambda instead }}
writer.WriteString("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{nameInPascalCase}}{{/lambda.camelcase_sanitize_param}}RawValue);
else
writer.WriteNull("{{baseName}}");
@@ -490,12 +490,12 @@
{{#allowableValues}}
{{#enumVars}}
{{#-first}}
{{#isString}}
writer.WriteString("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}});
{{/isString}}
{{^isString}}
{{^isNumeric}}
writer.WriteString("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue);
{{/isNumeric}}
{{#isNumeric}}
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/lambda.camelcase_sanitize_param}}RawValue);
{{/isString}}
{{/isNumeric}}
{{/-first}}
{{/enumVars}}
{{/allowableValues}}
@@ -507,16 +507,16 @@
{{#isNullable}}
if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option{{nrt!}}.Value != null)
{
var {{#lambda.pasteLine}}{{/lambda.pasteLine}} = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value{{nrt!}}.Value);
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{#isString}}WriteString {{/isString}}{{^isString}}WriteNumber {{/isString}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}});
var {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value{{nrt!}}.Value);
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{^isNumeric}}WriteString {{/isNumeric}}{{#isNumeric}}WriteNumber {{/isNumeric}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue);
}
else
writer.WriteNull("{{baseName}}");
{{/isNullable}}
{{^isNullable}}
{
var {{#lambda.pasteLine}}{{/lambda.pasteLine}} = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{nrt!}}.Value);
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{#isString}}WriteString {{/isString}}{{^isString}}WriteNumber {{/isString}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}});
var {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{nrt!}}.Value);
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{^isNumeric}}WriteString {{/isNumeric}}{{#isNumeric}}WriteNumber {{/isNumeric}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue);
}
{{/isNullable}}
{{/required}}

View File

@@ -1 +1 @@
{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{parent}}{{/lambda.camelcase_sanitize_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}}
{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{parent}}{{/lambda.camelcase_sanitize_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{{datatypeWithEnum}}}ToJsonValue{{/isInnerEnum}}{{^isInnerEnum}}{{{datatypeWithEnum}}}ValueConverter.ToJsonValue{{/isInnerEnum}}({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}}

View File

@@ -25,7 +25,7 @@
<ItemGroup>
{{#useCompareNetObjects}}
<PackageReference Include="CompareNETObjects" Version="4.82.0" />
<PackageReference Include="CompareNETObjects" Version="4.83.0" />
{{/useCompareNetObjects}}
{{^useGenericHost}}
<PackageReference Include="JsonSubTypes" Version="2.0.1" />
@@ -38,10 +38,10 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="{{#lambda.first}}{{#netStandard}}5.0.0 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.0 {{/net6.0}}{{#net7.0}}7.0.0 {{/net7.0}}{{#net8.0}}8.0.0 {{/net8.0}}{{/lambda.first}}" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="{{#lambda.first}}{{#netStandard}}5.0.0 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.1 {{/net6.0}}{{#net7.0}}7.0.1 {{/net7.0}}{{#net8.0}}8.0.0 {{/net8.0}}{{/lambda.first}}" />
{{#supportsRetry}}
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="{{#lambda.first}}{{#netStandard}}5.0.1 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.19 {{/net6.0}}{{#net7.0}}7.0.11 {{/net7.0}}{{#net8.0}}8.0.0 {{/net8.0}}{{/lambda.first}}" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="{{#lambda.first}}{{#netStandard}}5.0.1 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.19 {{/net6.0}}{{#net7.0}}7.0.11 {{/net7.0}}{{#net8.0}}8.0.3 {{/net8.0}}{{/lambda.first}}" />
{{/supportsRetry}}
{{#net80OrLater}}
<PackageReference Include="Microsoft.Net.Http.Headers" Version="8.0.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="8.0.3" />
{{/net80OrLater}}
{{#netStandard}}
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />

View File

@@ -9,9 +9,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="{{^netStandard}}17.8.0{{/netStandard}}{{#netStandard}}15.9.2{{/netStandard}}" />
<PackageReference Include="xunit" Version="{{^netStandard}}2.6.1{{/netStandard}}{{#netStandard}}2.4.2{{/netStandard}}" />
<PackageReference Include="xunit.runner.visualstudio" Version="{{^netStandard}}2.5.3{{/netStandard}}{{#netStandard}}2.4.5{{/netStandard}}" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="{{^netStandard}}17.9.0{{/netStandard}}{{#netStandard}}15.9.2{{/netStandard}}" />
<PackageReference Include="xunit" Version="{{^netStandard}}2.7.0{{/netStandard}}{{#netStandard}}2.4.2{{/netStandard}}" />
<PackageReference Include="xunit.runner.visualstudio" Version="{{^netStandard}}2.5.7{{/netStandard}}{{#netStandard}}2.4.5{{/netStandard}}" />
</ItemGroup>
<ItemGroup>

View File

@@ -13,7 +13,7 @@ require 'typhoeus'
{{#isFaraday}}
require 'faraday'
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
require 'filemagic'
require 'marcel'
{{/isFaraday}}
{{#isHttpx}}
require 'httpx'

View File

@@ -94,8 +94,7 @@
form_params.each do |key, value|
case value
when ::File, ::Tempfile
filemagic = FileMagic.new(FileMagic::MAGIC_MIME)
data[key] = Faraday::FilePart.new(value.path, filemagic.file(value.path, true))
data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
when ::Array, nil
# let Faraday handle Array and nil parameters
data[key] = value

View File

@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
{{#isFaraday}}
s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0'
s.add_runtime_dependency 'faraday-multipart'
s.add_runtime_dependency 'ruby-filemagic'
s.add_runtime_dependency 'marcel'
{{/isFaraday}}
{{#isTyphoeus}}
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'

View File

@@ -168,6 +168,12 @@ public class OpenAPINormalizerTest {
Schema schema9 = openAPI.getComponents().getSchemas().get("AnyOfStringArrayOfString");
assertEquals(schema9.getAnyOf().size(), 2);
Schema schema11 = openAPI.getComponents().getSchemas().get("AnyOfAnyType");
assertEquals(schema11.getAnyOf().size(), 6);
Schema schema13 = openAPI.getComponents().getSchemas().get("OneOfAnyType");
assertEquals(schema13.getOneOf().size(), 6);
Map<String, String> options = new HashMap<>();
options.put("SIMPLIFY_ONEOF_ANYOF", "true");
OpenAPINormalizer openAPINormalizer = new OpenAPINormalizer(openAPI, options);
@@ -192,6 +198,15 @@ public class OpenAPINormalizerTest {
Schema schema10 = openAPI.getComponents().getSchemas().get("AnyOfStringArrayOfString");
assertEquals(schema10.getAnyOf().size(), 2);
Schema schema12 = openAPI.getComponents().getSchemas().get("AnyOfAnyType");
assertEquals(schema12.getAnyOf(), null);
assertEquals(schema12.getType(), null);
Schema schema14 = openAPI.getComponents().getSchemas().get("OneOfAnyType");
assertEquals(schema14.getOneOf(), null);
assertEquals(schema14.getType(), null);
}
@Test
@@ -514,6 +529,48 @@ public class OpenAPINormalizerTest {
assertEquals(((Schema) schema4.getProperties().get("map_property")).getNullable(), null);
}
@Test
public void testSetPrimitiveTypesToNullable() {
// test `string|integer|number|boolean`
OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_0//setPrimitiveTypesToNullable_test.yaml");
Schema schema = openAPI.getComponents().getSchemas().get("Person");
assertEquals(((Schema) schema.getProperties().get("lastName")).getNullable(), null);
assertEquals(((Schema) schema.getProperties().get("first_integer")).getNullable(), null);
assertEquals(((Schema) schema.getProperties().get("first_number")).getNullable(), null);
assertEquals(((Schema) schema.getProperties().get("first_boolean")).getNullable(), null);
Map<String, String> options = new HashMap<>();
options.put("SET_PRIMITIVE_TYPES_TO_NULLABLE", "string|integer|number|boolean");
OpenAPINormalizer openAPINormalizer = new OpenAPINormalizer(openAPI, options);
openAPINormalizer.normalize();
Schema schema2 = openAPI.getComponents().getSchemas().get("Person");
assertEquals(((Schema) schema2.getProperties().get("lastName")).getNullable(), true);
assertEquals(((Schema) schema2.getProperties().get("first_integer")).getNullable(), true);
assertEquals(((Schema) schema2.getProperties().get("first_number")).getNullable(), true);
assertEquals(((Schema) schema2.getProperties().get("first_boolean")).getNullable(), true);
// test `number` only
OpenAPI openAPI2 = TestUtils.parseSpec("src/test/resources/3_0//setPrimitiveTypesToNullable_test.yaml");
Schema schema3 = openAPI2.getComponents().getSchemas().get("Person");
assertEquals(((Schema) schema3.getProperties().get("lastName")).getNullable(), null);
assertEquals(((Schema) schema3.getProperties().get("first_integer")).getNullable(), null);
assertEquals(((Schema) schema3.getProperties().get("first_number")).getNullable(), null);
assertEquals(((Schema) schema3.getProperties().get("first_boolean")).getNullable(), null);
options.put("SET_PRIMITIVE_TYPES_TO_NULLABLE", "number");
OpenAPINormalizer openAPINormalizer2 = new OpenAPINormalizer(openAPI2, options);
openAPINormalizer2.normalize();
Schema schema4 = openAPI2.getComponents().getSchemas().get("Person");
assertEquals(((Schema) schema4.getProperties().get("lastName")).getNullable(), null);
assertEquals(((Schema) schema4.getProperties().get("first_integer")).getNullable(), null);
assertEquals(((Schema) schema4.getProperties().get("first_number")).getNullable(), true);
assertEquals(((Schema) schema4.getProperties().get("first_boolean")).getNullable(), null);
}
@Test
public void testOpenAPINormalizerSimplifyOneOfAnyOf31Spec() {
// to test the rule SIMPLIFY_ONEOF_ANYOF in 3.1 spec

View File

@@ -57,7 +57,6 @@ import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.api.MapAssert;
import org.openapitools.codegen.CliOption;
@@ -1198,7 +1197,7 @@ public class SpringCodegenTest {
output.deleteOnExit();
OpenAPI openAPI = new OpenAPIParser()
.readLocation("src/test/resources/3_0/issue_18090.yaml", null, new ParseOptions()).getOpenAPI();
.readLocation("src/test/resources/3_0/spring/petstore-auth.yaml", null, new ParseOptions()).getOpenAPI();
final SpringCodegen codegen = new SpringCodegen();
codegen.setOpenAPI(openAPI);
@@ -1226,9 +1225,23 @@ public class SpringCodegenTest {
Path filePath = Paths.get(output.getAbsolutePath(), "src/main/java/org/openapitools/configuration/ClientPropertiesConfiguration.java");
String content = new String(Files.readAllBytes(filePath), "UTF-8");
Assert.assertTrue(content.contains("properties.put(\"spring.security.oauth2.client.provider.oAuth2AccessCode.token-uri\", \"${tokenUrl}\" );"));
Assert.assertTrue(content.contains("properties.put(\"spring.security.oauth2.client.provider.oAuth2AccessCode.authorization-uri\", \"${authorizationUrl}\" );"));
assertFileContains(filePath,
"oAuth2AccessCode.put(\"spring.security.oauth2.client.registration.oAuth2AccessCode.redirect-uri\", \"set-oAuth2AccessCode-redirect-uri\" );",
"oAuth2AccessCode.put(\"spring.security.oauth2.client.registration.oAuth2AccessCode.authorization-grant-type\", \"authorization_code\" );",
"oAuth2AccessCode.put(\"spring.security.oauth2.client.registration.oAuth2AccessCode.client-id\", \"set-oAuth2AccessCode-client-id\" );",
"oAuth2AccessCode.put(\"spring.security.oauth2.client.registration.oAuth2AccessCode.scope\", \"openid,profile,aud\" );",
"oAuth2AccessCode.put(\"spring.security.oauth2.client.provider.oAuth2AccessCode.token-uri\", \"${tokenUrl}\" );",
"oAuth2AccessCode.put(\"spring.security.oauth2.client.provider.oAuth2AccessCode.authorization-uri\", \"${authorizationUrl}\" );",
"oAuth2Application.put(\"spring.security.oauth2.client.registration.oAuth2Application.client-id\", \"set-oAuth2Application-client-id\" );",
"oAuth2Application.put(\"spring.security.oauth2.client.registration.oAuth2Application.authorization-grant-type\", \"client_credentials\" );",
"oAuth2Application.put(\"spring.security.oauth2.client.provider.oAuth2Application.token-uri\", \"/openid-connect/token\" );"
);
assertFileNotContains(filePath,"spring.security.oauth2.client.registration.oAuth2Application.scope");
}
@Test
@@ -2706,6 +2719,26 @@ public class SpringCodegenTest {
.assertMethod("typeConverter");
}
@Test
public void contractWithResolvedInnerEnumContainsEnumConverter() throws IOException {
File output = Files.createTempDirectory("test").toFile();
output.deleteOnExit();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("spring")
.setInputSpec("src/test/resources/3_0/inner_enum.yaml")
.addInlineSchemaOption("RESOLVE_INLINE_ENUMS", "true")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
Map<String, File> files = generator.opts(clientOptInput).generate().stream()
.collect(Collectors.toMap(File::getName, Function.identity()));
JavaFileAssert.assertThat(files.get("EnumConverterConfiguration.java"))
.assertMethod("ponyTypeConverter");
}
@Test
public void shouldUseTheSameTagNameForTheInterfaceAndTheMethod_issue11570() throws IOException {
final Map<String, File> output = generateFromContract("src/test/resources/bugs/issue_11570.yml", SPRING_BOOT);

View File

@@ -295,6 +295,25 @@ public class ModelUtilsTest {
Assert.assertEquals(decoded, "~1 Hallo/Welt");
}
@Test
public void testRefToSchemaProperties() {
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/petstore.yaml");
Schema category = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, "#/components/schemas/Pet/properties/category");
Assert.assertEquals(category.get$ref(), "#/components/schemas/Category");
Schema name = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, "#/components/schemas/Pet/properties/name");
Assert.assertEquals(name.getType(), "string");
Schema id = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, "#/components/schemas/Pet/properties/id");
Assert.assertEquals(id.getType(), "integer");
Assert.assertEquals(id.getFormat(), "int64");
Assert.assertEquals(null, ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, "#/components/schemas/Pet/prop/category"));
Assert.assertEquals(null, ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, "#/components/schemas/Pet/properties/categoryyyy"));
Assert.assertEquals(null, ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, "#/components/schemas/Pet"));
}
// 3.0 spec tests
@Test

View File

@@ -0,0 +1,30 @@
openapi: 3.0.0
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
paths:
/ponies:
get:
summary: Returns all animals.
description: Optional extended description in Markdown.
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pony'
components:
schemas:
Pony:
type: object
properties:
type:
type: string
enum:
- Earth
- Pegasi
- Unicorn

View File

@@ -1,29 +0,0 @@
openapi: "3.0.3"
info:
title: Test for OAuth2 provider
version: 1.0.0
security:
- OAuth2:
- openid
- profile
paths:
/some/endpoint:
get:
responses:
"200":
description: OK
components:
securitySchemes:
OAuth2:
type: oauth2
x-tokenName: id_token
flows:
authorizationCode:
authorizationUrl: "${authorizationUrl}"
tokenUrl: "${tokenUrl}"
scopes:
openid: Access OpenId Connect info
profile: Profile info

View File

@@ -2655,3 +2655,23 @@ components:
PetComposition:
allOf:
- $ref: '#/components/schemas/Pet'
PetRef:
type: object
required:
- name
- photoUrls
properties:
id:
$ref: '#/components/schemas/Pet/properties/id'
category:
$ref: '#/components/schemas/Pet/properties/category'
name:
$ref: '#/components/schemas/Pet/properties/name'
photoUrls:
$ref: '#/components/schemas/Pet/properties/photoUrls'
tags:
$ref: '#/components/schemas/Pet/properties/tags'
status:
$ref: '#/components/schemas/Pet/properties/status'
xml:
name: Pet

View File

@@ -0,0 +1,29 @@
openapi: 3.0.1
info:
version: 1.0.0
title: Example - oneOf data type
license:
name: MIT
servers:
- url: http://api.example.xyz/v1
paths:
/example:
get:
operationId: list
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Example"
components:
schemas:
Example:
oneOf:
- type: array
items:
type: number
- type: array
items:
type: integer

View File

@@ -0,0 +1,28 @@
openapi: 3.0.1
info:
version: 1.0.0
title: Example - oneOf data type
license:
name: MIT
servers:
- url: http://api.example.xyz/v1
paths:
/example:
get:
operationId: list
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Example"
components:
schemas:
Example:
oneOf:
- type: string
format: uuid
- type: array
items:
type: integer

View File

@@ -0,0 +1,44 @@
openapi: 3.0.1
info:
version: 1.0.0
title: Example
license:
name: MIT
servers:
- url: http://api.example.xyz/v1
paths:
/person/display/{personId}:
get:
tags:
- person
- basic
parameters:
- name: personId
in: path
required: true
description: The id of the person to retrieve
schema:
type: string
operationId: list
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Person"
components:
schemas:
Person:
description: person
type: object
properties:
lastName:
type: string
first_integer:
type: integer
first_number:
type: number
first_boolean:
type: boolean

View File

@@ -88,4 +88,22 @@ components:
- type: string
- type: array
items:
type: string
type: string
AnyOfAnyType:
anyOf:
- type: boolean
- type: array
items: {}
- type: object
- type: string
- type: number
- type: integer
OneOfAnyType:
oneOf:
- type: object
- type: boolean
- type: number
- type: string
- type: integer
- type: array
items: {}

View File

@@ -0,0 +1,37 @@
openapi: "3.0.3"
info:
description: 'This spec is mainly for testing Petstore server and contains fake
endpoints, models. Please do not use this for any other purpose. Special
characters: " \'
version: 1.0.0
title: OpenAPI Petstore Auth
license:
name: Apache-2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
security:
- OAuth2: [openid, profile, aud]
paths:
/some/endpoint:
get:
responses:
"200":
description: OK
components:
securitySchemes:
OAuth2:
type: oauth2
x-tokenName: id_token
flows:
authorizationCode:
authorizationUrl: "${authorizationUrl}"
tokenUrl: "${tokenUrl}"
scopes:
openid: Access OpenId Connect info
profile: Profile info
aud: Audience info
clientCredentials:
tokenUrl: '/openid-connect/token'
scopes: { }

View File

@@ -9,9 +9,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7" />
</ItemGroup>
<ItemGroup>

View File

@@ -108,8 +108,8 @@ ext {
dependencies {
implementation 'io.swagger:swagger-annotations:1.6.8'
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'javax.ws.rs:jsr311-api:1.1.1'

View File

@@ -10,8 +10,8 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.6.5",
"com.squareup.okhttp3" % "okhttp" % "4.10.0",
"com.squareup.okhttp3" % "logging-interceptor" % "4.10.0",
"com.squareup.okhttp3" % "okhttp" % "4.12.0",
"com.squareup.okhttp3" % "logging-interceptor" % "4.12.0",
"com.google.code.gson" % "gson" % "2.9.1",
"org.apache.commons" % "commons-lang3" % "3.12.0",
"javax.ws.rs" % "jsr311-api" % "1.1.1",

View File

@@ -100,10 +100,10 @@ ext {
jackson_version = "2.14.2"
jackson_databind_version = "2.15.1"
jackson_databind_nullable_version = "0.2.6"
spring_web_version = "5.3.32"
spring_web_version = "5.3.33"
jakarta_annotation_version = "1.3.5"
jodatime_version = "2.9.9"
junit_version = "4.13.2"
junit_version = "5.10.2"
}
dependencies {
@@ -117,5 +117,20 @@ dependencies {
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
test {
// Enable JUnit 5 (Gradle 4.6+).
useJUnitPlatform()
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
// Show test results.
testLogging {
events "passed", "skipped", "failed"
}
}

View File

@@ -69,6 +69,14 @@
<forkMode>pertest</forkMode>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
<dependencies>
<!--Custom provider and engine for Junit 5 to surefire-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -258,19 +266,26 @@
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit-platform-runner.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-web-version>5.3.32</spring-web-version>
<spring-web-version>5.3.33</spring-web-version>
<jackson-version>2.15.2</jackson-version>
<jackson-databind-version>2.15.2</jackson-databind-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>4.13.2</junit-version>
<junit-version>5.10.2</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
</properties>
</project>

View File

@@ -17,7 +17,7 @@ require 'tempfile'
require 'time'
require 'faraday'
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
require 'filemagic'
require 'marcel'
module OpenapiClient
@@ -141,8 +141,7 @@ module OpenapiClient
form_params.each do |key, value|
case value
when ::File, ::Tempfile
filemagic = FileMagic.new(FileMagic::MAGIC_MIME)
data[key] = Faraday::FilePart.new(value.path, filemagic.file(value.path, true))
data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
when ::Array, nil
# let Faraday handle Array and nil parameters
data[key] = value

View File

@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0'
s.add_runtime_dependency 'faraday-multipart'
s.add_runtime_dependency 'ruby-filemagic'
s.add_runtime_dependency 'marcel'
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'

View File

@@ -20,7 +20,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CompareNETObjects" Version="4.82.0" />
<PackageReference Include="CompareNETObjects" Version="4.83.0" />
<PackageReference Include="JsonSubTypes" Version="2.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="RestSharp" Version="110.2.0" />

View File

@@ -0,0 +1,30 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
#
# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)
name: Java CI with Maven
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
build:
name: Build Example - oneOf data type
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8' ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --no-transfer-progress --file pom.xml

View File

@@ -0,0 +1,21 @@
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# exclude jar for gradle wrapper
!gradle/wrapper/*.jar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# build files
**/target
target
.gradle
build

View File

@@ -0,0 +1,36 @@
.github/workflows/maven.yml
.gitignore
.travis.yml
README.md
api/openapi.yaml
build.gradle
build.sbt
docs/DefaultApi.md
docs/Example.md
git_push.sh
gradle.properties
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
src/main/java/org/openapitools/client/ApiException.java
src/main/java/org/openapitools/client/ApiResponse.java
src/main/java/org/openapitools/client/Configuration.java
src/main/java/org/openapitools/client/JSON.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/Pair.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/ServerConfiguration.java
src/main/java/org/openapitools/client/ServerVariable.java
src/main/java/org/openapitools/client/StringUtil.java
src/main/java/org/openapitools/client/api/DefaultApi.java
src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
src/main/java/org/openapitools/client/auth/Authentication.java
src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
src/main/java/org/openapitools/client/model/Example.java

View File

@@ -0,0 +1,22 @@
#
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
# Ref: https://docs.travis-ci.com/user/languages/java/
#
language: java
jdk:
- openjdk12
- openjdk11
- openjdk10
- openjdk9
- openjdk8
before_install:
# ensure gradlew has proper permission
- chmod a+x ./gradlew
script:
# test using maven
#- mvn test
# test using gradle
- gradle test
# test using sbt
# - sbt test

View File

@@ -0,0 +1,163 @@
# openapi-java-client
Example - oneOf data type
- API version: 1.0.0
- Generator version: 7.5.0-SNAPSHOT
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
## Requirements
Building the API client library requires:
1. Java 1.8+
2. Maven (3.8.3+)/Gradle (7.2+)
## Installation
To install the API client library to your local Maven repository, simply execute:
```shell
mvn clean install
```
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
```shell
mvn clean deploy
```
Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
### Maven users
Add this dependency to your project's POM:
```xml
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-java-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
```
### Gradle users
Add this dependency to your project's build file:
```groovy
repositories {
mavenCentral() // Needed if the 'openapi-java-client' jar has been published to maven central.
mavenLocal() // Needed if the 'openapi-java-client' jar has been published to the local maven repo.
}
dependencies {
implementation "org.openapitools:openapi-java-client:1.0.0"
}
```
### Others
At first generate the JAR by executing:
```shell
mvn clean package
```
Then manually install the following JARs:
- `target/openapi-java-client-1.0.0.jar`
- `target/lib/*.jar`
## Usage
To add a HTTP proxy for the API client, use `ClientConfig`:
```java
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.openapitools.client.*;
import org.openapitools.client.api.DefaultApi;
...
ApiClient defaultClient = Configuration.getDefaultApiClient();
ClientConfig clientConfig = defaultClient.getClientConfig();
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");
defaultClient.setClientConfig(clientConfig);
DefaultApi apiInstance = new DefaultApi(defaultClient);
```
## Getting Started
Please follow the [installation](#installation) instruction and execute the following Java code:
```java
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.DefaultApi;
public class DefaultApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://api.example.xyz/v1");
DefaultApi apiInstance = new DefaultApi(defaultClient);
try {
Example result = apiInstance.callList();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#callList");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
## Documentation for API Endpoints
All URIs are relative to *http://api.example.xyz/v1*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**callList**](docs/DefaultApi.md#callList) | **GET** /example |
## Documentation for Models
- [Example](docs/Example.md)
<a id="documentation-for-authorization"></a>
## Documentation for Authorization
Endpoints do not require authorization.
## Recommendation
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
## Author

View File

@@ -0,0 +1,31 @@
openapi: 3.0.1
info:
license:
name: MIT
title: Example - oneOf data type
version: 1.0.0
servers:
- url: http://api.example.xyz/v1
paths:
/example:
get:
operationId: list
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/Example'
description: OK
x-accepts:
- application/json
components:
schemas:
Example:
oneOf:
- format: uuid
type: string
- items:
type: integer
type: array

View File

@@ -0,0 +1,158 @@
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'com.diffplug.spotless'
group = 'org.openapitools'
version = '1.0.0'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.3.0'
}
}
repositories {
mavenCentral()
}
if(hasProperty('target') && target == 'android') {
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
dependencies {
provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
}
}
afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDirectory
task.destinationDirectory = project.file("${project.buildDir}/outputs/jar")
task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
} else {
apply plugin: 'java'
apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
publishing {
publications {
maven(MavenPublication) {
artifactId = 'openapi-java-client'
from components.java
}
}
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
ext {
swagger_annotations_version = "1.6.5"
jackson_version = "2.13.4"
jackson_databind_version = "2.13.4.2"
jackson_databind_nullable_version = "0.2.6"
jakarta_annotation_version = "1.3.5"
jersey_version = "2.35"
junit_version = "5.8.2"
}
dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "org.glassfish.jersey.core:jersey-client:$jersey_version"
implementation "org.glassfish.jersey.inject:jersey-hk2:$jersey_version"
implementation "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
implementation "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"
implementation "org.glassfish.jersey.connectors:jersey-apache-connector:$jersey_version"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
test {
useJUnitPlatform()
}
javadoc {
options.tags = [ "http.response.details:a:Http Response Details" ]
}
// Use spotless plugin to automatically format code, remove unused import, etc
// To apply changes directly to the file, run `gradlew spotlessApply`
// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {
// comment out below to run spotless as part of the `check` task
enforceCheck false
format 'misc', {
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
target '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // Takes an integer argument if you don't like 4
endWithNewline()
}
java {
// don't need to set target, it is inferred from java
// apply a specific flavor of google-java-format
googleJavaFormat('1.8').aosp().reflowLongStrings()
removeUnusedImports()
importOrder()
}
}

View File

@@ -0,0 +1,27 @@
lazy val root = (project in file(".")).
settings(
organization := "org.openapitools",
name := "openapi-java-client",
version := "1.0.0",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
Compile / javacOptions ++= Seq("-Xlint:deprecation"),
Compile / packageDoc / publishArtifact := false,
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"com.google.code.findbugs" % "jsr305" % "3.0.0",
"io.swagger" % "swagger-annotations" % "1.6.5",
"org.glassfish.jersey.core" % "jersey-client" % "2.35",
"org.glassfish.jersey.inject" % "jersey-hk2" % "2.35",
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.35",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.35",
"org.glassfish.jersey.connectors" % "jersey-apache-connector" % "2.35",
"com.fasterxml.jackson.core" % "jackson-core" % "2.13.2" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.13.2" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4.1" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.13.2" % "compile",
"org.openapitools" % "jackson-databind-nullable" % "0.2.6" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"org.junit.jupiter" % "junit-jupiter-api" % "5.8.2" % "test"
)
)

View File

@@ -0,0 +1,68 @@
# DefaultApi
All URIs are relative to *http://api.example.xyz/v1*
| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**callList**](DefaultApi.md#callList) | **GET** /example | |
## callList
> Example callList()
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.model.*;
import org.openapitools.client.api.DefaultApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://api.example.xyz/v1");
DefaultApi apiInstance = new DefaultApi(defaultClient);
try {
Example result = apiInstance.callList();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#callList");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**Example**](Example.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | OK | - |

View File

@@ -0,0 +1,37 @@
# Example
## oneOf schemas
* [List<Integer>](List<Integer>.md)
* [UUID](UUID.md)
## Example
```java
// Import classes:
import org.openapitools.client.model.Example;
import org.openapitools.client.model.List<Integer>;
import org.openapitools.client.model.UUID;
public class Example {
public static void main(String[] args) {
Example exampleExample = new Example();
// create a new List<Integer>
List<Integer> exampleList<Integer> = new List<Integer>();
// set Example to List<Integer>
exampleExample.setActualInstance(exampleList<Integer>);
// to get back the List<Integer> set earlier
List<Integer> testList<Integer> = (List<Integer>) exampleExample.getActualInstance();
// create a new UUID
UUID exampleUUID = new UUID();
// set Example to UUID
exampleExample.setActualInstance(exampleUUID);
// to get back the UUID set earlier
UUID testUUID = (UUID) exampleExample.getActualInstance();
}
}
```

View File

@@ -0,0 +1,6 @@
# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator).
# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option.
#
# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
# For example, uncomment below to build for Android
#target = android

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -0,0 +1,234 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

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