|8.0|
|buildTarget|Target to build an application or library|
**program**
Generate code for a standalone server
**library**
Generate code for a server abstract class library
|program|
|classModifier|Class Modifier for controller classes: Empty string or abstract.| ||
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_2|
@@ -45,7 +45,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src|
-|swashbuckleVersion|Swashbuckle version: 3.0.0 (deprecated), 4.0.0 (deprecated), 5.0.0 (deprecated), 6.4.0|
|6.4.0|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|useDateTimeForDate|Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only)| |false|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
diff --git a/docs/generators/cpp-restsdk.md b/docs/generators/cpp-restsdk.md
index aef6bfe1c39..f8095ede910 100644
--- a/docs/generators/cpp-restsdk.md
+++ b/docs/generators/cpp-restsdk.md
@@ -249,7 +249,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|Union|✗|OAS3
|allOf|✗|OAS2,OAS3
|anyOf|✗|OAS3
-|oneOf|✗|OAS3
+|oneOf|✓|OAS3
|not|✗|OAS3
### Security Feature
diff --git a/docs/generators/csharp.md b/docs/generators/csharp.md
index 97122c15677..8e6cd6abb7d 100644
--- a/docs/generators/csharp.md
+++ b/docs/generators/csharp.md
@@ -31,9 +31,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|library|HTTP library template (sub-template) to use|
**generichost**
HttpClient with Generic Host dependency injection (https://docs.microsoft.com/en-us/dotnet/core/extensions/generic-host) (Experimental. Subject to breaking changes without notice.)
**httpclient**
HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) (Experimental. Subject to breaking changes without notice.)
**unityWebRequest**
UnityWebRequest (...) (Experimental. Subject to breaking changes without notice.)
|restsharp|
|licenseId|The identifier of the license| |null|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |PascalCase|
+|modelPropertySorting|One of legacy, alphabetical, default (only `generichost` library supports this option).| |legacy|
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|nullableReferenceTypes|Use nullable annotations in the project. Only supported on C# 8 / ASP.NET Core 3.1 or newer. Starting in .NET 6.0 the default is true.| |false|
+|operationParameterSorting|One of legacy, alphabetical, default (only `generichost` library supports this option).| |legacy|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
diff --git a/docs/generators/elixir.md b/docs/generators/elixir.md
index b13adcbad45..bc1a7a9beb8 100644
--- a/docs/generators/elixir.md
+++ b/docs/generators/elixir.md
@@ -68,9 +68,22 @@ These options may be applied as additional-properties (cli) or configOptions (pl
__ENV__
__FILE__
__MODULE__
+
__struct__
+
after
+
and
+
catch
+
do
+
else
+
end
false
+
fn
+
in
nil
+
not
+
or
+
rescue
true
+
when
## FEATURE SET
diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md
index 12bc9a24ae9..5407b0b894e 100644
--- a/docs/generators/groovy.md
+++ b/docs/generators/groovy.md
@@ -80,7 +80,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md
index 1c7efa14ec8..e77c38151eb 100644
--- a/docs/generators/java-camel.md
+++ b/docs/generators/java-camel.md
@@ -120,11 +120,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|x-operation-extra-annotation|List of custom annotations to be added to operation|OPERATION|null
|x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
-|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD|null
+|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-helidon-client.md b/docs/generators/java-helidon-client.md
index 7f60cf91dbd..a274c0e0307 100644
--- a/docs/generators/java-helidon-client.md
+++ b/docs/generators/java-helidon-client.md
@@ -77,7 +77,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono/Flux` or `return T/List/Set` & execute `.block()` inside generated method)|OPERATION|false
diff --git a/docs/generators/java-helidon-server.md b/docs/generators/java-helidon-server.md
index 2035bb8c6fb..a34d62118c1 100644
--- a/docs/generators/java-helidon-server.md
+++ b/docs/generators/java-helidon-server.md
@@ -80,7 +80,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md
index c97cc488b15..8b8b35ea29d 100644
--- a/docs/generators/java-inflector.md
+++ b/docs/generators/java-inflector.md
@@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md
index f8c968280ec..1d3c4c201bd 100644
--- a/docs/generators/java-micronaut-client.md
+++ b/docs/generators/java-micronaut-client.md
@@ -103,7 +103,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-micronaut-server.md b/docs/generators/java-micronaut-server.md
index 9cb2ad4dbbc..a848e57254a 100644
--- a/docs/generators/java-micronaut-server.md
+++ b/docs/generators/java-micronaut-server.md
@@ -102,7 +102,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-microprofile.md b/docs/generators/java-microprofile.md
index dada45f96d5..1a6d6369a0a 100644
--- a/docs/generators/java-microprofile.md
+++ b/docs/generators/java-microprofile.md
@@ -60,7 +60,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true|
-|library|library template (sub-template) to use|
**jersey2**
HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x
**jersey3**
HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x
**feign**
HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x
**okhttp-gson**
[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
**retrofit2**
HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
**resttemplate**
HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x
**webclient**
HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x
**restclient**
HTTP client: Spring RestClient 6.1. JSON processing: Jackson 2.9.x
**resteasy**
HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x
**vertx**
HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x
**google-api-client**
HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x
**rest-assured**
HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8
**native**
HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+
**microprofile**
HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x
**apache-httpclient**
HTTP client: Apache httpclient 5.x
|okhttp-gson|
+|library|library template (sub-template) to use|
**jersey2**
HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.17.1
**jersey3**
HTTP client: Jersey client 3.1.1. JSON processing: Jackson 2.17.1
**feign**
HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.17.1 or Gson 2.10.1
**okhttp-gson**
[DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
**retrofit2**
HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.17.1. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
**resttemplate**
HTTP client: Spring RestTemplate 5.3.33 (6.1.5 if `useJakartaEe=true`). JSON processing: Jackson 2.17.1
**webclient**
HTTP client: Spring WebClient 5.1.18. JSON processing: Jackson 2.17.1
**restclient**
HTTP client: Spring RestClient 6.1.6. JSON processing: Jackson 2.17.1
**resteasy**
HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.17.1
**vertx**
HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.17.1
**google-api-client**
HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.17.1
**rest-assured**
HTTP client: rest-assured 5.3.2. JSON processing: Gson 2.10.1 or Jackson 2.17.1. Only for Java 8
**native**
HTTP client: Java native HttpClient. JSON processing: Jackson 2.17.1. Only for Java11+
**microprofile**
HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.17.1
**apache-httpclient**
HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.17.1
|okhttp-gson|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
@@ -114,7 +114,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono/Flux` or `return T/List/Set` & execute `.block()` inside generated method)|OPERATION|false
diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md
index 52455c5fea1..d321b030be8 100644
--- a/docs/generators/java-msf4j.md
+++ b/docs/generators/java-msf4j.md
@@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md
index 6ecb576ac90..4a96c9d89d9 100644
--- a/docs/generators/java-pkmst.md
+++ b/docs/generators/java-pkmst.md
@@ -89,7 +89,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md
index bfdef88970f..1e4efaaeae5 100644
--- a/docs/generators/java-play-framework.md
+++ b/docs/generators/java-play-framework.md
@@ -92,7 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md
index 202f013209d..ca484ad146e 100644
--- a/docs/generators/java-undertow-server.md
+++ b/docs/generators/java-undertow-server.md
@@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md
index 3144df23e1a..8c98816db81 100644
--- a/docs/generators/java-vertx-web.md
+++ b/docs/generators/java-vertx-web.md
@@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md
index 4592996516e..9720c15d8bd 100644
--- a/docs/generators/java-vertx.md
+++ b/docs/generators/java-vertx.md
@@ -85,7 +85,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java-wiremock.md b/docs/generators/java-wiremock.md
index 081a1296745..09fb082309e 100644
--- a/docs/generators/java-wiremock.md
+++ b/docs/generators/java-wiremock.md
@@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/java.md b/docs/generators/java.md
index 028280b4562..816f4f2228a 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -60,7 +60,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true|
-|library|library template (sub-template) to use|
**jersey2**
HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x
**jersey3**
HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x
**feign**
HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x
**okhttp-gson**
[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
**retrofit2**
HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
**resttemplate**
HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x
**webclient**
HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x
**restclient**
HTTP client: Spring RestClient 6.1. JSON processing: Jackson 2.9.x
**resteasy**
HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x
**vertx**
HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x
**google-api-client**
HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x
**rest-assured**
HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8
**native**
HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+
**microprofile**
HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x
**apache-httpclient**
HTTP client: Apache httpclient 5.x
|okhttp-gson|
+|library|library template (sub-template) to use|
**jersey2**
HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.17.1
**jersey3**
HTTP client: Jersey client 3.1.1. JSON processing: Jackson 2.17.1
**feign**
HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.17.1 or Gson 2.10.1
**okhttp-gson**
[DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
**retrofit2**
HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.17.1. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
**resttemplate**
HTTP client: Spring RestTemplate 5.3.33 (6.1.5 if `useJakartaEe=true`). JSON processing: Jackson 2.17.1
**webclient**
HTTP client: Spring WebClient 5.1.18. JSON processing: Jackson 2.17.1
**restclient**
HTTP client: Spring RestClient 6.1.6. JSON processing: Jackson 2.17.1
**resteasy**
HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.17.1
**vertx**
HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.17.1
**google-api-client**
HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.17.1
**rest-assured**
HTTP client: rest-assured 5.3.2. JSON processing: Gson 2.10.1 or Jackson 2.17.1. Only for Java 8
**native**
HTTP client: Java native HttpClient. JSON processing: Jackson 2.17.1. Only for Java11+
**microprofile**
HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.17.1
**apache-httpclient**
HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.17.1
|okhttp-gson|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
@@ -114,7 +114,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono/Flux` or `return T/List/Set` & execute `.block()` inside generated method)|OPERATION|false
diff --git a/docs/generators/javascript-closure-angular.md b/docs/generators/javascript-closure-angular.md
index 452a628eb94..860b2f523f5 100644
--- a/docs/generators/javascript-closure-angular.md
+++ b/docs/generators/javascript-closure-angular.md
@@ -7,11 +7,11 @@ title: Documentation for the javascript-closure-angular Generator
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | javascript-closure-angular | pass this to the generate command after -g |
-| generator stability | STABLE | |
+| generator stability | BETA | |
| generator type | CLIENT | |
| generator language | Javascript | |
| generator default templating engine | mustache | |
-| helpTxt | Generates a Javascript AngularJS client library (beta) annotated with Google Closure Compiler annotations(https://developers.google.com/closure/compiler/docs/js-for-compiler?hl=en) | |
+| helpTxt | Generates a Javascript AngularJS client library annotated with Google Closure Compiler annotations(https://developers.google.com/closure/compiler/docs/js-for-compiler?hl=en) | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
@@ -217,6 +217,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
-|XML|✓|OAS2,OAS3
+|XML|✗|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3
diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md
index f990de40ddb..d911fd30b0f 100644
--- a/docs/generators/jaxrs-cxf-cdi.md
+++ b/docs/generators/jaxrs-cxf-cdi.md
@@ -96,7 +96,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md
index 68d153daf20..04ae1cfee4e 100644
--- a/docs/generators/jaxrs-cxf-client.md
+++ b/docs/generators/jaxrs-cxf-client.md
@@ -87,7 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md
index f72c477c3b7..8c34c65d146 100644
--- a/docs/generators/jaxrs-cxf-extended.md
+++ b/docs/generators/jaxrs-cxf-extended.md
@@ -110,7 +110,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md
index 89caf27c7ad..12deda54824 100644
--- a/docs/generators/jaxrs-cxf.md
+++ b/docs/generators/jaxrs-cxf.md
@@ -105,7 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md
index d3b30f001e4..0965570fdde 100644
--- a/docs/generators/jaxrs-jersey.md
+++ b/docs/generators/jaxrs-jersey.md
@@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md
index 8645361f843..6973aecf1db 100644
--- a/docs/generators/jaxrs-resteasy-eap.md
+++ b/docs/generators/jaxrs-resteasy-eap.md
@@ -89,7 +89,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md
index af6e8c0aa2d..f48428ba1c9 100644
--- a/docs/generators/jaxrs-resteasy.md
+++ b/docs/generators/jaxrs-resteasy.md
@@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md
index f1ff6d31bb6..6f9fb5a4062 100644
--- a/docs/generators/jaxrs-spec.md
+++ b/docs/generators/jaxrs-spec.md
@@ -96,7 +96,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/kotlin-server.md b/docs/generators/kotlin-server.md
index e8bcf88662c..9e8c7c2291d 100644
--- a/docs/generators/kotlin-server.md
+++ b/docs/generators/kotlin-server.md
@@ -32,7 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|featureResources|Generates routes in a typed way, for both: constructing URLs and reading the parameters.| |true|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|interfaceOnly|Whether to generate only API interface stubs without the server files. This option is currently supported only when using jaxrs-spec library.| |false|
-|library|library template (sub-template)|
**ktor**
ktor framework
**jaxrs-spec**
JAX-RS spec only
**javalin5**
Javalin 5
|ktor|
+|library|library template (sub-template)|
**ktor**
ktor framework
**jaxrs-spec**
JAX-RS spec only
**javalin5**
Javalin 5
**javalin6**
Javalin 6
|ktor|
|modelMutable|Create mutable models| |false|
|omitGradleWrapper|Whether to omit Gradle wrapper for creating a sub project.| |false|
|packageName|Generated artifact package name.| |org.openapitools.server|
diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md
index 3df8e4781ff..b40ecbbc5f0 100644
--- a/docs/generators/kotlin-spring.md
+++ b/docs/generators/kotlin-spring.md
@@ -41,11 +41,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|packageName|Generated artifact package name.| |org.openapitools|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|reactive|use coroutines for reactive behavior| |false|
+|requestMappingMode|Where to generate the class level @RequestMapping annotation.|
**api_interface**
Generate the @RequestMapping annotation on the generated Api Interface.
**controller**
Generate the @RequestMapping annotation on the generated Api Controller Implementation.
**none**
Do not add a class level @RequestMapping annotation.
|controller|
|serializableModel|boolean - toggle "implements Serializable" for generated models| |null|
|serverPort|configuration the port in which the sever is to run on| |8080|
|serviceImplementation|generate stub service implementations that extends service interfaces. If this is set to true service interfaces will also be generated| |false|
|serviceInterface|generate service interfaces to go alongside controllers. In most cases this option would be used to update an existing project, so not to override implementations. Useful to help facilitate the generation gap pattern| |false|
-|skipDefaultInterface|Whether to skip generation of default implementations for interfaces| |false|
+|skipDefaultInterface|Whether to skip generation of default implementations for interfaces (Api interfaces or Delegate interfaces depending on the delegatePattern option)| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |null|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |null|
|sourceFolder|source folder for generated code| |src/main/kotlin|
@@ -56,6 +57,18 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|useTags|Whether to use tags for creating interface and controller class names| |false|
+## SUPPORTED VENDOR EXTENSIONS
+
+| Extension name | Description | Applicable for | Default value |
+| -------------- | ----------- | -------------- | ------------- |
+|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
+|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
+|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
+|x-discriminator-value|Used with model inheritance to specify value for discriminator that identifies current model|MODEL|
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
+|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null
+
+
## IMPORT MAPPING
| Type/Alias | Imports |
diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md
index 136f31d1871..060b0d2c626 100644
--- a/docs/generators/kotlin.md
+++ b/docs/generators/kotlin.md
@@ -25,6 +25,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|collectionType|Option. Collection type to use|
**array**
kotlin.Array
**list**
kotlin.collections.List
|list|
|dateLibrary|Option. Date library to use|
**threetenbp-localdatetime**
Threetenbp - Backport of JSR310 (jvm only, for legacy app only)
**kotlinx-datetime**
kotlinx-datetime (preferred for multiplatform)
**string**
String
**java8-localdatetime**
Java 8 native JSR310 (jvm only, for legacy app only)
**java8**
Java 8 native JSR310 (jvm only, preferred for jdk 1.8+)
**threetenbp**
Threetenbp - Backport of JSR310 (jvm only, preferred for jdk < 1.8)
|java8|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
+|generateOneOfAnyOfWrappers|Generate oneOf, anyOf schemas as wrappers.| |false|
|generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false|
diff --git a/docs/generators/python-fastapi.md b/docs/generators/python-fastapi.md
index 92b0ce78680..0beee68d757 100644
--- a/docs/generators/python-fastapi.md
+++ b/docs/generators/python-fastapi.md
@@ -86,6 +86,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
except
exec
false
+
field
finally
float
for
diff --git a/docs/generators/python.md b/docs/generators/python.md
index 736de837ede..fc2e686a275 100644
--- a/docs/generators/python.md
+++ b/docs/generators/python.md
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|packageVersion|python package version.| |1.0.0|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
+|setEnsureAsciiToFalse|When set to true, add `ensure_ascii=False` in json.dumps when creating the HTTP request body.| |false|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
## IMPORT MAPPING
diff --git a/docs/generators/rust.md b/docs/generators/rust.md
index 5da5f95b342..1b4ff6f400d 100644
--- a/docs/generators/rust.md
+++ b/docs/generators/rust.md
@@ -22,7 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bestFitInt|Use best fitting integer type where minimum or maximum is set| |false|
|enumNameSuffix|Suffix that will be appended to all enum names.| ||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
-|library|library template (sub-template) to use.|
**hyper**
HTTP client: Hyper.
**reqwest**
HTTP client: Reqwest.
|reqwest|
+|library|library template (sub-template) to use.|
**hyper**
HTTP client: Hyper (v1.x).
**hyper0x**
HTTP client: Hyper (v0.x).
**reqwest**
HTTP client: Reqwest.
|reqwest|
|packageName|Rust package name (convention: lowercase).| |openapi|
|packageVersion|Rust package version.| |1.0.0|
|preferUnsignedInt|Prefer unsigned integers where minimum value is >= 0| |false|
diff --git a/docs/generators/spring.md b/docs/generators/spring.md
index 6ae3b647ac6..b71cefb3c12 100644
--- a/docs/generators/spring.md
+++ b/docs/generators/spring.md
@@ -113,11 +113,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
-|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
+|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|x-operation-extra-annotation|List of custom annotations to be added to operation|OPERATION|null
|x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
-|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD|null
+|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null
## IMPORT MAPPING
diff --git a/docs/generators/typescript-angular.md b/docs/generators/typescript-angular.md
index 3e62082c095..16542b6a36d 100644
--- a/docs/generators/typescript-angular.md
+++ b/docs/generators/typescript-angular.md
@@ -11,7 +11,7 @@ title: Documentation for the typescript-angular Generator
| generator type | CLIENT | |
| generator language | Typescript | |
| generator default templating engine | mustache | |
-| helpTxt | Generates a TypeScript Angular (9.x - 17.x) client library. | |
+| helpTxt | Generates a TypeScript Angular (9.x - 18.x) client library. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
@@ -32,7 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|modelSuffix|The suffix of the generated model.| |null|
-|ngVersion|The version of Angular. (At least 9.0.0)| |17.0.0|
+|ngVersion|The version of Angular. (At least 9.0.0)| |18.0.0|
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
@@ -50,6 +50,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|supportsES6|Generate code that conforms to ES6.| |false|
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |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|
+|useSquareBracketsInArrayNames|Setting this property to true will add brackets to array attribute names, e.g. my_values[].| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
## IMPORT MAPPING
diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md
index 253dbb0801c..f4a70222200 100644
--- a/docs/generators/typescript-axios.md
+++ b/docs/generators/typescript-axios.md
@@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|apiPackage|package for generated api classes| |null|
+|axiosVersion|Use this property to override the axios version in package.json| |^1.6.1|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
@@ -40,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |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|
+|useSquareBracketsInArrayNames|Setting this property to true will add brackets to array attribute names, e.g. my_values[].| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|withNodeImports|Setting this property to true adds imports for NodeJS| |false|
|withSeparateModelsAndApi|Put the model and api in separate folders and in separate classes. This requires in addition a value for 'apiPackage' and 'modelPackage'| |false|
diff --git a/docs/generators/typescript-fetch.md b/docs/generators/typescript-fetch.md
index 63a97cf5360..e5216325d81 100644
--- a/docs/generators/typescript-fetch.md
+++ b/docs/generators/typescript-fetch.md
@@ -43,6 +43,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |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.| |true|
+|useSquareBracketsInArrayNames|Setting this property to true will add brackets to array attribute names, e.g. my_values[].| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|withoutRuntimeChecks|Setting this property to true will remove any runtime checks on the request and response payloads. Payloads will be casted to their expected types.| |false|
diff --git a/docs/installation.md b/docs/installation.md
index 40c792c779d..69e59a70523 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -103,18 +103,18 @@ docker run --rm \
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
-JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar`
+JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.7.0/openapi-generator-cli-7.7.0.jar`
For **Mac/Linux** users:
```bash
-wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar -O openapi-generator-cli.jar
+wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.7.0/openapi-generator-cli-7.7.0.jar -O openapi-generator-cli.jar
```
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```powershell
-Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar
+Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.7.0/openapi-generator-cli-7.7.0.jar
```
diff --git a/modules/openapi-generator-cli/pom.xml b/modules/openapi-generator-cli/pom.xml
index 3fb9501a504..d12181edd84 100644
--- a/modules/openapi-generator-cli/pom.xml
+++ b/modules/openapi-generator-cli/pom.xml
@@ -6,7 +6,7 @@
8.0.0-SNAPSHOT
- ../..
+ ../../pom.xml4.0.0openapi-generator-cli
diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/GenerateBatch.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/GenerateBatch.java
index 7c8cc543bcd..b59c458e4b0 100644
--- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/GenerateBatch.java
+++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/GenerateBatch.java
@@ -19,16 +19,12 @@ package org.openapitools.codegen.cmd;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
import com.fasterxml.jackson.databind.deser.std.DelegatingDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.util.TokenBuffer;
import io.airlift.airline.Arguments;
diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java
index 52043e2ce0c..a0ec3e314d7 100644
--- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java
+++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java
@@ -28,7 +28,6 @@ import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.commons.io.FileUtils;
import org.openapitools.codegen.CodegenConfig;
-import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.TemplateManager;
import org.openapitools.codegen.api.TemplatePathLocator;
@@ -40,7 +39,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
-import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
diff --git a/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/AuthorTemplateTest.java b/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/AuthorTemplateTest.java
index 4826464ad91..a8a7f1b0ba2 100644
--- a/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/AuthorTemplateTest.java
+++ b/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/AuthorTemplateTest.java
@@ -9,7 +9,6 @@ import org.testng.annotations.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Arrays;
public class AuthorTemplateTest {
Path outputDirectory;
diff --git a/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateBatchTest.java b/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateBatchTest.java
index ce446523f1e..9988ccf989d 100644
--- a/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateBatchTest.java
+++ b/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateBatchTest.java
@@ -6,7 +6,6 @@ import org.openapitools.codegen.config.Context;
import org.openapitools.codegen.config.GeneratorSettings;
import org.openapitools.codegen.config.WorkflowSettings;
import org.testng.ITestContext;
-import org.testng.TestRunner;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
diff --git a/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateTest.java b/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateTest.java
index 5b013006739..3c459b04075 100644
--- a/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateTest.java
+++ b/modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateTest.java
@@ -24,7 +24,6 @@ import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.Generator;
import org.openapitools.codegen.SpecValidationException;
import org.openapitools.codegen.config.CodegenConfigurator;
-import org.testng.TestException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
diff --git a/modules/openapi-generator-core/pom.xml b/modules/openapi-generator-core/pom.xml
index b18f685300a..d22dda49cc7 100644
--- a/modules/openapi-generator-core/pom.xml
+++ b/modules/openapi-generator-core/pom.xml
@@ -8,7 +8,7 @@
8.0.0-SNAPSHOT
- ../..
+ ../../pom.xml4.0.0
diff --git a/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/meta/features/DocumentationFeature.java b/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/meta/features/DocumentationFeature.java
index dda611e4740..e5479d51ed6 100644
--- a/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/meta/features/DocumentationFeature.java
+++ b/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/meta/features/DocumentationFeature.java
@@ -38,5 +38,5 @@ public enum DocumentationFeature {
* Generated output includes documentation for all generated APIs.
*/
@ToolingExtension
- Api;
+ Api
}
diff --git a/modules/openapi-generator-gradle-plugin/README.adoc b/modules/openapi-generator-gradle-plugin/README.adoc
index 804d41c4a69..7d1c43c6bda 100644
--- a/modules/openapi-generator-gradle-plugin/README.adoc
+++ b/modules/openapi-generator-gradle-plugin/README.adoc
@@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
[source,group]
----
plugins {
- id "org.openapi.generator" version "7.5.0"
+ id "org.openapi.generator" version "7.7.0"
}
----
@@ -113,7 +113,7 @@ buildscript {
// url "https://plugins.gradle.org/m2/"
}
dependencies {
- classpath "org.openapitools:openapi-generator-gradle-plugin:7.2.0"
+ classpath "org.openapitools:openapi-generator-gradle-plugin:7.7.0"
}
}
@@ -174,6 +174,11 @@ apply plugin: 'org.openapi.generator'
|None
|The template directory holding a custom template.
+|templateResourcePath
+|String
+|None
+|Directory with mustache templates via resource path. This option will overwrite any option defined in `templateDir`
+
|auth
|String
|None
@@ -754,7 +759,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
- classpath('org.openapitools:openapi-generator-gradle-plugin:7.2.0') {
+ classpath('org.openapitools:openapi-generator-gradle-plugin:7.7.0') {
exclude group: 'com.google.guava'
}
}
diff --git a/modules/openapi-generator-gradle-plugin/gradle.properties b/modules/openapi-generator-gradle-plugin/gradle.properties
index 5d82081e5ea..c86ac39b259 100644
--- a/modules/openapi-generator-gradle-plugin/gradle.properties
+++ b/modules/openapi-generator-gradle-plugin/gradle.properties
@@ -1,9 +1,5 @@
# RELEASE_VERSION
-<<<<<<< HEAD
openApiGeneratorVersion=8.0.0-SNAPSHOT
-=======
-openApiGeneratorVersion=7.7.0-SNAPSHOT
->>>>>>> master
# /RELEASE_VERSION
# BEGIN placeholders
diff --git a/modules/openapi-generator-gradle-plugin/pom.xml b/modules/openapi-generator-gradle-plugin/pom.xml
index 0ea4bf9bbfc..34e0980473f 100644
--- a/modules/openapi-generator-gradle-plugin/pom.xml
+++ b/modules/openapi-generator-gradle-plugin/pom.xml
@@ -6,7 +6,7 @@
8.0.0-SNAPSHOT
- ../..
+ ../../pom.xml4.0.0
diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/README.md b/modules/openapi-generator-gradle-plugin/samples/local-spec/README.md
index a9009fc4984..24744744420 100644
--- a/modules/openapi-generator-gradle-plugin/samples/local-spec/README.md
+++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/README.md
@@ -19,5 +19,5 @@ gradle generateGoWithInvalidSpec # expected outcome: BUILD FAILED
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
```bash
-gradle -PopenApiGeneratorVersion=7.2.0 openApiValidate
+gradle -PopenApiGeneratorVersion=7.7.0 openApiValidate
```
diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties
index 40cc6251ebe..e9ca0983084 100644
--- a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties
+++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties
@@ -1,11 +1,3 @@
# RELEASE_VERSION
-<<<<<<< HEAD
-<<<<<<< HEAD
openApiGeneratorVersion=8.0.0-SNAPSHOT
-=======
-openApiGeneratorVersion=7.5.0-SNAPSHOT
->>>>>>> origin/master
-=======
-openApiGeneratorVersion=7.7.0-SNAPSHOT
->>>>>>> master
# /RELEASE_VERSION
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt
index 46d6cfcc690..f1b1d9e74ed 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt
@@ -100,6 +100,7 @@ class OpenApiGeneratorPlugin : Plugin {
inputSpecRootDirectory.set(generate.inputSpecRootDirectory)
remoteInputSpec.set(generate.remoteInputSpec)
templateDir.set(generate.templateDir)
+ templateResourcePath.set(generate.templateResourcePath)
auth.set(generate.auth)
globalProperties.set(generate.globalProperties)
configFile.set(generate.configFile)
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt
index b80ffbcdd69..48c5e88259f 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt
@@ -69,6 +69,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
*/
val templateDir = project.objects.property()
+ /**
+ * The template location (which may be a directory or a classpath location) holding custom templates.
+ */
+ val templateResourcePath = project.objects.property()
+
/**
* Adds authorization headers when fetching the OpenAPI definitions remotely.
* Pass in a URL-encoded string of name:header with a comma separating multiple values
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
index 193cdbed15d..6733f61476a 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
@@ -133,6 +133,13 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
@PathSensitive(PathSensitivity.RELATIVE)
val templateDir = project.objects.property()
+ /**
+ * Resource path containing template files.
+ */
+ @Optional
+ @Input
+ val templateResourcePath = project.objects.property()
+
/**
* Adds authorization headers when fetching the OpenAPI definitions remotely.
* Pass in a URL-encoded string of name:header with a comma separating multiple values
@@ -707,6 +714,13 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
configurator.setTemplateDir(value)
}
+ templateResourcePath.ifNotEmpty { value ->
+ templateDir.ifNotEmpty {
+ logger.warn("Both templateDir and templateResourcePath were configured. templateResourcePath overwrites templateDir.")
+ }
+ configurator.setTemplateDir(value)
+ }
+
packageName.ifNotEmpty { value ->
configurator.setPackageName(value)
}
diff --git a/modules/openapi-generator-maven-plugin/README.md b/modules/openapi-generator-maven-plugin/README.md
index a3d45bd2c38..5f9123afff6 100644
--- a/modules/openapi-generator-maven-plugin/README.md
+++ b/modules/openapi-generator-maven-plugin/README.md
@@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
org.openapitoolsopenapi-generator-maven-plugin
- 7.5.0
+ 7.7.0
diff --git a/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml b/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml
index 8c966d98687..b5c0170b0c3 100644
--- a/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml
+++ b/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml
@@ -27,9 +27,15 @@
sample-schema${project.parent.version}
+
+ ${project.groupId}
+ sample-external-ref-schema
+ ${project.parent.version}
+
+ defaultgenerate
@@ -48,6 +54,30 @@
joda
+
+ jersey2
+
+
+
+ external-ref
+
+ generate
+
+
+
+ external-ref/petstore.yaml
+
+
+ java
+
+
+
+
+
+ joda
+
+
jersey2
diff --git a/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/pom.xml b/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/pom.xml
new file mode 100644
index 00000000000..0b766820d84
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/pom.xml
@@ -0,0 +1,13 @@
+
+
+ 4.0.0
+ org.openapitools
+ sample-external-ref-schema
+ jar
+ 1.0-SNAPSHOT
+ sample-external-ref-schema
+ https://maven.apache.org
+
+
+
+
diff --git a/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/src/main/resources/external-ref/petstore.yaml b/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/src/main/resources/external-ref/petstore.yaml
new file mode 100644
index 00000000000..88b99532757
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/src/main/resources/external-ref/petstore.yaml
@@ -0,0 +1,105 @@
+openapi: 3.0.0
+servers:
+ - url: 'http://petstore.swagger.io/v2'
+info:
+ description: Sample file with just two endpoints and one schema (defined in an external file $ref)
+ version: 1.0.0
+ title: OpenAPI Petstore
+paths:
+ /pet:
+ post:
+ tags:
+ - pet
+ summary: Add a new pet to the store
+ description: ''
+ operationId: addPet
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ '405':
+ description: Invalid input
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ requestBody:
+ $ref: '#/components/requestBodies/Pet'
+ '/pet/{petId}':
+ get:
+ tags:
+ - pet
+ summary: Find pet by ID
+ description: Returns a single pet
+ operationId: getPetById
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to return
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Pet not found
+ security:
+ - api_key: []
+ delete:
+ tags:
+ - pet
+ summary: Deletes a pet
+ description: ''
+ operationId: deletePet
+ parameters:
+ - name: api_key
+ in: header
+ required: false
+ schema:
+ type: string
+ - name: petId
+ in: path
+ description: Pet id to delete
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '400':
+ description: Invalid pet value
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+components:
+ requestBodies:
+ Pet:
+ content:
+ application/json:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ application/xml:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ description: Pet object that needs to be added to the store
+ required: true
+ schemas:
+ Pet:
+ $ref: 'schemas/Pet.yaml'
diff --git a/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/src/main/resources/external-ref/schemas/Pet.yaml b/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/src/main/resources/external-ref/schemas/Pet.yaml
new file mode 100644
index 00000000000..8f93f9075f3
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/examples/multi-module/sample-external-ref-schema/src/main/resources/external-ref/schemas/Pet.yaml
@@ -0,0 +1,29 @@
+title: a Pet
+description: A pet for sale in the pet store
+type: object
+required:
+ - name
+ - photoUrls
+properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ example: doggie
+ photoUrls:
+ type: array
+ xml:
+ name: photoUrl
+ wrapped: true
+ items:
+ type: string
+ status:
+ type: string
+ description: pet status in the store
+ enum:
+ - available
+ - pending
+ - sold
+xml:
+ name: Pet
\ No newline at end of file
diff --git a/modules/openapi-generator-maven-plugin/pom.xml b/modules/openapi-generator-maven-plugin/pom.xml
index 83773ed26bf..2d6117ca48a 100644
--- a/modules/openapi-generator-maven-plugin/pom.xml
+++ b/modules/openapi-generator-maven-plugin/pom.xml
@@ -7,7 +7,7 @@
8.0.0-SNAPSHOT
- ../..
+ ../../pom.xmlopenapi-generator-maven-pluginopenapi-generator (maven-plugin)
diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
index 372b9aeb47e..7fa87c39968 100644
--- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
+++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
@@ -17,40 +17,15 @@
package org.openapitools.codegen.plugin;
-import static org.apache.commons.lang3.StringUtils.isNotEmpty;
-import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
-
+import com.google.common.hash.Hashing;
+import com.google.common.io.Files;
+import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.parser.OpenAPIResolver;
import io.swagger.v3.parser.OpenAPIV3Parser;
-import io.swagger.v3.parser.core.models.AuthorizationValue;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLConnection;
-import java.nio.channels.Channels;
-import java.nio.channels.FileChannel;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Path;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.io.ByteSource;
-import com.google.common.io.CharSource;
import io.swagger.v3.parser.core.models.ParseOptions;
-import io.swagger.v3.parser.util.ClasspathHelper;
+import lombok.Setter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
@@ -58,36 +33,34 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.annotations.*;
import org.apache.maven.project.MavenProject;
-
import org.apache.maven.project.MavenProjectHelper;
-import org.openapitools.codegen.CliOption;
-import org.openapitools.codegen.ClientOptInput;
-import org.openapitools.codegen.CodegenConfig;
-import org.openapitools.codegen.CodegenConstants;
-import org.openapitools.codegen.DefaultGenerator;
-import org.openapitools.codegen.auth.AuthParser;
+import org.openapitools.codegen.*;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.config.MergedSpecBuilder;
-import org.sonatype.plexus.build.incremental.BuildContext;
-import org.sonatype.plexus.build.incremental.DefaultBuildContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonatype.plexus.build.incremental.BuildContext;
+import org.sonatype.plexus.build.incremental.DefaultBuildContext;
-import com.google.common.hash.Hashing;
-import com.google.common.io.Files;
+import java.io.File;
+import java.io.IOException;
+import java.net.*;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.text.MessageFormat;
+import java.util.*;
+
+import static org.apache.commons.lang3.StringUtils.isNotEmpty;
+import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
/**
* Goal which generates client/server code from a OpenAPI json/yaml definition.
*/
@SuppressWarnings({"unused", "MismatchedQueryAndUpdateOfCollection"})
-@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true)
+@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class CodeGenMojo extends AbstractMojo {
private final Logger LOGGER = LoggerFactory.getLogger(CodeGenMojo.class);
@@ -96,6 +69,7 @@ public class CodeGenMojo extends AbstractMojo {
* The build context is only avail when running from within eclipse.
* It is used to update the eclipse-m2e-layer when the plugin is executed inside the IDE.
*/
+ @Setter
@Component
private BuildContext buildContext = new DefaultBuildContext();
@@ -556,10 +530,6 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(readonly = true, required = true, defaultValue = "${project}")
private MavenProject project;
- public void setBuildContext(BuildContext buildContext) {
- this.buildContext = buildContext;
- }
-
@Override
public void execute() throws MojoExecutionException {
if (StringUtils.isBlank(inputSpec) && StringUtils.isBlank(inputSpecRootDirectory)) {
@@ -611,19 +581,11 @@ public class CodeGenMojo extends AbstractMojo {
}
if (Boolean.TRUE.equals(skipIfSpecIsUnchanged)) {
- File storedInputSpecHashFile = getHashFile(inputSpecFile);
+ final File storedInputSpecHashFile = getHashFile(inputSpecFile);
if (storedInputSpecHashFile.exists()) {
- String inputSpecHash = null;
- try {
- inputSpecHash = calculateInputSpecHash(inputSpecFile);
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- @SuppressWarnings("UnstableApiUsage")
String storedInputSpecHash = Files.asCharSource(storedInputSpecHashFile, StandardCharsets.UTF_8).read();
- if (storedInputSpecHash.equals(inputSpecHash)) {
- getLog().info(
- "Code generation is skipped because input was unchanged");
+ if (storedInputSpecHash.equals(calculateInputSpecHash(inputSpec))) {
+ getLog().info("Code generation is skipped because input was unchanged");
return;
}
}
@@ -661,13 +623,7 @@ public class CodeGenMojo extends AbstractMojo {
}
if (isNotEmpty(inputSpec)) {
- URL url = inputSpecRemoteUrl();
-
- if ((! inputSpecFile.exists()) && url != null) {
- configurator.setInputSpec(url.toString());
- } else {
- configurator.setInputSpec(inputSpec);
- }
+ configurator.setInputSpec(inputSpec);
}
if (isNotEmpty(gitHost)) {
@@ -1012,8 +968,6 @@ public class CodeGenMojo extends AbstractMojo {
// Store a checksum of the input spec
File storedInputSpecHashFile = getHashFile(inputSpecFile);
- String inputSpecHash = calculateInputSpecHash(inputSpecFile);
-
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
File parent = new File(storedInputSpecHashFile.getParent());
if (!parent.mkdirs()) {
@@ -1021,8 +975,8 @@ public class CodeGenMojo extends AbstractMojo {
" to store the checksum of the input spec.");
}
}
- Files.asCharSink(storedInputSpecHashFile, StandardCharsets.UTF_8).write(inputSpecHash);
+ Files.asCharSink(storedInputSpecHashFile, StandardCharsets.UTF_8).write(calculateInputSpecHash(inputSpec));
} catch (Exception e) {
// Maven logs exceptions thrown by plugins only if invoked with -e
// I find it annoying to jump through hoops to get basic diagnostic information,
@@ -1037,77 +991,33 @@ public class CodeGenMojo extends AbstractMojo {
}
/**
- * Calculate openapi specification file hash. If specification is hosted on remote resource it is downloaded first
+ * Calculate an SHA256 hash for the openapi specification.
+ * If the specification is hosted on a remote resource it is downloaded first.
*
- * @param inputSpecFile - Openapi specification input file to calculate its hash.
- * Does not take into account if input spec is hosted on remote resource
- * @return openapi specification file hash
- * @throws IOException
+ * @param inputSpec - Openapi specification input file. Can denote a URL or file path.
+ * @return openapi specification hash
*/
- private String calculateInputSpecHash(File inputSpecFile) throws IOException {
-
- URL inputSpecRemoteUrl = inputSpecRemoteUrl();
-
- File inputSpecTempFile = inputSpecFile;
-
- if (inputSpecRemoteUrl != null) {
- inputSpecTempFile = java.nio.file.Files.createTempFile("openapi-spec", ".tmp").toFile();
-
- URLConnection conn = inputSpecRemoteUrl.openConnection();
- if (isNotEmpty(auth)) {
- List authList = AuthParser.parse(auth);
- for (AuthorizationValue a : authList) {
- conn.setRequestProperty(a.getKeyName(), a.getValue());
- }
- }
- try (ReadableByteChannel readableByteChannel = Channels.newChannel(conn.getInputStream())) {
- FileChannel fileChannel;
- try (FileOutputStream fileOutputStream = new FileOutputStream(inputSpecTempFile)) {
- fileChannel = fileOutputStream.getChannel();
- fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
- }
- }
- }
-
- ByteSource inputSpecByteSource =
- inputSpecTempFile.exists()
- ? Files.asByteSource(inputSpecTempFile)
- : CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecTempFile.toString().replaceAll("\\\\","/")))
- .asByteSource(StandardCharsets.UTF_8);
-
- return inputSpecByteSource.hash(Hashing.sha256()).toString();
+ private String calculateInputSpecHash(String inputSpec) {
+ final ParseOptions parseOptions = new ParseOptions();
+ parseOptions.setResolve(true);
+
+ final URL remoteUrl = inputSpecRemoteUrl();
+ return Hashing.sha256().hashBytes(
+ new OpenAPIParser().readLocation(remoteUrl == null ? inputSpec : remoteUrl.toString(), null, parseOptions)
+ .getOpenAPI().toString().getBytes(StandardCharsets.UTF_8)
+ ).toString();
}
/**
- * Try to parse inputSpec setting string into URL (truly remote or resource)
+ * Try to parse inputSpec setting string into URL
* @return A valid URL or null if inputSpec is not a valid URL
*/
private URL inputSpecRemoteUrl() {
- URL url = dependencyClassLoader().getResource(inputSpec);
-
- if (url == null) {
- try {
- url = new URI(FilenameUtils.separatorsToUnix(inputSpec)).toURL();
- } catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
- }
+ try {
+ return new URI(FilenameUtils.separatorsToUnix(inputSpec)).toURL();
+ } catch (URISyntaxException | MalformedURLException | IllegalArgumentException ignored) {
+ return null;
}
-
- return url;
- }
-
- private ClassLoader dependencyClassLoader() {
- List list = new ArrayList<>();
-
- for (Artifact artifact : project.getArtifacts()) {
- try {
- if (artifact.isResolved() && artifact.getType().equals("jar")) {
- list.add(new URL("jar:" + artifact.getFile().toURI() + "!/"));
- }
- } catch (Exception e) {
- }
- }
-
- return new URLClassLoader(list.toArray(new URL[] { }), getClass().getClassLoader());
}
/**
diff --git a/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java b/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java
index d39da0d8a62..d7fad6c2b6b 100644
--- a/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java
+++ b/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java
@@ -16,17 +16,6 @@
package org.openapitools.codegen.plugin;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
@@ -39,10 +28,23 @@ import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.impl.DefaultServiceLocator;
+import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.RepositorySystem;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class CodeGenMojoTest extends BaseTestCase {
@Override
@@ -58,14 +60,17 @@ public class CodeGenMojoTest extends BaseTestCase {
testCommonConfiguration("resource");
}
- public void testCommonConfigurationWithURLInputSpec() throws Exception {
- testCommonConfiguration("url");
+ public void testCommonConfigurationWithResourceExternalRefInputSpec() throws Exception {
+ testCommonConfiguration("resource-external-ref");
+ }
+
+ public void testCommonConfigurationWithJARInputSpec() throws Exception {
+ testCommonConfiguration("jar");
}
@SuppressWarnings("unchecked")
private void testCommonConfiguration(String profile) throws Exception {
- File folder = Files.createTempDirectory("test").toFile();
- CodeGenMojo mojo = loadMojo(folder, "src/test/resources/default", profile);
+ CodeGenMojo mojo = loadMojo(newTempFolder(), "src/test/resources/default", profile);
mojo.execute();
assertEquals("java", getVariableValueFromObject(mojo, "generatorName"));
assertEquals("jersey2", getVariableValueFromObject(mojo, "library"));
@@ -81,43 +86,42 @@ public class CodeGenMojoTest extends BaseTestCase {
public void testHashGenerationFileContainsExecutionId() throws Exception {
// GIVEN
- Path folder = Files.createTempDirectory("test");
- CodeGenMojo mojo = loadMojo(folder.toFile(), "src/test/resources/default", "file", "executionId");
+ final Path tempDir = newTempFolder();
+ CodeGenMojo mojo = loadMojo(tempDir, "src/test/resources/default", "file", "executionId");
// WHEN
mojo.execute();
// THEN
- Path hashFolder = folder.resolve("target/generated-sources/common-maven/remote-openapi/.openapi-generator");
- assertTrue(hashFolder.resolve("petstore.yaml-executionId.sha256").toFile().exists());
+ assertTrue(Files.exists(tempDir.resolve(
+ "target/generated-sources/common-maven/remote-openapi/.openapi-generator/petstore.yaml-executionId.sha256"
+ )));
}
/**
- * For a Pom file which refers to a input file which will be on the classpath, as opposed to a file path,
+ * For a Pom file which refers to an input file which will be on the classpath, as opposed to a file path,
* test that the spec is not regenerated when the hash has not changed.
- *
- * @throws Exception
*/
public void testSkipRegenerationForClasspathSpecFileNoChange() throws Exception {
-
//GIVEN
- /* Setup the mojo */
- final Path folder = Files.createTempDirectory("test-classpath");
- final CodeGenMojo mojo = loadMojo(folder.toFile(), "src/test/resources/classpath", null, "executionId");
+ /* Set up the mojo */
+ final Path tempDir = newTempFolder();
+ final CodeGenMojo mojo = loadMojo(tempDir, "src/test/resources/classpath", null, "executionId");
/* Perform an initial generation */
mojo.execute();
/* Check the hash file was created */
- final Path hashFolder = folder.resolve("target/generated-sources/common-maven/remote-openapi/.openapi-generator");
- assertTrue(hashFolder.resolve("petstore-on-classpath.yaml-executionId.sha256").toFile().exists());
+ final Path generatedDir = tempDir.resolve("target/generated-sources/common-maven/remote-openapi");
+ assertTrue(Files.exists(
+ generatedDir.resolve(".openapi-generator/petstore-on-classpath.yaml-executionId.sha256")
+ ));
/* Remove the generated source */
- Files.walk(folder.resolve("target/generated-sources/common-maven/remote-openapi/src"))
- .sorted(Comparator.reverseOrder())
- .map(Path::toFile)
- .forEach(File::delete);
-
+ try (Stream files = Files.walk(generatedDir.resolve("src"))) {
+ //noinspection ResultOfMethodCallIgnored
+ files.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
+ }
// WHEN
/* Execute the mojo again */
@@ -125,41 +129,37 @@ public class CodeGenMojoTest extends BaseTestCase {
// THEN
/* Verify that the source directory has not been repopulated. If it has then we generated code again */
- assertFalse("src directory should not have been regenerated",
- folder.resolve("target/generated-sources/common-maven/remote-openapi/src").toFile().exists());
-
+ assertFalse("src directory should not have been regenerated", Files.exists(generatedDir.resolve("src")));
}
/**
- * For a Pom file which refers to a input file which will be on the classpath, as opposed to a file path,
+ * For a Pom file which refers to an input file which will be on the classpath, as opposed to a file path,
* test that the generated source is regenerated when the hash has changed.
- *
- * @throws Exception
*/
public void testSkipRegenerationForClasspathSpecFileWithChange() throws Exception {
-
//GIVEN
- /* Setup the mojo */
- final Path folder = Files.createTempDirectory("test-classpath");
- final CodeGenMojo mojo = loadMojo(folder.toFile(), "src/test/resources/classpath", null, "executionId");
+ /* Set up the mojo */
+ final Path tempDir = newTempFolder();
+ final CodeGenMojo mojo = loadMojo(tempDir, "src/test/resources/classpath", null, "executionId");
/* Perform an initial generation */
mojo.execute();
/* Check the hash file was created, proving a generation occurred */
- final Path hashFolder = folder.resolve("target/generated-sources/common-maven/remote-openapi/.openapi-generator");
- assertTrue(hashFolder.resolve("petstore-on-classpath.yaml-executionId.sha256").toFile().exists());
+ final Path generatedDir = tempDir.resolve("target/generated-sources/common-maven/remote-openapi");
+ assertTrue(Files.exists(generatedDir.resolve(".openapi-generator/petstore-on-classpath.yaml-executionId.sha256")));
/* Update the hash contents to be a different value, simulating a spec change */
Files.write(
- hashFolder.resolve("petstore-on-classpath.yaml-executionId.sha256"),
- Arrays.asList("bd1bf4a953c858f9d47b67ed6029daacf1707e5cbd3d2e4b01383ba30363366f"));
+ generatedDir.resolve(".openapi-generator/petstore-on-classpath.yaml-executionId.sha256"),
+ List.of("bd1bf4a953c858f9d47b67ed6029daacf1707e5cbd3d2e4b01383ba30363366f")
+ );
/* Remove the generated source */
- Files.walk(folder.resolve("target/generated-sources/common-maven/remote-openapi/src"))
- .sorted(Comparator.reverseOrder())
- .map(Path::toFile)
- .forEach(File::delete);
+ try(Stream files = Files.walk(generatedDir.resolve("src"))) {
+ //noinspection ResultOfMethodCallIgnored
+ files.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
+ }
// WHEN
@@ -167,29 +167,27 @@ public class CodeGenMojoTest extends BaseTestCase {
mojo.execute();
// THEN
- /* Verify that the source directory has not been repopulated. If it has then we generated code again */
- assertTrue("src directory should have been regenerated",
- folder.resolve("target/generated-sources/common-maven/remote-openapi/src").toFile().exists());
-
+ /* Verify that the source directory has been repopulated. */
+ assertTrue("src directory should have been regenerated", Files.exists(generatedDir.resolve("src")));
}
public void testCollapsedSpecProduced() throws Exception {
// GIVEN
- Path folder = Files.createTempDirectory("test");
- CodeGenMojo mojo = loadMojo(folder.toFile(), "src/test/resources/default", "file", "executionId");
+ final Path tempDir = newTempFolder();
+ CodeGenMojo mojo = loadMojo(tempDir, "src/test/resources/default", "file", "executionId");
// WHEN
mojo.execute();
// THEN
- File collapseSpecFile = folder.resolve("target/generated-sources/common-maven/remote-openapi/petstore-full-spec.yaml").toFile();
- assertTrue(collapseSpecFile.exists());
+ assertTrue(Files.exists(
+ tempDir.resolve("target/generated-sources/common-maven/remote-openapi/petstore-full-spec.yaml")
+ ));
}
public void testCollapsedSpecAddedToArtifacts() throws Exception {
// GIVEN
- Path folder = Files.createTempDirectory("test");
- CodeGenMojo mojo = loadMojo(folder.toFile(), "src/test/resources/default", "file", "executionId");
+ CodeGenMojo mojo = loadMojo(newTempFolder(), "src/test/resources/default", "file", "executionId");
// WHEN
mojo.execute();
@@ -203,8 +201,7 @@ public class CodeGenMojoTest extends BaseTestCase {
public void testAnyInputSpecMustBeProvided() throws Exception {
// GIVEN
- Path folder = Files.createTempDirectory("test");
- CodeGenMojo mojo = loadMojo(folder.toFile(), "src/test/resources/default", "file", "executionId");
+ CodeGenMojo mojo = loadMojo(newTempFolder(), "src/test/resources/default", "file", "executionId");
mojo.inputSpec = null;
mojo.inputSpecRootDirectory = null;
@@ -217,8 +214,8 @@ public class CodeGenMojoTest extends BaseTestCase {
public void testInputSpecRootDirectoryDoesNotRequireInputSpec() throws Exception {
// GIVEN
- Path folder = Files.createTempDirectory("test");
- CodeGenMojo mojo = loadMojo(folder.toFile(), "src/test/resources/default", "file", "executionId");
+ final Path tempDir = newTempFolder();
+ CodeGenMojo mojo = loadMojo(tempDir, "src/test/resources/default", "file", "executionId");
mojo.inputSpec = null;
mojo.inputSpecRootDirectory = "src/test/resources/default";
@@ -227,17 +224,43 @@ public class CodeGenMojoTest extends BaseTestCase {
// THEN
/* Check the hash file was created */
- final Path hashFolder = folder.resolve("target/generated-sources/common-maven/remote-openapi/.openapi-generator");
- assertTrue(hashFolder.resolve("_merged_spec.yaml-executionId.sha256").toFile().exists());
+ final Path hashFolder = tempDir.resolve("target/generated-sources/common-maven/remote-openapi/.openapi-generator");
+ assertTrue(Files.exists(hashFolder.resolve("_merged_spec.yaml-executionId.sha256")));
}
- protected CodeGenMojo loadMojo(File temporaryFolder, String projectRoot, String profile) throws Exception {
+ /**
+ * Regression test for #16489
+ */
+ public void test_skipIfSpecIsUnchanged_recognizesUpdatesInExternalReferencedFile() throws Exception {
+
+ //GIVEN
+ final Path tempDir = newTempFolder();
+ final Path generatedDir = tempDir.resolve("target/generated-sources/issue-16489");
+ final Path hashFile = generatedDir.resolve(".openapi-generator/petstore.yaml-default.sha256");
+ final CodeGenMojo mojo = loadMojo(tempDir, "src/test/resources/issue-16489", null);
+ mojo.execute(); // Perform an initial generation
+ var currentHash = Files.readString(hashFile); // read hash
+ FileUtils.deleteDirectory(generatedDir.resolve("src").toFile()); // Remove the generated source
+ Files.writeString( // change schema definition in external file
+ tempDir.resolve("schemas/Pet.yaml"),"\n wrapped: true", StandardOpenOption.APPEND
+ );
+
+ // WHEN
+ mojo.execute(); // Execute the mojo again
+
+ // THEN
+ assertNotEquals(
+ Files.readString(hashFile), currentHash, "Checksum should not be the same after external file change"
+ );
+ assertTrue("Src directory should have been regenerated", Files.exists(generatedDir.resolve("src")));
+ }
+
+ protected CodeGenMojo loadMojo(Path temporaryFolder, String projectRoot, String profile) throws Exception {
return loadMojo(temporaryFolder, projectRoot, profile, "default");
}
- protected CodeGenMojo loadMojo(File temporaryFolder, String projectRoot, String profile, String executionId) throws Exception {
- File file = new File(projectRoot);
- FileUtils.copyDirectory(file, temporaryFolder);
+ protected CodeGenMojo loadMojo(Path temporaryFolder, String projectRoot, String profile, String executionId) throws Exception {
+ FileUtils.copyDirectory(new File(projectRoot), temporaryFolder.toFile());
MavenProject project = readMavenProject(temporaryFolder, profile);
MavenSession session = newMavenSession(project);
MojoExecution execution = newMojoExecution("generate");
@@ -251,22 +274,29 @@ public class CodeGenMojoTest extends BaseTestCase {
return executionWithId;
}
- protected MavenProject readMavenProject(File basedir, String profile)
- throws Exception {
- File pom = new File(basedir, "pom.xml");
- LocalRepository localRepo = new LocalRepository(new File(basedir, "local-repo"));
+ protected MavenProject readMavenProject(Path basedir, String profile) throws Exception {
+ LocalRepository localRepo = new LocalRepository(basedir.resolve("local-repo").toFile());
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
- session.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory().newInstance(session, localRepo));
- MavenExecutionRequest request = new DefaultMavenExecutionRequest();
- request.setBaseDirectory(basedir);
+ session.setLocalRepositoryManager(
+ new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()).newInstance(session, localRepo)
+ );
+ MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory(basedir.toFile());
if (profile != null) {
request.addActiveProfile(profile);
}
- ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
- configuration.setRepositorySession(session);
- configuration.setResolveDependencies(true);
- MavenProject project = lookup(ProjectBuilder.class).build(pom, configuration).getProject();
+ ProjectBuildingRequest configuration = request.getProjectBuildingRequest()
+ .setRepositorySession(session)
+ .setResolveDependencies(true);
+ MavenProject project = lookup(ProjectBuilder.class)
+ .build(basedir.resolve("pom.xml").toFile(), configuration)
+ .getProject();
assertNotNull(project);
return project;
}
+
+ static private Path newTempFolder() throws IOException {
+ final Path tempDir = Files.createTempDirectory("test");
+ tempDir.toFile().deleteOnExit();
+ return tempDir;
+ }
}
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/default/pom.xml b/modules/openapi-generator-maven-plugin/src/test/resources/default/pom.xml
index 67a74ce3745..9ef40042d38 100644
--- a/modules/openapi-generator-maven-plugin/src/test/resources/default/pom.xml
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/default/pom.xml
@@ -32,23 +32,30 @@
resource
- petstore.yaml
+ petstore-on-classpath.yaml
- url
+ resource-external-ref
+
+
+ schema-external-ref/petstore-on-classpath.yaml
+
+
+
+ jarjar:file:${basedir}/local-repo/petstore/schema/1/schema-1.jar!/petstore.yaml
+
+
+ petstore
+ schema
+ 1
+
+
-
-
- petstore
- schema
- 1
-
- common-maven
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/petstore.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/petstore.yaml
new file mode 100644
index 00000000000..88b99532757
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/petstore.yaml
@@ -0,0 +1,105 @@
+openapi: 3.0.0
+servers:
+ - url: 'http://petstore.swagger.io/v2'
+info:
+ description: Sample file with just two endpoints and one schema (defined in an external file $ref)
+ version: 1.0.0
+ title: OpenAPI Petstore
+paths:
+ /pet:
+ post:
+ tags:
+ - pet
+ summary: Add a new pet to the store
+ description: ''
+ operationId: addPet
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ '405':
+ description: Invalid input
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ requestBody:
+ $ref: '#/components/requestBodies/Pet'
+ '/pet/{petId}':
+ get:
+ tags:
+ - pet
+ summary: Find pet by ID
+ description: Returns a single pet
+ operationId: getPetById
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to return
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Pet not found
+ security:
+ - api_key: []
+ delete:
+ tags:
+ - pet
+ summary: Deletes a pet
+ description: ''
+ operationId: deletePet
+ parameters:
+ - name: api_key
+ in: header
+ required: false
+ schema:
+ type: string
+ - name: petId
+ in: path
+ description: Pet id to delete
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ '400':
+ description: Invalid pet value
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+components:
+ requestBodies:
+ Pet:
+ content:
+ application/json:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ application/xml:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ description: Pet object that needs to be added to the store
+ required: true
+ schemas:
+ Pet:
+ $ref: 'schemas/Pet.yaml'
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/pom.xml b/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/pom.xml
new file mode 100644
index 00000000000..54724ef7fa6
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/pom.xml
@@ -0,0 +1,61 @@
+
+
+
+ 4.0.0
+ common.maven
+ issue-16489
+ jar
+ 1.0.0-SNAPSHOT
+ OpenAPI Generator Configuration Test
+ https://openapi-generator.tech/
+
+
+
+ org.openapitools
+ openapi-generator-maven-plugin
+ 7.6.0
+
+ java
+
+ true
+
+ native
+
+ hideGenerationTimestamp=true
+ ${basedir}/petstore.yaml
+ false
+ false
+ false
+ false
+ false
+
+ true
+
+
+
+
+ generate
+ generate-sources
+
+ generate
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/schemas/Pet.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/schemas/Pet.yaml
new file mode 100644
index 00000000000..8f93f9075f3
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/issue-16489/schemas/Pet.yaml
@@ -0,0 +1,29 @@
+title: a Pet
+description: A pet for sale in the pet store
+type: object
+required:
+ - name
+ - photoUrls
+properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ example: doggie
+ photoUrls:
+ type: array
+ xml:
+ name: photoUrl
+ wrapped: true
+ items:
+ type: string
+ status:
+ type: string
+ description: pet status in the store
+ enum:
+ - available
+ - pending
+ - sold
+xml:
+ name: Pet
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/2_0/python-flask/petstore.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/petstore-on-classpath.yaml
similarity index 52%
rename from modules/openapi-generator/src/test/resources/2_0/python-flask/petstore.yaml
rename to modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/petstore-on-classpath.yaml
index 952104fbb70..55cee186ad1 100644
--- a/modules/openapi-generator/src/test/resources/2_0/python-flask/petstore.yaml
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/petstore-on-classpath.yaml
@@ -1,13 +1,15 @@
-swagger: '2.0'
+openapi: 3.0.0
+servers:
+ - url: 'http://petstore.swagger.io/v2'
info:
- description: 'This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.'
+ description: >-
+ This is a sample server Petstore server. For this sample, you can use the api key
+ `special-key` to test the authorization filters.
version: 1.0.0
title: OpenAPI Petstore
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
-host: petstore.swagger.io
-basePath: /v2
tags:
- name: pet
description: Everything about your Pets
@@ -15,8 +17,6 @@ tags:
description: Access to Petstore orders
- name: user
description: Operations about user
-schemes:
- - http
paths:
/pet:
post:
@@ -25,46 +25,40 @@ paths:
summary: Add a new pet to the store
description: ''
operationId: addPet
- consumes:
- - application/json
- - application/xml
- produces:
- - application/xml
- - application/json
- parameters:
- - in: body
- name: body
- description: Pet object that needs to be added to the store
- required: true
- schema:
- $ref: '#/definitions/Pet'
responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ application/json:
+ schema:
+ $ref: 'schemas/Pet.yaml'
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
+ requestBody:
+ $ref: '#/components/requestBodies/Pet'
put:
tags:
- pet
summary: Update an existing pet
description: ''
operationId: updatePet
- consumes:
- - application/json
- - application/xml
- produces:
- - application/xml
- - application/json
- parameters:
- - in: body
- name: body
- description: Pet object that needs to be added to the store
- required: true
- schema:
- $ref: '#/definitions/Pet'
responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ application/json:
+ schema:
+ $ref: 'schemas/Pet.yaml'
'400':
description: Invalid ID supplied
'404':
@@ -75,6 +69,8 @@ paths:
- petstore_auth:
- 'write:pets'
- 'read:pets'
+ requestBody:
+ $ref: '#/components/requestBodies/Pet'
/pet/findByStatus:
get:
tags:
@@ -82,67 +78,79 @@ paths:
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
- produces:
- - application/xml
- - application/json
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: true
- type: array
- items:
- type: string
- enum:
- - available
- - pending
- - sold
- default: available
- collectionFormat: csv
- responses:
- '200':
- description: successful operation
+ style: form
+ explode: false
schema:
type: array
items:
- $ref: '#/definitions/Pet'
+ type: string
+ enum:
+ - available
+ - pending
+ - sold
+ default: available
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ type: array
+ items:
+ $ref: 'schemas/Pet.yaml'
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: 'schemas/Pet.yaml'
'400':
description: Invalid status value
security:
- petstore_auth:
- - 'write:pets'
- 'read:pets'
/pet/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
- description: 'Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.'
+ description: >-
+ Multiple tags can be provided with comma separated strings. Use tag1,
+ tag2, tag3 for testing.
operationId: findPetsByTags
- produces:
- - application/xml
- - application/json
parameters:
- name: tags
in: query
description: Tags to filter by
required: true
- type: array
- items:
- type: string
- collectionFormat: csv
- responses:
- '200':
- description: successful operation
+ style: form
+ explode: false
schema:
type: array
items:
- $ref: '#/definitions/Pet'
+ type: string
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/xml:
+ schema:
+ type: array
+ items:
+ $ref: 'schemas/Pet.yaml'
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: 'schemas/Pet.yaml'
'400':
description: Invalid tag value
security:
- petstore_auth:
- - 'write:pets'
- 'read:pets'
deprecated: true
'/pet/{petId}':
@@ -152,21 +160,24 @@ paths:
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
- produces:
- - application/xml
- - application/json
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
- type: integer
- format: int64
+ schema:
+ type: integer
+ format: int64
responses:
'200':
description: successful operation
- schema:
- $ref: '#/definitions/Pet'
+ content:
+ application/xml:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ application/json:
+ schema:
+ $ref: 'schemas/Pet.yaml'
'400':
description: Invalid ID supplied
'404':
@@ -179,28 +190,14 @@ paths:
summary: Updates a pet in the store with form data
description: ''
operationId: updatePetWithForm
- consumes:
- - application/x-www-form-urlencoded
- produces:
- - application/xml
- - application/json
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
- type: integer
- format: int64
- - name: name
- in: formData
- description: Updated name of the pet
- required: false
- type: string
- - name: status
- in: formData
- description: Updated status of the pet
- required: false
- type: string
+ schema:
+ type: integer
+ format: int64
responses:
'405':
description: Invalid input
@@ -208,26 +205,37 @@ paths:
- petstore_auth:
- 'write:pets'
- 'read:pets'
+ requestBody:
+ content:
+ application/x-www-form-urlencoded:
+ schema:
+ type: object
+ properties:
+ name:
+ description: Updated name of the pet
+ type: string
+ status:
+ description: Updated status of the pet
+ type: string
delete:
tags:
- pet
summary: Deletes a pet
description: ''
operationId: deletePet
- produces:
- - application/xml
- - application/json
parameters:
- name: api_key
in: header
required: false
- type: string
+ schema:
+ type: string
- name: petId
in: path
description: Pet id to delete
required: true
- type: integer
- format: int64
+ schema:
+ type: integer
+ format: int64
responses:
'400':
description: Invalid pet value
@@ -242,36 +250,38 @@ paths:
summary: uploads an image
description: ''
operationId: uploadFile
- consumes:
- - multipart/form-data
- produces:
- - application/json
parameters:
- name: petId
in: path
description: ID of pet to update
required: true
- type: integer
- format: int64
- - name: additionalMetadata
- in: formData
- description: Additional data to pass to server
- required: false
- type: string
- - name: file
- in: formData
- description: file to upload
- required: false
- type: file
+ schema:
+ type: integer
+ format: int64
responses:
'200':
description: successful operation
- schema:
- $ref: '#/definitions/ApiResponse'
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ApiResponse'
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
+ requestBody:
+ content:
+ multipart/form-data:
+ schema:
+ type: object
+ properties:
+ additionalMetadata:
+ description: Additional data to pass to server
+ type: string
+ file:
+ description: file to upload
+ type: string
+ format: binary
/store/inventory:
get:
tags:
@@ -279,17 +289,16 @@ paths:
summary: Returns pet inventories by status
description: Returns a map of status codes to quantities
operationId: getInventory
- produces:
- - application/json
- parameters: []
responses:
'200':
description: successful operation
- schema:
- type: object
- additionalProperties:
- type: integer
- format: int32
+ content:
+ application/json:
+ schema:
+ type: object
+ additionalProperties:
+ type: integer
+ format: int32
security:
- api_key: []
/store/order:
@@ -299,47 +308,54 @@ paths:
summary: Place an order for a pet
description: ''
operationId: placeOrder
- produces:
- - application/xml
- - application/json
- parameters:
- - in: body
- name: body
- description: order placed for purchasing the pet
- required: true
- schema:
- $ref: '#/definitions/Order'
responses:
'200':
description: successful operation
- schema:
- $ref: '#/definitions/Order'
+ content:
+ application/xml:
+ schema:
+ $ref: 'schemas/Order.yaml'
+ application/json:
+ schema:
+ $ref: 'schemas/Order.yaml'
'400':
description: Invalid Order
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: 'schemas/Order.yaml'
+ description: order placed for purchasing the pet
+ required: true
'/store/order/{orderId}':
get:
tags:
- store
summary: Find purchase order by ID
- description: 'For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions'
+ description: >-
+ For valid response try integer IDs with value <= 5 or > 10. Other values
+ will generate exceptions
operationId: getOrderById
- produces:
- - application/xml
- - application/json
parameters:
- name: orderId
in: path
description: ID of pet that needs to be fetched
required: true
- type: integer
- maximum: 5
- minimum: 1
- format: int64
+ schema:
+ type: integer
+ format: int64
+ minimum: 1
+ maximum: 5
responses:
'200':
description: successful operation
- schema:
- $ref: '#/definitions/Order'
+ content:
+ application/xml:
+ schema:
+ $ref: 'schemas/Order.yaml'
+ application/json:
+ schema:
+ $ref: 'schemas/Order.yaml'
'400':
description: Invalid ID supplied
'404':
@@ -348,17 +364,17 @@ paths:
tags:
- store
summary: Delete purchase order by ID
- description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ description: >-
+ For valid response try integer IDs with value < 1000. Anything above
+ 1000 or nonintegers will generate API errors
operationId: deleteOrder
- produces:
- - application/xml
- - application/json
parameters:
- name: orderId
in: path
description: ID of the order that needs to be deleted
required: true
- type: string
+ schema:
+ type: string
responses:
'400':
description: Invalid ID supplied
@@ -371,19 +387,18 @@ paths:
summary: Create user
description: This can only be done by the logged in user.
operationId: createUser
- produces:
- - application/xml
- - application/json
- parameters:
- - in: body
- name: body
- description: Created user object
- required: true
- schema:
- $ref: '#/definitions/User'
responses:
default:
description: successful operation
+ security:
+ - api_key: []
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: 'schemas/User.yaml'
+ description: Created user object
+ required: true
/user/createWithArray:
post:
tags:
@@ -391,21 +406,13 @@ paths:
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithArrayInput
- produces:
- - application/xml
- - application/json
- parameters:
- - in: body
- name: body
- description: List of user object
- required: true
- schema:
- type: array
- items:
- $ref: '#/definitions/User'
responses:
default:
description: successful operation
+ security:
+ - api_key: []
+ requestBody:
+ $ref: '#/components/requestBodies/UserArray'
/user/createWithList:
post:
tags:
@@ -413,21 +420,13 @@ paths:
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithListInput
- produces:
- - application/xml
- - application/json
- parameters:
- - in: body
- name: body
- description: List of user object
- required: true
- schema:
- type: array
- items:
- $ref: '#/definitions/User'
responses:
default:
description: successful operation
+ security:
+ - api_key: []
+ requestBody:
+ $ref: '#/components/requestBodies/UserArray'
/user/login:
get:
tags:
@@ -435,34 +434,48 @@ paths:
summary: Logs user into the system
description: ''
operationId: loginUser
- produces:
- - application/xml
- - application/json
parameters:
- name: username
in: query
description: The user name for login
required: true
- type: string
+ schema:
+ type: string
+ pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$'
- name: password
in: query
description: The password for login in clear text
required: true
- type: string
+ schema:
+ type: string
responses:
'200':
description: successful operation
- schema:
- type: string
headers:
+ Set-Cookie:
+ description: >-
+ Cookie authentication key for use with the `api_key`
+ apiKey authentication.
+ schema:
+ type: string
+ example: AUTH_KEY=abcde12345; Path=/; HttpOnly
X-Rate-Limit:
- type: integer
- format: int32
description: calls per hour allowed by the user
+ schema:
+ type: integer
+ format: int32
X-Expires-After:
- type: string
- format: date-time
description: date in UTC when token expires
+ schema:
+ type: string
+ format: date-time
+ content:
+ application/xml:
+ schema:
+ type: string
+ application/json:
+ schema:
+ type: string
'400':
description: Invalid username/password supplied
/user/logout:
@@ -472,13 +485,11 @@ paths:
summary: Logs out current logged in user session
description: ''
operationId: logoutUser
- produces:
- - application/xml
- - application/json
- parameters: []
responses:
default:
description: successful operation
+ security:
+ - api_key: []
'/user/{username}':
get:
tags:
@@ -486,20 +497,23 @@ paths:
summary: Get user by user name
description: ''
operationId: getUserByName
- produces:
- - application/xml
- - application/json
parameters:
- name: username
in: path
- description: 'The name that needs to be fetched. Use user1 for testing.'
+ description: The name that needs to be fetched. Use user1 for testing.
required: true
- type: string
+ schema:
+ type: string
responses:
'200':
description: successful operation
- schema:
- $ref: '#/definitions/User'
+ content:
+ application/xml:
+ schema:
+ $ref: 'schemas/User.yaml'
+ application/json:
+ schema:
+ $ref: 'schemas/User.yaml'
'400':
description: Invalid username supplied
'404':
@@ -510,194 +524,94 @@ paths:
summary: Updated user
description: This can only be done by the logged in user.
operationId: updateUser
- produces:
- - application/xml
- - application/json
parameters:
- name: username
in: path
description: name that need to be deleted
required: true
- type: string
- - in: body
- name: body
- description: Updated user object
- required: true
schema:
- $ref: '#/definitions/User'
+ type: string
responses:
'400':
description: Invalid user supplied
'404':
description: User not found
+ security:
+ - api_key: []
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: 'schemas/User.yaml'
+ description: Updated user object
+ required: true
delete:
tags:
- user
summary: Delete user
description: This can only be done by the logged in user.
operationId: deleteUser
- produces:
- - application/xml
- - application/json
parameters:
- name: username
in: path
description: The name that needs to be deleted
required: true
- type: string
+ schema:
+ type: string
responses:
'400':
description: Invalid username supplied
'404':
description: User not found
-securityDefinitions:
- petstore_auth:
- type: oauth2
- authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
- flow: implicit
- scopes:
- 'write:pets': modify pets in your account
- 'read:pets': read your pets
- api_key:
- type: apiKey
- name: api_key
- in: header
-definitions:
- Order:
- title: Pet Order
- description: An order for a pets from the pet store
- type: object
- properties:
- id:
- type: integer
- format: int64
- petId:
- type: integer
- format: int64
- quantity:
- type: integer
- format: int32
- shipDate:
- type: string
- format: date-time
- status:
- type: string
- description: Order Status
- enum:
- - placed
- - approved
- - delivered
- complete:
- type: boolean
- default: false
- xml:
- name: Order
- Category:
- title: Pet category
- description: A category for a pet
- type: object
- properties:
- id:
- type: integer
- format: int64
- name:
- type: string
- xml:
- name: Category
- User:
- title: a User
- description: A User who is purchasing from the pet store
- type: object
- properties:
- id:
- type: integer
- format: int64
- username:
- type: string
- firstName:
- type: string
- lastName:
- type: string
- email:
- type: string
- password:
- type: string
- phone:
- type: string
- userStatus:
- type: integer
- format: int32
- description: User Status
- xml:
- name: User
- Tag:
- title: Pet Tag
- description: A tag for a pet
- type: object
- properties:
- id:
- type: integer
- format: int64
- name:
- type: string
- xml:
- name: Tag
- Pet:
- title: a Pet
- description: A pet for sale in the pet store
- type: object
- required:
- - name
- - photoUrls
- properties:
- id:
- type: integer
- format: int64
- category:
- $ref: '#/definitions/Category'
- name:
- type: string
- example: doggie
- photoUrls:
- type: array
- xml:
- name: photoUrl
- wrapped: true
- items:
+ security:
+ - api_key: []
+externalDocs:
+ description: Find out more about Swagger
+ url: 'http://swagger.io'
+components:
+ requestBodies:
+ UserArray:
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: 'schemas/User.yaml'
+ description: List of user object
+ required: true
+ Pet:
+ content:
+ application/json:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ application/xml:
+ schema:
+ $ref: 'schemas/Pet.yaml'
+ description: Pet object that needs to be added to the store
+ required: true
+ securitySchemes:
+ petstore_auth:
+ type: oauth2
+ flows:
+ implicit:
+ authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
+ scopes:
+ 'write:pets': modify pets in your account
+ 'read:pets': read your pets
+ api_key:
+ type: apiKey
+ name: api_key
+ in: header
+ schemas:
+ ApiResponse:
+ title: An uploaded response
+ description: Describes the result of uploading an image resource
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ type:
+ type: string
+ message:
type: string
- tags:
- type: array
- xml:
- name: tag
- wrapped: true
- items:
- $ref: '#/definitions/Tag'
- status:
- type: string
- description: pet status in the store
- enum:
- - available
- - pending
- - sold
- xml:
- name: Pet
- ApiResponse:
- title: An uploaded response
- description: Describes the result of uploading an image resource
- type: object
- properties:
- code:
- type: integer
- format: int32
- type:
- type: string
- message:
- type: string
- EnumModel:
- enum:
- - available>
- - pending<
- - sold
- - 1
- - 2
- type: string
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Category.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Category.yaml
new file mode 100644
index 00000000000..7c746a435f0
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Category.yaml
@@ -0,0 +1,12 @@
+title: Pet category
+description: A category for a pet
+type: object
+properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$'
+xml:
+ name: Category
\ No newline at end of file
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Order.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Order.yaml
new file mode 100644
index 00000000000..fa6d787d4fe
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Order.yaml
@@ -0,0 +1,28 @@
+title: Pet Order
+description: An order for a pets from the pet store
+type: object
+properties:
+ id:
+ type: integer
+ format: int64
+ petId:
+ type: integer
+ format: int64
+ quantity:
+ type: integer
+ format: int32
+ shipDate:
+ type: string
+ format: date-time
+ status:
+ type: string
+ description: Order Status
+ enum:
+ - placed
+ - approved
+ - delivered
+ complete:
+ type: boolean
+ default: false
+xml:
+ name: Order
\ No newline at end of file
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Pet.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Pet.yaml
new file mode 100644
index 00000000000..7cc642a8cca
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Pet.yaml
@@ -0,0 +1,38 @@
+title: a Pet
+description: A pet for sale in the pet store
+type: object
+required:
+ - name
+ - photoUrls
+properties:
+ id:
+ type: integer
+ format: int64
+ category:
+ $ref: 'Category.yaml'
+ name:
+ type: string
+ example: doggie
+ photoUrls:
+ type: array
+ xml:
+ name: photoUrl
+ wrapped: true
+ items:
+ type: string
+ tags:
+ type: array
+ xml:
+ name: tag
+ wrapped: true
+ items:
+ $ref: 'Tag.yaml'
+ status:
+ type: string
+ description: pet status in the store
+ enum:
+ - available
+ - pending
+ - sold
+xml:
+ name: Pet
\ No newline at end of file
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Tag.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Tag.yaml
new file mode 100644
index 00000000000..ff2a87dffcc
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/Tag.yaml
@@ -0,0 +1,11 @@
+title: Pet Tag
+description: A tag for a pet
+type: object
+properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+xml:
+ name: Tag
\ No newline at end of file
diff --git a/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/User.yaml b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/User.yaml
new file mode 100644
index 00000000000..90bdee3fb1f
--- /dev/null
+++ b/modules/openapi-generator-maven-plugin/src/test/resources/schema-external-ref/schemas/User.yaml
@@ -0,0 +1,25 @@
+title: a User
+description: A User who is purchasing from the pet store
+type: object
+properties:
+ id:
+ type: integer
+ format: int64
+ username:
+ type: string
+ firstName:
+ type: string
+ lastName:
+ type: string
+ email:
+ type: string
+ password:
+ type: string
+ phone:
+ type: string
+ userStatus:
+ type: integer
+ format: int32
+ description: User Status
+xml:
+ name: User
\ No newline at end of file
diff --git a/modules/openapi-generator-online/pom.xml b/modules/openapi-generator-online/pom.xml
index 59c26ed68fc..ec32396ee21 100644
--- a/modules/openapi-generator-online/pom.xml
+++ b/modules/openapi-generator-online/pom.xml
@@ -6,7 +6,7 @@
8.0.0-SNAPSHOT
- ../..
+ ../../pom.xmlopenapi-generator-onlinejar
@@ -18,6 +18,13 @@
+
+ com.fasterxml.jackson
+ jackson-bom
+ ${jackson.version}
+ pom
+ import
+ org.springframework.bootspring-boot-dependencies
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/RFC3339DateFormat.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/RFC3339DateFormat.java
index 9a089de40c3..fa2752bd6f8 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/RFC3339DateFormat.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/RFC3339DateFormat.java
@@ -17,35 +17,23 @@
package org.openapitools.codegen.online;
-import com.fasterxml.jackson.databind.util.StdDateFormat;
+import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
+import com.fasterxml.jackson.databind.util.ISO8601Utils;
-import java.text.DateFormat;
import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.format.DateTimeFormatter;
import java.util.Date;
-import java.util.TimeZone;
-public class RFC3339DateFormat extends DateFormat {
+
+public class RFC3339DateFormat extends ISO8601DateFormat {
private static final long serialVersionUID = 1L;
- private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
- private static final StdDateFormat sdf = new StdDateFormat()
- .withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
- .withColonInTimeZone(true);
+ // Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
- String value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
+ String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
- @Override
- public Date parse(String source, ParsePosition pos) {
- return sdf.parse(source, pos);
- }
-
-}
+}
\ No newline at end of file
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ApiResponse.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ApiResponse.java
index b1a1938200b..3362e09d346 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ApiResponse.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ApiResponse.java
@@ -17,8 +17,12 @@
package org.openapitools.codegen.online.model;
+import lombok.Getter;
+import lombok.Setter;
+
import javax.xml.bind.annotation.XmlTransient;
+@Setter
@javax.xml.bind.annotation.XmlRootElement
public class ApiResponse {
public static final int ERROR = 1;
@@ -28,8 +32,8 @@ public class ApiResponse {
public static final int TOO_BUSY = 5;
int code;
- String type;
- String message;
+ @Getter String type;
+ @Getter String message;
public ApiResponse() {}
@@ -62,24 +66,4 @@ public class ApiResponse {
public int getCode() {
return code;
}
-
- public void setCode(int code) {
- this.code = code;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
}
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/Generated.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/Generated.java
index 832e178caf9..709ec3b8b1d 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/Generated.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/Generated.java
@@ -17,23 +17,11 @@
package org.openapitools.codegen.online.model;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter @Setter
public class Generated {
private String filename;
private String friendlyName;
-
- public String getFilename() {
- return filename;
- }
-
- public void setFilename(String filename) {
- this.filename = filename;
- }
-
- public String getFriendlyName() {
- return friendlyName;
- }
-
- public void setFriendlyName(String friendlyName) {
- this.friendlyName = friendlyName;
- }
}
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/GeneratorInput.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/GeneratorInput.java
index 15c71a60c2c..0844839e9e5 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/GeneratorInput.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/GeneratorInput.java
@@ -20,45 +20,20 @@ package org.openapitools.codegen.online.model;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.parser.core.models.AuthorizationValue;
+import lombok.Getter;
+import lombok.Setter;
import java.util.Map;
+@Setter
public class GeneratorInput {
- private JsonNode spec;
- private Map options;
+ @Getter private JsonNode spec;
+ @Getter private Map options;
private String openAPIUrl;
- private AuthorizationValue authorizationValue;
-
- public AuthorizationValue getAuthorizationValue() {
- return authorizationValue;
- }
-
- public void setAuthorizationValue(AuthorizationValue authorizationValue) {
- this.authorizationValue = authorizationValue;
- }
-
- public JsonNode getSpec() {
- return spec;
- }
-
- public void setSpec(JsonNode spec) {
- this.spec = spec;
- }
-
- public Map getOptions() {
- return options;
- }
-
- public void setOptions(Map options) {
- this.options = options;
- }
+ @Getter private AuthorizationValue authorizationValue;
@ApiModelProperty(example = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml")
public String getOpenAPIUrl() {
return openAPIUrl;
}
-
- public void setOpenAPIUrl(String url) {
- this.openAPIUrl = url;
- }
}
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ResponseCode.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ResponseCode.java
index a8af9ab76ff..85529434ab8 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ResponseCode.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/model/ResponseCode.java
@@ -18,36 +18,25 @@
package org.openapitools.codegen.online.model;
import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+@Setter @NoArgsConstructor @AllArgsConstructor
public class ResponseCode {
private String code;
private String link;
- public ResponseCode() {}
-
- public ResponseCode(String code, String link) {
- setCode(code);
- setLink(link);
- }
-
@ApiModelProperty(value = "File download code",
example = "d40029be-eda6-4d62-b1ef-d05e2e91a72a")
public String getCode() {
return code;
}
- public void setCode(String code) {
- this.code = code;
- }
-
@ApiModelProperty(
value = "URL for fetching the generated client",
example = "http://localhost:8080/api/gen/download/d40029be-eda6-4d62-b1ef-d05e2e91a72a")
public String getLink() {
return link;
}
-
- public void setLink(String link) {
- this.link = link;
- }
}
diff --git a/modules/openapi-generator/pom.xml b/modules/openapi-generator/pom.xml
index 63c138fef41..88221982c0a 100644
--- a/modules/openapi-generator/pom.xml
+++ b/modules/openapi-generator/pom.xml
@@ -6,7 +6,7 @@
8.0.0-SNAPSHOT
- ../..
+ ../../pom.xml4.0.0openapi-generator
@@ -288,6 +288,7 @@
org.slf4jslf4j-simple${slf4j.version}
+ runtimeorg.apache.commons
@@ -338,9 +339,9 @@
test
- org.testng
- testng
- ${testng.version}
+ org.junit.support
+ testng-engine
+ 1.0.5test
@@ -349,17 +350,6 @@
3.24.9test
-
- org.openrewrite
- rewrite-maven
- test
-
-
- org.reflections
- reflections
- ${reflections.version}
- test
- com.googlecode.java-diff-utilsdiffutils
@@ -390,7 +380,13 @@
com.fasterxml.jackson.corejackson-databind
- ${jackson-databind.version}
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+ ${jackson.version}
+ testcom.fasterxml.jackson.datatype
@@ -433,7 +429,13 @@
com.google.guavaguava-testlib
- 31.1-jre
+ ${guava.version}
+
+
+ junit
+ junit
+
+ test
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CliOption.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CliOption.java
index 7226c7dd931..f4a04b8fd32 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CliOption.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CliOption.java
@@ -19,17 +19,21 @@ package org.openapitools.codegen;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.parser.util.SchemaTypeUtil;
+import lombok.Getter;
+import lombok.Setter;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
public class CliOption {
- private final String opt;
+ @Getter private final String opt;
+ @Getter @Setter
private String description;
+ @Getter @Setter
private String type;
private String defaultValue;
- private String optValue;
+ @Getter private String optValue;
private Map enumValues;
public CliOption(String opt, String description) {
@@ -42,26 +46,6 @@ public class CliOption {
this.type = type;
}
- public String getOpt() {
- return opt;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
public String getDefault() {
return defaultValue;
}
@@ -75,10 +59,6 @@ public class CliOption {
return this;
}
- public String getOptValue() {
- return this.optValue;
- }
-
public void setOptValue(String optValue) {
if (this.enumValues!=null && this.enumValues.containsKey(optValue)) {
this.optValue = optValue;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ClientOptInput.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ClientOptInput.java
index cf5960cf633..519a390a0d5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ClientOptInput.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ClientOptInput.java
@@ -20,6 +20,7 @@ package org.openapitools.codegen;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.AuthorizationValue;
+import lombok.Getter;
import org.openapitools.codegen.api.TemplateDefinition;
import org.openapitools.codegen.auth.AuthParser;
import org.openapitools.codegen.config.GeneratorSettings;
@@ -31,7 +32,8 @@ public class ClientOptInput {
private GeneratorSettings generatorSettings;
private OpenAPI openAPI;
private List auths;
- private List userDefinedTemplates;
+ // not deprecated as this is added to match other functionality, we need to move to Context> instead of ClientOptInput.
+ @Getter private List userDefinedTemplates;
public ClientOptInput openAPI(OpenAPI openAPI) {
this.setOpenAPI(openAPI);
@@ -79,11 +81,6 @@ public class ClientOptInput {
return config;
}
- public List getUserDefinedTemplates() {
- // not deprecated as this is added to match other functionality, we need to move to Context> instead of ClientOptInput.
- return userDefinedTemplates;
- }
-
/**
* Sets the generator/config instance
*
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
index e2fe8187004..08e261c165e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
@@ -16,8 +16,12 @@
package org.openapitools.codegen;
+import lombok.Getter;
+import lombok.Setter;
+
import java.util.*;
+@Getter @Setter
public class CodegenComposedSchemas {
private List allOf;
private List oneOf;
@@ -31,38 +35,6 @@ public class CodegenComposedSchemas {
this.not = not;
}
- public List getAllOf() {
- return allOf;
- }
-
- public List getOneOf() {
- return oneOf;
- }
-
- public List getAnyOf() {
- return anyOf;
- }
-
- public CodegenProperty getNot() {
- return not;
- }
-
- public void setAllOf(List allOf) {
- this.allOf = allOf;
- }
-
- public void setOneOf(List oneOf) {
- this.oneOf = oneOf;
- }
-
- public void setAnyOf(List anyOf) {
- this.anyOf = anyOf;
- }
-
- public void setNot(CodegenProperty not) {
- this.not = not;
- }
-
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenComposedSchemas{");
sb.append("oneOf=").append(oneOf);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
index 33f8e754f67..81811d4071a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
@@ -232,6 +232,8 @@ public class CodegenConstants {
public static final String TEMPLATING_ENGINE = "templatingEngine";
public static final String TEMPLATING_ENGINE_DESC = "The templating engine plugin to use: \"mustache\" (default) or \"handlebars\" (beta)";
+ public static final String MUSTACHE_PARENT_CONTEXT = "MUSTACHE_PARENT_CONTEXT";
+
public static enum PARAM_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java
index cabdf4d911d..fdc41c984fa 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java
@@ -1,5 +1,8 @@
package org.openapitools.codegen;
+import lombok.Getter;
+import lombok.Setter;
+
import java.util.*;
/**
@@ -14,10 +17,15 @@ import java.util.*;
public class CodegenDiscriminator {
// The name of the property in the payload that will hold the discriminator value.
// This is the propertyName as specified in the OpenAPI discriminator object.
+ @Getter @Setter
private String propertyName;
+ @Getter @Setter
private String propertyBaseName;
+ @Getter @Setter
private String propertyGetter;
+ @Getter @Setter
private String propertyType;
+ @Getter @Setter
private Map mapping;
private boolean isEnum;
@@ -36,58 +44,12 @@ public class CodegenDiscriminator {
//
// see the method createDiscriminator in DefaultCodegen.java
+ @Getter @Setter
private Set mappedModels = new TreeSet<>();
+ @Getter @Setter
private Map vendorExtensions = new HashMap<>();
- public String getPropertyName() {
- return propertyName;
- }
-
- public void setPropertyName(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public String getPropertyGetter() {
- return propertyGetter;
- }
-
- public void setPropertyGetter(String propertyGetter) {
- this.propertyGetter = propertyGetter;
- }
-
- public String getPropertyBaseName() {
- return propertyBaseName;
- }
-
- public void setPropertyBaseName(String propertyBaseName) {
- this.propertyBaseName = propertyBaseName;
- }
-
- public String getPropertyType() {
- return propertyType;
- }
-
- public void setPropertyType(String propertyType) {
- this.propertyType = propertyType;
- }
-
- public Map getMapping() {
- return mapping;
- }
-
- public void setMapping(Map mapping) {
- this.mapping = mapping;
- }
-
- public Set getMappedModels() {
- return mappedModels;
- }
-
- public void setMappedModels(Set mappedModels) {
- this.mappedModels = mappedModels;
- }
-
public boolean getIsEnum() {
return isEnum;
}
@@ -95,15 +57,7 @@ public class CodegenDiscriminator {
public void setIsEnum(boolean isEnum) {
this.isEnum = isEnum;
}
-
- public Map getVendorExtensions() {
- return vendorExtensions;
- }
-
- public void setVendorExtensions(Map vendorExtensions) {
- this.vendorExtensions = vendorExtensions;
- }
-
+
/**
* An object to hold discriminator mappings between payload values and schema names or
* references.
@@ -116,11 +70,14 @@ public class CodegenDiscriminator {
*/
public static class MappedModel implements Comparable{
// The value of the discriminator property in the payload.
+ @Getter @Setter
private String mappingName;
// The OAS schema name. It is obtained from the OAS document, and the string value
// is converted to a sanitized, internal representation within codegen.
+ @Getter @Setter
private String modelName;
+ @Getter @Setter
private CodegenModel model;
private final boolean explicitMapping;
@@ -154,26 +111,6 @@ public class CodegenDiscriminator {
}
}
- public String getMappingName() {
- return mappingName;
- }
-
- public void setMappingName(String mappingName) {
- this.mappingName = mappingName;
- }
-
- public String getModelName() {
- return modelName;
- }
-
- public void setModelName(String modelName) {
- this.modelName = modelName;
- }
-
- public CodegenModel getModel() { return model; }
-
- public void setModel(CodegenModel model) { this.model = model; }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenEncoding.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenEncoding.java
index d53ee21cc57..c110c5d3ebe 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenEncoding.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenEncoding.java
@@ -1,17 +1,19 @@
package org.openapitools.codegen;
+import lombok.Getter;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class CodegenEncoding {
- private String contentType;
- private List headers;
- private String style;
+ @Getter private String contentType;
+ @Getter private List headers;
+ @Getter private String style;
private boolean explode;
private boolean allowReserved;
- public Map vendorExtensions = new HashMap<>();
+ @Getter public Map vendorExtensions = new HashMap<>();
public CodegenEncoding(String contentType, List headers, String style, boolean explode, boolean allowReserved) {
this.contentType = contentType;
@@ -21,18 +23,6 @@ public class CodegenEncoding {
this.allowReserved = allowReserved;
}
- public String getContentType() {
- return contentType;
- }
-
- public List getHeaders() {
- return headers;
- }
-
- public String getStyle() {
- return style;
- }
-
public boolean getExplode() {
return explode;
}
@@ -41,10 +31,6 @@ public class CodegenEncoding {
return allowReserved;
}
- public Map getVendorExtensions() {
- return vendorExtensions;
- }
-
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenEncoding{");
sb.append("contentType=").append(contentType);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenMediaType.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenMediaType.java
index e314daf14b4..55222dc2ceb 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenMediaType.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenMediaType.java
@@ -1,13 +1,14 @@
package org.openapitools.codegen;
import io.swagger.v3.oas.models.examples.Example;
+import lombok.Getter;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
-public class CodegenMediaType {
+@Getter public class CodegenMediaType {
private CodegenProperty schema;
private LinkedHashMap encoding;
private HashMap testCases = new HashMap<>();
@@ -33,28 +34,6 @@ public class CodegenMediaType {
this.example = example;
}
- public CodegenProperty getSchema() {
- return schema;
- }
-
- public LinkedHashMap getEncoding() {
- return encoding;
- }
-
- public HashMap getTestCases() { return testCases; }
-
- public Map getExamples() {
- return examples;
- }
-
- public Object getExample() {
- return example;
- }
-
- public Map getVendorExtensions() {
- return vendorExtensions;
- }
-
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenMediaType{");
sb.append("schema=").append(schema);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
index 0260d687052..41a3a176ab2 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
@@ -22,6 +22,8 @@ import io.swagger.v3.oas.models.ExternalDocumentation;
import java.util.*;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
/**
@@ -35,15 +37,21 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
// object is a discriminator, that object is set as the parent. If no discriminator is specified,
// codegen returns the first one in the list, i.e. there is no obvious parent in the OpenAPI specification.
// When possible, the mustache templates should use 'allParents' to handle multiple parents.
+ @Getter @Setter
public String parent, parentSchema;
+ @Getter @Setter
public List interfaces;
// The list of parent model name from the schemas. In order of preference, the parent is obtained
// from the 'allOf' attribute, then 'anyOf', and finally 'oneOf'.
+ @Getter @Setter
public List allParents;
// References to parent and interface CodegenModels. Only set when code generator supports inheritance.
+ @Getter @Setter
public CodegenModel parentModel;
+ @Getter @Setter
public List interfaceModels;
+ @Getter @Setter
public List children;
// anyOf, oneOf, allOf
@@ -53,42 +61,101 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
// The schema name as written in the OpenAPI document
// If it's a reserved word, it will be escaped.
+ @Getter @Setter
public String name;
// The original schema name as written in the OpenAPI document.
+ @Getter @Setter
public String schemaName;
// The language-specific name of the class that implements this schema.
// The name of the class is derived from the OpenAPI schema name with formatting rules applied.
// The classname is derived from the OpenAPI schema name, with sanitization and escaping rules applied.
+ @Getter @Setter
public String classname;
// The value of the 'title' attribute in the OpenAPI document.
+ @Getter @Setter
public String title;
+ @Getter @Setter
public String description, classVarName, modelJson, dataType, xmlPrefix, xmlNamespace, xmlName;
+ @Getter @Setter
public String classFilename; // store the class file name, mainly used for import
+ @Getter @Setter
public String unescapedDescription;
- public CodegenDiscriminator discriminator;
+ /**
+ * -- GETTER --
+ * Returns the discriminator for this schema object, or null if no discriminator has been specified.
+ * The list of all possible schema discriminator mapping values is obtained
+ * from explicit discriminator mapping values in the OpenAPI document, and from
+ * inherited discriminators through oneOf, allOf, anyOf.
+ * For example, a discriminator may be defined in a 'Pet' schema as shown below.
+ * The Dog and Cat schemas inherit the discriminator through the allOf reference.
+ * In the 'Pet' schema, the supported discriminator mapping values for the
+ * 'objectType' properties are 'Dog' and 'Cat'.
+ * The allowed discriminator mapping value for the Dog schema is 'Dog'.
+ * The allowed discriminator mapping value for the Cat schema is 'Dog'.
+ * Pet:
+ * type: object
+ * discriminator:
+ * propertyName: objectType
+ * required:
+ * - objectType
+ * properties:
+ * objectType:
+ * type: string
+ * Dog:
+ * allOf:
+ * - $ref: '#/components/schemas/Pet'
+ * - type: object
+ * properties:
+ * p1:
+ * type: string
+ * Cat:
+ * allOf:
+ * - $ref: '#/components/schemas/Pet'
+ * - type: object
+ * properties:
+ * p2:
+ * type: string
+ *
+ * @return the discriminator.
+ */
+ @Getter public CodegenDiscriminator discriminator;
+ @Getter @Setter
public String defaultValue;
+ @Getter @Setter
public String arrayModelType;
public boolean isAlias; // Is this effectively an alias of another simple type
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime,
isDecimal, isShort, isUnboundedInteger, isPrimitiveType, isBoolean, isFreeFormObject;
private boolean additionalPropertiesIsAnyType;
public List vars = new ArrayList<>(); // all properties (without parent's properties)
+ @Getter @Setter
public List allVars = new ArrayList<>(); // all properties (with parent's properties)
public List requiredVars = new ArrayList<>(); // a list of required properties
+ @Getter @Setter
public List optionalVars = new ArrayList<>(); // a list of optional properties
+ @Getter @Setter
public List readOnlyVars = new ArrayList<>(); // a list of read-only properties
+ @Getter @Setter
public List readWriteVars = new ArrayList<>(); // a list of properties for read, write
+ @Getter @Setter
public List parentVars = new ArrayList<>();
public List parentRequiredVars = new ArrayList<>();
+ @Getter @Setter
public List nonNullableVars = new ArrayList<>(); // a list of non-nullable properties
+ @Getter @Setter
public Map allowableValues;
// Sorted sets of required parameters.
+ @Getter @Setter
public Set mandatory = new TreeSet<>(); // without parent's required properties
+ @Getter @Setter
public Set allMandatory = new TreeSet<>(); // with parent's required properties
+ @Getter @Setter
public Set imports = new TreeSet<>();
- public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasValidation;
+ @Getter @Setter
+ public boolean emptyVars;
+ public boolean hasVars, hasMoreModels, hasEnums, isEnum, hasValidation;
/**
* Indicates the OAS schema specifies "nullable: true".
*/
@@ -104,6 +171,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public boolean isArray;
public boolean hasChildren;
public boolean isMap;
+ /** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
+ public boolean isOptional;
public boolean isNull;
public boolean isVoid = false;
/**
@@ -118,8 +187,10 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
* Indicates the all properties of the type are read-only.
*/
public boolean hasOnlyReadOnly = true;
+ @Getter @Setter
public ExternalDocumentation externalDocumentation;
+ @Getter @Setter
public Map vendorExtensions = new HashMap<>();
private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false;
@@ -156,6 +227,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
* type: integer
*
*/
+ @Getter @Setter
public String additionalPropertiesType;
/**
@@ -191,14 +263,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
private Map requiredVarsMap;
private String ref;
- public String getAdditionalPropertiesType() {
- return additionalPropertiesType;
- }
-
- public void setAdditionalPropertiesType(String additionalPropertiesType) {
- this.additionalPropertiesType = additionalPropertiesType;
- }
-
@Override
public CodegenProperty getContains() {
return contains;
@@ -269,78 +333,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.schemaIsFromAdditionalProperties = schemaIsFromAdditionalProperties;
}
- public Set getAllMandatory() {
- return allMandatory;
- }
-
- public void setAllMandatory(Set allMandatory) {
- this.allMandatory = allMandatory;
- }
-
- public List getAllParents() {
- return allParents;
- }
-
- public void setAllParents(List allParents) {
- this.allParents = allParents;
- }
-
- public List getAllVars() {
- return allVars;
- }
-
- public void setAllVars(List allVars) {
- this.allVars = allVars;
- }
-
- public List getNonNullableVars() {
- return nonNullableVars;
- }
-
- public void setNonNullableVars(List nonNullableVars) {
- this.nonNullableVars = nonNullableVars;
- }
-
- public Map getAllowableValues() {
- return allowableValues;
- }
-
- public void setAllowableValues(Map allowableValues) {
- this.allowableValues = allowableValues;
- }
-
- public String getArrayModelType() {
- return arrayModelType;
- }
-
- public void setArrayModelType(String arrayModelType) {
- this.arrayModelType = arrayModelType;
- }
-
- public List getChildren() {
- return children;
- }
-
- public void setChildren(List children) {
- this.children = children;
- }
-
- public String getClassFilename() {
- return classFilename;
- }
-
- public void setClassFilename(String classFilename) {
- this.classFilename = classFilename;
- }
-
- public String getClassVarName() {
- return classVarName;
- }
-
- public void setClassVarName(String classVarName) {
- this.classVarName = classVarName;
- }
-
/**
* Return true if the classname property is sanitized, false if it is the same as the OpenAPI schema name.
* The OpenAPI schema name may be any valid JSON schema name, including non-ASCII characters.
@@ -352,81 +344,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
return !StringUtils.equals(classname, name);
}
- public String getClassname() {
- return classname;
- }
-
- public void setClassname(String classname) {
- this.classname = classname;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * Returns the discriminator for this schema object, or null if no discriminator has been specified.
- *
- * The list of all possible schema discriminator mapping values is obtained
- * from explicit discriminator mapping values in the OpenAPI document, and from
- * inherited discriminators through oneOf, allOf, anyOf.
- * For example, a discriminator may be defined in a 'Pet' schema as shown below.
- * The Dog and Cat schemas inherit the discriminator through the allOf reference.
- * In the 'Pet' schema, the supported discriminator mapping values for the
- * 'objectType' properties are 'Dog' and 'Cat'.
- * The allowed discriminator mapping value for the Dog schema is 'Dog'.
- * The allowed discriminator mapping value for the Cat schema is 'Dog'.
- *
- * Pet:
- * type: object
- * discriminator:
- * propertyName: objectType
- * required:
- * - objectType
- * properties:
- * objectType:
- * type: string
- * Dog:
- * allOf:
- * - $ref: '#/components/schemas/Pet'
- * - type: object
- * properties:
- * p1:
- * type: string
- * Cat:
- * allOf:
- * - $ref: '#/components/schemas/Pet'
- * - type: object
- * properties:
- * p2:
- * type: string
- *
- * @return the discriminator.
- */
- public CodegenDiscriminator getDiscriminator() {
- return discriminator;
- }
-
public void setDiscriminator(CodegenDiscriminator discriminator) {
this.discriminator = discriminator;
if (discriminator != null && !discriminator.getMappedModels().isEmpty()) {
@@ -446,110 +363,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
return discriminator == null ? null : discriminator.getPropertyName();
}
- public ExternalDocumentation getExternalDocumentation() {
- return externalDocumentation;
- }
-
- public void setExternalDocumentation(ExternalDocumentation externalDocumentation) {
- this.externalDocumentation = externalDocumentation;
- }
-
- public Set getImports() {
- return imports;
- }
-
- public void setImports(Set imports) {
- this.imports = imports;
- }
-
- public List getInterfaceModels() {
- return interfaceModels;
- }
-
- public void setInterfaceModels(List interfaceModels) {
- this.interfaceModels = interfaceModels;
- }
-
- public List getInterfaces() {
- return interfaces;
- }
-
- public void setInterfaces(List interfaces) {
- this.interfaces = interfaces;
- }
-
- public Set getMandatory() {
- return mandatory;
- }
-
- public void setMandatory(Set mandatory) {
- this.mandatory = mandatory;
- }
-
- public String getModelJson() {
- return modelJson;
- }
-
- public void setModelJson(String modelJson) {
- this.modelJson = modelJson;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getSchemaName() {
- return schemaName;
- }
-
- public void setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- }
-
-
- public List getOptionalVars() {
- return optionalVars;
- }
-
- public void setOptionalVars(List optionalVars) {
- this.optionalVars = optionalVars;
- }
-
- public String getParent() {
- return parent;
- }
-
- public void setParent(String parent) {
- this.parent = parent;
- }
-
- public CodegenModel getParentModel() {
- return parentModel;
- }
-
- public void setParentModel(CodegenModel parentModel) {
- this.parentModel = parentModel;
- }
-
- public String getParentSchema() {
- return parentSchema;
- }
-
- public void setParentSchema(String parentSchema) {
- this.parentSchema = parentSchema;
- }
-
- public List getParentVars() {
- return parentVars;
- }
-
- public void setParentVars(List parentVars) {
- this.parentVars = parentVars;
- }
@Override
public String getPattern() {
@@ -741,6 +554,16 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.isMap = isMap;
}
+ @Override
+ public boolean getIsOptional() {
+ return isOptional;
+ }
+
+ @Override
+ public void setIsOptional(boolean isOptional) {
+ this.isOptional = isOptional;
+ }
+
@Override
public boolean getIsArray() {
return isArray;
@@ -811,22 +634,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.hasValidation = hasValidation;
}
- public List getReadOnlyVars() {
- return readOnlyVars;
- }
-
- public void setReadOnlyVars(List readOnlyVars) {
- this.readOnlyVars = readOnlyVars;
- }
-
- public List getReadWriteVars() {
- return readWriteVars;
- }
-
- public void setReadWriteVars(List readWriteVars) {
- this.readWriteVars = readWriteVars;
- }
-
@Override
public List getRequiredVars() {
return requiredVars;
@@ -837,22 +644,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.requiredVars = requiredVars;
}
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getUnescapedDescription() {
- return unescapedDescription;
- }
-
- public void setUnescapedDescription(String unescapedDescription) {
- this.unescapedDescription = unescapedDescription;
- }
-
@Override
public List getVars() {
return vars;
@@ -863,38 +654,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.vars = vars;
}
- public Map getVendorExtensions() {
- return vendorExtensions;
- }
-
- public void setVendorExtensions(Map vendorExtensions) {
- this.vendorExtensions = vendorExtensions;
- }
-
- public String getXmlName() {
- return xmlName;
- }
-
- public void setXmlName(String xmlName) {
- this.xmlName = xmlName;
- }
-
- public String getXmlNamespace() {
- return xmlNamespace;
- }
-
- public void setXmlNamespace(String xmlNamespace) {
- this.xmlNamespace = xmlNamespace;
- }
-
- public String getXmlPrefix() {
- return xmlPrefix;
- }
-
- public void setXmlPrefix(String xmlPrefix) {
- this.xmlPrefix = xmlPrefix;
- }
-
@Override
public boolean getIsNull() {
return isNull;
@@ -995,8 +754,10 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.isFreeFormObject = isFreeFormObject;
}
+ @Override
public boolean getIsUuid() { return isUuid; }
+ @Override
public void setIsUuid(boolean isUuid) { this.isUuid = isUuid; }
public boolean getIsUri() { return isUri; }
@@ -1128,6 +889,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
isArray == that.isArray &&
hasChildren == that.hasChildren &&
isMap == that.isMap &&
+ isOptional == that.isOptional &&
isDeprecated == that.isDeprecated &&
hasReadOnly == that.hasReadOnly &&
hasOnlyReadOnly == that.hasOnlyReadOnly &&
@@ -1221,7 +983,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
getVars(), getAllVars(), getNonNullableVars(), getRequiredVars(), getOptionalVars(), getReadOnlyVars(), getReadWriteVars(),
getParentVars(), getAllowableValues(), getMandatory(), getAllMandatory(), getImports(), hasVars,
isEmptyVars(), hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArray,
- hasChildren, isMap, isDeprecated, hasReadOnly, hasOnlyReadOnly, getExternalDocumentation(), getVendorExtensions(),
+ hasChildren, isMap, isOptional, isDeprecated, hasReadOnly, hasOnlyReadOnly, getExternalDocumentation(), getVendorExtensions(),
getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(),
getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(),
getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(),
@@ -1296,6 +1058,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", isArray=").append(isArray);
sb.append(", hasChildren=").append(hasChildren);
sb.append(", isMap=").append(isMap);
+ sb.append(", isOptional=").append(isOptional);
sb.append(", isDeprecated=").append(isDeprecated);
sb.append(", hasReadOnly=").append(hasReadOnly);
sb.append(", hasOnlyReadOnly=").append(hasOnlyReadOnly);
@@ -1368,14 +1131,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
}
}
- public boolean isEmptyVars() {
- return emptyVars;
- }
-
- public void setEmptyVars(boolean emptyVars) {
- this.emptyVars = emptyVars;
- }
-
public boolean getHasItems() {
return this.items != null;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModelType.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModelType.java
index 6d85bcf2c2e..6627b81a22c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModelType.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModelType.java
@@ -17,7 +17,9 @@
package org.openapitools.codegen;
-public enum CodegenModelType {
+import lombok.Getter;
+
+@Getter public enum CodegenModelType {
MODEL(CodegenModel.class),
OPERATION(CodegenOperation.class),
@@ -32,7 +34,4 @@ public enum CodegenModelType {
this.defaultImplementation = defaultImplementation;
}
- public Class> getDefaultImplementation() {
- return defaultImplementation;
- }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
index 578b86152e8..0497bf49c55 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
@@ -25,6 +25,8 @@ import java.util.Map;
import java.util.Objects;
import io.swagger.v3.oas.models.examples.Example;
+import lombok.Getter;
+import lombok.Setter;
/**
* Describes a single operation parameter in the OAS specification.
@@ -48,6 +50,8 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary,
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
public boolean isArray, isMap;
+ /** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
+ public boolean isOptional;
public boolean isFile;
public boolean isEnum;
public boolean isEnumRef; // true if the enum is a ref (model) but not defined inline
@@ -65,6 +69,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public String containerType;
public String containerTypeMapped; // language-specified container type (e.g. `dict` in python for map)
+ @Getter @Setter
private CodegenProperty schema;
private boolean additionalPropertiesIsAnyType;
private boolean hasVars;
@@ -128,6 +133,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
private boolean hasDiscriminatorWithNonEmptyMapping;
private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false;
+ @Getter @Setter
private LinkedHashMap content;
private Map requiredVarsMap;
private String ref;
@@ -261,6 +267,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
output.isAnyType = this.isAnyType;
output.isArray = this.isArray;
output.isMap = this.isMap;
+ output.isOptional = this.isOptional;
output.isExplode = this.isExplode;
output.style = this.style;
output.isDeepObject = this.isDeepObject;
@@ -280,7 +287,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples,
jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal,
isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword,
- isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues,
+ isFreeFormObject, isAnyType, isArray, isMap, isOptional, isFile, isEnum, isEnumRef, _enum, allowableValues,
items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation,
getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(),
getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(),
@@ -330,6 +337,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
isAnyType == that.isAnyType &&
isArray == that.isArray &&
isMap == that.isMap &&
+ isOptional == that.isOptional &&
isFile == that.isFile &&
isEnum == that.isEnum &&
isEnumRef == that.isEnumRef &&
@@ -463,6 +471,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
sb.append(", isAnyType=").append(isAnyType);
sb.append(", isArray=").append(isArray);
sb.append(", isMap=").append(isMap);
+ sb.append(", isOptional=").append(isOptional);
sb.append(", isFile=").append(isFile);
sb.append(", isEnum=").append(isEnum);
sb.append(", isEnumRef=").append(isEnumRef);
@@ -755,6 +764,16 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
this.isMap = isMap;
}
+ @Override
+ public boolean getIsOptional() {
+ return isOptional;
+ }
+
+ @Override
+ public void setIsOptional(boolean isOptional) {
+ this.isOptional = isOptional;
+ }
+
@Override
public boolean getIsArray() {
return isArray;
@@ -908,8 +927,6 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
return hasDiscriminatorWithNonEmptyMapping;
}
- ;
-
@Override
public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithNonEmptyMapping) {
this.hasDiscriminatorWithNonEmptyMapping = hasDiscriminatorWithNonEmptyMapping;
@@ -975,22 +992,6 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
this.hasMultipleTypes = hasMultipleTypes;
}
- public CodegenProperty getSchema() {
- return schema;
- }
-
- public void setSchema(CodegenProperty schema) {
- this.schema = schema;
- }
-
- public LinkedHashMap getContent() {
- return content;
- }
-
- public void setContent(LinkedHashMap content) {
- this.content = content;
- }
-
@Override
public String getBaseType() {
return baseType;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
index 6eee9294dcb..babaaa1727d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
@@ -17,6 +17,9 @@
package org.openapitools.codegen;
+import lombok.Getter;
+import lombok.Setter;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -29,42 +32,58 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
* The value of the 'type' attribute in the OpenAPI schema.
* The per-language codegen logic may change to a language-specific type.
*/
+ @Getter
public String openApiType;
+ @Getter @Setter
public String baseName;
- public String complexType;
+ @Setter public String complexType;
+ @Getter @Setter
public String getter;
+ @Getter @Setter
public String setter;
/**
* The value of the 'description' attribute in the OpenAPI schema.
*/
+ @Getter @Setter
public String description;
/**
* The language-specific data type for this property. For example, the OpenAPI type 'integer'
* may be represented as 'int', 'int32', 'Integer', etc, depending on the programming language.
*/
public String dataType;
+ @Getter @Setter
public String datatypeWithEnum;
+ @Getter @Setter
public String dataFormat;
/**
* The name of this property in the OpenAPI schema.
*/
+ @Getter @Setter
public String name;
+ @Getter @Setter
public String min; // TODO: is this really used?
+ @Getter @Setter
public String max; // TODO: is this really used?
+ @Getter @Setter
public String defaultValue;
+ @Getter @Setter
public String defaultValueWithParam;
- public String baseType;
+ @Setter public String baseType;
+ @Getter @Setter
public String containerType;
+ @Getter @Setter
public String containerTypeMapped; // language-specified container type (e.g. `dict` in python for map)
/**
* The value of the 'title' attribute in the OpenAPI schema.
*/
+ @Getter @Setter
public String title;
/**
* The 'description' string without escape characters needed by some programming languages/targets
*/
+ @Getter @Setter
public String unescapedDescription;
/**
@@ -82,8 +101,10 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
/**
* A free-form property to include an example of an instance for this schema.
*/
+ @Getter @Setter
public String example;
+ @Getter @Setter
public String jsonSchema;
/**
* The value of the 'minimum' attribute in the OpenAPI schema.
@@ -110,7 +131,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
* The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance.
*/
public boolean exclusiveMaximum;
- public boolean required;
+ @Setter public boolean required;
public boolean deprecated;
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
public boolean isPrimitiveType;
@@ -157,6 +178,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public boolean isAnyType;
public boolean isArray;
public boolean isMap;
+ /** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
+ public boolean isOptional;
public boolean isEnum; // true if the enum is defined inline
public boolean isInnerEnum; // Enums declared inline will be located inside the generic model, changing how the enum is referenced in some cases.
public boolean isEnumRef; // true if it's a reference to an enum
@@ -168,7 +191,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public boolean isDiscriminator;
public boolean isNew; // true when this property overrides an inherited property
public Boolean isOverridden; // true if the property is a parent property (not defined in child/current schema)
+ @Getter @Setter
public List _enum;
+ @Getter @Setter
public Map allowableValues;
// If 'additionalProperties' is not set, items is null.
// If 'additionalProperties' is set to a type or refers to a type, 'items' provides the type information for
@@ -178,16 +203,22 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public List vars = new ArrayList(); // all properties (without parent's properties)
public List requiredVars = new ArrayList<>();
public CodegenProperty mostInnerItems;
+ @Getter @Setter
public Map vendorExtensions = new HashMap();
public boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
public boolean isInherited;
public String discriminatorValue;
+ @Getter @Setter
public String nameInLowerCase; // property name in lower case
+ @Getter @Setter
public String nameInCamelCase; // property name in camel case (e.g. modifiedDate)
+ @Getter @Setter
public String nameInPascalCase; // property name in pascal case (e.g. ModifiedDate)
+ @Getter
public String nameInSnakeCase; // property name in upper snake case
// enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
+ @Getter @Setter
public String enumName;
public Integer maxItems;
public Integer minItems;
@@ -199,8 +230,11 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
// XML
public boolean isXmlAttribute = false;
+ @Getter @Setter
public String xmlPrefix;
+ @Getter @Setter
public String xmlName;
+ @Getter @Setter
public String xmlNamespace;
public boolean isXmlWrapped = false;
private boolean additionalPropertiesIsAnyType;
@@ -268,48 +302,11 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isBooleanSchemaFalse = isBooleanSchemaFalse;
}
- public String getOpenApiType() { return openApiType; }
-
- public String getBaseName() {
- return baseName;
- }
-
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
+ @Override
public String getComplexType() {
return complexType;
}
- public void setComplexType(String complexType) {
- this.complexType = complexType;
- }
-
- public String getGetter() {
- return getter;
- }
-
- public void setGetter(String getter) {
- this.getter = getter;
- }
-
- public String getSetter() {
- return setter;
- }
-
- public void setSetter(String setter) {
- this.setter = setter;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
/**
* @return dataType
* @deprecated since version 3.0.0, use {@link #getDataType()} instead.
@@ -320,119 +317,29 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
return getDataType();
}
+ @Override
public String getDataType() {
return dataType;
}
/**
- * @deprecated use {@link #setDataType()} instead.
+ * @deprecated use {@link #setDataType(String)} instead.
*/
@Deprecated
public void setDatatype(String datatype) {
this.dataType = datatype;
}
+ @Override
public void setDataType(String dataType) {
this.dataType = dataType;
}
- public String getDatatypeWithEnum() {
- return datatypeWithEnum;
- }
-
- public void setDatatypeWithEnum(String datatypeWithEnum) {
- this.datatypeWithEnum = datatypeWithEnum;
- }
-
- public String getDataFormat() {
- return dataFormat;
- }
-
- public void setDataFormat(String dataFormat) {
- this.dataFormat = dataFormat;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getMin() {
- return min;
- }
-
- public void setMin(String min) {
- this.min = min;
- }
-
- public String getMax() {
- return max;
- }
-
- public void setMax(String max) {
- this.max = max;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public String getDefaultValueWithParam() {
- return defaultValueWithParam;
- }
-
- public void setDefaultValueWithParam(String defaultValueWithParam) {
- this.defaultValueWithParam = defaultValueWithParam;
- }
-
+ @Override
public String getBaseType() {
return baseType;
}
- public void setBaseType(String baseType) {
- this.baseType = baseType;
- }
-
- public String getContainerType() {
- return containerType;
- }
-
- public void setContainerType(String containerType) {
- this.containerType = containerType;
- }
-
- public String getContainerTypeMapped() {
- return containerTypeMapped;
- }
-
- public void setContainerTypeMapped(String containerTypeMapped) {
- this.containerTypeMapped = containerTypeMapped;
- }
-
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getUnescapedDescription() {
- return unescapedDescription;
- }
-
- public void setUnescapedDescription(String unescapedDescription) {
- this.unescapedDescription = unescapedDescription;
- }
-
@Override
public boolean getSchemaIsFromAdditionalProperties() {
return schemaIsFromAdditionalProperties;
@@ -473,22 +380,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.pattern = pattern;
}
- public String getExample() {
- return example;
- }
-
- public void setExample(String example) {
- this.example = example;
- }
-
- public String getJsonSchema() {
- return jsonSchema;
- }
-
- public void setJsonSchema(String jsonSchema) {
- this.jsonSchema = jsonSchema;
- }
-
@Override
public String getMinimum() {
return minimum;
@@ -545,26 +436,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
return !getRequired() || isNullable;
}
- public void setRequired(boolean required) {
- this.required = required;
- }
-
- public List get_enum() {
- return _enum;
- }
-
- public void set_enum(List _enum) {
- this._enum = _enum;
- }
-
- public Map getAllowableValues() {
- return allowableValues;
- }
-
- public void setAllowableValues(Map allowableValues) {
- this.allowableValues = allowableValues;
- }
-
@Override
public CodegenProperty getItems() {
return items;
@@ -625,6 +496,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isMap = isMap;
}
+ @Override
+ public boolean getIsOptional() {
+ return isOptional;
+ }
+
+ @Override
+ public void setIsOptional(boolean isOptional) {
+ this.isOptional = isOptional;
+ }
+
@Override
public boolean getIsArray() {
return isArray;
@@ -675,50 +556,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isPrimitiveType = isPrimitiveType;
}
- public Map getVendorExtensions() {
- return vendorExtensions;
- }
-
- public void setVendorExtensions(Map vendorExtensions) {
- this.vendorExtensions = vendorExtensions;
- }
-
- public String getNameInLowerCase() {
- return nameInLowerCase;
- }
-
- public void setNameInLowerCase(String nameInLowerCase) {
- this.nameInLowerCase = nameInLowerCase;
- }
-
- public String getNameInCamelCase() {
- return nameInCamelCase;
- }
-
- public void setNameInCamelCase(String nameInCamelCase) {
- this.nameInCamelCase = nameInCamelCase;
- }
-
- public String getNameInPascalCase() {
- return nameInPascalCase;
- }
-
- public void setNameInPascalCase(String nameInPascalCase) {
- this.nameInPascalCase = nameInPascalCase;
- }
-
- public String getNameInSnakeCase() {
- return nameInSnakeCase;
- }
-
- public String getEnumName() {
- return enumName;
- }
-
- public void setEnumName(String enumName) {
- this.enumName = enumName;
- }
-
@Override
public Integer getMaxItems() {
return maxItems;
@@ -739,30 +576,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.minItems = minItems;
}
- public String getXmlPrefix() {
- return xmlPrefix;
- }
-
- public void setXmlPrefix(String xmlPrefix) {
- this.xmlPrefix = xmlPrefix;
- }
-
- public String getXmlName() {
- return xmlName;
- }
-
- public void setXmlName(String xmlName) {
- this.xmlName = xmlName;
- }
-
- public String getXmlNamespace() {
- return xmlNamespace;
- }
-
- public void setXmlNamespace(String xmlNamespace) {
- this.xmlNamespace = xmlNamespace;
- }
-
@Override
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
this.composedSchemas = composedSchemas;
@@ -971,8 +784,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
return hasDiscriminatorWithNonEmptyMapping;
}
- ;
-
@Override
public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithNonEmptyMapping) {
this.hasDiscriminatorWithNonEmptyMapping = hasDiscriminatorWithNonEmptyMapping;
@@ -1032,10 +843,12 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.hasMultipleTypes = hasMultipleTypes;
}
+ @Override
public boolean getIsUuid() {
return isUuid;
}
+ @Override
public void setIsUuid(boolean isUuid) {
this.isUuid = isUuid;
}
@@ -1200,6 +1013,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
sb.append(", isFreeFormObject=").append(isFreeFormObject);
sb.append(", isArray=").append(isArray);
sb.append(", isMap=").append(isMap);
+ sb.append(", isOptional=").append(isOptional);
sb.append(", isEnum=").append(isEnum);
sb.append(", isInnerEnum=").append(isInnerEnum);
sb.append(", isEnumRef=").append(isEnumRef);
@@ -1295,6 +1109,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
isFreeFormObject == that.isFreeFormObject &&
isArray == that.isArray &&
isMap == that.isMap &&
+ isOptional == that.isOptional &&
isEnum == that.isEnum &&
isInnerEnum == that.isInnerEnum &&
isEnumRef == that.isEnumRef &&
@@ -1386,7 +1201,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
hasMoreNonReadOnly, isPrimitiveType, isModel, isContainer, isString, isNumeric,
isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isFile,
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject,
- isArray, isMap, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
+ isArray, isMap, isOptional, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, isOverridden, _enum,
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInPascalCase, nameInCamelCase,
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
index e8d9090d5e9..9c8dc08aaa5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
@@ -17,10 +17,14 @@
package org.openapitools.codegen;
+import lombok.Getter;
+import lombok.Setter;
+
import java.util.*;
public class CodegenResponse implements IJsonSchemaValidationProperties {
public final List headers = new ArrayList();
+ @Getter @Setter
private List responseHeaders = new ArrayList();
public String code;
public boolean is1xx;
@@ -59,6 +63,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public boolean simpleType;
public boolean primitiveType;
public boolean isMap;
+ /** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
+ public boolean isOptional;
public boolean isArray;
public boolean isBinary = false;
public boolean isFile = false;
@@ -92,6 +98,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
private boolean hasDiscriminatorWithNonEmptyMapping;
private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false;
+ @Getter @Setter
private LinkedHashMap content;
private Map requiredVarsMap;
private String ref;
@@ -103,7 +110,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, containerTypeMapped, hasHeaders,
isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBoolean, isDate,
isDateTime, isUuid, isEmail, isPassword, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
- isMap, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties,
+ isMap, isOptional, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties,
vars, requiredVars, isNull, isVoid, hasValidation, isShort, isUnboundedInteger,
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
@@ -142,6 +149,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
simpleType == that.simpleType &&
primitiveType == that.primitiveType &&
isMap == that.isMap &&
+ isOptional == that.isOptional &&
isArray == that.isArray &&
isBinary == that.isBinary &&
isFile == that.isFile &&
@@ -246,22 +254,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
@Override
public void setFormat(String format) {}
- public LinkedHashMap getContent() {
- return content;
- }
-
- public void setContent(LinkedHashMap content) {
- this.content = content;
- }
-
- public List getResponseHeaders() {
- return responseHeaders;
- }
-
- public void setResponseHeaders(List responseHeaders) {
- this.responseHeaders = responseHeaders;
- }
-
@Override
public String getPattern() {
return pattern;
@@ -503,6 +495,16 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
this.isMap = isMap;
}
+ @Override
+ public boolean getIsOptional() {
+ return isOptional;
+ }
+
+ @Override
+ public void setIsOptional(boolean isOptional) {
+ this.isOptional = isOptional;
+ }
+
@Override
public CodegenProperty getAdditionalProperties() {
return additionalProperties;
@@ -594,6 +596,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
sb.append(", simpleType=").append(simpleType);
sb.append(", primitiveType=").append(primitiveType);
sb.append(", isMap=").append(isMap);
+ sb.append(", isOptional=").append(isOptional);
sb.append(", isArray=").append(isArray);
sb.append(", isBinary=").append(isBinary);
sb.append(", isFile=").append(isFile);
@@ -708,8 +711,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
return hasDiscriminatorWithNonEmptyMapping;
}
- ;
-
@Override
public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithNonEmptyMapping) {
this.hasDiscriminatorWithNonEmptyMapping = hasDiscriminatorWithNonEmptyMapping;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index 0682fe7c099..901696e1918 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -42,6 +42,8 @@ import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.servers.ServerVariable;
import io.swagger.v3.parser.util.SchemaTypeUtil;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.text.StringEscapeUtils;
@@ -74,6 +76,7 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
+import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -181,12 +184,15 @@ public class DefaultCodegen implements CodegenConfig {
protected Map operationIdNameMapping = new HashMap<>();
// a map to store the rules in OpenAPI Normalizer
protected Map openapiNormalizer = new HashMap<>();
- protected String modelPackage = "", apiPackage = "", fileSuffix;
+ @Setter protected String modelPackage = "", apiPackage = "";
+ protected String fileSuffix;
+ @Getter @Setter
protected String modelNamePrefix = "", modelNameSuffix = "";
+ @Getter @Setter
protected String apiNamePrefix = "", apiNameSuffix = "Api";
protected String testPackage = "";
- protected String filesMetadataFilename = "FILES";
- protected String versionMetadataFilename = "VERSION";
+ @Setter protected String filesMetadataFilename = "FILES";
+ @Setter protected String versionMetadataFilename = "VERSION";
/*
apiTemplateFiles are for API outputs only (controllers/handlers).
API templates may be written multiple times; APIs are grouped by tag and the file is written once per tag group.
@@ -198,7 +204,7 @@ public class DefaultCodegen implements CodegenConfig {
protected Map apiDocTemplateFiles = new HashMap<>();
protected Map modelDocTemplateFiles = new HashMap<>();
protected Map reservedWordsMappings = new HashMap<>();
- protected String templateDir;
+ @Setter protected String templateDir;
protected String embeddedTemplateDir;
protected Map additionalProperties = new HashMap<>();
protected Map serverVariables = new HashMap<>();
@@ -213,7 +219,9 @@ public class DefaultCodegen implements CodegenConfig {
protected List cliOptions = new ArrayList<>();
protected boolean skipOverwrite;
protected boolean removeOperationIdPrefix;
+ @Getter @Setter
protected String removeOperationIdPrefixDelimiter = "_";
+ @Getter @Setter
protected int removeOperationIdPrefixCount = 1;
protected boolean skipOperationExample;
@@ -246,9 +254,13 @@ public class DefaultCodegen implements CodegenConfig {
protected boolean supportsMixins;
protected Map supportedLibraries = new LinkedHashMap<>();
protected String library;
+ @Getter @Setter
protected Boolean sortParamsByRequiredFlag = true;
+ @Getter @Setter
protected Boolean sortModelPropertiesByRequiredFlag = false;
+ @Getter @Setter
protected Boolean ensureUniqueParams = true;
+ @Getter @Setter
protected Boolean allowUnicodeIdentifiers = false;
protected String gitHost, gitUserId, gitRepoId, releaseNote;
protected String httpUserAgent;
@@ -259,6 +271,7 @@ public class DefaultCodegen implements CodegenConfig {
protected Map specialCharReplacements = new LinkedHashMap<>();
// When a model is an alias for a simple type
protected Map typeAliases = Collections.emptyMap();
+ @Getter @Setter
protected Boolean prependFormOrBodyParameters = false;
// The extension of the generated documentation files (defaults to markdown .md)
protected String docExtension;
@@ -281,15 +294,15 @@ public class DefaultCodegen implements CodegenConfig {
protected boolean removeEnumValuePrefix = true;
// Support legacy logic for evaluating discriminators
- protected boolean legacyDiscriminatorBehavior = true;
+ @Setter protected boolean legacyDiscriminatorBehavior = true;
// Specify what to do if the 'additionalProperties' keyword is not present in a schema.
// See CodegenConstants.java for more details.
- protected boolean disallowAdditionalPropertiesIfNotPresent = true;
+ @Setter protected boolean disallowAdditionalPropertiesIfNotPresent = true;
// If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.
// With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.
- protected boolean enumUnknownDefaultCase = false;
+ @Setter protected boolean enumUnknownDefaultCase = false;
protected String enumUnknownDefaultCaseName = "unknown_default_open_api";
// make openapi available to all methods
@@ -312,8 +325,9 @@ public class DefaultCodegen implements CodegenConfig {
protected boolean addSuffixToDuplicateOperationNicknames = true;
// Whether to automatically hardcode params that are considered Constants by OpenAPI Spec
- protected boolean autosetConstants = false;
+ @Setter protected boolean autosetConstants = false;
+ @Override
public boolean getAddSuffixToDuplicateOperationNicknames() {
return addSuffixToDuplicateOperationNicknames;
}
@@ -323,125 +337,57 @@ public class DefaultCodegen implements CodegenConfig {
return cliOptions;
}
+ /**
+ * add this instance to additionalProperties.
+ * This instance is used as parent context in Mustache.
+ * It means that Mustache uses the values found in this order:
+ * first from additionalProperties
+ * then from the getter in this instance
+ * then from the fields in this instance
+ *
+ */
+ protected void useCodegenAsMustacheParentContext() {
+ additionalProperties.put(CodegenConstants.MUSTACHE_PARENT_CONTEXT, this);
+ }
+
@Override
public void processOpts() {
- if (additionalProperties.containsKey(CodegenConstants.TEMPLATE_DIR)) {
- this.setTemplateDir((String) additionalProperties.get(CodegenConstants.TEMPLATE_DIR));
+ if (!additionalProperties.containsKey(CodegenConstants.MUSTACHE_PARENT_CONTEXT)) {
+ // by default empty parent context
+ additionalProperties.put(CodegenConstants.MUSTACHE_PARENT_CONTEXT, new Object());
+ }
+ convertPropertyToStringAndWriteBack(CodegenConstants.TEMPLATE_DIR, this::setTemplateDir);
+ convertPropertyToStringAndWriteBack(CodegenConstants.MODEL_PACKAGE, this::setModelPackage);
+ convertPropertyToStringAndWriteBack(CodegenConstants.API_PACKAGE, this::setApiPackage);
+
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.HIDE_GENERATION_TIMESTAMP, this::setHideGenerationTimestamp);
+ // put the value back in additionalProperties for backward compatibility with generators not using yet convertPropertyToBooleanAndWriteBack
+ writePropertyBack(CodegenConstants.HIDE_GENERATION_TIMESTAMP, isHideGenerationTimestamp());
+
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, this::setSortParamsByRequiredFlag);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, this::setSortModelPropertiesByRequiredFlag);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, this::setPrependFormOrBodyParameters);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.ENSURE_UNIQUE_PARAMS, this::setEnsureUniqueParams);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, this::setAllowUnicodeIdentifiers);
+ convertPropertyToStringAndWriteBack(CodegenConstants.API_NAME_PREFIX, this::setApiNamePrefix);
+ convertPropertyToStringAndWriteBack(CodegenConstants.API_NAME_SUFFIX, this::setApiNameSuffix);
+ convertPropertyToStringAndWriteBack(CodegenConstants.MODEL_NAME_PREFIX, this::setModelNamePrefix);
+ convertPropertyToStringAndWriteBack(CodegenConstants.MODEL_NAME_SUFFIX, this::setModelNameSuffix);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.REMOVE_OPERATION_ID_PREFIX, this::setRemoveOperationIdPrefix);
+ convertPropertyToStringAndWriteBack(CodegenConstants.REMOVE_OPERATION_ID_PREFIX_DELIMITER, this::setRemoveOperationIdPrefixDelimiter);
+ convertPropertyToTypeAndWriteBack(CodegenConstants.REMOVE_OPERATION_ID_PREFIX_COUNT, Integer::parseInt, this::setRemoveOperationIdPrefixCount);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.SKIP_OPERATION_EXAMPLE, this::setSkipOperationExample);
+ convertPropertyToStringAndWriteBack(CodegenConstants.DOCEXTENSION, this::setDocExtension);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.ENABLE_POST_PROCESS_FILE, this::setEnablePostProcessFile);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.GENERATE_ALIAS_AS_MODEL, ModelUtils::setGenerateAliasAsModel);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.REMOVE_ENUM_VALUE_PREFIX, this::setRemoveEnumValuePrefix);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, this::setLegacyDiscriminatorBehavior);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, this::setDisallowAdditionalPropertiesIfNotPresent);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, this::setEnumUnknownDefaultCase);
+ convertPropertyToBooleanAndWriteBack(CodegenConstants.AUTOSET_CONSTANTS, this::setAutosetConstants);
}
- if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
- this.setModelPackage((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
- this.setApiPackage((String) additionalProperties.get(CodegenConstants.API_PACKAGE));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
- setHideGenerationTimestamp(convertPropertyToBooleanAndWriteBack(CodegenConstants.HIDE_GENERATION_TIMESTAMP));
- } else {
- additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, hideGenerationTimestamp);
- }
-
- if (additionalProperties.containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) {
- this.setSortParamsByRequiredFlag(Boolean.valueOf(additionalProperties
- .get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG)) {
- this.setSortModelPropertiesByRequiredFlag(Boolean.valueOf(additionalProperties
- .get(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS)) {
- this.setPrependFormOrBodyParameters(Boolean.valueOf(additionalProperties
- .get(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.ENSURE_UNIQUE_PARAMS)) {
- this.setEnsureUniqueParams(Boolean.valueOf(additionalProperties
- .get(CodegenConstants.ENSURE_UNIQUE_PARAMS).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS)) {
- this.setAllowUnicodeIdentifiers(Boolean.valueOf(additionalProperties
- .get(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.API_NAME_PREFIX)) {
- this.setApiNamePrefix((String) additionalProperties.get(CodegenConstants.API_NAME_PREFIX));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.API_NAME_SUFFIX)) {
- this.setApiNameSuffix((String) additionalProperties.get(CodegenConstants.API_NAME_SUFFIX));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.MODEL_NAME_PREFIX)) {
- this.setModelNamePrefix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_PREFIX));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.MODEL_NAME_SUFFIX)) {
- this.setModelNameSuffix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_SUFFIX));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.REMOVE_OPERATION_ID_PREFIX)) {
- this.setRemoveOperationIdPrefix(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.REMOVE_OPERATION_ID_PREFIX).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.REMOVE_OPERATION_ID_PREFIX_DELIMITER)) {
- this.setRemoveOperationIdPrefixDelimiter(additionalProperties
- .get(CodegenConstants.REMOVE_OPERATION_ID_PREFIX_DELIMITER).toString());
- }
-
- if (additionalProperties.containsKey(CodegenConstants.REMOVE_OPERATION_ID_PREFIX_COUNT)) {
- this.setRemoveOperationIdPrefixCount(Integer.parseInt(additionalProperties
- .get(CodegenConstants.REMOVE_OPERATION_ID_PREFIX_COUNT).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.SKIP_OPERATION_EXAMPLE)) {
- this.setSkipOperationExample(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.SKIP_OPERATION_EXAMPLE).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.DOCEXTENSION)) {
- this.setDocExtension(String.valueOf(additionalProperties
- .get(CodegenConstants.DOCEXTENSION).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.ENABLE_POST_PROCESS_FILE)) {
- this.setEnablePostProcessFile(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.ENABLE_POST_PROCESS_FILE).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.GENERATE_ALIAS_AS_MODEL)) {
- ModelUtils.setGenerateAliasAsModel(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.GENERATE_ALIAS_AS_MODEL).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.REMOVE_ENUM_VALUE_PREFIX)) {
- this.setRemoveEnumValuePrefix(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.REMOVE_ENUM_VALUE_PREFIX).toString()));
- }
-
- if (additionalProperties.containsKey(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR)) {
- this.setLegacyDiscriminatorBehavior(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR).toString()));
- }
- if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
- this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()));
- }
- if (additionalProperties.containsKey(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE)) {
- this.setEnumUnknownDefaultCase(Boolean.parseBoolean(additionalProperties
- .get(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE).toString()));
- }
- if (additionalProperties.containsKey(CodegenConstants.AUTOSET_CONSTANTS)) {
- this.setAutosetConstants(
- Boolean.parseBoolean(additionalProperties.get(CodegenConstants.AUTOSET_CONSTANTS).toString()));
- }
- }
/***
* Preset map builder with commonly used Mustache lambdas.
@@ -910,6 +856,18 @@ public class DefaultCodegen implements CodegenConfig {
return datatype + "." + value;
}
+ /**
+ * Return the enum default value in the language specified format
+ *
+ * @param property The codegen property to create the default for.
+ * @param value Enum variable name
+ * @return the default value for the enum
+ */
+ public String toEnumDefaultValue(CodegenProperty property, String value) {
+ // Use the datatype with the value.
+ return toEnumDefaultValue(value, property.datatypeWithEnum);
+ }
+
/**
* Return the enum value in the language specified format
* e.g. status becomes "status"
@@ -1456,127 +1414,23 @@ public class DefaultCodegen implements CodegenConfig {
return filesMetadataFilename;
}
- public void setFilesMetadataFilename(String filesMetadataFilename) {
- this.filesMetadataFilename = filesMetadataFilename;
- }
-
@Override
public String getVersionMetadataFilename() {
return versionMetadataFilename;
}
- public void setVersionMetadataFilename(String versionMetadataFilename) {
- this.versionMetadataFilename = versionMetadataFilename;
- }
-
- public void setTemplateDir(String templateDir) {
- this.templateDir = templateDir;
- }
-
- public void setModelPackage(String modelPackage) {
- this.modelPackage = modelPackage;
- }
-
- public String getModelNamePrefix() {
- return modelNamePrefix;
- }
-
- public void setModelNamePrefix(String modelNamePrefix) {
- this.modelNamePrefix = modelNamePrefix;
- }
-
- public String getModelNameSuffix() {
- return modelNameSuffix;
- }
-
- public void setModelNameSuffix(String modelNameSuffix) {
- this.modelNameSuffix = modelNameSuffix;
- }
-
- public String getApiNameSuffix() {
- return apiNameSuffix;
- }
-
- public void setApiNameSuffix(String apiNameSuffix) {
- this.apiNameSuffix = apiNameSuffix;
- }
-
- public String getApiNamePrefix() {
- return apiNamePrefix;
- }
-
- public void setApiNamePrefix(String apiNamePrefix) {
- this.apiNamePrefix = apiNamePrefix;
- }
-
- public void setApiPackage(String apiPackage) {
- this.apiPackage = apiPackage;
- }
-
- public Boolean getSortParamsByRequiredFlag() {
- return sortParamsByRequiredFlag;
- }
-
- public void setSortParamsByRequiredFlag(Boolean sortParamsByRequiredFlag) {
- this.sortParamsByRequiredFlag = sortParamsByRequiredFlag;
- }
-
- public Boolean getSortModelPropertiesByRequiredFlag() {
- return sortModelPropertiesByRequiredFlag;
- }
-
- public void setSortModelPropertiesByRequiredFlag(Boolean sortModelPropertiesByRequiredFlag) {
- this.sortModelPropertiesByRequiredFlag = sortModelPropertiesByRequiredFlag;
- }
-
- public Boolean getPrependFormOrBodyParameters() {
- return prependFormOrBodyParameters;
- }
-
- public void setPrependFormOrBodyParameters(Boolean prependFormOrBodyParameters) {
- this.prependFormOrBodyParameters = prependFormOrBodyParameters;
- }
-
- public Boolean getEnsureUniqueParams() {
- return ensureUniqueParams;
- }
-
- public void setEnsureUniqueParams(Boolean ensureUniqueParams) {
- this.ensureUniqueParams = ensureUniqueParams;
- }
-
public Boolean getLegacyDiscriminatorBehavior() {
return legacyDiscriminatorBehavior;
}
- public void setLegacyDiscriminatorBehavior(boolean val) {
- this.legacyDiscriminatorBehavior = val;
- }
-
public Boolean getDisallowAdditionalPropertiesIfNotPresent() {
return disallowAdditionalPropertiesIfNotPresent;
}
- public void setDisallowAdditionalPropertiesIfNotPresent(boolean val) {
- this.disallowAdditionalPropertiesIfNotPresent = val;
- }
-
public Boolean getEnumUnknownDefaultCase() {
return enumUnknownDefaultCase;
}
- public void setEnumUnknownDefaultCase(boolean val) {
- this.enumUnknownDefaultCase = val;
- }
-
- public Boolean getAllowUnicodeIdentifiers() {
- return allowUnicodeIdentifiers;
- }
-
- public void setAllowUnicodeIdentifiers(Boolean allowUnicodeIdentifiers) {
- this.allowUnicodeIdentifiers = allowUnicodeIdentifiers;
- }
-
public Boolean getUseOneOfInterfaces() {
return useOneOfInterfaces;
}
@@ -1979,6 +1833,7 @@ public class DefaultCodegen implements CodegenConfig {
specialCharReplacements.put("!=", "Not_Equal");
specialCharReplacements.put("<>", "Not_Equal");
specialCharReplacements.put("~=", "Tilde_Equal");
+ specialCharReplacements.put("==", "Double_Equal");
}
/**
@@ -2953,7 +2808,9 @@ public class DefaultCodegen implements CodegenConfig {
if (null != existingProperties && null != newProperties) {
Schema existingType = existingProperties.get("type");
Schema newType = newProperties.get("type");
- newProperties.forEach((key, value) -> existingProperties.put(key, ModelUtils.cloneSchema(value)));
+ newProperties.forEach((key, value) ->
+ existingProperties.put(key, ModelUtils.cloneSchema(value, specVersionGreaterThanOrEqualTo310(openAPI)))
+ );
if (null != existingType && null != newType && null != newType.getEnum() && !newType.getEnum().isEmpty()) {
for (Object e : newType.getEnum()) {
// ensure all interface enum types are added to schema
@@ -5265,6 +5122,9 @@ public class DefaultCodegen implements CodegenConfig {
if (parameter.getExtensions() != null && !parameter.getExtensions().isEmpty()) {
codegenParameter.vendorExtensions.putAll(parameter.getExtensions());
}
+ if (parameter.getSchema() != null && parameter.getSchema().getExtensions() != null && !parameter.getSchema().getExtensions().isEmpty()) {
+ codegenParameter.vendorExtensions.putAll(parameter.getSchema().getExtensions());
+ }
Schema parameterSchema;
@@ -6277,22 +6137,6 @@ public class DefaultCodegen implements CodegenConfig {
this.removeOperationIdPrefix = removeOperationIdPrefix;
}
- public String getRemoveOperationIdPrefixDelimiter() {
- return removeOperationIdPrefixDelimiter;
- }
-
- public void setRemoveOperationIdPrefixDelimiter(String removeOperationIdPrefixDelimiter) {
- this.removeOperationIdPrefixDelimiter = removeOperationIdPrefixDelimiter;
- }
-
- public int getRemoveOperationIdPrefixCount() {
- return removeOperationIdPrefixCount;
- }
-
- public void setRemoveOperationIdPrefixCount(int removeOperationIdPrefixCount) {
- this.removeOperationIdPrefixCount = removeOperationIdPrefixCount;
- }
-
@Override
public void setSkipOperationExample(boolean skipOperationExample) {
this.skipOperationExample = skipOperationExample;
@@ -6750,7 +6594,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if (enumName != null) {
- var.defaultValue = toEnumDefaultValue(enumName, var.datatypeWithEnum);
+ var.defaultValue = toEnumDefaultValue(var, enumName);
}
}
}
@@ -6887,6 +6731,59 @@ public class DefaultCodegen implements CodegenConfig {
return result;
}
+
+ /**
+ * reads propertyKey from additionalProperties, converts it to a boolean and
+ * writes it back to additionalProperties to be usable as a boolean in
+ * mustache files.
+ *
+ * @param propertyKey property key
+ * @param booleanSetter the setter function reference
+ * @return property value as boolean or false if it does not exist
+ */
+ public boolean convertPropertyToBooleanAndWriteBack(String propertyKey, Consumer booleanSetter) {
+ if (additionalProperties.containsKey(propertyKey)) {
+ boolean result = convertPropertyToBoolean(propertyKey);
+ writePropertyBack(propertyKey, result);
+ booleanSetter.accept(result);
+ return result;
+ }
+ return false;
+ }
+
+ /**
+ * reads propertyKey from additionalProperties, converts it to a string and
+ * writes it back to additionalProperties to be usable as a string in
+ * mustache files.
+ *
+ * @param propertyKey property key
+ * @param stringSetter the setter function reference
+ * @return property value as String or null if not found
+ */
+ public String convertPropertyToStringAndWriteBack(String propertyKey, Consumer stringSetter) {
+ return convertPropertyToTypeAndWriteBack(propertyKey, Function.identity(), stringSetter);
+ }
+
+ /**
+ * reads propertyKey from additionalProperties, converts it to T and
+ * writes it back to additionalProperties to be usable as T in
+ * mustache files.
+ *
+ * @param propertyKey property key
+ * @param genericTypeSetter the setter function reference
+ * @return property value as instance of type T or null if not found
+ */
+ public T convertPropertyToTypeAndWriteBack(String propertyKey, Function converter, Consumer genericTypeSetter) {
+ if (additionalProperties.containsKey(propertyKey)) {
+ String value = additionalProperties.get(propertyKey).toString();
+ T result = converter.apply(value);
+ writePropertyBack(propertyKey, result);
+ genericTypeSetter.accept(result);
+ return result;
+ }
+ return null;
+ }
+
/**
* Provides an override location, if any is specified, for the .openapi-generator-ignore.
*
@@ -8302,7 +8199,7 @@ public class DefaultCodegen implements CodegenConfig {
/**
* An map entry for cached sanitized names.
*/
- private static class SanitizeNameOptions {
+ @Getter private static class SanitizeNameOptions {
public SanitizeNameOptions(String name, String removeCharRegEx, List exceptions) {
this.name = name;
this.removeCharRegEx = removeCharRegEx;
@@ -8313,18 +8210,6 @@ public class DefaultCodegen implements CodegenConfig {
}
}
- public String getName() {
- return name;
- }
-
- public String getRemoveCharRegEx() {
- return removeCharRegEx;
- }
-
- public List getExceptions() {
- return exceptions;
- }
-
private final String name;
private final String removeCharRegEx;
private final List exceptions;
@@ -8533,10 +8418,6 @@ public class DefaultCodegen implements CodegenConfig {
}
}
- public void setAutosetConstants(boolean autosetConstants) {
- this.autosetConstants = autosetConstants;
- }
-
/**
* This method removes all constant Query, Header and Cookie Params from allParams and sets them as constantParams in the CodegenOperation.
* The definition of constant is single valued required enum params.
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java
index 8337b77be4d..ac1869f2d14 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java
@@ -29,7 +29,7 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.security.*;
import io.swagger.v3.oas.models.tags.Tag;
-
+import lombok.Getter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.comparator.PathFileComparator;
import org.apache.commons.lang3.ObjectUtils;
@@ -95,7 +95,11 @@ public class DefaultGenerator implements Generator {
private String basePathWithoutHost;
private String contextPath;
private Map generatorPropertyDefaults = new HashMap<>();
- protected TemplateProcessor templateProcessor = null;
+ /**
+ * Retrieves an instance to the configured template processor, available after user-defined options are
+ * applied via
+ */
+ @Getter protected TemplateProcessor templateProcessor = null;
private List userDefinedTemplates = new ArrayList<>();
private String generatorCheck = "spring";
@@ -160,16 +164,6 @@ public class DefaultGenerator implements Generator {
return this;
}
- /**
- * Retrieves an instance to the configured template processor, available after user-defined options are
- * applied via {@link DefaultGenerator#opts(ClientOptInput)}.
- *
- * @return A configured {@link TemplateProcessor}, or null.
- */
- public TemplateProcessor getTemplateProcessor() {
- return templateProcessor;
- }
-
/**
* Programmatically disable the output of .openapi-generator/VERSION, .openapi-generator-ignore,
* or other metadata files used by OpenAPI Generator.
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunStatus.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunStatus.java
index bd755e3a83d..862d29b4861 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunStatus.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunStatus.java
@@ -1,5 +1,7 @@
package org.openapitools.codegen;
+import lombok.Getter;
+
import java.io.IOException;
import java.nio.file.Path;
import java.util.Locale;
@@ -7,9 +9,28 @@ import java.util.Locale;
/**
* Holds details about a file's write status for display via the --dry-run option of CLI
*/
-class DryRunStatus {
- private Path path;
+@Getter class DryRunStatus {
+ /**
+ * -- GETTER --
+ * Gets the target path of the file write operation
+ *
+ * @return a {@link Path} instance
+ */
+ private final Path path;
+ /**
+ * -- GETTER --
+ * Gets the
+ * as determined by the generator's workflow
+ *
+ * @return A {@link State} enum detailing the expected operation of the generator's workflow
+ */
private State state;
+ /**
+ * -- GETTER --
+ * Gets the reason for the file's
+ *
+ * @return A human-readable string which explains why this file's dry-run resulted in the defined {@link State}
+ */
private String reason;
/**
@@ -55,33 +76,6 @@ class DryRunStatus {
appendable.append(String.format(Locale.ROOT, "%s %s", this.state.getShortDisplay(), this.path.toAbsolutePath()));
}
- /**
- * Gets the target path of the file write operation
- *
- * @return a {@link Path} instance
- */
- public Path getPath() {
- return path;
- }
-
- /**
- * Gets the reason for the file's {@link State}
- *
- * @return A human-readable string which explains why this file's dry-run resulted in the defined {@link State}
- */
- public String getReason() {
- return reason;
- }
-
- /**
- * Gets the {@link State} as determined by the generator's workflow
- *
- * @return A {@link State} enum detailing the expected operation of the generator's workflow
- */
- public State getState() {
- return state;
- }
-
/**
* Sets the {@link State} as determined by the generator's workflow.
*
@@ -116,7 +110,7 @@ class DryRunStatus {
/**
* Represents the possible states of a file write operation as determined by the Generator
*/
- enum State {
+ @Getter enum State {
Write("w", "Write"),
WriteIfNewer("n", "Write if New/Updated"),
Ignored("i", "Ignored"),
@@ -124,7 +118,19 @@ class DryRunStatus {
Skipped("k", "Skipped by user option(s)"),
Error("e", "Error evaluating file write state");
+ /**
+ * -- GETTER --
+ * Gets the short value used for display
+ *
+ * @return A character representing this state
+ */
private final String shortDisplay;
+ /**
+ * -- GETTER --
+ * Gets a description of the state which is more human-readable than the enum's name
+ *
+ * @return A human-readable description
+ */
private final String description;
/**
@@ -139,22 +145,5 @@ class DryRunStatus {
this.description = description;
}
- /**
- * Gets a description of the state which is more human-readable than the enum's name
- *
- * @return A human-readable description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Gets the short value used for display
- *
- * @return A character representing this state
- */
- public String getShortDisplay() {
- return shortDisplay;
- }
}
}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunTemplateManager.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunTemplateManager.java
index eb8f05d3dab..d9de181e2f2 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunTemplateManager.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DryRunTemplateManager.java
@@ -18,6 +18,9 @@ import java.util.Map;
public class DryRunTemplateManager implements TemplateProcessor {
private final TemplateManagerOptions options;
private final Map dryRunStatusMap = new HashMap<>();
+
+ private final Map> capturedTemplateData = new HashMap<>();
+ private boolean recordTemplateData = false;
/**
* Constructs a new instance of {@link DryRunTemplateManager} for the provided options
@@ -47,6 +50,9 @@ public class DryRunTemplateManager implements TemplateProcessor {
*/
@Override
public File write(Map data, String template, File target) throws IOException {
+ if (recordTemplateData) {
+ this.capturedTemplateData.put(target.getAbsolutePath(), data);
+ }
return writeToFile(target.getAbsolutePath(), "dummy".getBytes(StandardCharsets.UTF_8));
}
@@ -101,4 +107,25 @@ public class DryRunTemplateManager implements TemplateProcessor {
public void error(Path path, String context) {
dryRunStatusMap.put(path.toString(), new DryRunStatus(path, DryRunStatus.State.Error, context));
}
+
+ /**
+ * Enable capturing of data being passed to the files as they are being written.
+ * Call this method before calling {@link Generator#generate()}.
+ */
+ public DryRunTemplateManager enableTemplateDataCapturing() {
+ recordTemplateData = true;
+ return this;
+ }
+
+ /**
+ * Retrieve the captured template data for a specific file. Capturing must have
+ * been enabled via {@link #enableTemplateDataCapturing()} prior to generation.
+ * Note: Not all files have template data (e.g. Metadata files) – in such case an empty
+ * map is returned.
+ * @param generatedFile An absolute path to the generated file
+ * @return Typically one of the *Map types found in {@link org.openapitools.codegen.model}
+ */
+ public Map getCapturedTemplateData(Path generatedFile) {
+ return capturedTemplateData.getOrDefault(generatedFile.toString(), Map.of());
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
index 7abc0e39d6f..ba2454c3c53 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
@@ -105,9 +105,21 @@ public interface IJsonSchemaValidationProperties {
void setIsMap(boolean isMap);
+ /**
+ * Tells if the datatype is a generic inner parameter of a std::optional for C++, or Optional (Java)
+ * to resolve cases (detected in issue #6726) where :
+ * - categoryOneOf is a parameter of class GetAccountVideos_categoryOneOf_parameter, a model parameter that correctly prefixed by its namespace: org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter
+ * - but that GetAccountVideos_categoryOneOf_parameter class is inside an std::optional
+ *
+ * Then a correct generation of that parameter can be (for C++) const std::optional<org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter> &categoryOneOf
+ * but using #isModel alone without #isOptional in mustache might produce const org::openapitools::server::model::std::optional<org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter> &categoryOneOf instead, that do not compile.
+ */
+ boolean getIsOptional();
+ void setIsOptional(boolean isOptional);
+
boolean getIsArray();
- void setIsArray(boolean isShort);
+ void setIsArray(boolean isArray);
boolean getIsShort();
@@ -180,7 +192,7 @@ public interface IJsonSchemaValidationProperties {
boolean getIsString();
- void setIsString(boolean isNumber);
+ void setIsString(boolean isString);
boolean getIsNumber();
@@ -236,7 +248,7 @@ public interface IJsonSchemaValidationProperties {
boolean getIsDouble();
- void setIsInteger(boolean isDouble);
+ void setIsInteger(boolean isInteger);
boolean getIsInteger();
@@ -278,7 +290,6 @@ public interface IJsonSchemaValidationProperties {
setIsArray(true);
} else if (ModelUtils.isFileSchema(p) && !ModelUtils.isStringSchema(p)) {
// swagger v2 only, type file
- ;
} else if (ModelUtils.isStringSchema(p)) {
setIsString(true);
if (ModelUtils.isByteArraySchema(p)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java
index 7ccb8996795..172c26eb0bb 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java
@@ -231,7 +231,9 @@ public class InlineModelResolver {
if (schema.equals(c)) {
return isModelNeeded((Schema) schema.getAllOf().get(0), visitedSchemas);
}
- } else if (isSingleAllOf && StringUtils.isNotEmpty(((Schema) schema.getAllOf().get(0)).get$ref())) {
+ }
+
+ if (isSingleAllOf && StringUtils.isNotEmpty(((Schema) schema.getAllOf().get(0)).get$ref())) {
// single allOf and it's a ref
return isModelNeeded((Schema) schema.getAllOf().get(0), visitedSchemas);
}
@@ -314,7 +316,7 @@ public class InlineModelResolver {
if (schema.getAdditionalProperties() instanceof Schema) {
Schema inner = (Schema) schema.getAdditionalProperties();
if (inner != null) {
- String schemaName = resolveModelName(schema.getTitle(), modelPrefix + this.inlineSchemaOptions.get("MAP_ITEM_SUFFIX"));
+ String schemaName = resolveModelName(inner.getTitle(), modelPrefix + this.inlineSchemaOptions.get("MAP_ITEM_SUFFIX"));
// Recurse to create $refs for inner models
gatherInlineModels(inner, schemaName);
if (isModelNeeded(inner)) {
@@ -1013,4 +1015,4 @@ public class InlineModelResolver {
return name;
}
-}
\ No newline at end of file
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java
index f8b7371c10c..704fedc44f3 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java
@@ -1,8 +1,12 @@
package org.openapitools.codegen;
+import lombok.Getter;
+import lombok.Setter;
+
import java.util.Optional;
import java.util.Set;
+@Getter @Setter
public class SpecValidationException extends RuntimeException {
private Set errors;
@@ -81,22 +85,6 @@ public class SpecValidationException extends RuntimeException {
super(message, cause, enableSuppression, writableStackTrace);
}
- public Set getErrors() {
- return errors;
- }
-
- public Set getWarnings() {
- return warnings;
- }
-
- public void setErrors(Set errors) {
- this.errors = errors;
- }
-
- public void setWarnings(Set warnings) {
- this.warnings = warnings;
- }
-
/**
* Returns the detail message string of this throwable.
*
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java
index 2d72fa2f216..9202a81e94f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java
@@ -17,6 +17,7 @@
package org.openapitools.codegen;
+import lombok.Getter;
import org.openapitools.codegen.api.TemplateDefinition;
import org.openapitools.codegen.api.TemplateFileType;
@@ -30,7 +31,7 @@ import java.util.StringJoiner;
* Supporting files are generated once for an entire application while api/model bound definitions are generated multiple
* times according to their target use.
*/
-public class SupportingFile extends TemplateDefinition {
+@Getter public class SupportingFile extends TemplateDefinition {
private boolean canOverwrite = true;
public SupportingFile(String templateFile, String destinationFilename) {
@@ -80,10 +81,6 @@ public class SupportingFile extends TemplateDefinition {
return isCanOverwrite() == that.isCanOverwrite();
}
- public boolean isCanOverwrite() {
- return canOverwrite;
- }
-
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), isCanOverwrite());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java
index 8fb9ce1bdae..61cee17f86f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java
@@ -1,9 +1,12 @@
package org.openapitools.codegen;
+import lombok.Getter;
+
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-public enum VendorExtension {
+@Getter public enum VendorExtension {
X_IMPLEMENTS("x-implements", ExtensionLevel.MODEL, "Ability to specify interfaces that model must implements", "empty array"),
X_SPRING_PAGINATED("x-spring-paginated", ExtensionLevel.OPERATION, "Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters", "false"),
@@ -16,10 +19,10 @@ public enum VendorExtension {
X_ACCEPTS("x-accepts", ExtensionLevel.OPERATION, "Specify custom value for 'Accept' header for operation", null),
X_CONTENT_TYPE("x-content-type", ExtensionLevel.OPERATION, "Specify custom value for 'Content-Type' header for operation", null),
X_CLASS_EXTRA_ANNOTATION("x-class-extra-annotation", ExtensionLevel.MODEL, "List of custom annotations to be added to model", null),
- X_FIELD_EXTRA_ANNOTATION("x-field-extra-annotation", ExtensionLevel.FIELD, "List of custom annotations to be added to property", null),
+ X_FIELD_EXTRA_ANNOTATION("x-field-extra-annotation", Arrays.asList(ExtensionLevel.FIELD, ExtensionLevel.OPERATION_PARAMETER), "List of custom annotations to be added to property", null),
X_OPERATION_EXTRA_ANNOTATION("x-operation-extra-annotation", ExtensionLevel.OPERATION, "List of custom annotations to be added to operation", null),
X_VERSION_PARAM("x-version-param", ExtensionLevel.OPERATION_PARAMETER, "Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false", null),
- X_PATTERN_MESSAGE("x-pattern-message", ExtensionLevel.FIELD, "Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable", null),
+ X_PATTERN_MESSAGE("x-pattern-message", Arrays.asList(ExtensionLevel.FIELD, ExtensionLevel.OPERATION_PARAMETER), "Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable", null),
;
private final String name;
@@ -38,22 +41,6 @@ public enum VendorExtension {
this(name, Collections.singletonList(level), description, defaultValue);
}
- public String getName() {
- return name;
- }
-
- public List getLevels() {
- return levels;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
public enum ExtensionLevel {
FIELD,
MODEL,
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/auth/AuthParser.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/auth/AuthParser.java
index a18d8bdcfde..0254798d927 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/auth/AuthParser.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/auth/AuthParser.java
@@ -21,9 +21,9 @@ import io.swagger.v3.parser.core.models.AuthorizationValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@@ -40,11 +40,11 @@ public class AuthParser {
for (String part : parts) {
String[] kvPair = part.split(":");
if (kvPair.length == 2) {
- try {
- auths.add(new AuthorizationValue(URLDecoder.decode(kvPair[0], "UTF-8"), URLDecoder.decode(kvPair[1], "UTF-8"), "header"));
- } catch (UnsupportedEncodingException e) {
- LOGGER.warn(e.getMessage());
- }
+ auths.add(new AuthorizationValue(
+ URLDecoder.decode(kvPair[0], StandardCharsets.UTF_8),
+ URLDecoder.decode(kvPair[1], StandardCharsets.UTF_8),
+ "header"
+ ));
}
}
}
@@ -55,17 +55,11 @@ public class AuthParser {
if (authorizationValueList != null) {
StringBuilder b = new StringBuilder();
for (AuthorizationValue v : authorizationValueList) {
- try {
- if (b.toString().length() > 0) {
- b.append(",");
- }
- b.append(URLEncoder.encode(v.getKeyName(), "UTF-8"))
- .append(":")
- .append(URLEncoder.encode(v.getValue(), "UTF-8"));
- } catch (Exception e) {
- // continue
- LOGGER.error(e.getMessage(), e);
+ if (b.toString().length() > 0) {
+ b.append(",");
}
+ b.append(URLEncoder.encode(v.getKeyName(), StandardCharsets.UTF_8))
+ .append(":").append(URLEncoder.encode(v.getValue(), StandardCharsets.UTF_8));
}
return b.toString();
} else {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/DynamicSettings.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/DynamicSettings.java
index 2dcedc0f7c7..66165692d1a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/DynamicSettings.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/DynamicSettings.java
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.api.TemplateDefinition;
import org.openapitools.codegen.api.TemplateFileType;
@@ -20,7 +21,13 @@ import java.util.stream.Collectors;
*/
@SuppressWarnings({"unused", "WeakerAccess"})
public class DynamicSettings {
- @JsonAnySetter
+ /**
+ * -- GETTER --
+ * Gets all "custom" properties included in the config object.
+ *
+ * @return All user-specified custom properties.
+ */
+ @Getter @JsonAnySetter
private Map dynamicProperties = new HashMap<>();
@JsonUnwrapped
@@ -91,15 +98,6 @@ public class DynamicSettings {
@JsonCreator
public DynamicSettings() { }
- /**
- * Gets all "custom" properties included in the config object.
- *
- * @return All user-specified custom properties.
- */
- public Map getDynamicProperties() {
- return dynamicProperties;
- }
-
private void excludeSettingsFromDynamicProperties(){
Set fieldNames = new HashSet<>();
for (Field field : GeneratorSettings.class.getDeclaredFields()) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/GlobalSettings.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/GlobalSettings.java
index fae47e37f8e..5f7fad79627 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/GlobalSettings.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/GlobalSettings.java
@@ -45,7 +45,7 @@ public class GlobalSettings {
Properties copy = new Properties();
copy.putAll(System.getProperties());
return copy;
- };
+ }
};
public static String getProperty(String key, String defaultValue) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/XmlExampleGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/XmlExampleGenerator.java
index b636c1f69a3..70cd50cbdd2 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/XmlExampleGenerator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/XmlExampleGenerator.java
@@ -17,7 +17,6 @@
package org.openapitools.codegen.examples;
-import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.XML;
import org.apache.commons.lang3.StringUtils;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/IgnoreLineParser.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/IgnoreLineParser.java
index 7bdb44b525b..2702c036d2b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/IgnoreLineParser.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/IgnoreLineParser.java
@@ -17,11 +17,13 @@
package org.openapitools.codegen.ignore.rules;
+import lombok.Getter;
+
import java.util.ArrayList;
import java.util.List;
public class IgnoreLineParser {
- enum Token {
+ @Getter enum Token {
MATCH_ALL("**"),
MATCH_ANY("*"),
ESCAPED_EXCLAMATION("\\!"),
@@ -39,9 +41,6 @@ public class IgnoreLineParser {
this.pattern = pattern;
}
- public String getPattern() {
- return pattern;
- }
}
// NOTE: Comments that start with a : (e.g. //:) are pulled from git documentation for .gitignore
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/InvalidRule.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/InvalidRule.java
index 841a4ff7c0f..00c126db7d5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/InvalidRule.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/InvalidRule.java
@@ -17,9 +17,11 @@
package org.openapitools.codegen.ignore.rules;
+import lombok.Getter;
+
import java.util.List;
-public class InvalidRule extends Rule {
+@Getter public class InvalidRule extends Rule {
private final String reason;
InvalidRule(List syntax, String definition, String reason) {
@@ -37,7 +39,4 @@ public class InvalidRule extends Rule {
return Operation.NOOP;
}
- public String getReason() {
- return reason;
- }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Part.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Part.java
index eeb47acea50..e5cb6dff23d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Part.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Part.java
@@ -17,7 +17,9 @@
package org.openapitools.codegen.ignore.rules;
-class Part {
+import lombok.Getter;
+
+@Getter class Part {
private final IgnoreLineParser.Token token;
private final String value;
@@ -31,11 +33,4 @@ class Part {
this.value = token.getPattern();
}
- public IgnoreLineParser.Token getToken() {
- return token;
- }
-
- public String getValue() {
- return value;
- }
}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Rule.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Rule.java
index fd56a053293..40f1bb1e756 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Rule.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/Rule.java
@@ -17,6 +17,8 @@
package org.openapitools.codegen.ignore.rules;
+import lombok.Getter;
+
import java.util.List;
public abstract class Rule {
@@ -24,7 +26,7 @@ public abstract class Rule {
public enum Operation {EXCLUDE, INCLUDE, NOOP, EXCLUDE_AND_TERMINATE}
// The original rule
- private final String definition;
+ @Getter private final String definition;
private final List syntax;
@@ -35,10 +37,6 @@ public abstract class Rule {
public abstract Boolean matches(String relativePath);
- public String getDefinition() {
- return this.definition;
- }
-
protected String getPattern() {
if(syntax == null) return this.definition;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
index da798350211..d67987aca81 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
@@ -20,7 +20,6 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Escapers;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.Operation;
-import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
@@ -885,6 +884,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
this.name = name;
}
+ @Override
public int compareTo(ModelDepend second) {
if (depend != null && depend.contains(second.name)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
index 06823c3a294..6a090df03d5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
@@ -19,11 +19,11 @@ package org.openapitools.codegen.languages;
import com.google.common.base.Strings;
import io.swagger.v3.oas.models.Operation;
-import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.MapSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.servers.Server;
+import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.model.ModelsMap;
@@ -39,7 +39,7 @@ import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(AbstractApexCodegen.class);
- protected Boolean serializableModel = false;
+ @Setter protected Boolean serializableModel = false;
public AbstractApexCodegen() {
super();
@@ -208,14 +208,6 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
return super.getTypeDeclaration(p);
}
- @Override
- public String getAlias(String name) {
- if (typeAliases != null && typeAliases.containsKey(name)) {
- return typeAliases.get(name);
- }
- return name;
- }
-
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isArraySchema(p)) {
@@ -634,10 +626,6 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
}
- public void setSerializableModel(Boolean serializableModel) {
- this.serializableModel = serializableModel;
- }
-
private String sanitizePath(String p) {
//prefer replace a ", instead of a fuLL URL encode for readability
return p.replaceAll("\"", "%22");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
index ddb24d37bf6..bf77ff2ef25 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
@@ -22,8 +22,9 @@ import com.samskivert.mustache.Mustache.Lambda;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
-import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
@@ -47,59 +48,61 @@ import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETT
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
-public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig {
+public abstract class AbstractCSharpCodegen extends DefaultCodegen {
protected boolean optionalAssemblyInfoFlag = true;
protected boolean optionalEmitDefaultValuesFlag = false;
protected boolean conditionalSerialization = false;
protected boolean optionalProjectFileFlag = true;
- protected boolean optionalMethodArgumentFlag = true;
+ @Setter protected boolean optionalMethodArgumentFlag = true;
protected boolean useDateTimeOffsetFlag = false;
protected boolean useDateTimeForDateFlag = false;
protected boolean useCollection = false;
- protected boolean returnICollection = false;
- protected boolean netCoreProjectFileFlag = false;
+ @Setter protected boolean returnICollection = false;
+ @Setter protected boolean netCoreProjectFileFlag = false;
protected boolean nullReferenceTypesFlag = false;
protected boolean useSourceGeneration = false;
protected String modelPropertyNaming = CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.PascalCase.name();
- protected String licenseUrl = "http://localhost";
- protected String licenseName = "NoLicense";
+ @Setter protected String licenseUrl = "http://localhost";
+ @Setter protected String licenseName = "NoLicense";
- protected String packageVersion = "1.0.0";
- protected String packageName = "Org.OpenAPITools";
- protected String packageTitle = "OpenAPI Library";
- protected String packageProductName = "OpenAPILibrary";
- protected String packageDescription = "A library generated from a OpenAPI doc";
- protected String packageCompany = "OpenAPI";
- protected String packageCopyright = "No Copyright";
- protected String packageAuthors = "OpenAPI";
+ @Setter protected String packageVersion = "1.0.0";
+ @Setter protected String packageName = "Org.OpenAPITools";
+ @Setter protected String packageTitle = "OpenAPI Library";
+ @Setter protected String packageProductName = "OpenAPILibrary";
+ @Setter protected String packageDescription = "A library generated from a OpenAPI doc";
+ @Setter protected String packageCompany = "OpenAPI";
+ @Setter protected String packageCopyright = "No Copyright";
+ @Setter protected String packageAuthors = "OpenAPI";
public static final String DATE_FORMAT = "dateFormat";
- protected String dateFormat = "yyyy'-'MM'-'dd";
+ @Setter protected String dateFormat = "yyyy'-'MM'-'dd";
public static final String DATETIME_FORMAT = "dateTimeFormat";
- protected String dateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK";
+ @Setter protected String dateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK";
+ @Getter @Setter
protected String interfacePrefix = "I";
- protected String enumNameSuffix = "Enum";
- protected String enumValueSuffix = "Enum";
+ @Setter protected String enumNameSuffix = "Enum";
+ @Setter protected String enumValueSuffix = "Enum";
- protected String sourceFolder = "src";
+ @Setter protected String sourceFolder = "src";
protected static final String invalidParameterNamePrefix = "var";
protected static final String invalidPropertyNamePrefix = "Var";
- protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.PascalCase;
+ @Getter protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.PascalCase;
// TODO: Add option for test folder output location. Nice to allow e.g. ./test instead of ./src.
// This would require updating relative paths (e.g. path to main project file in test project file)
- protected String testFolder = sourceFolder;
+ @Setter protected String testFolder = sourceFolder;
protected Set collectionTypes;
protected Set mapTypes;
// true if support nullable type
+ @Getter @Setter
protected boolean supportNullable = Boolean.FALSE;
- protected Boolean zeroBasedEnums = null;
+ @Setter protected Boolean zeroBasedEnums = null;
protected static final String zeroBasedEnumVendorExtension = "x-zero-based-enum";
private final Logger LOGGER = LoggerFactory.getLogger(AbstractCSharpCodegen.class);
@@ -108,7 +111,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
protected Set propertySpecialKeywords = new HashSet<>(Arrays.asList("ToString", "ToJson", "GetHashCode", "Equals", "ShouldSerializeToString"));
// A cache to efficiently lookup schema `toModelName()` based on the schema Key
- private Map schemaKeyToModelNameCache = new HashMap<>();
+ private final Map schemaKeyToModelNameCache = new HashMap<>();
public AbstractCSharpCodegen() {
super();
@@ -205,15 +208,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
instantiationTypes.put("array", "List");
instantiationTypes.put("list", "List");
instantiationTypes.put("map", "Dictionary");
-
- this.setSortParamsByRequiredFlag(true);
-
- // do it only on newer libraries to avoid breaking changes
- // this.setSortModelPropertiesByRequiredFlag(true);
- }
-
- public void setReturnICollection(boolean returnICollection) {
- this.returnICollection = returnICollection;
}
public void setUseCollection(boolean useCollection) {
@@ -225,14 +219,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
this.setTypeMapping();
}
- public void setOptionalMethodArgumentFlag(boolean flag) {
- this.optionalMethodArgumentFlag = flag;
- }
-
- public void setNetCoreProjectFileFlag(boolean flag) {
- this.netCoreProjectFileFlag = flag;
- }
-
public void useDateTimeOffset(boolean flag) {
this.useDateTimeOffsetFlag = flag;
this.setTypeMapping();
@@ -464,7 +450,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
.put("uniqueLines", new UniqueLambda("\n", false))
.put("unique", new UniqueLambda("\n", true))
.put("camel_case", new CamelCaseLambda())
- .put("escape_reserved_word", new EscapeKeywordLambda((val) -> this.escapeKeyword(val)));
+ .put("escape_reserved_word", new EscapeKeywordLambda(this::escapeKeyword));
}
@Override
@@ -476,14 +462,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
property.dataType = property.datatypeWithEnum;
}
- if (property.isEnum && !property.vendorExtensions.containsKey(this.zeroBasedEnumVendorExtension)) {
+ if (property.isEnum && !property.vendorExtensions.containsKey(AbstractCSharpCodegen.zeroBasedEnumVendorExtension)) {
if (Boolean.TRUE.equals(this.zeroBasedEnums)) {
- property.vendorExtensions.put(this.zeroBasedEnumVendorExtension, true);
+ property.vendorExtensions.put(AbstractCSharpCodegen.zeroBasedEnumVendorExtension, true);
} else if (!Boolean.FALSE.equals(this.zeroBasedEnums)) {
if (property.allowableValues.containsKey("values")) {
- final List