Merge remote-tracking branch 'origin/master' into timcbaoth-improve-camlization-in-default-codegen

This commit is contained in:
William Cheng 2024-03-27 16:56:43 +08:00
commit f10a9939dd
4599 changed files with 1402 additions and 296 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -44,22 +44,22 @@ build_script:
test_script: test_script:
# test c# API client (multiple frameworks) # test c# API client (multiple frameworks)
- dotnet test samples\client\petstore\csharp\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\restsharp\net4.7\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (httpclient) # test c# API client (httpclient)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-httpclient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\httpclient\standard2.0\OpenAPIClient-httpclient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (generichost) # test c# API client (generichost)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-generichost-netstandard2.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\generichost\standard2.0\OpenAPIClient-generichost-netstandard2.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (netcore) # 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\restsharp\net7\OpenAPIClientCore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
#- dotnet test samples\client\petstore\csharp\OpenAPIClient\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) # test C# API client (.net framework 4.7)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\restsharp\net4.7\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net framework 4.8) # test C# API client (.net framework 4.8)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\restsharp\net4.8\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net 5.0) # test C# API client (.net 5.0)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\restsharp\net7\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API Client using conditional-serialization # 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\restsharp\standard2.0\OpenAPIClient-ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
### TODO: Execute all generators via powershell or other ### TODO: Execute all generators via powershell or other
# generate all petstore clients # generate all petstore clients

View File

@ -1,6 +1,6 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp
@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: false nullableReferenceTypes: false
equatable: true equatable: true
targetFramework: net8.0

View File

@ -1,6 +1,6 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp
@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true nullableReferenceTypes: true
equatable: true equatable: true
targetFramework: net8.0

View File

@ -1,6 +1,6 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp
@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true nullableReferenceTypes: true
equatable: true equatable: true
targetFramework: net8.0

View File

@ -1,6 +1,6 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp
@ -11,3 +11,4 @@ additionalProperties:
useSourceGeneration: true useSourceGeneration: true
packageName: UseSourceGeneration packageName: UseSourceGeneration
equatable: true equatable: true
targetFramework: net8.0

View File

@ -1,6 +1,6 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp
@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true nullableReferenceTypes: true
equatable: true equatable: true
targetFramework: net8.0

View File

@ -1,6 +1,6 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp
@ -10,3 +10,4 @@ additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true nullableReferenceTypes: true
equatable: true equatable: true
targetFramework: net8.0

View File

@ -1,9 +1,10 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties: additionalProperties:
packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}' packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}'
useDateTimeForDate: true useDateTimeForDate: true
targetFramework: net8.0

View File

@ -1,6 +1,6 @@
# for csharp generichost # for csharp generichost
generatorName: csharp 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp templateDir: modules/openapi-generator/src/main/resources/csharp

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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 # 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/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
sha256: e323c7e646a0ceb6d1d8f34f287175ac666fdbbe057791b45d138de3d9582666 sha256: e323c7e646a0ceb6d1d8f34f287175ac666fdbbe057791b45d138de3d9582666
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs" - filename: "samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
sha256: 7dad88554fe630d25c787cae05305d302d5e34ca810aee4fa23f20055f9188e1 sha256: 7dad88554fe630d25c787cae05305d302d5e34ca810aee4fa23f20055f9188e1
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png" - filename: "samples/client/petstore/csharp/restsharp/standard2.0/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230 sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
# java okhttp gson test files # java okhttp gson test files
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java" - filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java"

View File

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

View File

