mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 08:46:55 +00:00
Compare commits
66 Commits
jochenr-ma
...
kotlin-for
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be68142c8b | ||
|
|
b9d4b56d1c | ||
|
|
ea62c676c9 | ||
|
|
6be8fb3047 | ||
|
|
6e0fe098f1 | ||
|
|
41024dc23b | ||
|
|
9116411dac | ||
|
|
1c447a1605 | ||
|
|
4a7e0c9bdc | ||
|
|
65f99ebb21 | ||
|
|
5d12e71b40 | ||
|
|
5711f391e9 | ||
|
|
ddfcc95b61 | ||
|
|
c5e0d0840b | ||
|
|
8a4246cbaf | ||
|
|
a1b962d0b6 | ||
|
|
3b4494d751 | ||
|
|
2c4c24728f | ||
|
|
5ad2f84650 | ||
|
|
74be550d94 | ||
|
|
554e10dc34 | ||
|
|
6699ecd9d2 | ||
|
|
9655c22ff6 | ||
|
|
6210db308e | ||
|
|
e86daf9059 | ||
|
|
c52cc1f275 | ||
|
|
2c7efda060 | ||
|
|
107d72c5f5 | ||
|
|
a52e902cb5 | ||
|
|
547eee1970 | ||
|
|
c1c74c0ec8 | ||
|
|
7690545276 | ||
|
|
ecb1e9e2cb | ||
|
|
039de98d4f | ||
|
|
6892768009 | ||
|
|
fd72d4d521 | ||
|
|
1e3f6d0ed9 | ||
|
|
886e4a6dd0 | ||
|
|
57d304f3f6 | ||
|
|
59f7d09c2e | ||
|
|
ec8ca20dec | ||
|
|
2ab5365fb2 | ||
|
|
2326eef7cf | ||
|
|
d318752478 | ||
|
|
86ff873a03 | ||
|
|
28e2254e7a | ||
|
|
69da1ea470 | ||
|
|
b1f2a67bc3 | ||
|
|
48648a4051 | ||
|
|
a6c753ea69 | ||
|
|
81285b75e4 | ||
|
|
c596bb7d8a | ||
|
|
ce338a4a23 | ||
|
|
fb444bf15e | ||
|
|
a144678459 | ||
|
|
95b9438fd9 | ||
|
|
7beb8a6102 | ||
|
|
2107686d3d | ||
|
|
7486f12e62 | ||
|
|
600c051fa5 | ||
|
|
f37b8cce58 | ||
|
|
64c8711356 | ||
|
|
65359d8050 | ||
|
|
7ce0096e73 | ||
|
|
0ae50f5a10 | ||
|
|
3347204425 |
@@ -26,7 +26,7 @@ jobs:
|
||||
- samples/server/petstore/aspnet/fastendpoints-useValidators
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/Petstore/
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
- name: Build
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: 3.1.*
|
||||
- name: Build
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
- samples/server/petstore/aspnetcore-6.0-useSwashBuckle
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
- name: Build
|
||||
|
||||
2
.github/workflows/samples-dotnet7-client.yml
vendored
2
.github/workflows/samples-dotnet7-client.yml
vendored
@@ -43,7 +43,7 @@ jobs:
|
||||
- samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
- name: Build
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
- samples/client/echo_api/csharp/restsharp/net8/EchoApi
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Run echo server
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
- samples/client/petstore/csharp/restsharp/net8/useVirtualForHooks/
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
- samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
|
||||
2
.github/workflows/samples-dotnet8.yaml
vendored
2
.github/workflows/samples-dotnet8.yaml
vendored
@@ -34,7 +34,7 @@ jobs:
|
||||
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
|
||||
2
.github/workflows/samples-dotnet9.yaml
vendored
2
.github/workflows/samples-dotnet9.yaml
vendored
@@ -48,7 +48,7 @@ jobs:
|
||||
#- samples/client/petstore/csharp/unityWebRequest/net9/Petstore
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-dotnet@v5.0.0
|
||||
- uses: actions/setup-dotnet@v5.0.1
|
||||
with:
|
||||
dotnet-version: '9.0.101'
|
||||
- name: Build
|
||||
|
||||
@@ -61,6 +61,7 @@ jobs:
|
||||
- samples/client/petstore/java/native
|
||||
- samples/client/petstore/java/native-async
|
||||
- samples/client/petstore/java/native-jakarta
|
||||
- samples/client/petstore/java/native-useGzipFeature
|
||||
- samples/client/petstore/java/retrofit2
|
||||
- samples/client/petstore/java/retrofit2rx2
|
||||
- samples/client/petstore/java/retrofit2rx3
|
||||
|
||||
3
.github/workflows/samples-jaxrs.yaml
vendored
3
.github/workflows/samples-jaxrs.yaml
vendored
@@ -34,6 +34,9 @@ jobs:
|
||||
- samples/server/petstore/jaxrs-cxf-cdi
|
||||
- samples/server/petstore/jaxrs-cxf-non-spring-app
|
||||
- samples/server/petstore/jaxrs-spec-microprofile-openapi-annotations
|
||||
- samples/server/petstore/jaxrs-spec-swagger-annotations
|
||||
- samples/server/petstore/jaxrs-spec-swagger-v3-annotations-jakarta
|
||||
- samples/server/petstore/jaxrs-spec-swagger-v3-annotations
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-java@v5
|
||||
|
||||
2
.github/workflows/samples-kotlin-client.yaml
vendored
2
.github/workflows/samples-kotlin-client.yaml
vendored
@@ -44,6 +44,7 @@ jobs:
|
||||
- samples/client/petstore/kotlin-threetenbp
|
||||
- samples/client/petstore/kotlin-kotlinx-datetime
|
||||
- samples/client/petstore/kotlin-uppercase-enum
|
||||
- samples/client/petstore/kotlin-array-integer-enum
|
||||
- samples/client/petstore/kotlin-default-values-jvm-okhttp4
|
||||
- samples/client/petstore/kotlin-default-values-jvm-retrofit2
|
||||
- samples/client/petstore/kotlin-default-values-jvm-volley
|
||||
@@ -71,6 +72,7 @@ jobs:
|
||||
- samples/client/others/kotlin-jvm-okhttp-path-comments
|
||||
- samples/client/others/kotlin-integer-enum
|
||||
- samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization
|
||||
- samples/client/others/kotlin-oneOf-discriminator-kotlinx-serialization
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-java@v5
|
||||
|
||||
@@ -8,6 +8,7 @@ on:
|
||||
- 'samples/server/petstore/kotlin-server-modelMutable/**'
|
||||
- 'samples/server/petstore/kotlin-springboot-*/**'
|
||||
- 'samples/server/petstore/kotlin-server-required-and-nullable-properties/**'
|
||||
- 'samples/server/petstore/kotlin-spring-declarative*/**'
|
||||
# comment out due to gradle build failure
|
||||
# - samples/server/petstore/kotlin-spring-default/**
|
||||
pull_request:
|
||||
@@ -17,6 +18,7 @@ on:
|
||||
- 'samples/server/petstore/kotlin-server-modelMutable/**'
|
||||
- 'samples/server/petstore/kotlin-springboot-*/**'
|
||||
- 'samples/server/petstore/kotlin-server-required-and-nullable-properties/**'
|
||||
- 'samples/server/petstore/kotlin-spring-declarative*/**'
|
||||
# comment out due to gradle build failure
|
||||
# - samples/server/petstore/kotlin-spring-default/**
|
||||
|
||||
@@ -44,6 +46,10 @@ jobs:
|
||||
- samples/server/petstore/kotlin-server/ktor
|
||||
- samples/server/petstore/kotlin-server/ktor2
|
||||
- samples/server/petstore/kotlin-misk
|
||||
- samples/server/petstore/kotlin-spring-declarative-interface
|
||||
- samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines
|
||||
- samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped
|
||||
- samples/server/petstore/kotlin-spring-declarative-interface-wrapped
|
||||
# comment out due to gradle build failure
|
||||
# - samples/server/petstore/kotlin-spring-default/
|
||||
steps:
|
||||
|
||||
1
.github/workflows/samples-kotlin-server.yaml
vendored
1
.github/workflows/samples-kotlin-server.yaml
vendored
@@ -39,6 +39,7 @@ jobs:
|
||||
- samples/server/petstore/kotlin-springboot-source-swagger2
|
||||
- samples/server/petstore/kotlin-springboot-springfox
|
||||
- samples/server/petstore/kotlin-springboot-x-kotlin-implements
|
||||
- samples/server/petstore/kotlin-springboot-include-http-request-context-delegate
|
||||
- samples/server/petstore/kotlin-server/ktor
|
||||
- samples/server/petstore/kotlin-server/ktor2
|
||||
- samples/server/petstore/kotlin-server/jaxrs-spec
|
||||
|
||||
@@ -1182,6 +1182,7 @@ Here is a list of template creators:
|
||||
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||
* Scala Lagom: @gmkumar2005
|
||||
* Scala Play: @adigerber
|
||||
* TypeScript NestJS: @aryobenholzner
|
||||
* Documentation
|
||||
* AsciiDoc: @man-at-home
|
||||
* HTML Doc 2: @jhitchcock
|
||||
|
||||
9
bin/configs/java-native-useGzipFeature.yaml
Normal file
9
bin/configs/java-native-useGzipFeature.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/native-useGzipFeature
|
||||
library: native
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-addpet-only.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: petstore-native-useGzipFeature
|
||||
hideGenerationTimestamp: "true"
|
||||
useJakartaEe: "true"
|
||||
11
bin/configs/jaxrs-spec-swagger-annotations.yaml
Normal file
11
bin/configs/jaxrs-spec-swagger-annotations.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: jaxrs-spec
|
||||
outputDir: samples/server/petstore/jaxrs-spec-swagger-annotations
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
|
||||
additionalProperties:
|
||||
artifactId: jaxrs-spec-petstore-server
|
||||
serializableModel: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
implicitHeadersRegex: (api_key|enum_header_string)
|
||||
generateBuilders: "true"
|
||||
useSwaggerAnnotations: "true"
|
||||
12
bin/configs/jaxrs-spec-swagger-v3-annotations-jakarta.yaml
Normal file
12
bin/configs/jaxrs-spec-swagger-v3-annotations-jakarta.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
generatorName: jaxrs-spec
|
||||
outputDir: samples/server/petstore/jaxrs-spec-swagger-v3-annotations-jakarta
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
|
||||
additionalProperties:
|
||||
artifactId: jaxrs-spec-petstore-server-jakarta-swagger-v3
|
||||
serializableModel: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
implicitHeadersRegex: (api_key|enum_header_string)
|
||||
generateBuilders: "true"
|
||||
useSwaggerV3Annotations: "true"
|
||||
useJakartaEe: "true"
|
||||
11
bin/configs/jaxrs-spec-swagger-v3-annotations.yaml
Normal file
11
bin/configs/jaxrs-spec-swagger-v3-annotations.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: jaxrs-spec
|
||||
outputDir: samples/server/petstore/jaxrs-spec-swagger-v3-annotations
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
|
||||
additionalProperties:
|
||||
artifactId: jaxrs-spec-petstore-server
|
||||
serializableModel: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
implicitHeadersRegex: (api_key|enum_header_string)
|
||||
generateBuilders: "true"
|
||||
useSwaggerV3Annotations: "true"
|
||||
8
bin/configs/kotlin-array-integer-enum.yaml
Normal file
8
bin/configs/kotlin-array-integer-enum.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: kotlin
|
||||
outputDir: samples/client/petstore/kotlin-array-integer-enum
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/issue15204-int-array-enum.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||
additionalProperties:
|
||||
artifactId: kotlin-array-integer-enum
|
||||
serializableModel: "true"
|
||||
dateLibrary: java8
|
||||
@@ -0,0 +1,12 @@
|
||||
generatorName: kotlin
|
||||
outputDir: samples/client/others/kotlin-oneOf-discriminator-kotlinx-serialization
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/polymorphism-oneof-discriminator.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||
additionalProperties:
|
||||
artifactId: kotlin-oneOf-discriminator
|
||||
serializableModel: "false"
|
||||
dateLibrary: java8
|
||||
library: jvm-retrofit2
|
||||
enumUnknownDefaultCase: true
|
||||
serializationLibrary: kotlinx_serialization
|
||||
generateOneOfAnyOfWrappers: true
|
||||
@@ -0,0 +1,17 @@
|
||||
generatorName: kotlin-spring
|
||||
outputDir: samples/server/petstore/kotlin-springboot-include-http-request-context-delegate
|
||||
library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-x-kotlin-implements.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
|
||||
additionalProperties:
|
||||
documentationProvider: none
|
||||
annotationLibrary: swagger1
|
||||
useSwaggerUI: false
|
||||
serviceImplementation: false
|
||||
skipDefaultInterface: true
|
||||
interfaceOnly: false
|
||||
serializableModel: true
|
||||
beanValidations: true
|
||||
includeHttpRequestContext: true
|
||||
reactive: true
|
||||
delegatePattern: true
|
||||
@@ -5,10 +5,11 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
|
||||
additionalProperties:
|
||||
documentationProvider: none
|
||||
annotationLibrary: none
|
||||
useSwaggerUI: "false"
|
||||
serviceImplementation: "false"
|
||||
skipDefaultInterface: "true"
|
||||
interfaceOnly: "true"
|
||||
serializableModel: "true"
|
||||
beanValidations: "true"
|
||||
annotationLibrary: swagger1
|
||||
useSwaggerUI: false
|
||||
serviceImplementation: false
|
||||
skipDefaultInterface: true
|
||||
interfaceOnly: true
|
||||
serializableModel: true
|
||||
beanValidations: true
|
||||
includeHttpRequestContext: true
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
generatorName: kotlin-spring
|
||||
outputDir: samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines
|
||||
library: spring-declarative-http-interface
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
|
||||
additionalProperties:
|
||||
documentationProvider: springDoc
|
||||
annotationLibrary: swagger2
|
||||
useSwaggerUI: "false"
|
||||
serializableModel: "true"
|
||||
beanValidations: "true"
|
||||
interfaceOnly: true
|
||||
reactive: true
|
||||
declarativeInterfaceWrapResponses: false
|
||||
useFlowForArrayReturnType: false
|
||||
declarativeInterfaceReactiveMode: "coroutines"
|
||||
@@ -0,0 +1,16 @@
|
||||
generatorName: kotlin-spring
|
||||
outputDir: samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped
|
||||
library: spring-declarative-http-interface
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
|
||||
additionalProperties:
|
||||
documentationProvider: springDoc
|
||||
annotationLibrary: swagger2
|
||||
useSwaggerUI: "false"
|
||||
serializableModel: "true"
|
||||
beanValidations: "true"
|
||||
interfaceOnly: true
|
||||
reactive: true
|
||||
declarativeInterfaceWrapResponses: true
|
||||
useFlowForArrayReturnType: false
|
||||
declarativeInterfaceReactiveMode: "reactor"
|
||||
15
bin/configs/kotlin-spring-declarative-interface-wrapped.yaml
Normal file
15
bin/configs/kotlin-spring-declarative-interface-wrapped.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: kotlin-spring
|
||||
outputDir: samples/server/petstore/kotlin-spring-declarative-interface-wrapped
|
||||
library: spring-declarative-http-interface
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
|
||||
additionalProperties:
|
||||
documentationProvider: springDoc
|
||||
annotationLibrary: swagger2
|
||||
useSwaggerUI: "false"
|
||||
serializableModel: "true"
|
||||
beanValidations: "true"
|
||||
interfaceOnly: true
|
||||
reactive: false
|
||||
declarativeInterfaceWrapResponses: true
|
||||
useFlowForArrayReturnType: false
|
||||
15
bin/configs/kotlin-spring-declarative-interface.yaml
Normal file
15
bin/configs/kotlin-spring-declarative-interface.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: kotlin-spring
|
||||
outputDir: samples/server/petstore/kotlin-spring-declarative-interface
|
||||
library: spring-declarative-http-interface
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
|
||||
additionalProperties:
|
||||
documentationProvider: springDoc
|
||||
annotationLibrary: swagger2
|
||||
useSwaggerUI: "false"
|
||||
serializableModel: "true"
|
||||
beanValidations: "true"
|
||||
interfaceOnly: true
|
||||
reactive: false
|
||||
declarativeInterfaceWrapResponses: true
|
||||
useFlowForArrayReturnType: false
|
||||
@@ -6,7 +6,7 @@ library: httpx
|
||||
additionalProperties:
|
||||
packageName: petstore_api
|
||||
mapNumberTo: float
|
||||
poetry1: true
|
||||
poetry1: false
|
||||
nameMappings:
|
||||
_type: underscore_type
|
||||
type_: type_with_underscore
|
||||
|
||||
8
bin/configs/rust-reqwest-enum-query-params.yaml
Normal file
8
bin/configs/rust-reqwest-enum-query-params.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/others/rust/reqwest/enum-query-params
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/enum-query-params.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: true
|
||||
packageName: enum-query-params-reqwest
|
||||
10
bin/configs/rust-reqwest-petstore-serde-path-to-error.yaml
Normal file
10
bin/configs/rust-reqwest-petstore-serde-path-to-error.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/petstore/rust/reqwest/petstore-serde-path-to-error
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
packageName: petstore-reqwest-serde-path-to-error
|
||||
useSerdePathToError: true
|
||||
enumNameMappings:
|
||||
delivered: shipped
|
||||
@@ -31,10 +31,10 @@
|
||||
sha256: 24c6a39a9d7327d397dc038c368a19c84f14ed96a69fe28d53719b3eaf0a725c
|
||||
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/api/PetApiTest.java"
|
||||
sha256: 5e9f471d34310f94895751bb96cc79583376f043593c3a387c82077c70f8102f
|
||||
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/MammalTest.java"
|
||||
sha256: 67a9e63e13ebddac21cb236aa015edce30f5d3bd8d6adcf50044cad00d48c45e
|
||||
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/ZebraTest.java"
|
||||
sha256: 15eeb6d8a9a79d0f1930b861540d9c5780d6c49ea4fdb68269ac3e7ec481e142
|
||||
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/MammalTest.java"
|
||||
sha256: a09c120b694788b12f8d73cc0dd307e509ee1744b2ff45c5711b1186c419f915
|
||||
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/ZebraTest.java"
|
||||
sha256: 15e509d8cb8e9b050c6418cfbf8a5dced9acc97cf29e5727da9f907c52d11f1e
|
||||
- filename: "samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/api/PetApiTest.java"
|
||||
sha256: d8f7fff724f81e666daf115cc25f8347e1fda4e861aa30df0dae3fa50c91404c
|
||||
- filename: "samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/api/PetApiTest.java"
|
||||
|
||||
@@ -105,6 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false|
|
||||
|useSealedOneOfInterfaces|Generate the oneOf interfaces as sealed interfaces. Only supported for WebClient and RestClient.| |false|
|
||||
|useSingleRequestParameter|Setting this property to "true" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY native, jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to "static" does the same as "true", but also makes the generated arguments class static with single parameter instantiation.| |false|
|
||||
|useUnaryInterceptor|If true it will generate ResponseInterceptors using a UnaryOperator. This can be usefull for manipulating the request before it gets passed, for example doing your own decryption| |false|
|
||||
|webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false|
|
||||
|withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|
||||
@@ -105,6 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false|
|
||||
|useSealedOneOfInterfaces|Generate the oneOf interfaces as sealed interfaces. Only supported for WebClient and RestClient.| |false|
|
||||
|useSingleRequestParameter|Setting this property to "true" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY native, jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to "static" does the same as "true", but also makes the generated arguments class static with single parameter instantiation.| |false|
|
||||
|useUnaryInterceptor|If true it will generate ResponseInterceptors using a UnaryOperator. This can be usefull for manipulating the request before it gets passed, for example doing your own decryption| |false|
|
||||
|webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false|
|
||||
|withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|
||||
@@ -84,6 +84,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|
||||
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|
||||
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|
||||
|useSwaggerV3Annotations|Whether to generate Swagger v3 (OpenAPI v3) annotations.| |false|
|
||||
|useTags|use tags for creating interface and controller classnames| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|
||||
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|
||||
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|
||||
|useSwaggerV3Annotations|Whether to generate Swagger v3 (OpenAPI v3) annotations.| |false|
|
||||
|useTags|use tags for creating interface and controller classnames| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|
||||
|
||||
@@ -27,14 +27,17 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|
||||
|beanQualifiers|Whether to add fully-qualifier class names as bean qualifiers in @Component and @RestController annotations. May be used to prevent bean names clash if multiple generated libraries (contexts) added to single project.| |false|
|
||||
|configPackage|configuration package for generated code| |org.openapitools.configuration|
|
||||
|declarativeInterfaceReactiveMode|What type of reactive style to use in Spring Http declarative interface|<dl><dt>**coroutines**</dt><dd>Use kotlin-idiomatic 'suspend' functions</dd><dt>**reactor**</dt><dd>Use reactor return wrappers 'Mono' and 'Flux'</dd></dl>|coroutines|
|
||||
|declarativeInterfaceWrapResponses|Whether (when false) to return actual type (e.g. List<Fruit>) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>)| |false|
|
||||
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|
||||
|documentationProvider|Select the OpenAPI documentation provider.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springfox**</dt><dd>Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x. Deprecated (for removal); use springdoc instead.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|springdoc|
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
|
||||
|exceptionHandler|generate default global exception handlers (not compatible with reactive. enabling reactive will disable exceptionHandler )| |true|
|
||||
|gradleBuildFile|generate a gradle build file using the Kotlin DSL| |true|
|
||||
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|
||||
|includeHttpRequestContext|Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods.| |false|
|
||||
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|
||||
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd></dl>|spring-boot|
|
||||
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-declarative-http-interface**</dt><dd>Spring Declarative Interface client</dd></dl>|spring-boot|
|
||||
|modelMutable|Create mutable models| |false|
|
||||
|modelPackage|model package for generated code| |org.openapitools.model|
|
||||
|packageName|Generated artifact package name.| |org.openapitools|
|
||||
|
||||
@@ -226,8 +226,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Polymorphism|✗|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|anyOf|✓|OAS3
|
||||
|oneOf|✓|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
|
||||
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<ul class="column-ul">
|
||||
<li>Dict</li>
|
||||
<li>List</li>
|
||||
<li>UUID</li>
|
||||
<li>bool</li>
|
||||
<li>bytes</li>
|
||||
<li>date</li>
|
||||
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Uuid|✓|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|
||||
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<ul class="column-ul">
|
||||
<li>Dict</li>
|
||||
<li>List</li>
|
||||
<li>UUID</li>
|
||||
<li>bool</li>
|
||||
<li>bytes</li>
|
||||
<li>date</li>
|
||||
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Uuid|✓|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|
||||
@@ -50,6 +50,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<ul class="column-ul">
|
||||
<li>Dict</li>
|
||||
<li>List</li>
|
||||
<li>UUID</li>
|
||||
<li>bool</li>
|
||||
<li>bytes</li>
|
||||
<li>date</li>
|
||||
@@ -150,7 +151,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Uuid|✓|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|
||||
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<ul class="column-ul">
|
||||
<li>Dict</li>
|
||||
<li>List</li>
|
||||
<li>UUID</li>
|
||||
<li>bool</li>
|
||||
<li>bytes</li>
|
||||
<li>date</li>
|
||||
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Uuid|✓|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|
||||
@@ -53,6 +53,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<ul class="column-ul">
|
||||
<li>Dict</li>
|
||||
<li>List</li>
|
||||
<li>UUID</li>
|
||||
<li>bool</li>
|
||||
<li>bytearray</li>
|
||||
<li>bytes</li>
|
||||
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Uuid|✓|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|
||||
@@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option| |false|
|
||||
|topLevelApiClient|Creates a top level `Api` trait and `ApiClient` struct that contain all Apis. This option is for 'reqwest-trait' library only| |false|
|
||||
|useBonBuilder|Use the bon crate for building parameter types. This option is for the 'reqwest-trait' library only| |false|
|
||||
|useSerdePathToError|If set, use the serde_path_to_error library to enhance serde error messages. This option is for 'reqwest' and 'reqwest-trait' library only| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|
||||
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
|
||||
|
||||
|
||||
@@ -265,6 +265,15 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
private Map<String, CodegenProperty> requiredVarsMap;
|
||||
private String ref;
|
||||
|
||||
/**
|
||||
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
|
||||
*
|
||||
* @return vendor extensions
|
||||
*/
|
||||
public Map<String, Object> getExts() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getContains() {
|
||||
return contains;
|
||||
@@ -365,7 +374,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
return discriminator == null ? null : discriminator.getPropertyName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPattern() {
|
||||
return pattern;
|
||||
|
||||
@@ -79,6 +79,15 @@ public class CodegenOperation {
|
||||
return params != null && !params.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
|
||||
*
|
||||
* @return vendor extensions
|
||||
*/
|
||||
public Map<String, Object> getExts() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one parameter
|
||||
*
|
||||
|
||||
@@ -534,6 +534,15 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
|
||||
*
|
||||
* @return vendor extensions
|
||||
*/
|
||||
public Map<String, Object> getExts() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
|
||||
// use schema.getContains or content.mediaType.schema.getContains instead of this
|
||||
@Override
|
||||
public CodegenProperty getContains() {
|
||||
|
||||
@@ -436,6 +436,15 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
return !getRequired() || isNullable;
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
|
||||
*
|
||||
* @return vendor extensions
|
||||
*/
|
||||
public Map<String, Object> getExts() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getItems() {
|
||||
return items;
|
||||
|
||||
@@ -206,6 +206,15 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
|
||||
*
|
||||
* @return vendor extensions
|
||||
*/
|
||||
public Map<String, Object> getExts() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
|
||||
// use content.mediaType.schema.getContains instead of this
|
||||
@Override
|
||||
public CodegenProperty getContains() {
|
||||
|
||||
@@ -38,4 +38,13 @@ public class CodegenServer {
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
|
||||
*
|
||||
* @return vendor extensions
|
||||
*/
|
||||
public Map<String, Object> getExts() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1843,6 +1843,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected void initializeSpecialCharacterMapping() {
|
||||
// Initialize special characters
|
||||
specialCharReplacements.put("$", "Dollar");
|
||||
specialCharReplacements.put("€", "Euro");
|
||||
specialCharReplacements.put("^", "Caret");
|
||||
specialCharReplacements.put("|", "Pipe");
|
||||
specialCharReplacements.put("=", "Equal");
|
||||
|
||||
@@ -696,6 +696,11 @@ public class OpenAPINormalizer {
|
||||
* @return Schema
|
||||
*/
|
||||
public Schema normalizeSchema(Schema schema, Set<Schema> visitedSchemas) {
|
||||
// normalize reference schema
|
||||
if (StringUtils.isNotEmpty(schema.get$ref())) {
|
||||
normalizeReferenceSchema(schema);
|
||||
}
|
||||
|
||||
if (skipNormalization(schema, visitedSchemas)) {
|
||||
return schema;
|
||||
}
|
||||
@@ -763,6 +768,30 @@ public class OpenAPINormalizer {
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize reference schema with allOf to support sibling properties
|
||||
*
|
||||
* @param schema Schema
|
||||
*/
|
||||
protected void normalizeReferenceSchema(Schema schema) {
|
||||
if (schema.getTitle() != null || schema.getDescription() != null
|
||||
|| schema.getNullable() != null || schema.getDefault() != null || schema.getDeprecated() != null
|
||||
|| schema.getMaximum() != null || schema.getMinimum() != null
|
||||
|| schema.getExclusiveMaximum() != null || schema.getExclusiveMinimum() != null
|
||||
|| schema.getMaxItems() != null || schema.getMinItems() != null
|
||||
|| schema.getMaxProperties() != null || schema.getMinProperties() != null
|
||||
|| schema.getMaxLength() != null || schema.getMinLength() != null
|
||||
|| schema.getWriteOnly() != null || schema.getReadOnly() != null
|
||||
|| schema.getExample() != null || (schema.getExamples() != null && !schema.getExamples().isEmpty())
|
||||
|| schema.getMultipleOf() != null || schema.getPattern() != null
|
||||
|| (schema.getExtensions() != null && !schema.getExtensions().isEmpty())
|
||||
) {
|
||||
// create allOf with a $ref schema
|
||||
schema.addAllOfItem(new Schema<>().$ref(schema.get$ref()));
|
||||
// clear $ref in original schema
|
||||
schema.set$ref(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if normalization is needed.
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.openapitools.codegen.languages;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import lombok.Getter;
|
||||
@@ -35,6 +36,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -1172,4 +1176,15 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static abstract class CustomLambda implements Mustache.Lambda {
|
||||
@Override
|
||||
public void execute(Template.Fragment frag, Writer out) throws IOException {
|
||||
final StringWriter tempWriter = new StringWriter();
|
||||
frag.execute(tempWriter);
|
||||
out.write(formatFragment(tempWriter.toString()));
|
||||
}
|
||||
|
||||
public abstract String formatFragment(String fragment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.DataTypeFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
@@ -71,7 +72,9 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
SecurityFeature.BearerToken,
|
||||
SecurityFeature.ApiKey,
|
||||
SecurityFeature.OAuth2_Implicit
|
||||
)));
|
||||
)).includeDataTypeFeatures(
|
||||
DataTypeFeature.Uuid
|
||||
));
|
||||
|
||||
// from https://docs.python.org/3/reference/lexical_analysis.html#keywords
|
||||
setReservedWordsLowerCase(
|
||||
@@ -108,6 +111,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
// TODO file and binary is mapped as `file`
|
||||
languageSpecificPrimitives.add("file");
|
||||
languageSpecificPrimitives.add("bytes");
|
||||
languageSpecificPrimitives.add("UUID");
|
||||
|
||||
typeMapping.clear();
|
||||
typeMapping.put("integer", "int");
|
||||
@@ -129,8 +133,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "str");
|
||||
typeMapping.put("ByteArray", "str");
|
||||
// map uuid to string for the time being
|
||||
typeMapping.put("UUID", "str");
|
||||
typeMapping.put("UUID", "UUID");
|
||||
typeMapping.put("URI", "str");
|
||||
typeMapping.put("null", "none_type");
|
||||
|
||||
@@ -571,7 +574,12 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
type = p.dataType;
|
||||
}
|
||||
|
||||
if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
|
||||
if (Boolean.TRUE.equals(p.isUuid)) {
|
||||
if (example == null) {
|
||||
example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
|
||||
}
|
||||
example = "UUID('" + escapeTextInSingleQuotes(example) + "')";
|
||||
} else if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = p.paramName + "_example";
|
||||
}
|
||||
@@ -671,7 +679,13 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
return getSchemaType(p) + "[str, " + getCollectionItemTypeDeclaration(inner) + "]";
|
||||
}
|
||||
|
||||
String openAPIType = getSchemaType(p);
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
|
||||
if (openAPIType == null) {
|
||||
LOGGER.error("OpenAPI Type for {} is null. Default to UNKNOWN_OPENAPI_TYPE instead.", p.getName());
|
||||
openAPIType = "UNKNOWN_OPENAPI_TYPE";
|
||||
}
|
||||
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
return typeMapping.get(openAPIType);
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String FAIL_ON_UNKNOWN_PROPERTIES = "failOnUnknownProperties";
|
||||
public static final String SUPPORT_VERTX_FUTURE = "supportVertxFuture";
|
||||
public static final String USE_SEALED_ONE_OF_INTERFACES = "useSealedOneOfInterfaces";
|
||||
public static final String USE_UNARY_INTERCEPTOR = "useUnaryInterceptor";
|
||||
|
||||
// Internal configurations
|
||||
public static final String SINGLE_REQUEST_PARAMETER = "singleRequestParameter";
|
||||
@@ -149,6 +150,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
@Getter @Setter protected boolean failOnUnknownProperties = false;
|
||||
@Setter protected boolean supportVertxFuture = false;
|
||||
@Setter protected boolean useSealedOneOfInterfaces = false;
|
||||
@Setter protected boolean useUnaryInterceptor = false;
|
||||
protected String authFolder;
|
||||
/**
|
||||
* Serialization library.
|
||||
@@ -260,6 +262,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(FAIL_ON_UNKNOWN_PROPERTIES, "Fail Jackson de-serialization on unknown properties", this.failOnUnknownProperties));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_VERTX_FUTURE, "Also generate api methods that return a vertx Future instead of taking a callback. Only `vertx` supports this option. Requires vertx 4 or greater.", this.supportVertxFuture));
|
||||
cliOptions.add(CliOption.newBoolean(USE_SEALED_ONE_OF_INTERFACES, "Generate the oneOf interfaces as sealed interfaces. Only supported for WebClient and RestClient.", this.useSealedOneOfInterfaces));
|
||||
cliOptions.add(CliOption.newBoolean(USE_UNARY_INTERCEPTOR, "If true it will generate ResponseInterceptors using a UnaryOperator. This can be usefull for manipulating the request before it gets passed, for example doing your own decryption", this.useUnaryInterceptor));
|
||||
|
||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.17.1");
|
||||
supportedLibraries.put(JERSEY3, "HTTP client: Jersey client 3.1.1. JSON processing: Jackson 2.17.1");
|
||||
@@ -376,6 +379,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
convertPropertyToStringAndWriteBack(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, this::setUseSingleRequestParameter);
|
||||
convertPropertyToBooleanAndWriteBack(USE_SEALED_ONE_OF_INTERFACES, this::setUseSealedOneOfInterfaces);
|
||||
convertPropertyToBooleanAndWriteBack(USE_UNARY_INTERCEPTOR, this::setUseUnaryInterceptor);
|
||||
writePropertyBack(SINGLE_REQUEST_PARAMETER, getSingleRequestParameter());
|
||||
writePropertyBack(STATIC_REQUEST, getStaticRequest());
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public static final String GENERATE_POM = "generatePom";
|
||||
public static final String USE_SWAGGER_ANNOTATIONS = "useSwaggerAnnotations";
|
||||
public static final String USE_MICROPROFILE_OPENAPI_ANNOTATIONS = "useMicroProfileOpenAPIAnnotations";
|
||||
public static final String USE_SWAGGER_V3_ANNOTATIONS = "useSwaggerV3Annotations";
|
||||
public static final String USE_MUTINY = "useMutiny";
|
||||
public static final String OPEN_API_SPEC_FILE_LOCATION = "openApiSpecFileLocation";
|
||||
public static final String GENERATE_JSON_CREATOR = "generateJsonCreator";
|
||||
@@ -57,6 +58,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
private boolean returnJbossResponse = false;
|
||||
private boolean generatePom = true;
|
||||
private boolean useSwaggerAnnotations = true;
|
||||
private boolean useSwaggerV3Annotations = false;
|
||||
private boolean useMicroProfileOpenAPIAnnotations = false;
|
||||
private boolean useMutiny = false;
|
||||
|
||||
@@ -133,6 +135,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
cliOptions.add(CliOption.newBoolean(RETURN_RESPONSE, "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.").defaultValue(String.valueOf(returnResponse)));
|
||||
cliOptions.add(CliOption.newBoolean(RETURN_JBOSS_RESPONSE, "Whether generate API interface should return `org.jboss.resteasy.reactive.RestResponse` instead of a deserialized entity. This flag cannot be combined with `returnResponse` flag. It requires the flag `interfaceOnly` and `useJakartaEE` set to true, because `org.jboss.resteasy.reactive.RestResponse` was introduced in Quarkus 2.x").defaultValue(String.valueOf(returnJbossResponse)));
|
||||
cliOptions.add(CliOption.newBoolean(USE_SWAGGER_ANNOTATIONS, "Whether to generate Swagger annotations.", useSwaggerAnnotations));
|
||||
cliOptions.add(CliOption.newBoolean(USE_SWAGGER_V3_ANNOTATIONS, "Whether to generate Swagger v3 (OpenAPI v3) annotations.", useSwaggerV3Annotations));
|
||||
cliOptions.add(CliOption.newBoolean(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, "Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.", useMicroProfileOpenAPIAnnotations));
|
||||
cliOptions.add(CliOption.newString(OPEN_API_SPEC_FILE_LOCATION, "Location where the file containing the spec will be generated in the output folder. No file generated when set to null or empty string."));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_ASYNC, "Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).", supportAsync));
|
||||
@@ -149,14 +152,28 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
convertPropertyToBooleanAndWriteBack(RETURN_JBOSS_RESPONSE, value -> returnJbossResponse = value);
|
||||
convertPropertyToBooleanAndWriteBack(SUPPORT_ASYNC, this::setSupportAsync);
|
||||
if (QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || OPEN_LIBERTY_LIBRARY.equals(library) || KUMULUZEE_LIBRARY.equals(library)) {
|
||||
// disable Swagger v2 annotations in library modes; MicroProfile or Swagger v3 may be used instead
|
||||
useSwaggerAnnotations = false;
|
||||
} else {
|
||||
convertPropertyToBooleanAndWriteBack(USE_SWAGGER_ANNOTATIONS, value -> useSwaggerAnnotations = value);
|
||||
}
|
||||
// Swagger v3 can be used regardless of library
|
||||
convertPropertyToBooleanAndWriteBack(USE_SWAGGER_V3_ANNOTATIONS, value -> useSwaggerV3Annotations = value);
|
||||
// prefer v3 when requested
|
||||
if (useSwaggerV3Annotations) {
|
||||
useSwaggerAnnotations = false;
|
||||
}
|
||||
if (KUMULUZEE_LIBRARY.equals(library)) {
|
||||
super.setSourceFolder("src/main/java");
|
||||
}
|
||||
|
||||
if (useSwaggerAnnotations && useSwaggerV3Annotations) {
|
||||
throw new IllegalArgumentException("Flags 'useSwaggerAnnotations' (v2) and 'useSwaggerV3Annotations' (v3) are mutually exclusive. Please enable only one.");
|
||||
}
|
||||
if (useSwaggerV3Annotations && useMicroProfileOpenAPIAnnotations) {
|
||||
throw new IllegalArgumentException("Flags 'useSwaggerV3Annotations' and 'useMicroProfileOpenAPIAnnotations' are mutually exclusive. Please enable only one.");
|
||||
}
|
||||
|
||||
if (QUARKUS_LIBRARY.equals(library)) {
|
||||
convertPropertyToBooleanAndWriteBack(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, value -> useMicroProfileOpenAPIAnnotations = value);
|
||||
}
|
||||
@@ -184,6 +201,11 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
|
||||
super.processOpts();
|
||||
|
||||
// expose flags to templates
|
||||
additionalProperties.put(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);
|
||||
additionalProperties.put(USE_SWAGGER_V3_ANNOTATIONS, useSwaggerV3Annotations);
|
||||
additionalProperties.put(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, useMicroProfileOpenAPIAnnotations);
|
||||
|
||||
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
|
||||
.doNotOverwrite());
|
||||
|
||||
@@ -22,7 +22,6 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
@@ -40,10 +39,8 @@ import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
@@ -60,14 +57,7 @@ import org.openapitools.codegen.meta.features.ParameterFeature;
|
||||
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.ReplaceAllLambda;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.util.Collections.sort;
|
||||
|
||||
@@ -569,6 +559,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
// as the parser interrupts that as a start of a multiline comment.
|
||||
// We replace paths like `/v1/foo/*` with `/v1/foo/<*>` to avoid this
|
||||
additionalProperties.put("sanitizePathComment", new ReplaceAllLambda("\\/\\*", "/<*>"));
|
||||
additionalProperties.put("fnToOneOfWrapperName", new ToOneOfWrapperName());
|
||||
}
|
||||
|
||||
private void processDateLibrary() {
|
||||
@@ -974,11 +965,21 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (discriminator == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// When using generateOneOfAnyOfWrappers and encountering oneOf, we keep discriminator properties,
|
||||
// because single entity can be referenced in multiple "parent" entities,
|
||||
// so discriminator for one might not be discriminator for another.
|
||||
boolean shouldKeepDiscriminatorField = generateOneOfAnyOfWrappers && cm.oneOf != null && !cm.oneOf.isEmpty();
|
||||
|
||||
if (shouldKeepDiscriminatorField) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove discriminator property from the base class, it is not needed in the generated code
|
||||
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name.equals(discriminator.getPropertyName())));
|
||||
|
||||
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
|
||||
// Add the mapping name to additionalProperties.disciminatorValue
|
||||
// Add the mapping name to additionalProperties.discriminatorValue
|
||||
// The mapping name is used to define SerializedName, which in result makes derived classes
|
||||
// found by kotlinx-serialization during deserialization
|
||||
CodegenProperty additionalProperties = mappedModel.getModel().getAdditionalProperties();
|
||||
@@ -989,8 +990,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
additionalProperties.discriminatorValue = mappedModel.getMappingName();
|
||||
// Remove the discriminator property from the derived class, it is not needed in the generated code
|
||||
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name.equals(discriminator.getPropertyName())));
|
||||
}
|
||||
|
||||
// If model has no properties after removing discriminator, mark it as empty
|
||||
// so it generates as a class instead of an empty data class
|
||||
if (mappedModel.getModel().vars.isEmpty() && !mappedModel.getModel().isEnum && !mappedModel.getModel().isAlias) {
|
||||
mappedModel.getModel().setHasVars(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1135,6 +1141,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
param.defaultValue = type + "." + param.enumDefaultValue;
|
||||
}
|
||||
|
||||
private class ToOneOfWrapperName extends CustomLambda {
|
||||
@Override
|
||||
public String formatFragment(String fragment) {
|
||||
return toModelName(StringUtils.lowerCase(fragment)) + "Wrapper";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
System.out.println("################################################################################");
|
||||
|
||||
@@ -70,6 +70,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
public static final String BASE_PACKAGE = "basePackage";
|
||||
public static final String SPRING_BOOT = "spring-boot";
|
||||
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
|
||||
public static final String SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY = "spring-declarative-http-interface";
|
||||
public static final String EXCEPTION_HANDLER = "exceptionHandler";
|
||||
public static final String GRADLE_BUILD_FILE = "gradleBuildFile";
|
||||
public static final String SERVICE_INTERFACE = "serviceInterface";
|
||||
@@ -84,13 +85,30 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
public static final String DELEGATE_PATTERN = "delegatePattern";
|
||||
public static final String USE_TAGS = "useTags";
|
||||
public static final String BEAN_QUALIFIERS = "beanQualifiers";
|
||||
public static final String DECLARATIVE_INTERFACE_WRAP_RESPONSES = "declarativeInterfaceWrapResponses";
|
||||
public static final String DECLARATIVE_INTERFACE_REACTIVE_MODE = "declarativeInterfaceReactiveMode";
|
||||
|
||||
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
|
||||
public static final String INCLUDE_HTTP_REQUEST_CONTEXT = "includeHttpRequestContext";
|
||||
public static final String USE_FLOW_FOR_ARRAY_RETURN_TYPE = "useFlowForArrayReturnType";
|
||||
public static final String REQUEST_MAPPING_OPTION = "requestMappingMode";
|
||||
public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
|
||||
public static final String USE_REQUEST_MAPPING_ON_INTERFACE = "useRequestMappingOnInterface";
|
||||
|
||||
@Getter
|
||||
public enum DeclarativeInterfaceReactiveMode {
|
||||
coroutines("Use kotlin-idiomatic 'suspend' functions", "reactiveModeCoroutines"),
|
||||
reactor("Use reactor return wrappers 'Mono' and 'Flux'", "reactiveModeReactor");
|
||||
|
||||
private final String description;
|
||||
private final String additionalPropertyName;
|
||||
|
||||
DeclarativeInterfaceReactiveMode(String description, String additionalPropertyName) {
|
||||
this.description = description;
|
||||
this.additionalPropertyName = additionalPropertyName;
|
||||
}
|
||||
}
|
||||
|
||||
public enum RequestMappingMode {
|
||||
api_interface("Generate the @RequestMapping annotation on the generated Api Interface."),
|
||||
controller("Generate the @RequestMapping annotation on the generated Api Controller Implementation."),
|
||||
@@ -127,6 +145,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
@Setter private boolean serviceImplementation = false;
|
||||
@Getter @Setter
|
||||
private boolean reactive = false;
|
||||
@Setter private boolean includeHttpRequestContext = false;
|
||||
@Getter @Setter
|
||||
private boolean useFlowForArrayReturnType = true;
|
||||
@Setter private boolean interfaceOnly = false;
|
||||
@@ -135,6 +154,8 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
@Setter private boolean delegatePattern = false;
|
||||
@Setter protected boolean useTags = false;
|
||||
@Setter private boolean beanQualifiers = false;
|
||||
@Setter private DeclarativeInterfaceReactiveMode declarativeInterfaceReactiveMode = DeclarativeInterfaceReactiveMode.coroutines;
|
||||
@Setter private boolean declarativeInterfaceWrapResponses = false;
|
||||
|
||||
@Getter @Setter
|
||||
protected boolean useSpringBoot3 = false;
|
||||
@@ -220,9 +241,15 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
" (contexts) added to single project.", beanQualifiers);
|
||||
addSwitch(USE_SPRING_BOOT3, "Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.", useSpringBoot3);
|
||||
addSwitch(USE_FLOW_FOR_ARRAY_RETURN_TYPE, "Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.", useFlowForArrayReturnType);
|
||||
addSwitch(INCLUDE_HTTP_REQUEST_CONTEXT, "Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods.", includeHttpRequestContext);
|
||||
addSwitch(DECLARATIVE_INTERFACE_WRAP_RESPONSES,
|
||||
"Whether (when false) to return actual type (e.g. List<Fruit>) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>)",
|
||||
declarativeInterfaceWrapResponses);
|
||||
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
|
||||
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
|
||||
"Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
|
||||
supportedLibraries.put(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY,
|
||||
"Spring Declarative Interface client");
|
||||
setLibrary(SPRING_BOOT);
|
||||
|
||||
CliOption cliOpt = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC);
|
||||
@@ -238,6 +265,14 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
}
|
||||
cliOptions.add(requestMappingOpt);
|
||||
|
||||
CliOption declarativeInterfaceReactiveModeOpt = new CliOption(DECLARATIVE_INTERFACE_REACTIVE_MODE,
|
||||
"What type of reactive style to use in Spring Http declarative interface")
|
||||
.defaultValue(declarativeInterfaceReactiveMode.name());
|
||||
for (DeclarativeInterfaceReactiveMode mode : DeclarativeInterfaceReactiveMode.values()) {
|
||||
declarativeInterfaceReactiveModeOpt.addEnum(mode.name(), mode.getDescription());
|
||||
}
|
||||
cliOptions.add(declarativeInterfaceReactiveModeOpt);
|
||||
|
||||
if (null != defaultDocumentationProvider()) {
|
||||
CliOption documentationProviderCliOption = new CliOption(DOCUMENTATION_PROVIDER,
|
||||
"Select the OpenAPI documentation provider.")
|
||||
@@ -518,6 +553,41 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
this.setUseFlowForArrayReturnType(convertPropertyToBoolean(USE_FLOW_FOR_ARRAY_RETURN_TYPE));
|
||||
}
|
||||
}
|
||||
if (library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY)) {
|
||||
this.setReactive(convertPropertyToBoolean(REACTIVE));
|
||||
if (additionalProperties.containsKey(USE_FLOW_FOR_ARRAY_RETURN_TYPE)) {
|
||||
this.setUseFlowForArrayReturnType(convertPropertyToBoolean(USE_FLOW_FOR_ARRAY_RETURN_TYPE));
|
||||
}
|
||||
if (this.isUseFlowForArrayReturnType()) {
|
||||
{
|
||||
throw new IllegalArgumentException("Additional property '" + USE_FLOW_FOR_ARRAY_RETURN_TYPE + "' must be set to 'false' as it is not supported by Spring declarative HTTP interface");
|
||||
}
|
||||
}
|
||||
if (additionalProperties.containsKey(DECLARATIVE_INTERFACE_REACTIVE_MODE)) {
|
||||
try {
|
||||
DeclarativeInterfaceReactiveMode optValue = DeclarativeInterfaceReactiveMode.valueOf(
|
||||
String.valueOf(additionalProperties.get(DECLARATIVE_INTERFACE_REACTIVE_MODE)));
|
||||
setDeclarativeInterfaceReactiveMode(optValue);
|
||||
writePropertyBack(optValue.getAdditionalPropertyName(), true);
|
||||
additionalProperties.remove(DECLARATIVE_INTERFACE_REACTIVE_MODE);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid value for additional property '" + DECLARATIVE_INTERFACE_REACTIVE_MODE + "'. Supported values are " + Arrays.toString(DeclarativeInterfaceReactiveMode.values()) + "."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY.equals(library)) {
|
||||
this.setUseSpringBoot3(true);
|
||||
this.setInterfaceOnly(true);
|
||||
this.setUseFeignClient(false);
|
||||
this.setSkipDefaultInterface(true);
|
||||
|
||||
writePropertyBack(USE_SPRING_BOOT3, useSpringBoot3);
|
||||
writePropertyBack(INTERFACE_ONLY, interfaceOnly);
|
||||
writePropertyBack(USE_FEIGN_CLIENT, useFeignClient);
|
||||
writePropertyBack(SKIP_DEFAULT_INTERFACE, skipDefaultInterface);
|
||||
}
|
||||
writePropertyBack(REACTIVE, reactive);
|
||||
writePropertyBack(EXCEPTION_HANDLER, exceptionHandler);
|
||||
@@ -564,6 +634,9 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
if (additionalProperties.containsKey(USE_SPRING_BOOT3)) {
|
||||
this.setUseSpringBoot3(convertPropertyToBoolean(USE_SPRING_BOOT3));
|
||||
}
|
||||
if (additionalProperties.containsKey(INCLUDE_HTTP_REQUEST_CONTEXT)) {
|
||||
this.setIncludeHttpRequestContext(convertPropertyToBoolean(INCLUDE_HTTP_REQUEST_CONTEXT));
|
||||
}
|
||||
if (isUseSpringBoot3()) {
|
||||
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
|
||||
throw new IllegalArgumentException(DocumentationProvider.SPRINGFOX.getPropertyName() + " is not supported with Spring Boot > 3.x");
|
||||
@@ -606,7 +679,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
|
||||
if (this.exceptionHandler && !library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
if (this.exceptionHandler && !(library.equals(SPRING_CLOUD_LIBRARY) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY))) {
|
||||
supportingFiles.add(new SupportingFile("exceptions.mustache",
|
||||
sanitizeDirectory(sourceFolder + File.separator + apiPackage), "Exceptions.kt"));
|
||||
}
|
||||
@@ -699,8 +772,29 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
|
||||
apiTestTemplateFiles.clear();
|
||||
}
|
||||
if (library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY)) {
|
||||
LOGGER.info("Setup code generator for Kotlin Spring Declarative Http interface");
|
||||
|
||||
if (!reactive && !library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("pom-sb3.mustache", "pom.xml"));
|
||||
|
||||
if (this.gradleBuildFile) {
|
||||
supportingFiles.add(new SupportingFile("buildGradle-sb3-Kts.mustache", "build.gradle.kts"));
|
||||
supportingFiles.add(new SupportingFile("settingsGradle.mustache", "settings.gradle"));
|
||||
|
||||
String gradleWrapperPackage = "gradle.wrapper";
|
||||
supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
|
||||
supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
|
||||
supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache",
|
||||
gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.properties"));
|
||||
supportingFiles.add(new SupportingFile("gradle-wrapper.jar",
|
||||
gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.jar"));
|
||||
}
|
||||
|
||||
apiTemplateFiles.put("apiInterface.mustache", "Client.kt");
|
||||
apiTestTemplateFiles.clear();
|
||||
}
|
||||
|
||||
if (!reactive && !(library.equals(SPRING_CLOUD_LIBRARY) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY))) {
|
||||
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
|
||||
supportingFiles.add(new SupportingFile("springfoxDocumentationConfig.mustache",
|
||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),
|
||||
|
||||
@@ -34,6 +34,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
@@ -77,6 +79,10 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
.excludeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.Polymorphism
|
||||
)
|
||||
.includeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.oneOf,
|
||||
SchemaSupportFeature.anyOf
|
||||
)
|
||||
.excludeParameterFeatures(
|
||||
ParameterFeature.Cookie
|
||||
)
|
||||
@@ -167,11 +173,203 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("DateTime", "string");
|
||||
typeMapping.put("password", "string");
|
||||
typeMapping.put("file", "string");
|
||||
typeMapping.put("object", "JsonNode");
|
||||
typeMapping.put("AnyType", "JsonNode");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> allModels) {
|
||||
allModels = super.postProcessAllModels(allModels);
|
||||
|
||||
// First pass: identify all models that have fields with custom JSON names
|
||||
Set<String> modelsWithCustomJson = new HashSet<>();
|
||||
|
||||
for (Map.Entry<String, ModelsMap> entry : allModels.entrySet()) {
|
||||
ModelsMap modelsMap = entry.getValue();
|
||||
for (ModelMap mo : modelsMap.getModels()) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
|
||||
// Check if this model has fields with custom JSON names
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (var.vendorExtensions.containsKey("x-json-name")) {
|
||||
modelsWithCustomJson.add(cm.classname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Second pass: cascade custom JSON handling to parent models and mark array fields
|
||||
// We need multiple passes to handle transitive dependencies
|
||||
boolean changed = true;
|
||||
while (changed) {
|
||||
changed = false;
|
||||
for (Map.Entry<String, ModelsMap> entry : allModels.entrySet()) {
|
||||
ModelsMap modelsMap = entry.getValue();
|
||||
for (ModelMap mo : modelsMap.getModels()) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
|
||||
// Check if any field's type needs custom JSON and mark array fields appropriately
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
String fieldType = var.complexType != null ? var.complexType : var.baseType;
|
||||
|
||||
// Handle arrays - check if the inner type has custom JSON
|
||||
if (var.isArray && var.items != null) {
|
||||
String innerType = var.items.complexType != null ? var.items.complexType : var.items.baseType;
|
||||
if (innerType != null && modelsWithCustomJson.contains(innerType)) {
|
||||
// Mark this array field as containing types with custom JSON
|
||||
var.vendorExtensions.put("x-is-array-with-custom-json", "true");
|
||||
var.vendorExtensions.put("x-array-inner-type", innerType);
|
||||
}
|
||||
fieldType = innerType;
|
||||
}
|
||||
|
||||
// Cascade custom JSON to parent model if not already marked
|
||||
if (fieldType != null && modelsWithCustomJson.contains(fieldType)) {
|
||||
if (!cm.vendorExtensions.containsKey("x-has-custom-json-names")) {
|
||||
cm.vendorExtensions.put("x-has-custom-json-names", true);
|
||||
modelsWithCustomJson.add(cm.classname);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips surrounding quotes from integer enum values.
|
||||
* The base OpenAPI Generator stores all enum values as quoted strings (e.g., "0", "1", "2")
|
||||
* regardless of the enum's actual type. For Nim integer enums, we need the raw numbers
|
||||
* without quotes so they serialize correctly: %(0) instead of %("0")
|
||||
*/
|
||||
private void stripQuotesFromIntegerEnumValues(Map<String, Object> allowableValues) {
|
||||
if (allowableValues == null || !allowableValues.containsKey("enumVars")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) allowableValues.get("enumVars");
|
||||
for (Map<String, Object> enumVar : enumVars) {
|
||||
Object value = enumVar.get("value");
|
||||
if (value instanceof String) {
|
||||
String strValue = (String) value;
|
||||
// Remove surrounding quotes if present
|
||||
if (strValue.startsWith("\"") && strValue.endsWith("\"")) {
|
||||
enumVar.put("value", strValue.substring(1, strValue.length() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
objs = postProcessModelsEnum(objs);
|
||||
|
||||
for (ModelMap mo : objs.getModels()) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
|
||||
if (cm.isEnum && cm.allowableValues != null && cm.allowableValues.containsKey("enumVars")) {
|
||||
cm.vendorExtensions.put("x-is-top-level-enum", true);
|
||||
|
||||
// For integer enums, strip quotes from enum values
|
||||
if (cm.vendorExtensions.containsKey("x-is-integer-enum")) {
|
||||
stripQuotesFromIntegerEnumValues(cm.allowableValues);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any fields need custom JSON name mapping
|
||||
boolean hasCustomJsonNames = false;
|
||||
|
||||
// Fix dataType fields that contain underscored type names
|
||||
// This handles cases like Table[string, Record_string__foo__value]
|
||||
// Also wrap optional fields in Option[T]
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (var.dataType != null && var.dataType.contains("Record_")) {
|
||||
var.dataType = fixRecordTypeReferences(var.dataType);
|
||||
}
|
||||
if (var.datatypeWithEnum != null && var.datatypeWithEnum.contains("Record_")) {
|
||||
var.datatypeWithEnum = fixRecordTypeReferences(var.datatypeWithEnum);
|
||||
}
|
||||
|
||||
// Check if the field name was changed from the original (baseName)
|
||||
// This happens for fields like "_id" which are renamed to "id"
|
||||
// But we need to exclude cases where the name is just escaped with backticks
|
||||
// (e.g., "from" becomes "`from`" because it's a reserved word)
|
||||
if (var.baseName != null && !var.baseName.equals(var.name)) {
|
||||
// Check if this is just a reserved word escaping (name is `baseName`)
|
||||
String escapedName = "`" + var.baseName + "`";
|
||||
if (!var.name.equals(escapedName)) {
|
||||
// This is a real rename, not just escaping
|
||||
var.vendorExtensions.put("x-json-name", var.baseName);
|
||||
hasCustomJsonNames = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap optional (non-required) or nullable fields in Option[T]
|
||||
// For non-enum fields only (enums are handled specially in the template)
|
||||
if ((!var.required || var.isNullable) && !var.isReadOnly && !var.isEnum) {
|
||||
String baseType = var.dataType;
|
||||
if (baseType != null && !baseType.startsWith("Option[")) {
|
||||
var.dataType = "Option[" + baseType + "]";
|
||||
if (var.datatypeWithEnum != null) {
|
||||
var.datatypeWithEnum = "Option[" + var.datatypeWithEnum + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For enum fields, set x-is-optional if they are not required
|
||||
if (var.isEnum && (!var.required || var.isNullable)) {
|
||||
var.vendorExtensions.put("x-is-optional", true);
|
||||
}
|
||||
|
||||
// Always set x-is-optional based on the final dataType (for non-enum fields)
|
||||
// This ensures consistency between type declaration and JSON handling
|
||||
if (!var.isEnum && var.dataType != null && var.dataType.startsWith("Option[")) {
|
||||
var.vendorExtensions.put("x-is-optional", true);
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the model as needing custom JSON deserialization if any fields have custom names
|
||||
if (hasCustomJsonNames) {
|
||||
cm.vendorExtensions.put("x-has-custom-json-names", true);
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix underscored Record type references in dataType strings.
|
||||
* Converts Record_string__foo___value to RecordStringFooValue.
|
||||
*/
|
||||
private String fixRecordTypeReferences(String typeString) {
|
||||
if (typeString == null || !typeString.contains("Record_")) {
|
||||
return typeString;
|
||||
}
|
||||
|
||||
// Pattern to match Record_string_... type names with underscores
|
||||
// These are embedded in strings like: Table[string, Record_string__foo__value]
|
||||
String result = typeString;
|
||||
|
||||
// Match Record_ followed by any characters until end or comma/bracket
|
||||
Pattern pattern = Pattern.compile("Record_[a-z_]+");
|
||||
Matcher matcher = pattern.matcher(result);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String matched = matcher.group();
|
||||
// Camelize the matched Record type name
|
||||
String camelized = camelize(matched);
|
||||
matcher.appendReplacement(sb, camelized);
|
||||
}
|
||||
matcher.appendTail(sb);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,6 +390,8 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
apiPackage = File.separator + packageName + File.separator + "apis";
|
||||
modelPackage = File.separator + packageName + File.separator + "models";
|
||||
supportingFiles.add(new SupportingFile("lib.mustache", "", packageName + ".nim"));
|
||||
supportingFiles.add(new SupportingFile("model_any_type.mustache", packageName + File.separator + "models", "model_any_type.nim"));
|
||||
supportingFiles.add(new SupportingFile("model_object.mustache", packageName + File.separator + "models", "model_object.nim"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,11 +415,13 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
name = normalizeSchemaName(name);
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
if (importMapping.containsKey(name)) {
|
||||
return "model_" + StringUtils.underscore(importMapping.get(name));
|
||||
return sanitizeNimIdentifier("model_" + StringUtils.underscore(importMapping.get(name)));
|
||||
} else {
|
||||
return "model_" + StringUtils.underscore(name);
|
||||
return sanitizeNimIdentifier("model_" + StringUtils.underscore(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,22 +429,153 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toApiImport(String name) {
|
||||
name = name.replaceAll("-", "_");
|
||||
if (importMapping.containsKey(name)) {
|
||||
return "api_" + StringUtils.underscore(importMapping.get(name));
|
||||
return sanitizeNimIdentifier("api_" + StringUtils.underscore(importMapping.get(name)));
|
||||
} else {
|
||||
return "api_" + StringUtils.underscore(name);
|
||||
return sanitizeNimIdentifier("api_" + StringUtils.underscore(name));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize schema names to ensure consistency across filename, import, and type name generation.
|
||||
* This is called early in the pipeline so downstream methods work with consistent names.
|
||||
*/
|
||||
private String normalizeSchemaName(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
// Remove underscores around and before digits (HTTP status codes, version numbers, etc.)
|
||||
// e.g., "GetComments_200_response" -> "GetComments200response"
|
||||
// e.g., "Config_anyOf_1" -> "ConfiganyOf1"
|
||||
// This ensures consistent handling whether the name comes with or without underscores
|
||||
name = name.replaceAll("_(\\d+)_", "$1"); // Underscores on both sides
|
||||
name = name.replaceAll("_(\\d+)$", "$1"); // Trailing underscore before digits
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenModel fromModel(String name, Schema schema) {
|
||||
// Normalize the schema name before any processing
|
||||
name = normalizeSchemaName(name);
|
||||
CodegenModel mdl = super.fromModel(name, schema);
|
||||
|
||||
// Detect integer enums - check both the schema type and the dataType
|
||||
if (mdl.isEnum) {
|
||||
String schemaType = schema != null ? schema.getType() : null;
|
||||
if ("integer".equals(schemaType) || "int".equals(mdl.dataType) || "int64".equals(mdl.dataType)) {
|
||||
mdl.vendorExtensions.put("x-is-integer-enum", true);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle oneOf/anyOf schemas to use Nim object variants
|
||||
if (mdl.getComposedSchemas() != null) {
|
||||
if (mdl.getComposedSchemas().getOneOf() != null && !mdl.getComposedSchemas().getOneOf().isEmpty()) {
|
||||
mdl.vendorExtensions.put("x-is-one-of", true);
|
||||
processComposedSchemaVariants(mdl, mdl.getComposedSchemas().getOneOf(), schema);
|
||||
} else if (mdl.getComposedSchemas().getAnyOf() != null && !mdl.getComposedSchemas().getAnyOf().isEmpty()) {
|
||||
mdl.vendorExtensions.put("x-is-any-of", true);
|
||||
processComposedSchemaVariants(mdl, mdl.getComposedSchemas().getAnyOf(), schema);
|
||||
}
|
||||
}
|
||||
|
||||
return mdl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process oneOf/anyOf schemas to generate proper variant names for Nim object variants.
|
||||
*/
|
||||
private void processComposedSchemaVariants(CodegenModel mdl, List<CodegenProperty> variants, Schema schema) {
|
||||
List<CodegenProperty> newVariants = new ArrayList<>();
|
||||
List<Schema> schemas = ModelUtils.getInterfaces(schema);
|
||||
|
||||
if (variants.size() != schemas.size()) {
|
||||
LOGGER.warn("Variant size does not match schema interfaces size for model " + mdl.name);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < variants.size(); i++) {
|
||||
CodegenProperty variant = variants.get(i);
|
||||
Schema variantSchema = schemas.get(i);
|
||||
|
||||
// Create a clone to avoid modifying the original
|
||||
CodegenProperty newVariant = variant.clone();
|
||||
|
||||
// Sanitize baseName to remove underscores and properly format for Nim
|
||||
if (newVariant.baseName != null) {
|
||||
// Remove trailing underscores and convert to proper format
|
||||
String sanitizedBase = newVariant.baseName.replaceAll("_+$", ""); // Remove trailing underscores
|
||||
if (sanitizedBase.length() > 0 && Character.isUpperCase(sanitizedBase.charAt(0))) {
|
||||
newVariant.baseName = toModelName(sanitizedBase);
|
||||
} else {
|
||||
newVariant.baseName = sanitizeNimIdentifier(sanitizedBase);
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize dataType to remove underscores and properly format for Nim
|
||||
// For model types (not primitives), use toModelName to get the proper type name
|
||||
if (newVariant.dataType != null) {
|
||||
// Check if this is a model type (starts with uppercase) vs primitive
|
||||
if (newVariant.dataType.length() > 0 && Character.isUpperCase(newVariant.dataType.charAt(0))) {
|
||||
// This is likely a model type, use toModelName to properly format it
|
||||
newVariant.dataType = toModelName(newVariant.dataType);
|
||||
} else {
|
||||
// Primitive type, just sanitize
|
||||
newVariant.dataType = sanitizeNimIdentifier(newVariant.dataType);
|
||||
}
|
||||
}
|
||||
if (newVariant.datatypeWithEnum != null) {
|
||||
if (newVariant.datatypeWithEnum.length() > 0 && Character.isUpperCase(newVariant.datatypeWithEnum.charAt(0))) {
|
||||
newVariant.datatypeWithEnum = toModelName(newVariant.datatypeWithEnum);
|
||||
} else {
|
||||
newVariant.datatypeWithEnum = sanitizeNimIdentifier(newVariant.datatypeWithEnum);
|
||||
}
|
||||
}
|
||||
|
||||
// Set variant name based on schema reference or type
|
||||
if (variantSchema.get$ref() != null && !variantSchema.get$ref().isEmpty()) {
|
||||
String refName = ModelUtils.getSimpleRef(variantSchema.get$ref());
|
||||
if (refName != null) {
|
||||
newVariant.setName(toModelName(refName));
|
||||
newVariant.setBaseName(refName);
|
||||
}
|
||||
} else if (variantSchema.getType() != null) {
|
||||
// For primitive types or inline schemas
|
||||
String typeName = variantSchema.getType();
|
||||
if (variantSchema.getTitle() != null && !variantSchema.getTitle().isEmpty()) {
|
||||
typeName = variantSchema.getTitle();
|
||||
}
|
||||
newVariant.setName(camelize(typeName));
|
||||
newVariant.setBaseName(typeName);
|
||||
}
|
||||
|
||||
newVariants.add(newVariant);
|
||||
}
|
||||
|
||||
// Replace the original variants with the processed ones
|
||||
if (mdl.getComposedSchemas().getOneOf() != null) {
|
||||
mdl.getComposedSchemas().setOneOf(newVariants);
|
||||
} else if (mdl.getComposedSchemas().getAnyOf() != null) {
|
||||
mdl.getComposedSchemas().setAnyOf(newVariants);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// Name should be normalized by fromModel, but normalize again for safety
|
||||
name = normalizeSchemaName(name);
|
||||
return camelize(sanitizeName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
name = normalizeSchemaName(name);
|
||||
name = name.replaceAll("-", "_");
|
||||
return "model_" + StringUtils.underscore(name);
|
||||
return sanitizeNimIdentifier("model_" + StringUtils.underscore(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
name = name.replaceAll("-", "_");
|
||||
return "api_" + StringUtils.underscore(name);
|
||||
return sanitizeNimIdentifier("api_" + StringUtils.underscore(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,6 +595,12 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||
|
||||
// Set custom flag for DELETE operations with body to use different template logic
|
||||
// Nim's httpClient.delete() doesn't support a body parameter
|
||||
if ("delete".equals(operation.httpMethod) && operation.getHasBodyParam()) {
|
||||
operation.vendorExtensions.put("x-nim-delete-with-body", true);
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
@@ -360,6 +699,24 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return identifier.matches("^(?:[A-Z]|[a-z]|[\\x80-\\xff])(_?(?:[A-Z]|[a-z]|[\\x80-\\xff]|[0-9]))*$");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize a Nim identifier by removing trailing underscores and collapsing multiple underscores.
|
||||
* Nim does not allow identifiers to end with underscores.
|
||||
*
|
||||
* @param name the identifier to sanitize
|
||||
* @return the sanitized identifier
|
||||
*/
|
||||
private String sanitizeNimIdentifier(String name) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return name;
|
||||
}
|
||||
// Remove trailing underscores (Nim identifiers cannot end with underscore)
|
||||
name = name.replaceAll("_+$", "");
|
||||
// Collapse multiple consecutive underscores to single underscore
|
||||
name = name.replaceAll("_+", "_");
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
name = name.replace(" ", "_");
|
||||
|
||||
@@ -188,6 +188,7 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
|
||||
for (CodegenOperation operation : operations.getOperation()) {
|
||||
Set<String> phpReturnTypeOptions = new LinkedHashSet<>();
|
||||
Set<String> docReturnTypeOptions = new LinkedHashSet<>();
|
||||
boolean hasEmptyResponse = false;
|
||||
|
||||
for (CodegenResponse response : operation.responses) {
|
||||
if (response.dataType != null) {
|
||||
@@ -200,6 +201,8 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
|
||||
|
||||
phpReturnTypeOptions.add(returnType);
|
||||
docReturnTypeOptions.add(response.dataType);
|
||||
} else {
|
||||
hasEmptyResponse = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,9 +211,16 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
|
||||
operation.vendorExtensions.putIfAbsent("x-php-return-type", "void");
|
||||
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", "void");
|
||||
} else {
|
||||
String phpReturnType = String.join("|", phpReturnTypeOptions);
|
||||
String docReturnType = String.join("|", docReturnTypeOptions);
|
||||
if (hasEmptyResponse) {
|
||||
phpReturnType = "?" + phpReturnType;
|
||||
docReturnType = docReturnType + "|null";
|
||||
}
|
||||
|
||||
operation.vendorExtensions.putIfAbsent("x-php-return-type-is-void", false);
|
||||
operation.vendorExtensions.putIfAbsent("x-php-return-type", String.join("|", phpReturnTypeOptions));
|
||||
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", String.join("|", docReturnTypeOptions));
|
||||
operation.vendorExtensions.putIfAbsent("x-php-return-type", phpReturnType);
|
||||
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", docReturnType);
|
||||
}
|
||||
|
||||
for (CodegenParameter param : operation.allParams) {
|
||||
|
||||
@@ -385,7 +385,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
if(ModelUtils.isArraySchema(schema)) {
|
||||
Schema itemsSchema = ModelUtils.getSchemaItems(schema);
|
||||
itemsSchema = ModelUtils.getReferencedSchema(openAPI, itemsSchema);
|
||||
if(ModelUtils.isModel(itemsSchema)) {
|
||||
if(ModelUtils.isModel(itemsSchema) || (itemsSchema != null && ModelUtils.isEnumSchema(itemsSchema))) {
|
||||
String newSchemaName = ModelUtils.getSimpleRef(ModelUtils.getSchemaItems(schema).get$ref()) + ARRAY_SUFFIX;
|
||||
return addSchemas(schema, newSchemaName, visitedSchemas);
|
||||
}else if (ModelUtils.isPrimitiveType(itemsSchema)){
|
||||
@@ -400,7 +400,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
} else if(ModelUtils.isMapSchema(schema)) {
|
||||
Schema mapValueSchema = ModelUtils.getAdditionalProperties(schema);
|
||||
mapValueSchema = ModelUtils.getReferencedSchema(openAPI, mapValueSchema);
|
||||
if(ModelUtils.isModel(mapValueSchema) ) {
|
||||
if(ModelUtils.isModel(mapValueSchema) || (mapValueSchema != null && ModelUtils.isEnumSchema(mapValueSchema))) {
|
||||
String newSchemaName = ModelUtils.getSimpleRef(ModelUtils.getAdditionalProperties(schema).get$ref()) + MAP_SUFFIX;
|
||||
return addSchemas(schema, newSchemaName, visitedSchemas);
|
||||
}else if (ModelUtils.isPrimitiveType(mapValueSchema)){
|
||||
@@ -1116,7 +1116,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
} else {
|
||||
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
|
||||
if(additionalProperties == null) {
|
||||
return;
|
||||
return;
|
||||
} else if (additionalProperties.getTitle() != null) {
|
||||
addtionalPropertiesName = additionalProperties.getTitle();
|
||||
} else if (additionalProperties.get$ref() != null) {
|
||||
@@ -1124,8 +1124,8 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
addtionalPropertiesName = toVarName(toModelName(ref));
|
||||
}
|
||||
}
|
||||
|
||||
properties.put(addtionalPropertiesName, schema);
|
||||
|
||||
properties.put(addtionalPropertiesName, schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
@Setter(AccessLevel.PRIVATE) private boolean useSingleRequestParameter = false;
|
||||
@Setter(AccessLevel.PRIVATE) private boolean supportAsync = true;
|
||||
@Setter(AccessLevel.PRIVATE) private boolean supportMiddleware = false;
|
||||
@Setter(AccessLevel.PRIVATE) private boolean useSerdePathToError = false;
|
||||
@Setter(AccessLevel.PRIVATE) private boolean supportTokenSource = false;
|
||||
private boolean supportMultipleResponses = false;
|
||||
private boolean withAWSV4Signature = false;
|
||||
@@ -70,6 +71,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
public static final String REQWEST_TRAIT_LIBRARY_ATTR = "reqwestTrait";
|
||||
public static final String SUPPORT_ASYNC = "supportAsync";
|
||||
public static final String SUPPORT_MIDDLEWARE = "supportMiddleware";
|
||||
public static final String USE_SERDE_PATH_TO_ERROR = "useSerdePathToError";
|
||||
public static final String SUPPORT_TOKEN_SOURCE = "supportTokenSource";
|
||||
public static final String SUPPORT_MULTIPLE_RESPONSES = "supportMultipleResponses";
|
||||
public static final String PREFER_UNSIGNED_INT = "preferUnsignedInt";
|
||||
@@ -210,6 +212,8 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(new CliOption(SUPPORT_MIDDLEWARE, "If set, add support for reqwest-middleware. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(USE_SERDE_PATH_TO_ERROR, "If set, use the serde_path_to_error library to enhance serde error messages. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
|
||||
@@ -410,6 +414,11 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
}
|
||||
writePropertyBack(SUPPORT_MIDDLEWARE, getSupportMiddleware());
|
||||
|
||||
if (additionalProperties.containsKey(USE_SERDE_PATH_TO_ERROR)) {
|
||||
this.setUseSerdePathToError(convertPropertyToBoolean(USE_SERDE_PATH_TO_ERROR));
|
||||
}
|
||||
writePropertyBack(USE_SERDE_PATH_TO_ERROR, getUseSerdePathToError());
|
||||
|
||||
if (additionalProperties.containsKey(SUPPORT_TOKEN_SOURCE)) {
|
||||
this.setSupportTokenSource(convertPropertyToBoolean(SUPPORT_TOKEN_SOURCE));
|
||||
}
|
||||
@@ -527,6 +536,10 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
return supportMiddleware;
|
||||
}
|
||||
|
||||
private boolean getUseSerdePathToError() {
|
||||
return useSerdePathToError;
|
||||
}
|
||||
|
||||
private boolean getSupportTokenSource() {
|
||||
return supportTokenSource;
|
||||
}
|
||||
|
||||
@@ -370,6 +370,16 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
return sanitizeIdentifier(operationId, CasingType.CAMEL_CASE, "call", "method", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// rust-server doesn't support r# in param name.
|
||||
if (parameterNameMapping.containsKey(name)) {
|
||||
return parameterNameMapping.get(name);
|
||||
}
|
||||
|
||||
return sanitizeIdentifier(name, CasingType.SNAKE_CASE, "param", "parameter", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
// rust-server templates expect value to be in quotes
|
||||
@@ -860,6 +870,16 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
op.vendorExtensions.put("x-has-request-body", true);
|
||||
}
|
||||
|
||||
if (op.allParams.stream()
|
||||
.anyMatch(p -> p.isArray && !p.isPrimitiveType)) {
|
||||
op.vendorExtensions.put("x-has-borrowed-params", Boolean.TRUE);
|
||||
for (CodegenParameter param : op.allParams) {
|
||||
if (param.isArray) {
|
||||
param.vendorExtensions.put("x-param-needs-lifetime", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The CLI generates a structopt structure for each operation. This can only have a single
|
||||
// use of a short option, which comes from the parameter name, so we need to police
|
||||
// against duplicates
|
||||
@@ -1229,6 +1249,9 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
&& (mdl.dataType.startsWith("swagger::OneOf") || mdl.dataType.startsWith("swagger::AnyOf"))) {
|
||||
toStringSupport = false;
|
||||
partialOrdSupport = false;
|
||||
} else if (mdl.dataType != null && mdl.dataType.equals("serde_json::Value")) {
|
||||
// Value doesn't implement PartialOrd
|
||||
partialOrdSupport = false;
|
||||
} else if (mdl.getAdditionalPropertiesType() != null) {
|
||||
toStringSupport = false;
|
||||
} else if (model instanceof ComposedSchema) {
|
||||
@@ -1545,7 +1568,18 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
}
|
||||
} else {
|
||||
param.vendorExtensions.put("x-format-string", "{:?}");
|
||||
if (param.example != null) {
|
||||
// Check if this is a model-type enum (allowableValues with values list)
|
||||
if (param.allowableValues != null && param.allowableValues.containsKey("values")) {
|
||||
List<?> values = (List<?>) param.allowableValues.get("values");
|
||||
if (!values.isEmpty()) {
|
||||
// Use the first enum value as the example.
|
||||
String firstEnumValue = values.get(0).toString();
|
||||
String enumVariant = toEnumVarName(firstEnumValue, param.dataType);
|
||||
example = param.dataType + "::" + enumVariant;
|
||||
} else if (param.example != null) {
|
||||
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
|
||||
}
|
||||
} else if (param.example != null) {
|
||||
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1229,6 +1229,9 @@ public class RustServerCodegenDeprecated extends AbstractRustCodegen implements
|
||||
&& (mdl.dataType.startsWith("swagger::OneOf") || mdl.dataType.startsWith("swagger::AnyOf"))) {
|
||||
toStringSupport = false;
|
||||
partialOrdSupport = false;
|
||||
} else if (mdl.dataType != null && mdl.dataType.equals("serde_json::Value")) {
|
||||
// Value doesn't implement PartialOrd
|
||||
partialOrdSupport = false;
|
||||
} else if (mdl.getAdditionalPropertiesType() != null) {
|
||||
toStringSupport = false;
|
||||
} else if (model instanceof ComposedSchema) {
|
||||
@@ -1546,7 +1549,18 @@ public class RustServerCodegenDeprecated extends AbstractRustCodegen implements
|
||||
}
|
||||
else {
|
||||
param.vendorExtensions.put("x-format-string", "{:?}");
|
||||
if (param.example != null) {
|
||||
// Check if this is a model-type enum (allowableValues with values list)
|
||||
if (param.allowableValues != null && param.allowableValues.containsKey("values")) {
|
||||
List<?> values = (List<?>) param.allowableValues.get("values");
|
||||
if (!values.isEmpty()) {
|
||||
// Use the first enum value as the example.
|
||||
String firstEnumValue = values.get(0).toString();
|
||||
String enumVariant = toEnumVarName(firstEnumValue, param.dataType);
|
||||
example = param.dataType + "::" + enumVariant;
|
||||
} else if (param.example != null) {
|
||||
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
|
||||
}
|
||||
} else if (param.example != null) {
|
||||
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,15 +188,6 @@ end:
|
||||
|
||||
localVarPath = strReplace(localVarPath, localVarToReplace_{{paramName}}, {{^isEnum}}{{paramName}}{{/isEnum}}{{#isEnum}}{{{operationId}}}_{{enumName}}_ToString({{paramName}}){{/isEnum}});
|
||||
{{/isString}}
|
||||
{{#isUuid}}
|
||||
if({{paramName}} == NULL) {
|
||||
goto end;
|
||||
}
|
||||
char* localVarToReplace_{{paramName}} = malloc(sizeOfPathParams_{{paramName}});
|
||||
sprintf(localVarToReplace_{{paramName}}, "{%s}", "{{baseName}}");
|
||||
|
||||
localVarPath = strReplace(localVarPath, localVarToReplace_{{paramName}}, {{paramName}});
|
||||
{{/isUuid}}
|
||||
{{/pathParams}}
|
||||
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@
|
||||
{{#swagger2AnnotationLibrary}}
|
||||
<swagger-annotations-version>2.2.15</swagger-annotations-version>
|
||||
{{/swagger2AnnotationLibrary}}
|
||||
<jersey-version>3.1.1</jersey-version>
|
||||
<jersey-version>3.1.11</jersey-version>
|
||||
<jackson-version>2.19.2</jackson-version>
|
||||
<jackson-databind-version>2.19.2</jackson-databind-version>
|
||||
<jackson-databind-nullable-version>0.2.8</jackson-databind-nullable-version>
|
||||
|
||||
@@ -12,9 +12,7 @@ import java.util.Set;
|
||||
import {{rootJavaEEPackage}}.ws.rs.*;
|
||||
import {{rootJavaEEPackage}}.ws.rs.core.Response;
|
||||
import {{rootJavaEEPackage}}.ws.rs.core.MediaType;
|
||||
{{^disableMultipart}}
|
||||
import org.apache.cxf.jaxrs.ext.multipart.*;
|
||||
{{/disableMultipart}}
|
||||
|
||||
{{#microprofileMutiny}}
|
||||
import io.smallrye.mutiny.Uni;
|
||||
{{/microprofileMutiny}}
|
||||
@@ -29,6 +27,7 @@ import org.eclipse.microprofile.rest.client.annotation.RegisterProvider;
|
||||
{{/microprofileRegisterExceptionMapper}}
|
||||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||
|
||||
|
||||
{{#appName}}
|
||||
/**
|
||||
* {{{appName}}}
|
||||
|
||||
@@ -4,6 +4,9 @@ package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
{{#isFile}}
|
||||
import java.io.File;
|
||||
{{/isFile}}
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -70,7 +73,7 @@ public class {{classname}}Test {
|
||||
public void {{operationId}}Test() {
|
||||
// TODO: test validations
|
||||
{{#allParams}}
|
||||
{{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isFile}}
|
||||
{{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}File {{paramName}} = null;{{/isFile}}
|
||||
{{/allParams}}
|
||||
//{{^vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<{{{returnType}}}>{{/microprofileMutiny}}{{^microprofileMutiny}}{{{returnType}}}{{/microprofileMutiny}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
//{{#returnType}}Assertions.assertNotNull(response);{{/returnType}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isFormParam}}{{^isFile}}@Multipart(value = "{{baseName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}} @Multipart(value = "{{baseName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}
|
||||
{{#isFormParam}}{{^isFile}}{{#required}}{{#useBeanValidation}}@NotNull {{/useBeanValidation}}{{/required}}@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}} {{#required}}{{#useBeanValidation}}@NotNull {{/useBeanValidation}}{{/required}}@FormParam("{{baseName}}") File {{paramName}}Detail{{/isFile}}{{/isFormParam}}
|
||||
@@ -1 +1 @@
|
||||
{{#isFormParam}}{{^isFile}}{{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}} Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}
|
||||
{{#isFormParam}}{{^isFile}}{{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}} File {{paramName}}Detail{{/isFile}}{{/isFormParam}}
|
||||
@@ -12,7 +12,7 @@
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jboss.jandex</groupId>
|
||||
<groupId>io.smallrye</groupId>
|
||||
<artifactId>jandex-maven-plugin</artifactId>
|
||||
<version>${jandex.maven.plugin.version}</version>
|
||||
<executions>
|
||||
@@ -101,13 +101,7 @@
|
||||
<version>${smallrye.config.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
{{^disableMultipart}}
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
||||
<version>${cxf.rt.rs.extension.providers.version}</version>
|
||||
</dependency>
|
||||
{{/disableMultipart}}
|
||||
|
||||
{{#jsonb}}
|
||||
<dependency>
|
||||
<groupId>jakarta.json.bind</groupId>
|
||||
@@ -227,7 +221,6 @@
|
||||
{{#useBeanValidation}}
|
||||
<beanvalidation.version>3.0.2</beanvalidation.version>
|
||||
{{/useBeanValidation}}
|
||||
<cxf.version>3.2.7</cxf.version>
|
||||
<jackson.jaxrs.version>2.17.1</jackson.jaxrs.version>
|
||||
{{#jackson}}
|
||||
<jackson.version>2.17.1</jackson.version>
|
||||
@@ -241,11 +234,10 @@
|
||||
<microprofile.rest.client.api.version>{{microprofileRestClientVersion}}</microprofile.rest.client.api.version>
|
||||
<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>
|
||||
<smallrye.config.version>1.3.5</smallrye.config.version>
|
||||
<cxf.rt.rs.extension.providers.version>3.2.6</cxf.rt.rs.extension.providers.version>
|
||||
<jaxb.core.version>2.2.11</jaxb.core.version>
|
||||
<jaxb.impl.version>2.2.11</jaxb.impl.version>
|
||||
<hibernate.validator.version>5.2.2.Final</hibernate.validator.version>
|
||||
<jandex.maven.plugin.version>1.1.0</jandex.maven.plugin.version>
|
||||
<jandex.maven.plugin.version>3.2.7</jandex.maven.plugin.version>
|
||||
<maven.failsafe.plugin.version>2.6</maven.failsafe.plugin.version>
|
||||
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
|
||||
{{#microprofileMutiny}}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jboss.jandex</groupId>
|
||||
<groupId>io.smallrye</groupId>
|
||||
<artifactId>jandex-maven-plugin</artifactId>
|
||||
<version>${jandex.maven.plugin.version}</version>
|
||||
<executions>
|
||||
@@ -101,13 +101,7 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
{{^disableMultipart}}
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
||||
<version>${cxf.rt.rs.extension.providers.version}</version>
|
||||
</dependency>
|
||||
{{/disableMultipart}}
|
||||
|
||||
{{#jsonb}}
|
||||
<dependency>
|
||||
<groupId>jakarta.json.bind</groupId>
|
||||
@@ -178,7 +172,7 @@
|
||||
</dependency>
|
||||
{{#useBeanValidationFeature}}
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>${hibernate.validator.version}</version>
|
||||
</dependency>
|
||||
@@ -244,8 +238,8 @@
|
||||
<cxf.rt.rs.extension.providers.version>3.5.1</cxf.rt.rs.extension.providers.version>
|
||||
<jaxb.core.version>3.0.2</jaxb.core.version>
|
||||
<jaxb.impl.version>3.0.2</jaxb.impl.version>
|
||||
<hibernate.validator.version>7.0.4.Final</hibernate.validator.version>
|
||||
<jandex.maven.plugin.version>1.1.0</jandex.maven.plugin.version>
|
||||
<hibernate.validator.version>8.0.3.Final</hibernate.validator.version>
|
||||
<jandex.maven.plugin.version>3.2.7</jandex.maven.plugin.version>
|
||||
<maven.failsafe.plugin.version>2.6</maven.failsafe.plugin.version>
|
||||
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
|
||||
{{#microprofileMutiny}}
|
||||
|
||||
@@ -11,6 +11,10 @@ import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
{{/openApiNullable}}
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
{{#useGzipFeature}}
|
||||
import java.io.ByteArrayOutputStream;
|
||||
{{/useGzipFeature}}
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.http.HttpClient;
|
||||
@@ -25,7 +29,17 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Optional;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
{{#useGzipFeature}}
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Objects;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
{{/useGzipFeature}}
|
||||
import java.util.stream.Collectors;
|
||||
{{#useUnaryInterceptor}}
|
||||
import java.util.function.UnaryOperator;
|
||||
{{/useUnaryInterceptor}}
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
@@ -53,8 +67,14 @@ public class ApiClient {
|
||||
protected int port;
|
||||
protected String basePath;
|
||||
protected Consumer<HttpRequest.Builder> interceptor;
|
||||
{{#useUnaryInterceptor}}
|
||||
protected UnaryOperator<HttpResponse<InputStream>> responseInterceptor;
|
||||
protected UnaryOperator<HttpResponse<InputStream>> asyncResponseInterceptor;
|
||||
{{/useUnaryInterceptor}}
|
||||
{{^useUnaryInterceptor}}
|
||||
protected Consumer<HttpResponse<InputStream>> responseInterceptor;
|
||||
protected Consumer<HttpResponse<String>> asyncResponseInterceptor;
|
||||
protected Consumer<HttpResponse<InputStream>> asyncResponseInterceptor;
|
||||
{{/useUnaryInterceptor}}
|
||||
protected Duration readTimeout;
|
||||
protected Duration connectTimeout;
|
||||
|
||||
@@ -350,12 +370,12 @@ public class ApiClient {
|
||||
* Set a custom response interceptor.
|
||||
*
|
||||
* <p>This is useful for logging, monitoring or extraction of header variables</p>
|
||||
*
|
||||
*{{#useUnaryInterceptor}} <p>If you are using the UnaryInterceptor you can even manipulate the response to a certain degree</p>{{/useUnaryInterceptor}}
|
||||
* @param interceptor A function invoked before creating each request. A value
|
||||
* of null resets the interceptor to a no-op.
|
||||
* @return This object.
|
||||
*/
|
||||
public ApiClient setResponseInterceptor(Consumer<HttpResponse<InputStream>> interceptor) {
|
||||
public ApiClient setResponseInterceptor({{#useUnaryInterceptor}}UnaryOperator{{/useUnaryInterceptor}}{{^useUnaryInterceptor}}Consumer{{/useUnaryInterceptor}}<HttpResponse<InputStream>> interceptor) {
|
||||
this.responseInterceptor = interceptor;
|
||||
return this;
|
||||
}
|
||||
@@ -365,7 +385,7 @@ public class ApiClient {
|
||||
*
|
||||
* @return The custom interceptor that was set, or null if there isn't any.
|
||||
*/
|
||||
public Consumer<HttpResponse<InputStream>> getResponseInterceptor() {
|
||||
public {{#useUnaryInterceptor}}UnaryOperator{{/useUnaryInterceptor}}{{^useUnaryInterceptor}}Consumer{{/useUnaryInterceptor}}<HttpResponse<InputStream>> getResponseInterceptor() {
|
||||
return responseInterceptor;
|
||||
}
|
||||
|
||||
@@ -373,12 +393,12 @@ public class ApiClient {
|
||||
* Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'.
|
||||
*
|
||||
* <p>This is useful for logging, monitoring or extraction of header variables</p>
|
||||
*
|
||||
*{{#useUnaryInterceptor}} <p>If you are using the UnaryInterceptor you can even manipulate the response to a certain degree</p>{{/useUnaryInterceptor}}
|
||||
* @param interceptor A function invoked before creating each request. A value
|
||||
* of null resets the interceptor to a no-op.
|
||||
* @return This object.
|
||||
*/
|
||||
public ApiClient setAsyncResponseInterceptor(Consumer<HttpResponse<String>> interceptor) {
|
||||
public ApiClient setAsyncResponseInterceptor({{#useUnaryInterceptor}}UnaryOperator{{/useUnaryInterceptor}}{{^useUnaryInterceptor}}Consumer{{/useUnaryInterceptor}}<HttpResponse<InputStream>> interceptor) {
|
||||
this.asyncResponseInterceptor = interceptor;
|
||||
return this;
|
||||
}
|
||||
@@ -388,7 +408,7 @@ public class ApiClient {
|
||||
*
|
||||
* @return The custom interceptor that was set, or null if there isn't any.
|
||||
*/
|
||||
public Consumer<HttpResponse<String>> getAsyncResponseInterceptor() {
|
||||
public {{#useUnaryInterceptor}}UnaryOperator{{/useUnaryInterceptor}}{{^useUnaryInterceptor}}Consumer{{/useUnaryInterceptor}}<HttpResponse<InputStream>> getAsyncResponseInterceptor() {
|
||||
return asyncResponseInterceptor;
|
||||
}
|
||||
|
||||
@@ -448,4 +468,142 @@ public class ApiClient {
|
||||
public Duration getConnectTimeout() {
|
||||
return connectTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the response body InputStream, transparently decoding gzip-compressed
|
||||
* payloads when the server sets {@code Content-Encoding: gzip}.
|
||||
*
|
||||
* @param response HTTP response whose body should be consumed
|
||||
* @return Original or decompressed InputStream for the response body
|
||||
* @throws IOException if the response body cannot be accessed or wrapping fails
|
||||
*/
|
||||
public static InputStream getResponseBody(HttpResponse<InputStream> response) throws IOException {
|
||||
if (response == null) {
|
||||
return null;
|
||||
}
|
||||
InputStream body = response.body();
|
||||
if (body == null) {
|
||||
return null;
|
||||
}
|
||||
Optional<String> encoding = response.headers().firstValue("Content-Encoding");
|
||||
if (encoding.isPresent()) {
|
||||
for (String token : encoding.get().split(",")) {
|
||||
if ("gzip".equalsIgnoreCase(token.trim())) {
|
||||
return new GZIPInputStream(body);
|
||||
}
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
{{#useGzipFeature}}
|
||||
/**
|
||||
* Wraps a request body supplier with a streaming GZIP compressor so large payloads
|
||||
* can be sent without buffering the entire contents in memory.
|
||||
*
|
||||
* @param bodySupplier Supplies the original request body InputStream
|
||||
* @return BodyPublisher that emits gzip-compressed bytes from the supplied stream
|
||||
*/
|
||||
public static HttpRequest.BodyPublisher gzipRequestBody(Supplier<InputStream> bodySupplier) {
|
||||
Objects.requireNonNull(bodySupplier, "bodySupplier must not be null");
|
||||
return HttpRequest.BodyPublishers.ofInputStream(() -> new GzipCompressingInputStream(bodySupplier));
|
||||
}
|
||||
|
||||
private static final class GzipCompressingInputStream extends InputStream {
|
||||
private final Supplier<InputStream> supplier;
|
||||
private final byte[] readBuffer = new byte[8192];
|
||||
private final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
private InputStream source;
|
||||
private GZIPOutputStream gzipStream;
|
||||
private byte[] currentChunk = new byte[0];
|
||||
private int chunkPosition = 0;
|
||||
private boolean finished = false;
|
||||
|
||||
private GzipCompressingInputStream(Supplier<InputStream> supplier) {
|
||||
this.supplier = Objects.requireNonNull(supplier, "bodySupplier must not be null");
|
||||
}
|
||||
|
||||
private void ensureInitialized() throws IOException {
|
||||
if (source == null) {
|
||||
source = Objects.requireNonNull(supplier.get(), "bodySupplier returned null InputStream");
|
||||
gzipStream = new GZIPOutputStream(buffer, true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean fillBuffer() throws IOException {
|
||||
ensureInitialized();
|
||||
while (chunkPosition >= currentChunk.length) {
|
||||
buffer.reset();
|
||||
if (finished) {
|
||||
return false;
|
||||
}
|
||||
int bytesRead = source.read(readBuffer);
|
||||
if (bytesRead == -1) {
|
||||
gzipStream.finish();
|
||||
gzipStream.close();
|
||||
source.close();
|
||||
finished = true;
|
||||
} else {
|
||||
gzipStream.write(readBuffer, 0, bytesRead);
|
||||
gzipStream.flush();
|
||||
}
|
||||
currentChunk = buffer.toByteArray();
|
||||
chunkPosition = 0;
|
||||
if (currentChunk.length == 0 && !finished) {
|
||||
continue;
|
||||
}
|
||||
if (currentChunk.length == 0 && finished) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (!fillBuffer()) {
|
||||
return -1;
|
||||
}
|
||||
return currentChunk[chunkPosition++] & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
if (!fillBuffer()) {
|
||||
return -1;
|
||||
}
|
||||
int bytesToCopy = Math.min(len, currentChunk.length - chunkPosition);
|
||||
System.arraycopy(currentChunk, chunkPosition, b, off, bytesToCopy);
|
||||
chunkPosition += bytesToCopy;
|
||||
return bytesToCopy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
IOException exception = null;
|
||||
if (source != null) {
|
||||
try {
|
||||
source.close();
|
||||
} catch (IOException e) {
|
||||
exception = e;
|
||||
} finally {
|
||||
source = null;
|
||||
}
|
||||
}
|
||||
if (gzipStream != null) {
|
||||
try {
|
||||
gzipStream.close();
|
||||
} catch (IOException e) {
|
||||
exception = exception == null ? e : exception;
|
||||
} finally {
|
||||
gzipStream = null;
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/useGzipFeature}}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Locale;
|
||||
{{#useUnaryInterceptor}}
|
||||
import java.util.function.UnaryOperator;
|
||||
{{/useUnaryInterceptor}}
|
||||
import java.util.function.Consumer;
|
||||
{{#useGzipFeature}}
|
||||
import java.util.function.Supplier;
|
||||
{{/useGzipFeature}}
|
||||
{{#asyncNative}}
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -83,8 +89,14 @@ public class {{classname}} {
|
||||
private final String memberVarBaseUri;
|
||||
private final Consumer<HttpRequest.Builder> memberVarInterceptor;
|
||||
private final Duration memberVarReadTimeout;
|
||||
{{#useUnaryInterceptor}}
|
||||
private final UnaryOperator<HttpResponse<InputStream>> memberVarResponseInterceptor;
|
||||
private final UnaryOperator<HttpResponse<InputStream>> memberVarAsyncResponseInterceptor;
|
||||
{{/useUnaryInterceptor}}
|
||||
{{^useUnaryInterceptor}}
|
||||
private final Consumer<HttpResponse<InputStream>> memberVarResponseInterceptor;
|
||||
private final Consumer<HttpResponse<String>> memberVarAsyncResponseInterceptor;
|
||||
private final Consumer<HttpResponse<InputStream>> memberVarAsyncResponseInterceptor;
|
||||
{{/useUnaryInterceptor}}
|
||||
|
||||
public {{classname}}() {
|
||||
this(Configuration.getDefaultApiClient());
|
||||
@@ -102,15 +114,33 @@ public class {{classname}} {
|
||||
|
||||
{{#asyncNative}}
|
||||
|
||||
private ApiException getApiException(String operationId, HttpResponse<String> response) {
|
||||
String message = formatExceptionMessage(operationId, response.statusCode(), response.body());
|
||||
return new ApiException(response.statusCode(), message, response.headers(), response.body());
|
||||
private ApiException getApiException(String operationId, HttpResponse<InputStream> response) {
|
||||
try {
|
||||
InputStream responseBody = ApiClient.getResponseBody(response);
|
||||
String body = null;
|
||||
if (responseBody != null) {
|
||||
body = new String(responseBody.readAllBytes());
|
||||
responseBody.close();
|
||||
}
|
||||
String message = formatExceptionMessage(operationId, response.statusCode(), body);
|
||||
return new ApiException(response.statusCode(), message, response.headers(), body);
|
||||
} catch (IOException e) {
|
||||
return new ApiException(e);
|
||||
}
|
||||
}
|
||||
{{/asyncNative}}
|
||||
{{^asyncNative}}
|
||||
|
||||
protected ApiException getApiException(String operationId, HttpResponse<InputStream> response) throws IOException {
|
||||
String body = response.body() == null ? null : new String(response.body().readAllBytes());
|
||||
InputStream responseBody = ApiClient.getResponseBody(response);
|
||||
String body = null;
|
||||
try {
|
||||
body = responseBody == null ? null : new String(responseBody.readAllBytes());
|
||||
} finally {
|
||||
if (responseBody != null) {
|
||||
responseBody.close();
|
||||
}
|
||||
}
|
||||
String message = formatExceptionMessage(operationId, response.statusCode(), body);
|
||||
return new ApiException(response.statusCode(), message, response.headers(), body);
|
||||
}
|
||||
@@ -130,10 +160,13 @@ public class {{classname}} {
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response, InputStream responseBody) throws ApiException {
|
||||
if (responseBody == null) {
|
||||
throw new ApiException(new IOException("Response body is empty"));
|
||||
}
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
java.nio.file.Files.copy(responseBody, file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
@@ -349,27 +382,8 @@ public class {{classname}} {
|
||||
{{/asyncNative}}
|
||||
{{#asyncNative}}
|
||||
try {
|
||||
HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers);
|
||||
return memberVarHttpClient.sendAsync(
|
||||
localVarRequestBuilder.build(),
|
||||
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
return CompletableFuture.failedFuture(getApiException("{{operationId}}", localVarResponse));
|
||||
}
|
||||
{{#returnType}}
|
||||
try {
|
||||
String responseBody = localVarResponse.body();
|
||||
return CompletableFuture.completedFuture(
|
||||
responseBody == null || responseBody.isBlank() ? null : memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {})
|
||||
);
|
||||
} catch (IOException e) {
|
||||
return CompletableFuture.failedFuture(new ApiException(e));
|
||||
}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return CompletableFuture.completedFuture(null);
|
||||
{{/returnType}}
|
||||
});
|
||||
return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers)
|
||||
.thenApply(ApiResponse::getData);
|
||||
}
|
||||
catch (ApiException e) {
|
||||
return CompletableFuture.failedFuture(e);
|
||||
@@ -428,8 +442,14 @@ public class {{classname}} {
|
||||
localVarRequestBuilder.build(),
|
||||
HttpResponse.BodyHandlers.ofInputStream());
|
||||
if (memberVarResponseInterceptor != null) {
|
||||
{{#useUnaryInterceptor}}
|
||||
localVarResponse = memberVarResponseInterceptor.apply(localVarResponse);
|
||||
{{/useUnaryInterceptor}}
|
||||
{{^useUnaryInterceptor}}
|
||||
memberVarResponseInterceptor.accept(localVarResponse);
|
||||
{{/useUnaryInterceptor}}
|
||||
}
|
||||
InputStream localVarResponseBody = null;
|
||||
try {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
throw getApiException("{{operationId}}", localVarResponse);
|
||||
@@ -438,7 +458,8 @@ public class {{classname}} {
|
||||
// for plain text response
|
||||
if (localVarResponse.headers().map().containsKey("Content-Type") &&
|
||||
"text/plain".equalsIgnoreCase(localVarResponse.headers().map().get("Content-Type").get(0).split(";")[0].trim())) {
|
||||
java.util.Scanner s = new java.util.Scanner(localVarResponse.body()).useDelimiter("\\A");
|
||||
localVarResponseBody = ApiClient.getResponseBody(localVarResponse);
|
||||
java.util.Scanner s = new java.util.Scanner(localVarResponseBody == null ? InputStream.nullInputStream() : localVarResponseBody).useDelimiter("\\A");
|
||||
String responseBodyText = s.hasNext() ? s.next() : "";
|
||||
return new ApiResponse<String>(
|
||||
localVarResponse.statusCode(),
|
||||
@@ -460,7 +481,8 @@ public class {{classname}} {
|
||||
{{! A fix for that problem is to read it into a string and remove those characters, but if we need to read it before giving it to jackson to fix the string then just reading it into a string as is to do an emptiness check is the cleaner solution. }}
|
||||
{{! We could also manipulate the inputstream to remove that bad character, but string manipulation is easier to read and this codepath is not asyncronus so we do not gain anything by reading the stream later. }}
|
||||
{{! This fix does make it unsuitable for large amounts of data because `InputStream.readAllbytes` is not meant for it, but a synchronous client is already not the right tool for that.}}
|
||||
if (localVarResponse.body() == null) {
|
||||
localVarResponseBody = ApiClient.getResponseBody(localVarResponse);
|
||||
if (localVarResponseBody == null) {
|
||||
return new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
@@ -469,17 +491,16 @@ public class {{classname}} {
|
||||
}
|
||||
|
||||
{{^isResponseFile}}{{#isResponseBinary}}
|
||||
Byte[] responseValue = localVarResponse.body().readAllBytes();
|
||||
Byte[] responseValue = localVarResponseBody.readAllBytes();
|
||||
{{/isResponseBinary}}{{/isResponseFile}}
|
||||
{{#isResponseFile}}
|
||||
// Handle file downloading.
|
||||
File responseValue = downloadFileFromResponse(localVarResponse);
|
||||
File responseValue = downloadFileFromResponse(localVarResponse, localVarResponseBody);
|
||||
{{/isResponseFile}}
|
||||
{{^isResponseBinary}}{{^isResponseFile}}
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
String responseBody = new String(localVarResponseBody.readAllBytes());
|
||||
{{{returnType}}} responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {});
|
||||
{{/isResponseFile}}{{/isResponseBinary}}
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
@@ -488,6 +509,10 @@ public class {{classname}} {
|
||||
);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
localVarResponseBody = ApiClient.getResponseBody(localVarResponse);
|
||||
if (localVarResponseBody != null) {
|
||||
localVarResponseBody.readAllBytes();
|
||||
}
|
||||
return new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
@@ -496,13 +521,9 @@ public class {{classname}} {
|
||||
{{/returnType}}
|
||||
{{/vendorExtensions.x-java-text-plain-string}}
|
||||
} finally {
|
||||
{{^returnType}}
|
||||
// Drain the InputStream
|
||||
while (localVarResponse.body().read() != -1) {
|
||||
// Ignore
|
||||
if (localVarResponseBody != null) {
|
||||
localVarResponseBody.close();
|
||||
}
|
||||
localVarResponse.body().close();
|
||||
{{/returnType}}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
@@ -517,31 +538,83 @@ public class {{classname}} {
|
||||
HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers);
|
||||
return memberVarHttpClient.sendAsync(
|
||||
localVarRequestBuilder.build(),
|
||||
HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
|
||||
HttpResponse.BodyHandlers.ofInputStream()).thenComposeAsync(localVarResponse -> {
|
||||
if (memberVarAsyncResponseInterceptor != null) {
|
||||
{{#useUnaryInterceptor}}
|
||||
localVarResponse = memberVarAsyncResponseInterceptor.apply(localVarResponse);
|
||||
{{/useUnaryInterceptor}}
|
||||
{{^useUnaryInterceptor}}
|
||||
memberVarAsyncResponseInterceptor.accept(localVarResponse);
|
||||
{{/useUnaryInterceptor}}
|
||||
}
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
return CompletableFuture.failedFuture(getApiException("{{operationId}}", localVarResponse));
|
||||
}
|
||||
{{#returnType}}
|
||||
try {
|
||||
String responseBody = localVarResponse.body();
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody == null || responseBody.isBlank() ? null : memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {}))
|
||||
);
|
||||
InputStream localVarResponseBody = ApiClient.getResponseBody(localVarResponse);
|
||||
try {
|
||||
{{#vendorExtensions.x-java-text-plain-string}}
|
||||
if (localVarResponse.headers().map().containsKey("Content-Type") &&
|
||||
"text/plain".equalsIgnoreCase(localVarResponse.headers().map().get("Content-Type").get(0).split(";")[0].trim())) {
|
||||
java.util.Scanner s = new java.util.Scanner(localVarResponseBody == null ? InputStream.nullInputStream() : localVarResponseBody).useDelimiter("\\A");
|
||||
String responseBodyText = s.hasNext() ? s.next() : "";
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<String>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBodyText
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return CompletableFuture.failedFuture(new RuntimeException("Error! The response Content-Type is supposed to be `text/plain` but it's not: " + localVarResponse));
|
||||
}
|
||||
{{/vendorExtensions.x-java-text-plain-string}}
|
||||
{{^vendorExtensions.x-java-text-plain-string}}
|
||||
{{#returnType}}
|
||||
if (localVarResponseBody == null) {
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
null
|
||||
)
|
||||
);
|
||||
}
|
||||
{{^isResponseFile}}{{#isResponseBinary}}
|
||||
Byte[] responseValue = localVarResponseBody.readAllBytes();
|
||||
{{/isResponseBinary}}{{/isResponseFile}}
|
||||
{{#isResponseFile}}
|
||||
File responseValue = downloadFileFromResponse(localVarResponse, localVarResponseBody);
|
||||
{{/isResponseFile}}
|
||||
{{^isResponseBinary}}{{^isResponseFile}}
|
||||
String responseBody = new String(localVarResponseBody.readAllBytes());
|
||||
{{{returnType}}} responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {});
|
||||
{{/isResponseFile}}{{/isResponseBinary}}
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseValue
|
||||
)
|
||||
);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
if (localVarResponseBody != null) {
|
||||
localVarResponseBody.readAllBytes();
|
||||
}
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<Void>(localVarResponse.statusCode(), localVarResponse.headers().map(), null)
|
||||
);
|
||||
{{/returnType}}
|
||||
{{/vendorExtensions.x-java-text-plain-string}}
|
||||
} finally {
|
||||
if (localVarResponseBody != null) {
|
||||
localVarResponseBody.close();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return CompletableFuture.failedFuture(new ApiException(e));
|
||||
}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return CompletableFuture.completedFuture(
|
||||
new ApiResponse<Void>(localVarResponse.statusCode(), localVarResponse.headers().map(), null)
|
||||
);
|
||||
{{/returnType}}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -644,15 +717,32 @@ public class {{classname}} {
|
||||
localVarRequestBuilder.header("Content-Type", "{{#hasConsumes}}{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{/hasConsumes}}{{#hasConsumes}}{{^consumes}}application/json{{/consumes}}{{/hasConsumes}}{{^hasConsumes}}application/json{{/hasConsumes}}");
|
||||
{{/bodyParam}}
|
||||
localVarRequestBuilder.header("Accept", "{{#hasProduces}}{{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{/hasProduces}}{{#hasProduces}}{{^produces}}application/json{{/produces}}{{/hasProduces}}{{^hasProduces}}application/json{{/hasProduces}}");
|
||||
{{#useGzipFeature}}
|
||||
localVarRequestBuilder.header("Accept-Encoding", "gzip");
|
||||
{{/useGzipFeature}}
|
||||
|
||||
{{#bodyParam}}
|
||||
{{#isString}}
|
||||
{{#useGzipFeature}}
|
||||
Supplier<InputStream> localVarRequestBodySupplier = () -> new ByteArrayInputStream({{paramName}}.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
localVarRequestBuilder.header("Content-Encoding", "gzip");
|
||||
localVarRequestBuilder.method("{{httpMethod}}", ApiClient.gzipRequestBody(localVarRequestBodySupplier));
|
||||
{{/useGzipFeature}}
|
||||
{{^useGzipFeature}}
|
||||
localVarRequestBuilder.method("{{httpMethod}}", HttpRequest.BodyPublishers.ofString({{paramName}}));
|
||||
{{/useGzipFeature}}
|
||||
{{/isString}}
|
||||
{{^isString}}
|
||||
try {
|
||||
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes({{paramName}});
|
||||
{{#useGzipFeature}}
|
||||
Supplier<InputStream> localVarRequestBodySupplier = () -> new ByteArrayInputStream(localVarPostBody);
|
||||
localVarRequestBuilder.header("Content-Encoding", "gzip");
|
||||
localVarRequestBuilder.method("{{httpMethod}}", ApiClient.gzipRequestBody(localVarRequestBodySupplier));
|
||||
{{/useGzipFeature}}
|
||||
{{^useGzipFeature}}
|
||||
localVarRequestBuilder.method("{{httpMethod}}", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
|
||||
{{/useGzipFeature}}
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
@@ -690,6 +780,39 @@ public class {{classname}} {
|
||||
{{/isArray}}
|
||||
{{/formParams}}
|
||||
HttpEntity entity = multiPartBuilder.build();
|
||||
{{#useGzipFeature}}
|
||||
Supplier<InputStream> formDataSupplier;
|
||||
if (hasFiles) {
|
||||
Pipe pipe;
|
||||
try {
|
||||
pipe = Pipe.open();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
new Thread(() -> {
|
||||
try (OutputStream outputStream = Channels.newOutputStream(pipe.sink())) {
|
||||
entity.writeTo(outputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
formDataSupplier = () -> Channels.newInputStream(pipe.source());
|
||||
} else {
|
||||
ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
entity.writeTo(formOutputStream);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
byte[] formBytes = formOutputStream.toByteArray();
|
||||
formDataSupplier = () -> new ByteArrayInputStream(formBytes);
|
||||
}
|
||||
localVarRequestBuilder
|
||||
.header("Content-Type", entity.getContentType().getValue())
|
||||
.header("Content-Encoding", "gzip")
|
||||
.method("{{httpMethod}}", ApiClient.gzipRequestBody(formDataSupplier));
|
||||
{{/useGzipFeature}}
|
||||
{{^useGzipFeature}}
|
||||
HttpRequest.BodyPublisher formDataPublisher;
|
||||
if (hasFiles) {
|
||||
Pipe pipe;
|
||||
@@ -713,12 +836,14 @@ public class {{classname}} {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
byte[] formBytes = formOutputStream.toByteArray();
|
||||
formDataPublisher = HttpRequest.BodyPublishers
|
||||
.ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()));
|
||||
.ofInputStream(() -> new ByteArrayInputStream(formBytes));
|
||||
}
|
||||
localVarRequestBuilder
|
||||
.header("Content-Type", entity.getContentType().getValue())
|
||||
.method("{{httpMethod}}", formDataPublisher);
|
||||
{{/useGzipFeature}}
|
||||
{{/isMultipart}}
|
||||
{{^isMultipart}}
|
||||
List<NameValuePair> formValues = new ArrayList<>();
|
||||
@@ -743,10 +868,20 @@ public class {{classname}} {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
byte[] formBytes = formOutputStream.toByteArray();
|
||||
{{#useGzipFeature}}
|
||||
Supplier<InputStream> formDataSupplier = () -> new ByteArrayInputStream(formBytes);
|
||||
localVarRequestBuilder
|
||||
.header("Content-Type", entity.getContentType().getValue())
|
||||
.header("Content-Encoding", "gzip")
|
||||
.method("{{httpMethod}}", ApiClient.gzipRequestBody(formDataSupplier));
|
||||
{{/useGzipFeature}}
|
||||
{{^useGzipFeature}}
|
||||
localVarRequestBuilder
|
||||
.header("Content-Type", entity.getContentType().getValue())
|
||||
.method("{{httpMethod}}", HttpRequest.BodyPublishers
|
||||
.ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray())));
|
||||
.ofInputStream(() -> new ByteArrayInputStream(formBytes)));
|
||||
{{/useGzipFeature}}
|
||||
{{/isMultipart}}
|
||||
{{/hasFormParams}}
|
||||
{{^hasFormParams}}
|
||||
@@ -819,4 +954,4 @@ public class {{classname}} {
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
||||
@@ -17,6 +17,9 @@ import java.util.Locale;
|
||||
/**
|
||||
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#gson}}
|
||||
@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class)
|
||||
{{/gson}}
|
||||
|
||||
@@ -120,7 +120,8 @@ public class ApiClient {
|
||||
protected InputStream sslCaCert;
|
||||
protected boolean verifyingSsl;
|
||||
protected KeyManager[] keyManagers;
|
||||
|
||||
protected String tlsServerName;
|
||||
|
||||
protected OkHttpClient httpClient;
|
||||
protected JSON json;
|
||||
|
||||
@@ -433,6 +434,29 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TLS server name for SNI (Server Name Indication).
|
||||
*
|
||||
* @return The TLS server name
|
||||
*/
|
||||
public String getTlsServerName() {
|
||||
return tlsServerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TLS server name for SNI (Server Name Indication).
|
||||
* This is used to verify the server certificate against a specific hostname
|
||||
* instead of the hostname in the URL.
|
||||
*
|
||||
* @param tlsServerName The TLS server name to use for certificate verification
|
||||
* @return ApiClient
|
||||
*/
|
||||
public ApiClient setTlsServerName(String tlsServerName) {
|
||||
this.tlsServerName = tlsServerName;
|
||||
applySslSettings();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>dateFormat</code>.</p>
|
||||
*
|
||||
@@ -1820,7 +1844,17 @@ public class ApiClient {
|
||||
trustManagerFactory.init(caKeyStore);
|
||||
}
|
||||
trustManagers = trustManagerFactory.getTrustManagers();
|
||||
hostnameVerifier = OkHostnameVerifier.INSTANCE;
|
||||
if (tlsServerName != null && !tlsServerName.isEmpty()) {
|
||||
hostnameVerifier = new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
// Verify the certificate against tlsServerName instead of the actual hostname
|
||||
return OkHostnameVerifier.INSTANCE.verify(tlsServerName, session);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
hostnameVerifier = OkHostnameVerifier.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
|
||||
@@ -12,6 +12,9 @@ import com.google.gson.stream.JsonWriter;
|
||||
/**
|
||||
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class)
|
||||
{{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}{{#vendorExtensions.x-implements}}{{#-first}} implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
|
||||
@@ -343,9 +343,9 @@
|
||||
{{#performBeanValidation}}
|
||||
<!-- Bean Validation Impl. used to perform BeanValidation -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>5.4.3.Final</version>
|
||||
<version>8.0.3.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.el</groupId>
|
||||
|
||||
@@ -324,9 +324,9 @@
|
||||
{{#performBeanValidation}}
|
||||
<!-- Bean Validation Impl. used to perform BeanValidation -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.2.0.Final</version>
|
||||
<version>8.0.3.Final</version>
|
||||
</dependency>
|
||||
{{/performBeanValidation}}
|
||||
<!-- test dependencies -->
|
||||
|
||||
@@ -318,7 +318,7 @@
|
||||
{{#performBeanValidation}}
|
||||
<!-- Bean Validation Impl. used to perform BeanValidation -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>${hibernate-validator-version}</version>
|
||||
</dependency>
|
||||
@@ -358,7 +358,7 @@
|
||||
{{/joda}}
|
||||
<beanvalidation-version>3.0.2</beanvalidation-version>
|
||||
{{#performBeanValidation}}
|
||||
<hibernate-validator-version>5.4.3.Final</hibernate-validator-version>
|
||||
<hibernate-validator-version>8.0.3.Final</hibernate-validator-version>
|
||||
{{/performBeanValidation}}
|
||||
<junit-version>5.10.2</junit-version>
|
||||
</properties>
|
||||
|
||||
@@ -333,7 +333,7 @@
|
||||
{{#performBeanValidation}}
|
||||
<!-- Bean Validation Impl. used to perform BeanValidation -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>${hibernate-validator-version}</version>
|
||||
</dependency>
|
||||
@@ -380,7 +380,7 @@
|
||||
<jodatime-version>2.9.9</jodatime-version>
|
||||
{{/joda}}
|
||||
{{#performBeanValidation}}
|
||||
<hibernate-validator-version>5.4.3.Final</hibernate-validator-version>
|
||||
<hibernate-validator-version>8.0.3.Final</hibernate-validator-version>
|
||||
{{/performBeanValidation}}
|
||||
<junit-version>5.10.2</junit-version>
|
||||
</properties>
|
||||
|
||||
@@ -17,6 +17,9 @@ import java.util.Locale;
|
||||
/**
|
||||
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#gson}}
|
||||
@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class)
|
||||
{{/gson}}
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
/**
|
||||
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
|
||||
{{#gson}}
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
|
||||
@@ -9,6 +9,12 @@ import {{javaxPackage}}.ws.rs.core.Response;
|
||||
{{#useSwaggerAnnotations}}
|
||||
import io.swagger.annotations.*;
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useSwaggerV3Annotations}}
|
||||
import io.swagger.v3.oas.annotations.*;
|
||||
import io.swagger.v3.oas.annotations.media.*;
|
||||
import io.swagger.v3.oas.annotations.responses.*;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
{{/useSwaggerV3Annotations}}
|
||||
{{#supportAsync}}
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -23,11 +29,9 @@ import {{javaxPackage}}.validation.Valid;{{/useBeanValidation}}
|
||||
/**
|
||||
* Represents a collection of functions to interact with the API endpoints.
|
||||
*/
|
||||
{{^interfaceOnly}}
|
||||
@Path("{{commonPath}}")
|
||||
{{/interfaceOnly}}
|
||||
{{#useSwaggerAnnotations}}
|
||||
@Api(description = "the {{{baseName}}} API"){{/useSwaggerAnnotations}}{{#hasConsumes}}
|
||||
@Path("{{commonPath}}"){{#useSwaggerAnnotations}}
|
||||
@Api(description = "the {{{baseName}}} API"){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Tag(name = "{{{baseName}}}"){{/useSwaggerV3Annotations}}{{#hasConsumes}}
|
||||
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
|
||||
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* @return {{{message}}}
|
||||
{{/responses}}
|
||||
*/
|
||||
@{{httpMethod}}
|
||||
@Path("{{commonPath}}{{{path}}}"){{#hasConsumes}}
|
||||
@{{httpMethod}}{{#subresourceOperation}}
|
||||
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
|
||||
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
|
||||
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}{{#useSwaggerAnnotations}}
|
||||
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}"{{#hasAuthMethods}}, authorizations = {
|
||||
@@ -26,5 +26,8 @@
|
||||
})
|
||||
{{/implicitHeadersParams.0}}
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerV3Annotations}}
|
||||
{{#supportAsync}}{{>returnAsyncTypeInterface}}{{/supportAsync}}{{^supportAsync}}{{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{>returnTypeInterface}}{{/returnResponse}}{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}});
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
{{/implicitHeadersParams.0}}
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}}
|
||||
}){{/useSwaggerAnnotations}}
|
||||
}){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}}
|
||||
}){{/useSwaggerV3Annotations}}
|
||||
public {{#supportAsync}}CompletionStage<{{/supportAsync}}Response{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
|
||||
return {{#supportAsync}}CompletableFuture.supplyAsync(() -> {{/supportAsync}}Response.ok().entity("magic!").build(){{#supportAsync}}){{/supportAsync}};
|
||||
}
|
||||
@@ -14,6 +14,12 @@ import org.jboss.resteasy.annotations.GZIP;
|
||||
{{#useSwaggerAnnotations}}
|
||||
import io.swagger.annotations.*;
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useSwaggerV3Annotations}}
|
||||
import io.swagger.v3.oas.annotations.*;
|
||||
import io.swagger.v3.oas.annotations.media.*;
|
||||
import io.swagger.v3.oas.annotations.responses.*;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
{{/useSwaggerV3Annotations}}
|
||||
|
||||
{{#supportAsync}}
|
||||
{{#useMutiny}}
|
||||
@@ -96,7 +102,8 @@ import {{javaxPackage}}.validation.Valid;{{/useBeanValidation}}
|
||||
openIdConnectUrl = "{{openIdConnectUrl}}"
|
||||
){{^-last}}, {{/-last}}{{/isOpenId}}{{/authMethods}}
|
||||
}){{/hasAuthMethods}}{{/useMicroProfileOpenAPIAnnotations}}{{#useSwaggerAnnotations}}
|
||||
@Api(description = "the {{{baseName}}} API"){{/useSwaggerAnnotations}}
|
||||
@Api(description = "the {{{baseName}}} API"){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Tag(name = "{{{baseName}}}"){{/useSwaggerV3Annotations}}
|
||||
@Path("{{commonPath}}"){{#hasConsumes}}
|
||||
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
|
||||
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
})
|
||||
{{/implicitHeadersParams.0}}
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerV3Annotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
{{#hasAuthMethods}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirements(value = {
|
||||
{{#authMethods}}{{#isOAuth}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement(
|
||||
name = "{{name}}",
|
||||
|
||||
@@ -20,7 +20,11 @@
|
||||
{{/implicitHeadersParams.0}}
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}}
|
||||
}){{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
}){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}}
|
||||
}){{/useSwaggerV3Annotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
{{#hasAuthMethods}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirements(value={
|
||||
{{#authMethods}}{{#isOAuth}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement(name = "{{name}}", scopes = { {{#scopes}} "{{scope}}"{{^-last}},{{/-last}} {{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}}{{^isOAuth}} @org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement(name = "{{name}}"){{^-last}},{{/-last}}{{/isOAuth}}
|
||||
{{/authMethods}} }){{/hasAuthMethods}}
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
{{#useSwaggerAnnotations}}
|
||||
<io.swagger.annotations.version>1.6.10</io.swagger.annotations.version>
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useSwaggerV3Annotations}}
|
||||
<io.swagger.v3.annotations.version>2.2.21</io.swagger.v3.annotations.version>
|
||||
{{/useSwaggerV3Annotations}}
|
||||
{{#useMutiny}}
|
||||
<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>
|
||||
{{/useMutiny}}
|
||||
@@ -118,6 +121,14 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useSwaggerV3Annotations}}
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>${io.swagger.v3.annotations.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useSwaggerV3Annotations}}
|
||||
{{#useMutiny}}
|
||||
<dependency>
|
||||
<groupId>io.smallrye</groupId>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{{#useSwaggerAnnotations}}
|
||||
import io.swagger.annotations.*;
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useSwaggerV3Annotations}}
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
{{/useSwaggerV3Annotations}}
|
||||
import java.util.Objects;
|
||||
{{#jackson}}
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@@ -21,7 +24,8 @@ import {{javaxPackage}}.xml.bind.annotation.XmlEnumValue;
|
||||
{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{#description}}/**
|
||||
* {{.}}
|
||||
**/{{/description}}
|
||||
{{#useSwaggerAnnotations}}{{#description}}@ApiModel(description = "{{{.}}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
{{#useSwaggerAnnotations}}{{#description}}@ApiModel(description = "{{{.}}}"){{/description}}{{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Schema({{#title}}title="{{{.}}}", {{/title}}{{#description}}description="{{{.}}}"{{/description}}{{^description}}description=""{{/description}}){{/useSwaggerV3Annotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
@org.eclipse.microprofile.openapi.annotations.media.Schema({{#title}}title="{{{.}}}", {{/title}}{{#description}}description="{{{.}}}"{{/description}}{{^description}}description=""{{/description}}){{/useMicroProfileOpenAPIAnnotations}}
|
||||
{{#jackson}}@JsonTypeName("{{name}}"){{/jackson}}
|
||||
{{>generatedAnnotation}}{{>additionalModelTypeAnnotations}}{{>xmlPojoAnnotation}}
|
||||
@@ -109,7 +113,8 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
|
||||
@XmlElement(name="{{baseName}}"{{#required}}, required = {{required}}{{/required}})
|
||||
{{/withXml}}
|
||||
{{#vendorExtensions.x-extra-annotation}}{{{vendorExtensions.x-extra-annotation}}}{{/vendorExtensions.x-extra-annotation}}{{#useSwaggerAnnotations}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}"){{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}"){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
|
||||
@Schema({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}"){{/useSwaggerV3Annotations}}{{#useMicroProfileOpenAPIAnnotations}}
|
||||
@org.eclipse.microprofile.openapi.annotations.media.Schema({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}"){{/useMicroProfileOpenAPIAnnotations}}
|
||||
{{#jackson}}@JsonProperty({{#required}}required = {{required}}, value = {{/required}}"{{baseName}}"){{/jackson}}
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}public {{>beanValidatedType}} {{getter}}() {
|
||||
|
||||
@@ -120,6 +120,14 @@
|
||||
<version>1.5.3</version>
|
||||
</dependency>
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useSwaggerV3Annotations}}
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>${io.swagger.v3.annotations.version}</version>
|
||||
</dependency>
|
||||
{{/useSwaggerV3Annotations}}
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
@@ -202,5 +210,8 @@
|
||||
{{#openApiNullable}}
|
||||
<jackson-databind-nullable-version>0.2.8</jackson-databind-nullable-version>
|
||||
{{/openApiNullable}}
|
||||
{{#useSwaggerV3Annotations}}
|
||||
<io.swagger.v3.annotations.version>2.2.21</io.swagger.v3.annotations.version>
|
||||
{{/useSwaggerV3Annotations}}
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -39,7 +39,7 @@ cd build
|
||||
```
|
||||
|
||||
## Libraries required
|
||||
- [pistache](http://pistache.io/quickstart)
|
||||
- [pistache](https://pistacheio.github.io/pistache/docs/)
|
||||
- [JSON for Modern C++](https://github.com/nlohmann/json/#integration): Please download the `json.hpp` file and
|
||||
put it under the model/nlohmann folder
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ pplx::task<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{classname}}::{{
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
{
|
||||
utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("{{keyParamName}}"));
|
||||
utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("{{name}}"));
|
||||
if ( localVarApiKey.size() > 0 )
|
||||
{
|
||||
localVarHeaderParams[utility::conversions::to_string_t("{{keyParamName}}")] = localVarApiKey;
|
||||
@@ -248,7 +248,7 @@ pplx::task<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{classname}}::{{
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
{
|
||||
utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("{{keyParamName}}"));
|
||||
utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("{{name}}"));
|
||||
if ( localVarApiKey.size() > 0 )
|
||||
{
|
||||
localVarQueryParams[utility::conversions::to_string_t("{{keyParamName}}")] = localVarApiKey;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <variant>
|
||||
{{/-first}}
|
||||
{{/oneOf}}
|
||||
#include <boost/optional.hpp>
|
||||
{{^parent}}
|
||||
{{{defaultInclude}}}
|
||||
#include "{{packageName}}/ModelBase.h"
|
||||
@@ -264,6 +265,15 @@ public:
|
||||
protected:
|
||||
{{#vars}}
|
||||
{{^isInherited}}
|
||||
{{#isNullable}}
|
||||
{{^isEnum}}
|
||||
boost::optional<{{{dataType}}}> m_{{name}};
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
boost::optional<{{^isMap}}{{{datatypeWithEnum}}}{{/isMap}}{{#isMap}}{{{dataType}}}{{/isMap}}> m_{{name}};
|
||||
{{/isEnum}}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{^isEnum}}
|
||||
{{{dataType}}} m_{{name}};
|
||||
{{/isEnum}}
|
||||
@@ -271,6 +281,7 @@ protected:
|
||||
{{^isMap}}{{{datatypeWithEnum}}}{{/isMap}}{{#isMap}}{{{dataType}}}{{/isMap}} m_{{name}};
|
||||
{{/isEnum}}
|
||||
bool m_{{name}}IsSet;
|
||||
{{/isNullable}}
|
||||
{{/isInherited}}
|
||||
|
||||
{{/vars}}
|
||||
|
||||
@@ -187,6 +187,7 @@ void {{classname}}::setValue({{classname}}::e{{classname}} const value)
|
||||
{
|
||||
{{#vars}}
|
||||
{{^isInherited}}
|
||||
{{^isNullable}}
|
||||
{{^isContainer}}
|
||||
{{^isEnum}}
|
||||
{{#isPrimitiveType}}
|
||||
@@ -203,6 +204,7 @@ void {{classname}}::setValue({{classname}}::e{{classname}} const value)
|
||||
{{/isEnum}}
|
||||
{{/isContainer}}
|
||||
m_{{name}}IsSet = false;
|
||||
{{/isNullable}}
|
||||
{{/isInherited}}
|
||||
{{/vars}}
|
||||
}
|
||||
@@ -226,8 +228,25 @@ web::json::value {{classname}}::toJson() const
|
||||
{{/parent}}
|
||||
{{#vars}}
|
||||
{{^isInherited}}
|
||||
{{#isNullable}}
|
||||
if(m_{{name}}.has_value())
|
||||
{
|
||||
{{#isEnum}}{{#isContainer}}{{#isArray}}
|
||||
{{{dataType}}} refVal = from{{{enumName}}}(m_{{name}}.get());
|
||||
{{/isArray}}{{#isMap}}
|
||||
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}}.get());
|
||||
{{/isMap}}{{/isContainer}}{{^isContainer}}
|
||||
utility::string_t refVal = from{{{datatypeWithEnum}}}(m_{{name}}.get());
|
||||
{{/isContainer}}{{^isMap}}val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(refVal);
|
||||
{{/isMap}}{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}}.get());
|
||||
{{/isEnum}}
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
if(m_{{name}}IsSet)
|
||||
{
|
||||
{
|
||||
{{#isEnum}}{{#isContainer}}{{#isArray}}
|
||||
{{{dataType}}} refVal = from{{{enumName}}}(m_{{name}});
|
||||
{{/isArray}}{{#isMap}}
|
||||
@@ -240,6 +259,7 @@ web::json::value {{classname}}::toJson() const
|
||||
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}});
|
||||
{{/isEnum}}
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{/isInherited}}
|
||||
{{/vars}}
|
||||
|
||||
@@ -286,6 +306,27 @@ void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, co
|
||||
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
|
||||
}
|
||||
{{#vars}}
|
||||
{{#isNullable}}
|
||||
if(m_{{name}}.has_value())
|
||||
{
|
||||
{{^isEnum}}
|
||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), m_{{name}}.get()));
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{#isContainer}}
|
||||
{{#isArray}}
|
||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), from{{{enumName}}}(m_{{name}}.get())));
|
||||
{{/isArray}}{{#isMap}}
|
||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), m_{{name}}.get()));
|
||||
{{/isMap}}
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), from{{{datatypeWithEnum}}}(m_{{name}}.get())));
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
if(m_{{name}}IsSet)
|
||||
{
|
||||
{{^isEnum}}
|
||||
@@ -304,6 +345,7 @@ void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, co
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
@@ -405,7 +447,12 @@ const {{dataType}} {{classname}}::from{{{datatypeWithEnum}}}(const {{{datatypeWi
|
||||
{{^isEnum}}
|
||||
{{{dataType}}} {{classname}}::{{getter}}() const
|
||||
{
|
||||
{{#isNullable}}
|
||||
return m_{{name}}.get();
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
return m_{{name}};
|
||||
{{/isNullable}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/isContainer}}
|
||||
@@ -413,14 +460,24 @@ const {{dataType}} {{classname}}::from{{{datatypeWithEnum}}}(const {{{datatypeWi
|
||||
{{^isEnum}}
|
||||
{{{dataType}}} {{classname}}::{{getter}}() const
|
||||
{
|
||||
{{#isNullable}}
|
||||
return m_{{name}}.get();
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
return m_{{name}};
|
||||
{{/isNullable}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/isContainer}}
|
||||
{{#isEnum}}
|
||||
{{^isMap}}{{#isArray}}{{{baseType}}}<{{/isArray}}{{{classname}}}::{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isMap}}{{#isMap}}{{{dataType}}}{{/isMap}} {{classname}}::{{getter}}() const
|
||||
{
|
||||
{{#isNullable}}
|
||||
return m_{{name}}.get();
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
return m_{{name}};
|
||||
{{/isNullable}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
|
||||
@@ -433,17 +490,29 @@ void {{classname}}::{{setter}}(const {{^isMap}}{{{datatypeWithEnum}}}{{/isMap}}{
|
||||
{{/isEnum}}
|
||||
{
|
||||
m_{{name}} = value;
|
||||
{{^isNullable}}
|
||||
m_{{name}}IsSet = true;
|
||||
{{/isNullable}}
|
||||
}
|
||||
|
||||
bool {{classname}}::{{nameInCamelCase}}IsSet() const
|
||||
{
|
||||
{{#isNullable}}
|
||||
return m_{{name}}.has_value();
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
return m_{{name}}IsSet;
|
||||
{{/isNullable}}
|
||||
}
|
||||
|
||||
void {{classname}}::unset{{name}}()
|
||||
{
|
||||
{{#isNullable}}
|
||||
m_{{name}}.reset();
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
m_{{name}}IsSet = false;
|
||||
{{/isNullable}}
|
||||
}
|
||||
{{/isInherited}}{{/vars}}
|
||||
{{/isEnum}}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path);
|
||||
Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path);
|
||||
|
||||
@@ -74,7 +74,7 @@ try {
|
||||
{{#returnType}}
|
||||
print(response);
|
||||
{{/returnType}}
|
||||
} catch on DioException (e) {
|
||||
} on DioException catch (e) {
|
||||
print("Exception when calling {{classname}}->{{operationId}}: $e\n");
|
||||
}
|
||||
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
@@ -55,7 +55,7 @@ try {
|
||||
{{#returnType}}
|
||||
print(response);
|
||||
{{/returnType}}
|
||||
} catch on DioException (e) {
|
||||
} on DioException catch (e) {
|
||||
print('Exception when calling {{classname}}->{{operationId}}: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
@@ -23,7 +23,7 @@ require (
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.31.0 // indirect
|
||||
golang.org/x/crypto v0.45.0 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user