@ -2467,6 +2467,14 @@ public class DefaultCodegen implements CodegenConfig {
protected String getSingleSchemaType(Schema schema) { protected String getSingleSchemaType(Schema schema) {
Schema unaliasSchema = unaliasSchema(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 if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
// get the schema/model name from $ref // get the schema/model name from $ref
String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref()); String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
@ -3357,7 +3365,7 @@ public class DefaultCodegen implements CodegenConfig {
String modelName = ModelUtils.getSimpleRef(((Schema) oneOf).get$ref()); String modelName = ModelUtils.getSimpleRef(((Schema) oneOf).get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) oneOf, discPropName, visitedSchemas); CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) oneOf, discPropName, visitedSchemas);
if (thisCp == null) { if (thisCp == null) {
LOGGER.warn( once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}", "'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName); composedSchemaName, discPropName, modelName, discPropName);
} }
@ -3366,7 +3374,7 @@ public class DefaultCodegen implements CodegenConfig {
continue; continue;
} }
if (cp != thisCp) { 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", "'{}' 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); composedSchemaName, discPropName, modelName, discPropName, discPropName);
} }
@ -3380,7 +3388,7 @@ public class DefaultCodegen implements CodegenConfig {
String modelName = ModelUtils.getSimpleRef(((Schema) anyOf).get$ref()); String modelName = ModelUtils.getSimpleRef(((Schema) anyOf).get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) anyOf, discPropName, visitedSchemas); CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) anyOf, discPropName, visitedSchemas);
if (thisCp == null) { if (thisCp == null) {
LOGGER.warn( once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}", "'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName); composedSchemaName, discPropName, modelName, discPropName);
} }
@ -3389,7 +3397,7 @@ public class DefaultCodegen implements CodegenConfig {
continue; continue;
} }
if (cp != thisCp) { 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", "'{}' 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); composedSchemaName, discPropName, modelName, discPropName, discPropName);
} }
@ -3457,7 +3465,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
} }
if (discriminatorsPropNames.size() > 1) { 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)); "oneOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
} }
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getOneOf().size() && discriminatorsPropNames.size() == 1) { if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getOneOf().size() && discriminatorsPropNames.size() == 1) {
@ -3486,7 +3494,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
} }
if (discriminatorsPropNames.size() > 1) { 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)); "anyOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
} }
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getAnyOf().size() && discriminatorsPropNames.size() == 1) { if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getAnyOf().size() && discriminatorsPropNames.size() == 1) {
@ -3535,7 +3543,7 @@ public class DefaultCodegen implements CodegenConfig {
// schemas also has inline composed schemas // 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 // 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 // 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", "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); composedSchemaName);
} }
@ -3557,14 +3565,14 @@ public class DefaultCodegen implements CodegenConfig {
msgSuffix += spacer + "invalid optional definition of " + discPropName + ", include it in required"; 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); composedSchemaName, discPropName, modelName, msgSuffix);
} }
MappedModel mm = new MappedModel(modelName, toModelName(modelName)); MappedModel mm = new MappedModel(modelName, toModelName(modelName));
descendentSchemas.add(mm); descendentSchemas.add(mm);
Schema cs = ModelUtils.getSchema(openAPI, modelName); Schema cs = ModelUtils.getSchema(openAPI, modelName);
if (cs == null) { // cannot lookup the model based on the name 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 { } else {
Map<String, Object> vendorExtensions = cs.getExtensions(); Map<String, Object> vendorExtensions = cs.getExtensions();
if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) { if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) {
@ -3677,7 +3685,7 @@ public class DefaultCodegen implements CodegenConfig {
if (e.getValue().indexOf('/') >= 0) { if (e.getValue().indexOf('/') >= 0) {
name = ModelUtils.getSimpleRef(e.getValue()); name = ModelUtils.getSimpleRef(e.getValue());
if (ModelUtils.getSchema(openAPI, name) == null) { 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 { } else {
name = e.getValue(); name = e.getValue();
@ -3986,6 +3994,13 @@ public class DefaultCodegen implements CodegenConfig {
return cpc; 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; Schema original = null;
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level // 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) { if (ModelUtils.isAllOf(p) && p.getAllOf().size() == 1) {
@ -6960,6 +6975,7 @@ public class DefaultCodegen implements CodegenConfig {
scopes.add(scope); scopes.add(scope);
} }
codegenSecurity.scopes = scopes; codegenSecurity.scopes = scopes;
codegenSecurity.hasScopes = true;
} }
} }

View File

@ -929,16 +929,76 @@ public class ModelUtils {
* @return schema without '$ref' * @return schema without '$ref'
*/ */
public static Schema getReferencedSchema(OpenAPI openAPI, Schema schema) { public static Schema getReferencedSchema(OpenAPI openAPI, Schema schema) {
if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) { 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()); String name = getSimpleRef(schema.get$ref());
Schema referencedSchema = getSchema(openAPI, name); Schema referencedSchema = getSchema(openAPI, name);
if (referencedSchema != null) { if (referencedSchema != null) {
return referencedSchema; return referencedSchema;
} }
}
return schema; 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) { public static Schema getSchema(OpenAPI openAPI, String name) {
if (name == null) { if (name == null) {
return null; return null;
@ -1272,7 +1332,9 @@ public class ModelUtils {
} }
Schema ref = allSchemas.get(simpleRef); Schema ref = allSchemas.get(simpleRef);
if (ref == null) { if (ref == null) {
if (!isRefToSchemaWithProperties(schema.get$ref())) {
once(LOGGER).warn("{} is not defined", schema.get$ref()); once(LOGGER).warn("{} is not defined", schema.get$ref());
}
return schema; return schema;
} else if (ref.getEnum() != null && !ref.getEnum().isEmpty()) { } else if (ref.getEnum() != null && !ref.getEnum().isEmpty()) {
// top-level enum class // top-level enum class

View File

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

View File

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

View File

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

View File

@ -57,7 +57,6 @@ import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.assertj.core.api.MapAssert; import org.assertj.core.api.MapAssert;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
@ -1198,7 +1197,7 @@ public class SpringCodegenTest {
output.deleteOnExit(); output.deleteOnExit();
OpenAPI openAPI = new OpenAPIParser() 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(); final SpringCodegen codegen = new SpringCodegen();
codegen.setOpenAPI(openAPI); codegen.setOpenAPI(openAPI);
@ -1226,9 +1225,23 @@ public class SpringCodegenTest {
Path filePath = Paths.get(output.getAbsolutePath(), "src/main/java/org/openapitools/configuration/ClientPropertiesConfiguration.java"); 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}\" );")); assertFileContains(filePath,
Assert.assertTrue(content.contains("properties.put(\"spring.security.oauth2.client.provider.oAuth2AccessCode.authorization-uri\", \"${authorizationUrl}\" );")); "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 @Test

View File

@ -295,6 +295,25 @@ public class ModelUtilsTest {
Assert.assertEquals(decoded, "~1 Hallo/Welt"); 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 // 3.0 spec tests
@Test @Test

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: PetComposition:
allOf: allOf:
- $ref: '#/components/schemas/Pet' - $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,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

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

View File

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

View File

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

View File

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

View File

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

View File

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

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