diff --git a/.circleci/config.yml b/.circleci/config.yml
index c3611c57351..c5b0d3dc6f1 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -82,6 +82,7 @@ jobs:
- ~/.bundle
- ~/.go_workspace
- ~/.gradle
+ - ~/.pub-cache
- ~/.cache/bower
- ".git"
- ~/.stack
diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh
index 25705a08528..25bea6eb41e 100755
--- a/CI/circle_parallel.sh
+++ b/CI/circle_parallel.sh
@@ -14,6 +14,18 @@ function cleanup {
trap cleanup EXIT
+function installDart {
+ # install dart2
+ sudo apt-get update
+ sudo apt-get install apt-transport-https
+ sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
+ sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
+ sudo apt-get update
+ sudo apt-get install dart
+ export PATH="$PATH:/usr/lib/dart/bin"
+ export DART_POST_PROCESS="dart format"
+}
+
if [ "$NODE_INDEX" = "1" ]; then
echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..."
java -version
@@ -24,6 +36,8 @@ if [ "$NODE_INDEX" = "1" ]; then
ls -l /home/circleci/.ivy2/cache
elif [ "$NODE_INDEX" = "2" ]; then
+ installDart
+
# run ensure-up-to-date sample script on SNAPSHOT version only
project_version=`mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout`
if [[ $project_version == *"-SNAPSHOT" ]]; then
@@ -67,14 +81,7 @@ else
export PATH="/usr/local/go1.14/go/bin:$PATH"
go version
- # install dart2
- sudo apt-get update
- sudo apt-get install apt-transport-https
- sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
- sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
- sudo apt-get update
- sudo apt-get install dart
- export PATH="$PATH:/usr/lib/dart/bin"
+ installDart
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
diff --git a/README.md b/README.md
index 8fefeb92140..a4a757e954b 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
-[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`5.1.0`):
+[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`5.1.1`):
[](https://travis-ci.org/OpenAPITools/openapi-generator)
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
@@ -18,6 +18,14 @@
[](https://app.bitrise.io/app/4a2b10a819d12b67)
[](https://github.com/OpenAPITools/openapi-generator/actions?query=workflow%3A%22Check+Supported+Java+Versions%22)
+[5.2.x](https://github.com/OpenAPITools/openapi-generator/tree/5.2.x) (`5.2.x`):
+[](https://travis-ci.org/OpenAPITools/openapi-generator)
+[](https://circleci.com/gh/OpenAPITools/openapi-generator)
+[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
+[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
+[](https://cloud.drone.io/OpenAPITools/openapi-generator)
+[](https://app.bitrise.io/app/4a2b10a819d12b67)
+
[6.0.x](https://github.com/OpenAPITools/openapi-generator/tree/6.0.x) (`6.0.x`):
[](https://travis-ci.org/OpenAPITools/openapi-generator)
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
@@ -112,8 +120,9 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 6.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.0.0-SNAPSHOT/) | Nov/Dec 2021 | Minor release with breaking changes (no fallback) |
-| 5.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.1.0-SNAPSHOT/) | Mar/Apr 2021 | Minor release with breaking changes (with fallback) |
-| [5.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.0.1) (latest stable release) | 06.02.2021 | Patch release with enhancements, bug fixes, etc |
+| 5.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.2.0-SNAPSHOT/) | May/Jun 2021 | Minor release with breaking changes (with fallback) |
+| 5.1.0 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.1.1-SNAPSHOT/) | Apr/May 2021 | Patch release (enhancements, bug fixes, etc) |
+| [5.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.1.0) (latest stable release) | 20.03.2021 | Minor release with breaking changes (with fallback) |
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
@@ -170,16 +179,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
-JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.1/openapi-generator-cli-5.0.1.jar`
+JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.0/openapi-generator-cli-5.1.0.jar`
For **Mac/Linux** users:
```sh
-wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.1/openapi-generator-cli-5.0.1.jar -O openapi-generator-cli.jar
+wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.0/openapi-generator-cli-5.1.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.
```
-Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.1/openapi-generator-cli-5.0.1.jar
+Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.0/openapi-generator-cli-5.1.0.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@@ -404,7 +413,7 @@ openapi-generator-cli version
To use a specific version of "openapi-generator-cli"
```sh
-openapi-generator-cli version-manager set 5.0.1
+openapi-generator-cli version-manager set 5.1.0
```
Or install it as dev-dependency:
@@ -428,7 +437,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php -o c:\temp\php_api_client`)
-You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.1/openapi-generator-cli-5.0.1.jar)
+You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.0/openapi-generator-cli-5.1.0.jar)
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
diff --git a/bin/configs/jaxrs-cxf-cdi-default-values.yaml b/bin/configs/jaxrs-cxf-cdi-default-values.yaml
new file mode 100644
index 00000000000..75e2ad978ec
--- /dev/null
+++ b/bin/configs/jaxrs-cxf-cdi-default-values.yaml
@@ -0,0 +1,7 @@
+generatorName: jaxrs-cxf-cdi
+outputDir: samples/server/petstore/jaxrs-cxf-cdi-default-value
+inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml
+templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi
+additionalProperties:
+ hideGenerationTimestamp: "true"
+ artifactId: jaxrs-cxf-cdi-default-value
diff --git a/bin/configs/jaxrs-resteasy-default-values.yaml b/bin/configs/jaxrs-resteasy-default-values.yaml
new file mode 100644
index 00000000000..42ec0bff424
--- /dev/null
+++ b/bin/configs/jaxrs-resteasy-default-values.yaml
@@ -0,0 +1,7 @@
+generatorName: jaxrs-resteasy
+outputDir: samples/server/petstore/jaxrs-resteasy/default-value
+inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml
+templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy
+additionalProperties:
+ hideGenerationTimestamp: "true"
+ artifactId: jaxrs-resteasy-default-value
diff --git a/bin/configs/kotlin-jvm-retrofit2-kotlinx_serialization.yaml b/bin/configs/kotlin-jvm-retrofit2-kotlinx_serialization.yaml
new file mode 100644
index 00000000000..f54496d25f1
--- /dev/null
+++ b/bin/configs/kotlin-jvm-retrofit2-kotlinx_serialization.yaml
@@ -0,0 +1,10 @@
+generatorName: kotlin
+outputDir: samples/client/petstore/kotlin-retrofit2-kotlinx_serialization
+library: jvm-retrofit2
+inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-client
+additionalProperties:
+ serializationLibrary: kotlinx_serialization
+ artifactId: kotlin-petstore-retrofit2-kotlinx_serialization
+ enumPropertyNaming: UPPERCASE
+ serializableModel: "true"
diff --git a/bin/configs/other/dart-dio-next-petstore-client-lib-fake.yaml b/bin/configs/other/dart-dio-next-petstore-client-lib-fake.yaml
new file mode 100644
index 00000000000..d6a85861a8a
--- /dev/null
+++ b/bin/configs/other/dart-dio-next-petstore-client-lib-fake.yaml
@@ -0,0 +1,7 @@
+generatorName: dart-dio-next
+outputDir: samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
+templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio
+enablePostProcessFile: "true"
+additionalProperties:
+ hideGenerationTimestamp: "true"
diff --git a/bin/configs/other/openapi3/kotlin-jvm-retrofit2-rx2-kotlinx_serialization.yaml b/bin/configs/other/openapi3/kotlin-jvm-retrofit2-rx2-kotlinx_serialization.yaml
new file mode 100644
index 00000000000..afd9f324186
--- /dev/null
+++ b/bin/configs/other/openapi3/kotlin-jvm-retrofit2-rx2-kotlinx_serialization.yaml
@@ -0,0 +1,11 @@
+generatorName: kotlin
+outputDir: samples/openapi3/client/petstore/kotlin-jvm-retrofit2-rx2-kotlinx_serialization
+library: jvm-retrofit2
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-client
+additionalProperties:
+ serializationLibrary: kotlinx_serialization
+ useRxJava2: "true"
+ artifactId: kotlin-petstore-rx2-kotlinx_serialization-client
+ serializableModel: "true"
+ dateLibrary: java8
diff --git a/bin/configs/spring-mvc-default-values.yaml b/bin/configs/spring-mvc-default-values.yaml
new file mode 100644
index 00000000000..b1ae7fbd048
--- /dev/null
+++ b/bin/configs/spring-mvc-default-values.yaml
@@ -0,0 +1,7 @@
+generatorName: spring
+outputDir: samples/server/petstore/spring-mvc-default-value
+inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml
+templateDir: modules/openapi-generator/src/main/resources/JavaSpring
+additionalProperties:
+ hideGenerationTimestamp: "true"
+ artifactId: spring-mvc-default-value
\ No newline at end of file
diff --git a/docs/customization.md b/docs/customization.md
index 80774a0271e..23704452f60 100644
--- a/docs/customization.md
+++ b/docs/customization.md
@@ -216,7 +216,7 @@ These options default to true and don't limit the generation of the feature opti
When using selective generation, _only_ the templates needed for the specific generation will be used.
-To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to false) (this option is introduced at v3.2.2)
+To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to `true`) (this option is introduced at v3.2.2 and `true` by default starting from v5.x).
```sh
--global-property skipFormModel=true
diff --git a/docs/file-post-processing.md b/docs/file-post-processing.md
index a23845adae2..b0c66e28f8d 100644
--- a/docs/file-post-processing.md
+++ b/docs/file-post-processing.md
@@ -22,6 +22,7 @@ The following environment variables are supported by their respective generators
* `CPP_POST_PROCESS_FILE`
* `CSHARP_POST_PROCESS_FILE`
* `C_POST_PROCESS_FILE`
+* `DART_POST_PROCESS`
* `DART_POST_PROCESS_FILE`
* `FSHARP_POST_PROCESS_FILE`
* `GO_POST_PROCESS_FILE`
diff --git a/docs/generators.md b/docs/generators.md
index 6b4406e43ac..e581cc54fb1 100644
--- a/docs/generators.md
+++ b/docs/generators.md
@@ -22,6 +22,7 @@ The following generators are available:
* [csharp-netcore](generators/csharp-netcore.md)
* [dart](generators/dart.md)
* [dart-dio](generators/dart-dio.md)
+* [dart-dio-next (experimental)](generators/dart-dio-next.md)
* [dart-jaguar](generators/dart-jaguar.md)
* [eiffel](generators/eiffel.md)
* [elixir](generators/elixir.md)
diff --git a/docs/generators/aspnetcore.md b/docs/generators/aspnetcore.md
index 10efd153077..0a30830099f 100644
--- a/docs/generators/aspnetcore.md
+++ b/docs/generators/aspnetcore.md
@@ -24,6 +24,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|operationResultTask|Set methods result to Task<>.| |false|
|packageAuthors|Specifies Authors property in the .NET Core project file.| |OpenAPI|
|packageCopyright|Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |No Copyright|
+|packageDescription|Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |A library generated from a OpenAPI doc|
|packageGuid|The GUID that will be associated with the C# project| |null|
|packageName|C# package name (convention: Title.Case).| |Org.OpenAPITools|
|packageTitle|Specifies an AssemblyTitle for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |OpenAPI Library|
diff --git a/docs/generators/csharp-netcore.md b/docs/generators/csharp-netcore.md
index bdcc218dbbf..c7935752d01 100644
--- a/docs/generators/csharp-netcore.md
+++ b/docs/generators/csharp-netcore.md
@@ -12,7 +12,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|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|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| |I|
-|library|HTTP library template (sub-template) to use|
**httpclient** HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) (Beta support) **restsharp** RestSharp (https://github.com/restsharp/RestSharp) |restsharp|
+|library|HTTP library template (sub-template) to use|
**httpclient** HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) (Experimental. May subject to breaking changes without further notice.) **restsharp** RestSharp (https://github.com/restsharp/RestSharp) |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|
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
diff --git a/docs/generators/dart-dio-next.md b/docs/generators/dart-dio-next.md
new file mode 100644
index 00000000000..da4fbe4f9a8
--- /dev/null
+++ b/docs/generators/dart-dio-next.md
@@ -0,0 +1,233 @@
+---
+title: Config Options for dart-dio-next
+sidebar_label: dart-dio-next
+---
+
+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.
+
+| Option | Description | Values | Default |
+| ------ | ----------- | ------ | ------- |
+|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
+|dateLibrary|Specify Date library|
**core** [DEFAULT] Dart core library (DateTime) **timemachine** Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing. |core|
+|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|
+|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|
+|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
+|pubAuthor|Author name in generated pubspec| |null|
+|pubAuthorEmail|Email address of the author in generated pubspec| |null|
+|pubDescription|Description in generated pubspec| |null|
+|pubHomepage|Homepage in generated pubspec| |null|
+|pubLibrary|Library name in generated code| |null|
+|pubName|Name in generated pubspec| |null|
+|pubVersion|Version in generated pubspec| |null|
+|serializationLibrary|Specify serialization library|
**built_value** [DEFAULT] built_value |built_value|
+|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
+|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
+|sourceFolder|Source folder for generated code| |null|
+|useEnumExtension|Allow the 'x-enum-values' extension for enums| |null|
+
+## IMPORT MAPPING
+
+| Type/Alias | Imports |
+| ---------- | ------- |
+
+
+## INSTANTIATION TYPES
+
+| Type/Alias | Instantiated By |
+| ---------- | --------------- |
+
+
+## LANGUAGE PRIMITIVES
+
+
+String
+bool
+double
+dynamic
+int
+num
+
+
+## RESERVED WORDS
+
+
+abstract
+as
+assert
+async
+await
+break
+case
+catch
+class
+const
+continue
+covariant
+default
+deferred
+do
+dynamic
+else
+enum
+export
+extends
+extension
+external
+factory
+false
+final
+finally
+for
+function
+get
+hide
+if
+implements
+import
+in
+inout
+interface
+is
+late
+library
+mixin
+native
+new
+null
+of
+on
+operator
+out
+part
+patch
+required
+rethrow
+return
+set
+show
+source
+static
+super
+switch
+sync
+this
+throw
+true
+try
+typedef
+var
+void
+while
+with
+yield
+
+
+## FEATURE SET
+
+
+### Client Modification Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|BasePath|✗|ToolingExtension
+|Authorizations|✗|ToolingExtension
+|UserAgent|✗|ToolingExtension
+|MockServer|✗|ToolingExtension
+
+### Data Type Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Custom|✗|OAS2,OAS3
+|Int32|✗|OAS2,OAS3
+|Int64|✗|OAS2,OAS3
+|Float|✗|OAS2,OAS3
+|Double|✗|OAS2,OAS3
+|Decimal|✗|ToolingExtension
+|String|✗|OAS2,OAS3
+|Byte|✗|OAS2,OAS3
+|Binary|✗|OAS2,OAS3
+|Boolean|✗|OAS2,OAS3
+|Date|✗|OAS2,OAS3
+|DateTime|✗|OAS2,OAS3
+|Password|✗|OAS2,OAS3
+|File|✗|OAS2
+|Array|✗|OAS2,OAS3
+|Maps|✗|ToolingExtension
+|CollectionFormat|✗|OAS2
+|CollectionFormatMulti|✗|OAS2
+|Enum|✗|OAS2,OAS3
+|ArrayOfEnum|✗|ToolingExtension
+|ArrayOfModel|✗|ToolingExtension
+|ArrayOfCollectionOfPrimitives|✗|ToolingExtension
+|ArrayOfCollectionOfModel|✗|ToolingExtension
+|ArrayOfCollectionOfEnum|✗|ToolingExtension
+|MapOfEnum|✗|ToolingExtension
+|MapOfModel|✗|ToolingExtension
+|MapOfCollectionOfPrimitives|✗|ToolingExtension
+|MapOfCollectionOfModel|✗|ToolingExtension
+|MapOfCollectionOfEnum|✗|ToolingExtension
+
+### Documentation Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Readme|✗|ToolingExtension
+|Model|✗|ToolingExtension
+|Api|✗|ToolingExtension
+
+### Global Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Host|✗|OAS2,OAS3
+|BasePath|✗|OAS2,OAS3
+|Info|✗|OAS2,OAS3
+|Schemes|✗|OAS2,OAS3
+|PartialSchemes|✗|OAS2,OAS3
+|Consumes|✗|OAS2
+|Produces|✗|OAS2
+|ExternalDocumentation|✗|OAS2,OAS3
+|Examples|✗|OAS2,OAS3
+|XMLStructureDefinitions|✗|OAS2,OAS3
+|MultiServer|✗|OAS3
+|ParameterizedServer|✗|OAS3
+|ParameterStyling|✗|OAS3
+|Callbacks|✗|OAS3
+|LinkObjects|✗|OAS3
+
+### Parameter Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Path|✗|OAS2,OAS3
+|Query|✗|OAS2,OAS3
+|Header|✗|OAS2,OAS3
+|Body|✗|OAS2
+|FormUnencoded|✗|OAS2
+|FormMultipart|✗|OAS2
+|Cookie|✗|OAS3
+
+### Schema Support Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Simple|✗|OAS2,OAS3
+|Composite|✗|OAS2,OAS3
+|Polymorphism|✗|OAS2,OAS3
+|Union|✗|OAS3
+
+### Security Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|BasicAuth|✗|OAS2,OAS3
+|ApiKey|✗|OAS2,OAS3
+|OpenIDConnect|✗|OAS3
+|BearerToken|✗|OAS3
+|OAuth2_Implicit|✗|OAS2,OAS3
+|OAuth2_Password|✗|OAS2,OAS3
+|OAuth2_ClientCredentials|✗|OAS2,OAS3
+|OAuth2_AuthorizationCode|✗|OAS2,OAS3
+
+### Wire Format Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|JSON|✗|OAS2,OAS3
+|XML|✗|OAS2,OAS3
+|PROTOBUF|✗|ToolingExtension
+|Custom|✗|OAS2,OAS3
diff --git a/docs/generators/dart-dio.md b/docs/generators/dart-dio.md
index 916d3837ab7..767884d7eeb 100644
--- a/docs/generators/dart-dio.md
+++ b/docs/generators/dart-dio.md
@@ -135,8 +135,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✓|ToolingExtension
-|Authorizations|✗|ToolingExtension
-|UserAgent|✗|ToolingExtension
+|Authorizations|✓|ToolingExtension
+|UserAgent|✓|ToolingExtension
|MockServer|✗|ToolingExtension
### Data Type Feature
@@ -213,7 +213,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
-|Composite|✓|OAS2,OAS3
+|Composite|✗|OAS2,OAS3
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
@@ -223,7 +223,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
-|BearerToken|✗|OAS3
+|BearerToken|✓|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✗|OAS2,OAS3
|OAuth2_ClientCredentials|✗|OAS2,OAS3
@@ -233,6 +233,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/dart-jaguar.md b/docs/generators/dart-jaguar.md
index 0960f02886b..d357bae3146 100644
--- a/docs/generators/dart-jaguar.md
+++ b/docs/generators/dart-jaguar.md
@@ -208,7 +208,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
-|Composite|✓|OAS2,OAS3
+|Composite|✗|OAS2,OAS3
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
@@ -228,6 +228,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
-|XML|✓|OAS2,OAS3
-|PROTOBUF|✗|ToolingExtension
+|XML|✗|OAS2,OAS3
+|PROTOBUF|✓|ToolingExtension
|Custom|✗|OAS2,OAS3
diff --git a/docs/generators/dart.md b/docs/generators/dart.md
index fb835a98ee0..d550256877c 100644
--- a/docs/generators/dart.md
+++ b/docs/generators/dart.md
@@ -19,7 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|pubLibrary|Library name in generated code| |null|
|pubName|Name in generated pubspec| |null|
|pubVersion|Version in generated pubspec| |null|
-|serializationLibrary|Specify serialization library|
**native_serialization** Use native serializer, backwards compatible **json_serializable** Use json_serializable |native_serialization|
+|serializationLibrary|Specify serialization library|
**native_serialization** Use native serializer, backwards compatible **json_serializable** Use json_serializable. Experimental and subject to breaking changes without further notice |native_serialization|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|Source folder for generated code| |null|
@@ -207,7 +207,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
-|Composite|✓|OAS2,OAS3
+|Composite|✗|OAS2,OAS3
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
@@ -217,7 +217,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
-|BearerToken|✗|OAS3
+|BearerToken|✓|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✗|OAS2,OAS3
|OAuth2_ClientCredentials|✗|OAS2,OAS3
@@ -227,6 +227,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/rust.md b/docs/generators/rust.md
index d02c497c9f1..670ff8079a8 100644
--- a/docs/generators/rust.md
+++ b/docs/generators/rust.md
@@ -30,9 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES
-File
String
-Vec<u8>
bool
char
f32
@@ -41,10 +39,13 @@ These options may be applied as additional-properties (cli) or configOptions (pl
i32
i64
i8
+isize
+str
u16
u32
u64
u8
+usize
## RESERVED WORDS
diff --git a/docs/installation.md b/docs/installation.md
index 77db575d663..c6fca1ef57c 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -22,7 +22,7 @@ npm install @openapitools/openapi-generator-cli -g
To install a specific version of the tool, pass the version during installation:
```bash
-openapi-generator-cli version-manager set 5.0.1
+openapi-generator-cli version-manager set 5.1.0
```
To install the tool as a dev dependency in your current project:
@@ -80,18 +80,18 @@ docker run --rm \
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
-JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.1/openapi-generator-cli-5.0.1.jar`
+JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.0/openapi-generator-cli-5.1.0.jar`
For **Mac/Linux** users:
```bash
-wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.1/openapi-generator-cli-5.0.1.jar -O openapi-generator-cli.jar
+wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.0/openapi-generator-cli-5.1.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/5.0.1/openapi-generator-cli-5.0.1.jar
+Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.0/openapi-generator-cli-5.1.0.jar
```
diff --git a/modules/openapi-generator-gradle-plugin/README.adoc b/modules/openapi-generator-gradle-plugin/README.adoc
index a28290e8c61..ae55fb16136 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 "5.0.1"
+ id "org.openapi.generator" version "5.1.0"
}
----
@@ -113,7 +113,7 @@ buildscript {
// url "https://plugins.gradle.org/m2/"
}
dependencies {
- classpath "org.openapitools:openapi-generator-gradle-plugin:5.0.1"
+ classpath "org.openapitools:openapi-generator-gradle-plugin:5.1.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 8e771002b13..c4306892312 100644
--- a/modules/openapi-generator-gradle-plugin/samples/local-spec/README.md
+++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/README.md
@@ -18,5 +18,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=5.0.1 openApiValidate
+gradle -PopenApiGeneratorVersion=5.1.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 e60e6016e58..8b65b3b4572 100644
--- a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties
+++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties
@@ -1,3 +1,3 @@
# RELEASE_VERSION
-openApiGeneratorVersion=5.1.0-SNAPSHOT
+openApiGeneratorVersion=5.2.0-SNAPSHOT
# /RELEASE_VERSION
diff --git a/modules/openapi-generator-maven-plugin/README.md b/modules/openapi-generator-maven-plugin/README.md
index da9dd577b90..627fa155e63 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.openapitools
openapi-generator-maven-plugin
-
5.0.1
+
5.1.0
diff --git a/modules/openapi-generator-maven-plugin/examples/kotlin.xml b/modules/openapi-generator-maven-plugin/examples/kotlin.xml
index 51b21f3030e..3c3972591cb 100644
--- a/modules/openapi-generator-maven-plugin/examples/kotlin.xml
+++ b/modules/openapi-generator-maven-plugin/examples/kotlin.xml
@@ -15,7 +15,7 @@
org.openapitools
openapi-generator-maven-plugin
- 5.0.0-SNAPSHOT
+ 6.0.0-SNAPSHOT
diff --git a/modules/openapi-generator-maven-plugin/examples/spring.xml b/modules/openapi-generator-maven-plugin/examples/spring.xml
index b061a790432..5fa33e8abbc 100644
--- a/modules/openapi-generator-maven-plugin/examples/spring.xml
+++ b/modules/openapi-generator-maven-plugin/examples/spring.xml
@@ -20,7 +20,7 @@
org.openapitools
openapi-generator-maven-plugin
- 5.0.0-SNAPSHOT
+ 6.0.0-SNAPSHOT
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 76bdf64501b..206732f8d54 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
@@ -154,6 +154,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
private CodegenProperty items;
private CodegenProperty additionalProperties;
private boolean isModel;
+ private boolean hasRequiredVars;
public String getAdditionalPropertiesType() {
return additionalPropertiesType;
@@ -733,6 +734,16 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.hasVars = hasVars;
}
+ @Override
+ public boolean getHasRequired() {
+ return this.hasRequired;
+ }
+
+ @Override
+ public void setHasRequired(boolean hasRequired) {
+ this.hasRequired = hasRequired;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java
index 082c634fed1..db41efefd58 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java
@@ -114,6 +114,15 @@ public class CodegenOperation {
return nonempty(formParams);
}
+ /**
+ * Check if there's at least one body parameter or at least one form parameter
+ *
+ * @return true if body or form parameter exists, false otherwise
+ */
+ public boolean getHasBodyOrFormParams() {
+ return getHasBodyParam() || getHasFormParams();
+ }
+
/**
* Check if there's at least one form parameter
*
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 6a93e266730..326785046d9 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
@@ -104,6 +104,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
private Integer maxProperties;
private Integer minProperties;
public boolean isNull;
+ private boolean hasRequired;
public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter();
@@ -153,6 +154,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
output.isNull = this.isNull;
output.setAdditionalPropertiesIsAnyType(this.getAdditionalPropertiesIsAnyType());
output.setHasVars(this.hasVars);
+ output.setHasRequired(this.hasRequired);
if (this._enum != null) {
output._enum = new ArrayList(this._enum);
@@ -207,7 +209,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
@Override
public int hashCode() {
- return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars);
+ return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired);
}
@Override
@@ -254,6 +256,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
isNull == that.isNull &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getHasVars() == that.getHasVars() &&
+ getHasRequired() == that.getHasRequired() &&
getExclusiveMaximum() == that.getExclusiveMaximum() &&
getExclusiveMinimum() == that.getExclusiveMinimum() &&
getUniqueItems() == that.getUniqueItems() &&
@@ -372,6 +375,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
sb.append(", isNull=").append(isNull);
sb.append(", getAdditionalPropertiesIsAnyType=").append(additionalPropertiesIsAnyType);
sb.append(", getHasVars=").append(hasVars);
+ sb.append(", getHasRequired=").append(hasRequired);
sb.append('}');
return sb.toString();
}
@@ -619,5 +623,15 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public void setHasVars(boolean hasVars) {
this.hasVars = hasVars;
}
+
+ @Override
+ public boolean getHasRequired() {
+ return this.hasRequired;
+ }
+
+ @Override
+ public void setHasRequired(boolean hasRequired) {
+ this.hasRequired = hasRequired;
+ }
}
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 f00ef51ffba..ce54eaea389 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
@@ -187,6 +187,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public boolean isXmlWrapped = false;
private boolean additionalPropertiesIsAnyType;
private boolean hasVars;
+ private boolean hasRequired;
public String getBaseName() {
return baseName;
@@ -715,6 +716,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.hasVars = hasVars;
}
+ @Override
+ public boolean getHasRequired() {
+ return this.hasRequired;
+ }
+
+ @Override
+ public void setHasRequired(boolean hasRequired) {
+ this.hasRequired = hasRequired;
+ }
+
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{");
@@ -806,6 +817,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
sb.append(", isNull=").append(isNull);
sb.append(", getAdditionalPropertiesIsAnyType=").append(getAdditionalPropertiesIsAnyType());
sb.append(", getHasVars=").append(getHasVars());
+ sb.append(", getHasRequired=").append(getHasRequired());
sb.append('}');
return sb.toString();
}
@@ -857,6 +869,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
isNull == that.isNull &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getHasVars() == that.getHasVars() &&
+ getHasRequired() ==that.getHasRequired() &&
Objects.equals(openApiType, that.openApiType) &&
Objects.equals(baseName, that.baseName) &&
Objects.equals(complexType, that.complexType) &&
@@ -918,6 +931,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
items, mostInnerItems, additionalProperties, vars, requiredVars,
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
- xmlNamespace, isXmlWrapped, isNull, additionalPropertiesIsAnyType, hasVars);
+ xmlNamespace, isXmlWrapped, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired);
}
}
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 37a21190fc5..bb062c1304f 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
@@ -81,6 +81,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
private boolean hasValidation;
private boolean additionalPropertiesIsAnyType;
private boolean hasVars;
+ private boolean hasRequired;
@Override
public int hashCode() {
@@ -91,7 +92,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
vars, requiredVars, isNull, hasValidation,
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
- is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars);
+ is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars, hasRequired);
}
@Override
@@ -135,6 +136,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
is5xx == that.is5xx &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getHasVars() == that.getHasVars() &&
+ getHasRequired() == that.getHasRequired() &&
Objects.equals(vars, that.vars) &&
Objects.equals(requiredVars, that.requiredVars) &&
Objects.equals(headers, that.headers) &&
@@ -371,6 +373,16 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
this.requiredVars = requiredVars;
}
+ @Override
+ public boolean getHasRequired() {
+ return this.hasRequired;
+ }
+
+ @Override
+ public void setHasRequired(boolean hasRequired) {
+ this.hasRequired = hasRequired;
+ }
+
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenResponse{");
@@ -435,6 +447,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
sb.append(", hasValidation='").append(hasValidation);
sb.append(", getAdditionalPropertiesIsAnyType=").append(additionalPropertiesIsAnyType);
sb.append(", getHasVars=").append(hasVars);
+ sb.append(", getHasRequired=").append(hasRequired);
sb.append('}');
return sb.toString();
}
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 a5fce66d29c..5155526a4d3 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
@@ -1829,6 +1829,20 @@ public class DefaultCodegen implements CodegenConfig {
return getPropertyDefaultValue(schema);
}
+ /**
+ * Return the default value of the parameter
+ *
+ * Return null if you do NOT want a default value.
+ * Any non-null value will cause {{#defaultValue} check to pass.
+ *
+ * @param schema Parameter schema
+ * @return string presentation of the default value of the parameter
+ */
+ public String toDefaultParameterValue(Schema> schema) {
+ // by default works as original method to be backward compatible
+ return toDefaultValue(schema);
+ }
+
/**
* Return property value depending on property type.
*
@@ -2565,6 +2579,10 @@ public class DefaultCodegen implements CodegenConfig {
}
}
+ if (m.requiredVars != null && m.requiredVars.size() > 0){
+ m.setHasRequired(true);
+ }
+
if (sortModelPropertiesByRequiredFlag) {
Comparator comparator = new Comparator() {
@Override
@@ -3103,7 +3121,14 @@ public class DefaultCodegen implements CodegenConfig {
property.title = p.getTitle();
property.getter = toGetter(name);
property.setter = toSetter(name);
- property.example = toExampleValue(p);
+ // put toExampleValue in a try-catch block to log the error as example values are not critical
+ try {
+ property.example = toExampleValue(p);
+ } catch (Exception e) {
+ LOGGER.error("Error in generating `example` for the property {}. Default to ERROR_TO_EXAMPLE_VALUE. Enable debugging for more info.", property.baseName);
+ LOGGER.debug("Exception from toExampleValue: {}", e);
+ property.example = "ERROR_TO_EXAMPLE_VALUE";
+ }
property.defaultValue = toDefaultValue(p);
property.defaultValueWithParam = toDefaultValueWithParam(name, p);
property.jsonSchema = Json.pretty(p);
@@ -4198,7 +4223,7 @@ public class DefaultCodegen implements CodegenConfig {
}
// set default value
- codegenParameter.defaultValue = toDefaultValue(parameterSchema);
+ codegenParameter.defaultValue = toDefaultParameterValue(parameterSchema);
if (parameter.getStyle() != null) {
codegenParameter.style = parameter.getStyle().toString();
@@ -6149,6 +6174,9 @@ public class DefaultCodegen implements CodegenConfig {
.stream()
.filter(p -> Boolean.TRUE.equals(p.required)).collect(Collectors.toList());
property.setRequiredVars(requireCpVars);
+ if (property.getRequiredVars() != null && property.getRequiredVars().size() > 0) {
+ property.setHasRequired(true);
+ }
}
setAddProps(schema, property);
}
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 fa9c8f53597..4eb567b6cdc 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,5 +105,9 @@ public interface IJsonSchemaValidationProperties {
boolean getHasVars();
- void setHasVars(boolean hasVars);
+ void setHasVars(boolean hasRequiredVars);
+
+ boolean getHasRequired();
+
+ void setHasRequired(boolean hasRequired);
}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
index 0322228f975..ca4921ce1b0 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java
@@ -12,17 +12,16 @@ import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import static org.openapitools.codegen.utils.StringUtils.*;
-import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractDartCodegen extends DefaultCodegen {
@@ -63,6 +62,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
.securityFeatures(EnumSet.of(
SecurityFeature.OAuth2_Implicit,
SecurityFeature.BasicAuth,
+ SecurityFeature.BearerToken,
SecurityFeature.ApiKey
))
.excludeGlobalFeatures(
@@ -72,7 +72,9 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
GlobalFeature.ParameterStyling
)
.excludeSchemaSupportFeatures(
- SchemaSupportFeature.Polymorphism
+ SchemaSupportFeature.Polymorphism,
+ SchemaSupportFeature.Union,
+ SchemaSupportFeature.Composite
)
.includeParameterFeatures(
ParameterFeature.Cookie
@@ -80,6 +82,9 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
.includeClientModificationFeatures(
ClientModificationFeature.BasePath
)
+ .excludeWireFormatFeatures(
+ WireFormatFeature.XML
+ )
);
outputFolder = "generated-code/dart";
@@ -657,6 +662,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
@Override
public void postProcessFile(File file, String fileType) {
+ super.postProcessFile(file, fileType);
if (file == null) {
return;
}
@@ -668,7 +674,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
// process all files with dart extension
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
- // currently only support "dartfmt -w yourcode.dart"
+ // currently supported is "dartfmt -w" and "dart format"
String command = dartPostProcessFile + " " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
@@ -683,4 +689,31 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
}
}
}
+
+ @Override
+ public void postProcess() {
+ if (isEnablePostProcessFile()) {
+ // Using the condition here to have way to still disable this
+ // for older Dart generators in CI by default.
+
+ // Post processing the whole dart output is much faster then individual files.
+ // Setting this variable to "dart format" is the suggested way of doing this.
+ final String dartPostProcess = System.getenv("DART_POST_PROCESS");
+ if (!StringUtils.isEmpty(dartPostProcess)) {
+ final String command = dartPostProcess + " " + getOutputDir();
+ try {
+ Process p = Runtime.getRuntime().exec(command);
+ int exitValue = p.waitFor();
+ if (exitValue != 0) {
+ LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
+ } else {
+ LOGGER.info("Successfully executed: {}", command);
+ }
+ } catch (Exception e) {
+ LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
+ }
+ }
+ }
+ super.postProcess();
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
index 90dd6b05a98..90ef61d449d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
@@ -23,10 +23,13 @@ import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.ArraySchema;
+import io.swagger.v3.oas.models.media.Content;
import io.swagger.v3.oas.models.media.ComposedSchema;
+import io.swagger.v3.oas.models.media.MediaType;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.Parameter;
+import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.io.FilenameUtils;
@@ -943,6 +946,16 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return super.toDefaultValue(schema);
}
+ @Override
+ public String toDefaultParameterValue(final Schema> schema) {
+ Object defaultValue = schema.getDefault();
+ if (defaultValue == null) {
+ return null;
+ }
+ // escape quotes
+ return defaultValue.toString().replace("\"", "\\\"");
+ }
+
/**
* Return the example value of the parameter. Overrides the
* setParameterExampleValue(CodegenParameter, Parameter) method in
@@ -974,6 +987,49 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
setParameterExampleValue(codegenParameter);
}
+ /**
+ * Return the example value of the parameter. Overrides the parent method in DefaultCodegen
+ * to not set examples on complex models, as they don't compile properly.
+ *
+ * @param codegenParameter Codegen parameter
+ * @param requestBody Request body
+ */
+ @Override
+ public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) {
+ Boolean isModel = (codegenParameter.isModel || (codegenParameter.isContainer && codegenParameter.getItems().isModel));
+
+ Content content = requestBody.getContent();
+
+ if (content.size() > 1) {
+ // @see ModelUtils.getSchemaFromContent()
+ LOGGER.warn("Multiple MediaTypes found, using only the first one");
+ }
+
+ MediaType mediaType = content.values().iterator().next();
+ if (mediaType.getExample() != null) {
+ if (isModel) {
+ LOGGER.warn("Ignoring complex example on request body");
+ } else {
+ codegenParameter.example = mediaType.getExample().toString();
+ return;
+ }
+ }
+
+ if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty()) {
+ Example example = mediaType.getExamples().values().iterator().next();
+ if (example.getValue() != null) {
+ if (isModel) {
+ LOGGER.warn("Ignoring complex example on request body");
+ } else {
+ codegenParameter.example = example.getValue().toString();
+ return;
+ }
+ }
+ }
+
+ setParameterExampleValue(codegenParameter);
+ }
+
@Override
public void setParameterExampleValue(CodegenParameter p) {
String example;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
index abe950e6e9e..5bf6f40fe6a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
@@ -44,7 +44,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
public static final String SERIALIZATION_LIBRARY_DESC = "What serialization library to use: 'moshi' (default), or 'gson' or 'jackson'";
- public enum SERIALIZATION_LIBRARY_TYPE {moshi, gson, jackson}
+ public enum SERIALIZATION_LIBRARY_TYPE {moshi, gson, jackson, kotlinx_serialization}
public static final String MODEL_MUTABLE = "modelMutable";
public static final String MODEL_MUTABLE_DESC = "Create mutable models";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
index 09460b3a7ff..2b117934b76 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
@@ -148,6 +148,10 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
setSupportNullable(Boolean.TRUE);
// CLI options
+ addOption(CodegenConstants.PACKAGE_DESCRIPTION,
+ CodegenConstants.PACKAGE_DESCRIPTION_DESC,
+ packageDescription);
+
addOption(CodegenConstants.LICENSE_URL,
CodegenConstants.LICENSE_URL_DESC,
licenseUrl);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
index c87ec1dc0e2..5ba08432608 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
@@ -50,9 +50,6 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
public CLibcurlClientCodegen() {
super();
- // TODO: c maintainer review
- // Assumes that C community considers api/model header files as documentation.
- // Generator supports Basic, OAuth, and API key explicitly. Bearer is excluded although clients are able to set headers directly.
modifyFeatureSet(features -> features
.includeDocumentationFeatures(
DocumentationFeature.Readme
@@ -82,8 +79,8 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
modelTemplateFiles.put("model-body.mustache", ".c");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-body.mustache", ".c");
- //modelDocTemplateFiles.put("model_doc.mustache", ".md");
- //apiDocTemplateFiles.put("api_doc.mustache", ".md");
+ modelDocTemplateFiles.put("model_doc.mustache", ".md");
+ apiDocTemplateFiles.put("api_doc.mustache", ".md");
embeddedTemplateDir = templateDir = "C-libcurl";
// TODO add auto-generated test files
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
index 8aa4cc08ffb..87a6ae3faa7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
@@ -301,7 +301,8 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
regexModifiers.put('s', "Singleline");
regexModifiers.put('x', "IgnorePatternWhitespace");
- supportedLibraries.put(HTTPCLIENT, "HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) (Beta support)");
+ supportedLibraries.put(HTTPCLIENT, "HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) "
+ + "(Experimental. May subject to breaking changes without further notice.)");
supportedLibraries.put(RESTSHARP, "RestSharp (https://github.com/restsharp/RestSharp)");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "HTTP library template (sub-template) to use");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
index 266fbee0136..59578099cce 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
@@ -17,6 +17,7 @@
package org.openapitools.codegen.languages;
+import com.google.common.collect.Sets;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.SupportingFile;
@@ -37,14 +38,26 @@ public class DartClientCodegen extends AbstractDartCodegen {
public DartClientCodegen() {
super();
- final CliOption serializationLibrary = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY,
+ additionalReservedWords.addAll(
+ Sets.newHashSet(
+ "StreamedRequest",
+ "ApiClient",
+ "QueryParam",
+ "Authentication",
+ "HttpBasicAuth",
+ "HttpBearerAuth",
+ "ApiKeyAuth",
+ "OAuth"
+ )
+ );
+
+ final CliOption serializationLibrary = CliOption.newString(CodegenConstants.SERIALIZATION_LIBRARY,
"Specify serialization library");
serializationLibrary.setDefault(SERIALIZATION_LIBRARY_NATIVE);
- serializationLibrary.setType("String");
final Map serializationOptions = new HashMap<>();
serializationOptions.put(SERIALIZATION_LIBRARY_NATIVE, "Use native serializer, backwards compatible");
- serializationOptions.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "Use json_serializable");
+ serializationOptions.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "Use json_serializable. Experimental and subject to breaking changes without further notice");
serializationLibrary.setEnum(serializationOptions);
cliOptions.add(serializationLibrary);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java
index 54d94d7f1cc..a0bafd5e8ac 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java
@@ -22,6 +22,7 @@ import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
+import org.openapitools.codegen.meta.features.ClientModificationFeature;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.ProcessUtils;
import org.slf4j.Logger;
@@ -46,6 +47,14 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
public DartDioClientCodegen() {
super();
+
+ modifyFeatureSet(features -> features
+ .includeClientModificationFeatures(
+ ClientModificationFeature.Authorizations,
+ ClientModificationFeature.UserAgent
+ )
+ );
+
outputFolder = "generated-code/dart-dio";
embeddedTemplateDir = "dart-dio";
this.setTemplateDir(embeddedTemplateDir);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
new file mode 100644
index 00000000000..7034bc4bece
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
@@ -0,0 +1,402 @@
+/*
+ * Copyright 2021 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.languages;
+
+import com.google.common.collect.Sets;
+import io.swagger.v3.oas.models.media.Schema;
+import org.apache.commons.lang3.StringUtils;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
+import org.openapitools.codegen.meta.features.ClientModificationFeature;
+import org.openapitools.codegen.utils.ModelUtils;
+import org.openapitools.codegen.utils.ProcessUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.*;
+
+import static org.openapitools.codegen.utils.StringUtils.underscore;
+
+public class DartDioNextClientCodegen extends AbstractDartCodegen {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DartDioNextClientCodegen.class);
+
+ public static final String DATE_LIBRARY = "dateLibrary";
+ public static final String DATE_LIBRARY_CORE = "core";
+ public static final String DATE_LIBRARY_TIME_MACHINE = "timemachine";
+ public static final String DATE_LIBRARY_DEFAULT = DATE_LIBRARY_CORE;
+
+ public static final String SERIALIZATION_LIBRARY_BUILT_VALUE = "built_value";
+ public static final String SERIALIZATION_LIBRARY_DEFAULT = SERIALIZATION_LIBRARY_BUILT_VALUE;
+
+ private static final String CLIENT_NAME = "clientName";
+
+ private String dateLibrary;
+
+ private String clientName;
+
+ public DartDioNextClientCodegen() {
+ super();
+
+ modifyFeatureSet(features -> features
+ .includeClientModificationFeatures(
+ ClientModificationFeature.Authorizations,
+ ClientModificationFeature.UserAgent
+ )
+ );
+ generatorMetadata = GeneratorMetadata.newBuilder()
+ .stability(Stability.EXPERIMENTAL)
+ .build();
+
+ outputFolder = "generated-code/dart-dio-next";
+ embeddedTemplateDir = "dart/libraries/dio";
+ this.setTemplateDir(embeddedTemplateDir);
+
+ apiPackage = "lib.src.api";
+ modelPackage = "lib.src.model";
+
+ supportedLibraries.put(SERIALIZATION_LIBRARY_BUILT_VALUE, "[DEFAULT] built_value");
+ final CliOption serializationLibrary = CliOption.newString(CodegenConstants.SERIALIZATION_LIBRARY, "Specify serialization library");
+ serializationLibrary.setEnum(supportedLibraries);
+ serializationLibrary.setDefault(SERIALIZATION_LIBRARY_DEFAULT);
+ cliOptions.add(serializationLibrary);
+
+ final CliOption dateOption = CliOption.newString(DATE_LIBRARY, "Specify Date library");
+ dateOption.setDefault(DATE_LIBRARY_DEFAULT);
+
+ final Map dateOptions = new HashMap<>();
+ dateOptions.put(DATE_LIBRARY_CORE, "[DEFAULT] Dart core library (DateTime)");
+ dateOptions.put(DATE_LIBRARY_TIME_MACHINE, "Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.");
+ dateOption.setEnum(dateOptions);
+ cliOptions.add(dateOption);
+ }
+
+ public String getDateLibrary() {
+ return dateLibrary;
+ }
+
+ public void setDateLibrary(String library) {
+ this.dateLibrary = library;
+ }
+
+ public String getClientName() {
+ return clientName;
+ }
+
+ public void setClientName(String clientName) {
+ this.clientName = clientName;
+ }
+
+ @Override
+ public String getName() {
+ return "dart-dio-next";
+ }
+
+ @Override
+ public String getHelp() {
+ return "Generates a Dart Dio client library with null-safety.";
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+
+ if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
+ LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");
+ LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
+ }
+
+ if (!additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
+ additionalProperties.put(CodegenConstants.SERIALIZATION_LIBRARY, SERIALIZATION_LIBRARY_DEFAULT);
+ LOGGER.debug("Serialization library not set, using default {}", SERIALIZATION_LIBRARY_DEFAULT);
+ }
+ setLibrary(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString());
+
+ if (!additionalProperties.containsKey(DATE_LIBRARY)) {
+ additionalProperties.put(DATE_LIBRARY, DATE_LIBRARY_DEFAULT);
+ LOGGER.debug("Date library not set, using default {}", DATE_LIBRARY_DEFAULT);
+ }
+ setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
+
+ if (!additionalProperties.containsKey(CLIENT_NAME)) {
+ final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName);
+ additionalProperties.put(CLIENT_NAME, name);
+ LOGGER.debug("Client name not set, using default {}", DATE_LIBRARY_DEFAULT);
+ }
+ setClientName(additionalProperties.get(CLIENT_NAME).toString());
+
+ supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
+ supportingFiles.add(new SupportingFile("analysis_options.mustache", "", "analysis_options.yaml"));
+ supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+
+ final String libFolder = sourceFolder + File.separator + "lib";
+ supportingFiles.add(new SupportingFile("lib.mustache", libFolder, pubName + ".dart"));
+
+ final String srcFolder = libFolder + File.separator + "src";
+ supportingFiles.add(new SupportingFile("api_client.mustache", srcFolder, "api.dart"));
+ supportingFiles.add(new SupportingFile("api_util.mustache", srcFolder, "api_util.dart"));
+
+ final String authFolder = srcFolder + File.separator + "auth";
+ supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
+ supportingFiles.add(new SupportingFile("auth/basic_auth.mustache", authFolder, "basic_auth.dart"));
+ supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
+ supportingFiles.add(new SupportingFile("auth/auth.mustache", authFolder, "auth.dart"));
+
+ configureSerializationLibrary(srcFolder);
+ configureDateLibrary(srcFolder);
+ }
+
+ private void configureSerializationLibrary(String srcFolder) {
+ switch (library) {
+ default:
+ case SERIALIZATION_LIBRARY_BUILT_VALUE:
+ additionalProperties.put("useBuiltValue", "true");
+ configureSerializationLibraryBuiltValue(srcFolder);
+ break;
+ }
+ }
+
+ private void configureSerializationLibraryBuiltValue(String srcFolder) {
+ supportingFiles.add(new SupportingFile("serialization/built_value/serializers.mustache", srcFolder, "serializers.dart"));
+
+ typeMapping.put("Array", "BuiltList");
+ typeMapping.put("array", "BuiltList");
+ typeMapping.put("List", "BuiltList");
+ typeMapping.put("set", "BuiltSet");
+ typeMapping.put("map", "BuiltMap");
+ typeMapping.put("file", "Uint8List");
+ typeMapping.put("binary", "Uint8List");
+ typeMapping.put("object", "JsonObject");
+ typeMapping.put("AnyType", "JsonObject");
+
+ additionalReservedWords.addAll(Sets.newHashSet(
+ "EnumClass",
+ // The following are reserved dataTypes but can not be added to defaultIncludes
+ // as this would prevent them from being added to the imports.
+ "BuiltList",
+ "BuiltSet",
+ "BuiltMap",
+ "Uint8List",
+ "JsonObject"
+ ));
+
+ importMapping.put("BuiltList", "package:built_collection/built_collection.dart");
+ importMapping.put("BuiltSet", "package:built_collection/built_collection.dart");
+ importMapping.put("BuiltMap", "package:built_collection/built_collection.dart");
+ importMapping.put("JsonObject", "package:built_value/json_object.dart");
+ importMapping.put("Uint8List", "dart:typed_data");
+ }
+
+ private void configureDateLibrary(String srcFolder) {
+ switch (dateLibrary) {
+ case DATE_LIBRARY_TIME_MACHINE:
+ additionalProperties.put("useDateLibTimeMachine", "true");
+ typeMapping.put("date", "OffsetDate");
+ typeMapping.put("Date", "OffsetDate");
+ typeMapping.put("DateTime", "OffsetDateTime");
+ typeMapping.put("datetime", "OffsetDateTime");
+ additionalReservedWords.addAll(Sets.newHashSet("OffsetDate", "OffsetDateTime"));
+ importMapping.put("OffsetDate", "package:time_machine/time_machine.dart");
+ importMapping.put("OffsetDateTime", "package:time_machine/time_machine.dart");
+ if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library)) {
+ supportingFiles.add(new SupportingFile("serialization/built_value/local_date_serializer.mustache", srcFolder, "local_date_serializer.dart"));
+ }
+ break;
+ default:
+ case DATE_LIBRARY_CORE:
+ // this option uses the dart core classes
+ additionalProperties.put("useDateLibCore", "true");
+ break;
+ }
+ }
+
+ @Override
+ public String toDefaultValue(Schema schema) {
+ if (schema.getDefault() != null) {
+ if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library)) {
+ if (ModelUtils.isArraySchema(schema)) {
+ if (ModelUtils.isSet(schema)) {
+ return "SetBuilder()";
+ }
+ return "ListBuilder()";
+ }
+ if (ModelUtils.isMapSchema(schema)) {
+ return "MapBuilder()";
+ }
+ }
+ if (ModelUtils.isDateSchema(schema) || ModelUtils.isDateTimeSchema(schema)) {
+ // this is currently not supported and would create compile errors
+ return null;
+ }
+ if (ModelUtils.isStringSchema(schema)) {
+ return "'" + schema.getDefault().toString().replaceAll("'", "\\'") + "'";
+ }
+ return schema.getDefault().toString();
+ }
+ return null;
+ }
+
+ @Override
+ public Map postProcessModels(Map objs) {
+ objs = super.postProcessModels(objs);
+ List models = (List) objs.get("models");
+ ProcessUtils.addIndexToProperties(models, 1);
+
+ for (Object _mo : models) {
+ Map mo = (Map) _mo;
+ Set modelImports = new HashSet<>();
+ CodegenModel cm = (CodegenModel) mo.get("model");
+ for (String modelImport : cm.imports) {
+ if (needToImport(modelImport)) {
+ if (importMapping().containsKey(modelImport)) {
+ modelImports.add(importMapping().get(modelImport));
+ } else {
+ modelImports.add("package:" + pubName + "/src/model/" + underscore(modelImport) + ".dart");
+ }
+ }
+ }
+
+ cm.imports = modelImports;
+ boolean hasVars = cm.vars.size() > 0;
+ cm.vendorExtensions.put("x-has-vars", hasVars);
+ }
+ return objs;
+ }
+
+ @Override
+ public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
+ super.postProcessModelProperty(model, property);
+ if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library)) {
+ if (property.isEnum) {
+ // enums are generated with built_value and make use of BuiltSet
+ model.imports.add("BuiltSet");
+ }
+
+ property.getVendorExtensions().put("x-built-value-serializer-type", createBuiltValueSerializerType(property));
+ }
+ }
+
+ private String createBuiltValueSerializerType(CodegenProperty property) {
+ final StringBuilder sb = new StringBuilder("const FullType(");
+ if (property.isContainer) {
+ appendBuiltValueCollection(sb, property);
+ } else {
+ sb.append(property.datatypeWithEnum);
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ private void appendBuiltValueCollection(StringBuilder sb, CodegenProperty property) {
+ sb.append(property.baseType);
+ sb.append(", [FullType(");
+ if (property.isMap) {
+ // a map always has string keys
+ sb.append("String), FullType(");
+ }
+ if (property.items.isContainer) {
+ appendBuiltValueCollection(sb, property.items);
+ } else {
+ sb.append(property.items.datatypeWithEnum);
+ }
+ sb.append(")]");
+ }
+
+ @Override
+ public Map postProcessOperationsWithModels(Map objs, List allModels) {
+ objs = super.postProcessOperationsWithModels(objs, allModels);
+ Map operations = (Map) objs.get("operations");
+ List operationList = (List) operations.get("operation");
+
+ Set> serializers = new HashSet<>();
+ Set modelImports = new HashSet<>();
+ Set fullImports = new HashSet<>();
+
+ for (CodegenOperation op : operationList) {
+ op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
+ boolean isJson = true; //default to JSON
+ boolean isForm = false;
+ boolean isMultipart = false;
+ if (op.consumes != null) {
+ for (Map consume : op.consumes) {
+ if (consume.containsKey("mediaType")) {
+ String type = consume.get("mediaType");
+ isJson = type.equalsIgnoreCase("application/json");
+ isForm = type.equalsIgnoreCase("application/x-www-form-urlencoded");
+ isMultipart = type.equalsIgnoreCase("multipart/form-data");
+ break;
+ }
+ }
+ }
+
+ for (CodegenParameter param : op.bodyParams) {
+ if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
+ param.baseType = "MultipartFile";
+ param.dataType = "MultipartFile";
+ }
+ if (param.isContainer) {
+ final Map serializer = new HashMap<>();
+ serializer.put("isArray", param.isArray);
+ serializer.put("uniqueItems", param.uniqueItems);
+ serializer.put("isMap", param.isMap);
+ serializer.put("baseType", param.baseType);
+ serializers.add(serializer);
+ }
+ }
+
+ op.vendorExtensions.put("x-is-json", isJson);
+ op.vendorExtensions.put("x-is-form", isForm);
+ op.vendorExtensions.put("x-is-multipart", isMultipart);
+
+ if (op.getHasFormParams()) {
+ fullImports.add("package:" + pubName + "/src/api_util.dart");
+ }
+
+ Set imports = new HashSet<>();
+ for (String item : op.imports) {
+ if (needToImport(item)) {
+ if (importMapping().containsKey(item)) {
+ fullImports.add(importMapping().get(item));
+ } else {
+ imports.add(underscore(item));
+ }
+ }
+ }
+ modelImports.addAll(imports);
+ op.imports = imports;
+
+ if (op.returnContainer != null) {
+ final Map serializer = new HashMap<>();
+ serializer.put("isArray", Objects.equals("array", op.returnContainer) || Objects.equals("set", op.returnContainer));
+ serializer.put("uniqueItems", op.uniqueItems);
+ serializer.put("isMap", Objects.equals("map", op.returnContainer));
+ serializer.put("baseType", op.returnBaseType);
+ serializers.add(serializer);
+ }
+ }
+
+ objs.put("modelImports", modelImports);
+ objs.put("fullImports", fullImports);
+ objs.put("serializers", serializers);
+
+ return objs;
+ }
+
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java
index 7bcc374d369..f99e726cb6b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java
@@ -17,6 +17,8 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
@@ -79,6 +81,10 @@ public class DartJaguarClientCodegen extends AbstractDartCodegen {
.includeParameterFeatures(
ParameterFeature.Cookie
)
+ .wireFormatFeatures(EnumSet.of(
+ WireFormatFeature.JSON,
+ WireFormatFeature.PROTOBUF
+ ))
.includeClientModificationFeatures(
ClientModificationFeature.BasePath
)
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
index d4ee8e555ae..781e7546eb1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
@@ -235,7 +235,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
}
this.useRxJava2 = useRxJava2;
}
-
+
public void setUseRxJava3(boolean useRxJava3) {
if (useRxJava3) {
this.useRxJava = false;
@@ -379,7 +379,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
if(ProcessUtils.hasHttpBearerMethods(openAPI)) {
supportingFiles.add(new SupportingFile("auth/HttpBearerAuth.kt.mustache", authFolder, "HttpBearerAuth.kt"));
}
-
+
if(ProcessUtils.hasHttpBasicMethods(openAPI)) {
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.kt.mustache", authFolder, "HttpBasicAuth.kt"));
}
@@ -476,6 +476,22 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
//supportingFiles.add(new SupportingFile("jvm-common/infrastructure/DateAdapter.kt.mustache", infrastructureFolder, "DateAdapter.kt"));
break;
+ case kotlinx_serialization:
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/AtomicBooleanAdapter.kt.mustache", infrastructureFolder, "AtomicBooleanAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/AtomicIntegerAdapter.kt.mustache", infrastructureFolder, "AtomicIntegerAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/AtomicLongAdapter.kt.mustache", infrastructureFolder, "AtomicLongAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/URIAdapter.kt.mustache", infrastructureFolder, "URIAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/URLAdapter.kt.mustache", infrastructureFolder, "URLAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/BigIntegerAdapter.kt.mustache", infrastructureFolder, "BigIntegerAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/BigDecimalAdapter.kt.mustache", infrastructureFolder, "BigDecimalAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/DateAdapter.kt.mustache", infrastructureFolder, "DateAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache", infrastructureFolder, "OffsetDateTimeAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/StringBuilderAdapter.kt.mustache", infrastructureFolder, "StringBuilderAdapter.kt"));
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/proguard-rules.pro.mustache", "", "proguard-rules.pro"));
+ break;
}
}
@@ -551,12 +567,6 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("iosTest/Coroutine.kt.mustache", "src/iosTest/kotlin/util", "Coroutine.kt"));
supportingFiles.add(new SupportingFile("jsTest/Coroutine.kt.mustache", "src/jsTest/kotlin/util", "Coroutine.kt"));
supportingFiles.add(new SupportingFile("jvmTest/Coroutine.kt.mustache", "src/jvmTest/kotlin/util", "Coroutine.kt"));
-
- // gradle wrapper supporting files
- supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
- supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
- supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.properties"));
- supportingFiles.add(new SupportingFile("gradle-wrapper.jar", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.jar"));
}
@@ -571,6 +581,12 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
+
+ // gradle wrapper supporting files
+ supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
+ supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
+ supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.properties"));
+ supportingFiles.add(new SupportingFile("gradle-wrapper.jar", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.jar"));
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java
index 49ceeb1e227..ff9e5ea70a1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java
@@ -626,4 +626,17 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
}
}
}
+
+ @Override
+ public void postProcess() {
+ System.out.println("################################################################################");
+ System.out.println("# Thanks for using OpenAPI Generator. #");
+ System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
+ System.out.println("# https://opencollective.com/openapi_generator/donate #");
+ System.out.println("# #");
+ System.out.println("# This generator is created by wing328 (https://github.com/wing328) #");
+ System.out.println("# Please support his work directly by purchasing a copy of the eBook \ud83d\udcd8 #");
+ System.out.println("# - OpenAPI Generator for Perl Developers https://bit.ly/2OId6p3 #");
+ System.out.println("################################################################################");
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
index 208f4fc2cd3..1e1c18f069c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
@@ -774,4 +774,18 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
example += ")";
return example;
}
+
+ @Override
+ public void postProcess() {
+ System.out.println("################################################################################");
+ System.out.println("# Thanks for using OpenAPI Generator. #");
+ System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
+ System.out.println("# https://opencollective.com/openapi_generator/donate #");
+ System.out.println("# #");
+ System.out.println("# This generator has been refactored by wing328 (https://github.com/wing328) #");
+ System.out.println("# Please support his work directly by purchasing a copy of the eBook \ud83d\udcd8 #");
+ System.out.println("# - OpenAPI Generator for R Developers http://bit.ly/3lpywTG #");
+ System.out.println("################################################################################");
+ }
+
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
index 61a9cc2c0dc..fde0ae96d8b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
@@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
-import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -134,8 +133,8 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
Arrays.asList(
"i8", "i16", "i32", "i64",
"u8", "u16", "u32", "u64",
- "f32", "f64",
- "char", "bool", "String", "Vec", "File")
+ "f32", "f64", "isize", "usize",
+ "char", "bool", "str", "String")
);
instantiationTypes.clear();
@@ -212,6 +211,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
allModels.put(modelName, cm);
}
}
+
for (Map.Entry entry : objs.entrySet()) {
Map inner = (Map) entry.getValue();
List> models = (List>) inner.get("models");
@@ -224,7 +224,11 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
Map mas = new HashMap<>();
mas.put("modelName", camelize(mappedModel.getModelName()));
mas.put("mappingName", mappedModel.getMappingName());
- List vars = model.getVars();
+
+ // TODO: deleting the variable from the array was
+ // problematic; I don't know what this is supposed to do
+ // so I'm just cloning it for the moment
+ List vars = new ArrayList<>(model.getVars());
vars.removeIf(p -> p.name.equals(cm.discriminator.getPropertyName()));
mas.put("vars", vars);
discriminatorVars.add(mas);
@@ -480,14 +484,10 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getSchemaType(Schema p) {
String schemaType = super.getSchemaType(p);
- String type = null;
if (typeMapping.containsKey(schemaType)) {
- type = typeMapping.get(schemaType);
- if (languageSpecificPrimitives.contains(type))
- return (type);
- } else
- type = schemaType;
- return type;
+ return typeMapping.get(schemaType);
+ }
+ return schemaType;
}
@Override
@@ -637,7 +637,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
}
// string
- String enumName = sanitizeName(camelize(name));
+ String enumName = camelize(sanitizeName(name));
enumName = enumName.replaceFirst("^_", "");
enumName = enumName.replaceFirst("_$", "");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
index bf7a33d7b00..81425d35415 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
@@ -999,13 +999,13 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
List operations = (List) objectMap.get("operation");
for (CodegenOperation operation : operations) {
for (CodegenParameter cp : operation.allParams) {
- cp.vendorExtensions.put("x-swift-example", constructExampleCode(cp, modelMaps, new HashSet()));
+ cp.vendorExtensions.put("x-swift-example", constructExampleCode(cp, modelMaps, new HashSet()));
}
}
return objs;
}
- public String constructExampleCode(CodegenParameter codegenParameter, HashMap modelMaps, Set visitedModels) {
+ public String constructExampleCode(CodegenParameter codegenParameter, HashMap modelMaps, Set visitedModels) {
if (codegenParameter.isArray) { // array
return "[" + constructExampleCode(codegenParameter.items, modelMaps, visitedModels) + "]";
} else if (codegenParameter.isMap) { // TODO: map, file type
@@ -1037,11 +1037,11 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
} else { // model
// look up the model
if (modelMaps.containsKey(codegenParameter.dataType)) {
- if (visitedModels.contains(modelMaps.get(codegenParameter.dataType))) {
+ if (visitedModels.contains(codegenParameter.dataType)) {
// recursive/self-referencing model, simply return nil to avoid stackoverflow
return "nil";
} else {
- visitedModels.add(modelMaps.get(codegenParameter.dataType));
+ visitedModels.add(codegenParameter.dataType);
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, visitedModels);
}
} else {
@@ -1051,7 +1051,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
}
}
- public String constructExampleCode(CodegenProperty codegenProperty, HashMap modelMaps, Set visitedModels) {
+ public String constructExampleCode(CodegenProperty codegenProperty, HashMap modelMaps, Set visitedModels) {
if (codegenProperty.isArray) { // array
return "[" + constructExampleCode(codegenProperty.items, modelMaps, visitedModels) + "]";
} else if (codegenProperty.isMap) { // TODO: map, file type
@@ -1083,10 +1083,11 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
} else {
// look up the model
if (modelMaps.containsKey(codegenProperty.dataType)) {
- if (visitedModels.contains(modelMaps.get(codegenProperty.dataType))) {
+ if (visitedModels.contains(codegenProperty.dataType)) {
// recursive/self-referencing model, simply return nil to avoid stackoverflow
return "nil";
} else {
+ visitedModels.add(codegenProperty.dataType);
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, visitedModels);
}
} else {
@@ -1096,7 +1097,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
}
}
- public String constructExampleCode(CodegenModel codegenModel, HashMap modelMaps, Set visitedModels) {
+ public String constructExampleCode(CodegenModel codegenModel, HashMap modelMaps, Set visitedModels) {
String example;
example = codegenModel.name + "(";
List propertyExamples = new ArrayList<>();
diff --git a/modules/openapi-generator/src/main/resources/C-libcurl/README.md.mustache b/modules/openapi-generator/src/main/resources/C-libcurl/README.md.mustache
index e70bda9f6eb..5d5eb19c969 100644
--- a/modules/openapi-generator/src/main/resources/C-libcurl/README.md.mustache
+++ b/modules/openapi-generator/src/main/resources/C-libcurl/README.md.mustache
@@ -64,6 +64,55 @@ Once compiled, you can run it with ``` ./main ```
Note: You don't need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
+## Documentation for API Endpoints
+
+All URIs are relative to *{{basePath}}*
+
+Category | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{classname}}_{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{classname}}_{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}}
+{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
+
+## Documentation for Models
+
+{{#models}}{{#model}} - [{{classname}}_t]({{modelDocPath}}{{classname}}.md)
+{{/model}}{{/models}}
+
+## Documentation for Authorization
+
+{{^authMethods}}
+All endpoints do not require authorization.
+{{/authMethods}}
+{{#authMethods}}
+{{#last}}
+Authentication schemes defined for the API:
+{{/last}}
+{{/authMethods}}
+{{#authMethods}}
+
+### {{name}}
+
+{{#isApiKey}}- **Type**: API key
+
+- **API key parameter name**: {{keyParamName}}
+- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
+{{/isApiKey}}
+{{#isBasic}}
+
+- **Type**: HTTP basic authentication
+{{/isBasic}}
+{{#isOAuth}}
+
+- **Type**: OAuth
+- **Flow**: {{flow}}
+- **Authorization URL**: {{authorizationUrl}}
+- **Scopes**: {{^scopes}}N/A{{/scopes}}
+{{#scopes}} - {{scope}}: {{description}}
+{{/scopes}}
+{{/isOAuth}}
+
+{{/authMethods}}
+
## Author
{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
diff --git a/modules/openapi-generator/src/main/resources/C-libcurl/api_doc.mustache b/modules/openapi-generator/src/main/resources/C-libcurl/api_doc.mustache
new file mode 100644
index 00000000000..3f7d724655f
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/C-libcurl/api_doc.mustache
@@ -0,0 +1,60 @@
+# {{classname}}{{#description}}
+{{description}}{{/description}}
+
+All URIs are relative to *{{basePath}}*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+{{#operations}}{{#operation}}[**{{classname}}_{{operationId}}**]({{classname}}.md#{{classname}}_{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{/operation}}{{/operations}}
+
+{{#operations}}
+{{#operation}}
+# **{{classname}}_{{{operationId}}}**
+```c
+{{#summary}}
+// {{{summary}}}
+//
+{{/summary}}
+{{#notes}}
+// {{{notes}}}
+//
+{{/notes}}
+{{#returnType}}{{#returnTypeIsPrimitive}}{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}{{^returnSimpleType}}{{#isArray}}{{{.}}}_t*{{/isArray}}{{#isMap}}{{{.}}}{{/isMap}}{{/returnSimpleType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{{.}}}_t*{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void{{/returnType}} {{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}{{dataType}}_t *{{/isArray}}{{#isMap}}{{dataType}}{{/isMap}}{{/isContainer}} {{{paramName}}}{{/allParams}});
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+{{#allParams}}
+**{{paramName}}** | {{#isPrimitiveType}}{{#isNumber}}**{{{dataType}}}**{{/isNumber}}{{#isLong}}**{{{dataType}}}**{{/isLong}}{{#isInteger}}**{{{dataType}}}**{{/isInteger}}{{#isDouble}}**{{{dataType}}}**{{/isDouble}}{{#isFloat}}**{{{dataType}}}**{{/isFloat}}{{#isBoolean}}**{{dataType}}**{{/isBoolean}}{{#isEnum}}{{#isString}}**{{projectName}}_{{operationId}}_{{baseName}}_e**{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}**{{{dataType}}} \***{{/isString}}{{/isEnum}}{{#isByteArray}}**{{{dataType}}}**{{/isByteArray}}{{#isDate}}**{{{dataType}}}**{{/isDate}}{{#isDateTime}}**{{{dataType}}}**{{/isDateTime}}{{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isFreeFormObject}}**[{{dataType}}_t]({{baseType}}.md) \***{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}**{{datatypeWithEnum}}_e**{{/isEnum}}{{^isEnum}}**[{{{dataType}}}_t]({{{baseType}}}.md) \***{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}**{{datatypeWithEnum}}_e**{{/isEnum}}{{/isModel}}{{#isUuid}}**{{dataType}} \***{{/isUuid}}{{#isEmail}}**{{dataType}}**{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}**[{{dataType}}_t]({{baseType}}.md) \***{{/isArray}}{{#isMap}}**{{dataType}}**{{/isMap}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
+{{/allParams}}
+
+### Return type
+
+{{#returnType}}
+{{#returnTypeIsPrimitive}}
+{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}
+{{^returnSimpleType}}
+{{#isArray}}[{{{.}}}_t]({{returnBaseType}}.md) *{{/isArray}}
+{{#isMap}}{{{.}}}{{/isMap}}
+{{/returnSimpleType}}
+{{/returnTypeIsPrimitive}}
+{{^returnTypeIsPrimitive}}[{{{.}}}_t]({{returnBaseType}}.md) *{{/returnTypeIsPrimitive}}
+{{/returnType}}
+{{^returnType}}void{{/returnType}}
+
+### Authorization
+
+{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
+
+### HTTP request headers
+
+ - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+{{/operation}}
+{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/C-libcurl/model_doc.mustache b/modules/openapi-generator/src/main/resources/C-libcurl/model_doc.mustache
new file mode 100644
index 00000000000..a05a0d6f382
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/C-libcurl/model_doc.mustache
@@ -0,0 +1,12 @@
+{{#models}}{{#model}}# {{classname}}_t
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+{{#vars}}
+**{{name}}** | {{^isContainer}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}**{{projectName}}_{{classVarName}}_{{enumName}}_e**{{/isEnum}}{{^isEnum}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isEnum}}{{/isModel}}{{#isUuid}}**{{datatype}} \***{{/isUuid}}{{#isEmail}}**{{datatype}} \***{{/isEmail}}{{#isFreeFormObject}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isFreeFormObject}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isNumeric}}**{{datatype}}**{{/isNumeric}}{{#isBoolean}}**{{datatype}}**{{/isBoolean}}{{#isEnum}}{{#isString}}**{{projectName}}_{{classVarName}}_{{enumName}}_e**{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}**{{datatype}} \***{{/isString}}{{/isEnum}}{{#isByteArray}}**{{datatype}}**{{/isByteArray}}{{#isBinary}}**{{datatype}}**{{/isBinary}}{{#isDate}}**{{datatype}} \***{{/isDate}}{{#isDateTime}}**{{datatype}} \***{{/isDateTime}}{{/isPrimitiveType}}{{/isContainer}}{{#isContainer}}{{#isArray}}{{#isPrimitiveType}}**{{datatype}}_t \***{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isPrimitiveType}}{{/isArray}}{{#isMap}}**{{datatype}}**{{/isMap}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
+{{/vars}}
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+{{/model}}{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/Java/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/JSON.mustache
index 590ba386ea2..77b72ddc7fc 100644
--- a/modules/openapi-generator/src/main/resources/Java/JSON.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/JSON.mustache
@@ -61,14 +61,15 @@ public class JSON {
{{/jsr310}}
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
+ @SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
{{#models}}
{{#model}}
{{#discriminator}}
- .registerTypeSelector({{classname}}.class, new TypeSelector() {
+ .registerTypeSelector({{classname}}.class, new TypeSelector<{{classname}}>() {
@Override
- public Class getClassForElement(JsonElement readElement) {
+ public Class extends {{classname}}> getClassForElement(JsonElement readElement) {
Map classByDiscriminatorValue = new HashMap();
{{#mappedModels}}
classByDiscriminatorValue.put("{{mappingName}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{modelName}}.class);
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/queryParams.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/queryParams.mustache
index ca2c6e106f7..f89529fdb5d 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}} {{^isContainer}}{{#defaultValue}}@DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}) {{/defaultValue}}{{/isContainer}}{{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}} {{^isContainer}}{{#defaultValue}}@DefaultValue("{{{defaultValue}}}") {{/defaultValue}}{{/isContainer}}{{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
index e3eceebf93d..37ebae04830 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
@@ -1011,10 +1011,10 @@ public class ApiClient {
public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) {
// Binary (byte array) body parameter support.
- return RequestBody.create(MediaType.parse(contentType), (byte[]) obj);
+ return RequestBody.create((byte[]) obj, MediaType.parse(contentType));
} else if (obj instanceof File) {
// File body parameter support.
- return RequestBody.create(MediaType.parse(contentType), (File) obj);
+ return RequestBody.create((File) obj, MediaType.parse(contentType));
} else if (isJsonMime(contentType)) {
String content;
if (obj != null) {
@@ -1022,7 +1022,7 @@ public class ApiClient {
} else {
content = null;
}
- return RequestBody.create(MediaType.parse(contentType), content);
+ return RequestBody.create(content, MediaType.parse(contentType));
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
@@ -1272,7 +1272,7 @@ public class ApiClient {
reqBody = null;
} else {
// use an empty request body (for POST, PUT and PATCH)
- reqBody = RequestBody.create(MediaType.parse(contentType), "");
+ reqBody = RequestBody.create("", MediaType.parse(contentType));
}
} else {
reqBody = serialize(body, contentType);
@@ -1423,10 +1423,10 @@ public class ApiClient {
File file = (File) param.getValue();
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\"");
MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
- mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file));
+ mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType));
} else {
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"");
- mpBuilder.addPart(partHeaders, RequestBody.create(null, parameterToString(param.getValue())));
+ mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null));
}
}
return mpBuilder.build();
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache
index 46b2021c958..cb0e8250550 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/OAuthOkHttpClient.mustache
@@ -47,7 +47,7 @@ public class OAuthOkHttpClient implements HttpClient {
}
}
- RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
+ RequestBody body = request.getBody() != null ? RequestBody.create(request.getBody(), mediaType) : null;
requestBuilder.method(requestMethod, body);
try {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache
index 4d951239ea2..0fe89ccb026 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache
@@ -517,7 +517,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
} else if(MediaType.MULTIPART_FORM_DATA.equals(contentType)) {
return BodyInserters.fromMultipartData(formParams);
} else {
- return obj != null ? BodyInserters.fromObject(obj) : null;
+ return obj != null ? BodyInserters.fromValue(obj) : null;
}
}
@@ -573,7 +573,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
builder.queryParams(queryParams);
}
- final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(builder.encode().toUriString(), pathParams);
+ final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(builder.build(false).toUriString(), pathParams);
if(accept != null) {
requestBuilder.accept(accept.toArray(new MediaType[accept.size()]));
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
index c892d189243..793ad63cbfe 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
@@ -124,7 +124,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.6.2"
- spring_web_version = "5.0.16.RELEASE"
+ spring_web_version = "5.2.13.RELEASE"
jackson_version = "2.11.3"
jackson_databind_version = "2.11.3"
{{#openApiNullable}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
index 5aaeec6823d..39c55beb122 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
@@ -149,7 +149,7 @@
UTF-8
1.6.2
- 5.0.16.RELEASE
+ 5.2.13.RELEASE
2.11.3
2.11.3
{{#openApiNullable}}
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/headerParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/headerParams.mustache
index 48450b83c36..200a109ca64 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/headerParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/headerParams.mustache
@@ -1 +1 @@
-{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} @ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{{defaultValue}}}{{/defaultValue}})@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
+{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} @ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/queryParams.mustache
index 425de6a2292..e132b51a756 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{^isContainer}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{^isContainer}}{{#defaultValue}}@DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}) {{/defaultValue}}{{/isContainer}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{^isContainer}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{^isContainer}}{{#defaultValue}}@DefaultValue("{{{defaultValue}}}") {{/defaultValue}}{{/isContainer}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/queryParams.mustache
index ca2c6e106f7..f89529fdb5d 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}} {{^isContainer}}{{#defaultValue}}@DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}) {{/defaultValue}}{{/isContainer}}{{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}} {{^isContainer}}{{#defaultValue}}@DefaultValue("{{{defaultValue}}}") {{/defaultValue}}{{/isContainer}}{{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache
index be56da7535b..f938cb5b6be 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache
@@ -1 +1 @@
-{{#isBodyParam}}{{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
+{{#isBodyParam}}{{#useBeanValidation}}@Valid {{#required}}{{^isNullable}}@NotNull {{/isNullable}}{{/required}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/queryParams.mustache
index 1edde12bd3f..292a818f8f1 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}} {{^isContainer}}{{#defaultValue}}@DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/isContainer}}{{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}} {{^isContainer}}{{#defaultValue}}@DefaultValue("{{{defaultValue}}}"){{/defaultValue}}{{/isContainer}}{{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/queryParams.mustache
index 62687bc11b0..2600cbe7518 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/queryParams.mustache
@@ -4,25 +4,13 @@
}}{{#required}}, required = true{{/required}}{{!
}}{{^isContainer}}{{!
}}{{#allowableValues}}, {{> allowableValues}}{{/allowableValues}}{{!
- }}{{#defaultValue}}, defaultValue = {{!
- }}{{^isString}}"{{/isString}}{{!
- }}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{!
- }}{{{defaultValue}}}{{!
- }}{{^isString}}"{{/isString}}{{!
- }}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{!
- }}{{/defaultValue}}{{!
+ }}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}{{!
}}{{/isContainer}}{{!
}}){{!
}}{{^isContainer}}{{!
}}{{#defaultValue}}{{!
- }} @DefaultValue({{!
- }}{{^isString}}"{{/isString}}{{!
- }}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{!
- }}{{{defaultValue}}}{{!
- }}{{^isString}}"{{/isString}}{{!
- }}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{!
- }}){{!
+ }} @DefaultValue("{{{defaultValue}}}"){{!
}}{{/defaultValue}}{{!
}}{{/isContainer}}{{!
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/bodyParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/bodyParams.mustache
index d6e3dd87095..eec07e9062d 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/bodyParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/bodyParams.mustache
@@ -1 +1 @@
-{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}){{#useBeanValidation}}{{#required}} @NotNull{{/required}} @Valid{{/useBeanValidation}} {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
+{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#useBeanValidation}}{{#required}} @NotNull{{/required}} @Valid{{/useBeanValidation}} {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/bodyParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/bodyParams.mustache
index d6e3dd87095..eec07e9062d 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/bodyParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/bodyParams.mustache
@@ -1 +1 @@
-{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}){{#useBeanValidation}}{{#required}} @NotNull{{/required}} @Valid{{/useBeanValidation}} {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
+{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#useBeanValidation}}{{#required}} @NotNull{{/required}} @Valid{{/useBeanValidation}} {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/formParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/formParams.mustache
index f0e4c548270..79d5e482e3d 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/formParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/formParams.mustache
@@ -1 +1 @@
-{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
+{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/headerParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/headerParams.mustache
index 1ef8d252549..6dafce8fe79 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/headerParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/headerParams.mustache
@@ -1 +1 @@
-{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} @ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) @HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
+{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} @ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/queryParams.mustache
index 6bac52e200c..86b8bdf7b5b 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}} @DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/isContainer}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}}{{/isContainer}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/formParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/formParams.mustache
index f0e4c548270..79d5e482e3d 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/formParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/formParams.mustache
@@ -1 +1 @@
-{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
+{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/headerParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/headerParams.mustache
index 1ef8d252549..6dafce8fe79 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/headerParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/headerParams.mustache
@@ -1 +1 @@
-{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} @ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) @HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
+{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} @ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache
index 6bac52e200c..86b8bdf7b5b 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}} @DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/isContainer}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}}{{/isContainer}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/bodyParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/bodyParams.mustache
index be56da7535b..f938cb5b6be 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/bodyParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/bodyParams.mustache
@@ -1 +1 @@
-{{#isBodyParam}}{{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
+{{#isBodyParam}}{{#useBeanValidation}}@Valid {{#required}}{{^isNullable}}@NotNull {{/isNullable}}{{/required}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/cookieParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/cookieParams.mustache
index 11858cc194d..71dbe46aba2 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/cookieParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/cookieParams.mustache
@@ -1 +1 @@
-{{#isCookieParam}}@CookieParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{description}}"){{/description}}{{/useSwaggerAnnotations}} {{{dataType}}} {{paramName}}{{/isCookieParam}}
\ No newline at end of file
+{{#isCookieParam}}@CookieParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{description}}"){{/description}}{{/useSwaggerAnnotations}} {{{dataType}}} {{paramName}}{{/isCookieParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/queryParams.mustache
index c46b97688a9..198098046c0 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{description}}"){{/description}}{{/useSwaggerAnnotations}} {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{description}}"){{/description}}{{/useSwaggerAnnotations}} {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache
index ffcfc878d83..770bfd30183 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache
@@ -20,7 +20,9 @@ import org.springframework.http.ResponseEntity;
{{#useBeanValidation}}
import org.springframework.validation.annotation.Validated;
{{/useBeanValidation}}
+{{#vendorExtensions.x-spring-paginated}}
import org.springframework.data.domain.Pageable;
+{{/vendorExtensions.x-spring-paginated}}
import org.springframework.web.bind.annotation.*;
{{#jdk8-no-delegate}}
{{^reactive}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache
index 0b9e652937e..7478a0628c3 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache
@@ -25,7 +25,9 @@ import org.springframework.web.context.request.NativeWebRequest;
{{/isDelegate}}
{{^jdk8}}
import org.springframework.web.multipart.MultipartFile;
+{{#vendorExtensions.x-spring-paginated}}
import org.springframework.data.domain.Pageable;
+{{/vendorExtensions.x-spring-paginated}}
import springfox.documentation.annotations.ApiIgnore;
{{#useBeanValidation}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache
index 2e43536048e..ca990e7146b 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache
@@ -3,7 +3,9 @@ package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import io.swagger.annotations.*;
+{{#vendorExtensions.x-spring-paginated}}
import org.springframework.data.domain.Pageable;
+{{/vendorExtensions.x-spring-paginated}}
{{#jdk8}}
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache
index ebfaa14e68a..83780c73ae3 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache
@@ -1 +1 @@
-{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
+{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache
index 6e111692a9c..e21bd9ff4bf 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache
@@ -1 +1 @@
-{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @CookieValue("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isCookieParam}}
\ No newline at end of file
+{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) @CookieValue("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isCookieParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache
index 04564e162dc..f3291733ee4 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache
@@ -1 +1 @@
-{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{baseName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
+{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{baseName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache
index a8bbef330c8..2e2d907f583 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache
@@ -1 +1 @@
-{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
+{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache
index cec76d91502..0eb66fdee5a 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache
@@ -1 +1 @@
-{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @RequestParam("{{baseName}}") {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
+{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @RequestParam("{{baseName}}") {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache
index d3c16fab5f1..44cc98fff1c 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache
@@ -1 +1 @@
-{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}}
\ No newline at end of file
+{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache
index a22a8366cf0..fc630e6361e 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/isModel}}{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}){{/isModel}}{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
index 18bfd3dc556..886c41c7f4e 100644
--- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
+++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
@@ -24,6 +24,7 @@ org.openapitools.codegen.languages.CSharpDotNet2ClientCodegen
org.openapitools.codegen.languages.CSharpNancyFXServerCodegen
org.openapitools.codegen.languages.DartClientCodegen
org.openapitools.codegen.languages.DartDioClientCodegen
+org.openapitools.codegen.languages.DartDioNextClientCodegen
org.openapitools.codegen.languages.DartJaguarClientCodegen
org.openapitools.codegen.languages.EiffelClientCodegen
org.openapitools.codegen.languages.ElixirClientCodegen
diff --git a/modules/openapi-generator/src/main/resources/android/gradle-wrapper.jar b/modules/openapi-generator/src/main/resources/android/gradle-wrapper.jar
index 87b738cbd05..e708b1c023e 100644
Binary files a/modules/openapi-generator/src/main/resources/android/gradle-wrapper.jar and b/modules/openapi-generator/src/main/resources/android/gradle-wrapper.jar differ
diff --git a/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache b/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache
index e496c054f69..4d9ca164914 100644
--- a/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache
+++ b/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/modules/openapi-generator/src/main/resources/android/gradlew.bat.mustache b/modules/openapi-generator/src/main/resources/android/gradlew.bat.mustache
index f9553162f12..107acd32c4e 100644
--- a/modules/openapi-generator/src/main/resources/android/gradlew.bat.mustache
+++ b/modules/openapi-generator/src/main/resources/android/gradlew.bat.mustache
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/modules/openapi-generator/src/main/resources/android/gradlew.mustache b/modules/openapi-generator/src/main/resources/android/gradlew.mustache
index af6708ff229..4f906e0c811 100644
--- a/modules/openapi-generator/src/main/resources/android/gradlew.mustache
+++ b/modules/openapi-generator/src/main/resources/android/gradlew.mustache
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m"'
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache b/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache
index 7c6cb04c856..86933d07155 100644
--- a/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache
+++ b/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache
@@ -5,11 +5,15 @@ project.version = '{{artifactVersion}}'
buildscript {
repositories {
- maven { url "https://repo1.maven.org/maven2" }
+ mavenLocal()
+ google()
+ maven {
+ url 'https://dl.google.com/dl/android/maven2'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.+'
+ classpath 'com.android.tools.build:gradle:3.2.+'
{{#useAndroidMavenGradlePlugin}}
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
{{/useAndroidMavenGradlePlugin}}
@@ -18,6 +22,7 @@ buildscript {
allprojects {
repositories {
+ google()
jcenter()
}
}
@@ -30,7 +35,7 @@ apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 25
- buildToolsVersion '25.0.2'
+ buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
@@ -51,14 +56,15 @@ android {
{{/java8}}
{{/supportJava6}}
}
+ lintOptions {
+ abortOnError false
+ }
// Rename the aar correctly
libraryVariants.all { variant ->
- variant.outputs.each { output ->
- def outputFile = output.outputFile
- if (outputFile != null && outputFile.name.endsWith('.aar')) {
- def fileName = "${project.name}-${variant.baseName}-${version}.aar"
- output.outputFile = new File(outputFile.parent, fileName)
+ variant.outputs.all { output ->
+ if (outputFile != null && outputFileName.endsWith('.aar')) {
+ outputFileName = "${archivesBaseName}-${version}.aar"
}
}
}
@@ -68,29 +74,24 @@ android {
}
}
-
ext {
- swagger_annotations_version = "1.5.0"
- gson_version = "2.3.1"
- httpmime_version = "4.5.2"
- httpcore_version = "4.4.4"
- httpclient_version = "4.3.3"
- volley_version = "1.0.0"
- junit_version = "4.13"
- robolectric_version = "3.0"
- concurrent_unit_version = "0.4.2"
+ swagger_annotations_version = "1.6.2"
+ gson_version = "2.8.6"
+ httpmime_version = "4.5.13"
+ volley_version = "1.2.0"
+ junit_version = "4.13.2"
+ robolectric_version = "4.5.1"
+ concurrent_unit_version = "0.4.6"
}
dependencies {
- compile "io.swagger:swagger-annotations:$swagger_annotations_version"
- compile "com.google.code.gson:gson:$gson_version"
- compile "org.apache.httpcomponents:httpcore:$httpcore_version"
- compile "org.apache.httpcomponents:httpmime:$httpmime_version"
- compile "org.apache.httpcomponents:httpclient-android:$httpclient_version"
- compile "com.android.volley:volley:${volley_version}"
- testCompile "junit:junit:$junit_version"
- testCompile "org.robolectric:robolectric:${robolectric_version}"
- testCompile "net.jodah:concurrentunit:${concurrent_unit_version}"
+ implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
+ implementation "com.google.code.gson:gson:$gson_version"
+ implementation "org.apache.httpcomponents:httpmime:$httpmime_version"
+ implementation "com.android.volley:volley:${volley_version}"
+ testImplementation "junit:junit:$junit_version"
+ testImplementation "org.robolectric:robolectric:${robolectric_version}"
+ testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}"
}
afterEvaluate {
diff --git a/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache b/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache
index 3e5b52e5394..d0cf3b56e96 100644
--- a/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache
@@ -17,16 +17,6 @@
jsr305
3.0.2
-
- org.apache.httpcomponents
- httpcore
- ${httpcomponents-httpcore-version}
-
-
- org.apache.httpcomponents
- httpclient-android
- ${httpcomponents-httpclient-version}
-
org.apache.httpcomponents
httpmime
@@ -63,9 +53,7 @@
1.5.8
- 4.4.4
4.5.2
- 4.3.3
2.6.2
1.0.19
4.1.1.4
diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/2.0/Project.csproj.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/2.0/Project.csproj.mustache
index 184fe7dcff7..6732557feeb 100644
--- a/modules/openapi-generator/src/main/resources/aspnetcore/2.0/Project.csproj.mustache
+++ b/modules/openapi-generator/src/main/resources/aspnetcore/2.0/Project.csproj.mustache
@@ -1,7 +1,8 @@
- {{packageName}}
- {{packageName}}
+ {{^packageDescription}}{{packageName}}{{/packageDescription}}{{packageDescription}}
+ {{packageCopyright}}
+ {{packageAuthors}}
netcoreapp2.0
{{packageVersion}}
true
diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.csproj.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.csproj.mustache
index bb25404ee10..88a0fd7e44e 100644
--- a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.csproj.mustache
+++ b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.csproj.mustache
@@ -1,7 +1,8 @@
- {{packageName}}
- {{packageName}}
+ {{^packageDescription}}{{packageName}}{{/packageDescription}}{{packageDescription}}
+ {{packageCopyright}}
+ {{packageAuthors}}
netcoreapp{{aspnetCoreVersion}}
true
true
diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.nuspec.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.nuspec.mustache
index 03490d71129..d6a52c2c20a 100644
--- a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.nuspec.mustache
+++ b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/Project.nuspec.mustache
@@ -1,20 +1,20 @@
-
- $id$
- {{packageVersion}}
- {{packageTitle}}
- {{packageAuthors}}
- {{packageAuthors}}
- {{licenseUrl}}
-
- false
- {{packageName}}
- Summary of changes made in this release of the package.
- {{packageCopyright}}
- {{packageName}}
-
+
+ $id$
+ {{packageVersion}}
+ {{packageTitle}}
+ {{packageAuthors}}
+ {{packageAuthors}}
+ {{licenseUrl}}
+
+ false
+ {{^packageDescription}}{{packageName}}{{/packageDescription}}{{packageDescription}}
+ Summary of changes made in this release of the package.
+ {{packageCopyright}}
+ {{packageName}}
+
diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.csproj.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.csproj.mustache
index 69d7cca51d2..70f7388a988 100644
--- a/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.csproj.mustache
+++ b/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.csproj.mustache
@@ -1,7 +1,8 @@
- {{packageName}}
- {{packageName}}
+ {{^packageDescription}}{{packageName}}{{/packageDescription}}{{packageDescription}}
+ {{packageCopyright}}
+ {{packageAuthors}}
{{targetFramework}}
true
true
diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.nuspec.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.nuspec.mustache
index 03490d71129..b97c14d13d3 100644
--- a/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.nuspec.mustache
+++ b/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Project.nuspec.mustache
@@ -12,7 +12,7 @@
http://ICON_URL_HERE_OR_DELETE_THIS_LINE
-->
false
- {{packageName}}
+ {{^packageDescription}}{{packageName}}{{/packageDescription}}{{packageDescription}}
Summary of changes made in this release of the package.
{{packageCopyright}}
{{packageName}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache
index 6e290e6eb85..39c55843a74 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache
@@ -1,6 +1,5 @@
{{>licenseInfo}}
#include "{{classname}}.h"
-#include "{{prefix}}Helpers.h"
#include "{{prefix}}ServerConfiguration.h"
#include
#include
@@ -21,7 +20,6 @@ namespace {{this}} {
}
void {{classname}}::initializeServerConfigs(){
-
//Default server
QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>();
//varying endpoint server
@@ -38,8 +36,8 @@ void {{classname}}::initializeServerConfigs(){
{{#operations}}
{{#operation}}
{{^servers}}
- _serverConfigs.insert("{{nickname}}",defaultConf);
- _serverIndices.insert("{{nickname}}",0);
+ _serverConfigs.insert("{{nickname}}", defaultConf);
+ _serverIndices.insert("{{nickname}}", 0);
{{/servers}}
{{#servers}}
serverConf.append({{prefix}}ServerConfiguration(
@@ -49,8 +47,8 @@ void {{classname}}::initializeServerConfigs(){
{"{{{name}}}", {{prefix}}ServerVariable("{{{description}}}{{^description}}No description provided{{/description}}","{{{defaultValue}}}",
QSet{ {{#enumValues}}{"{{{.}}}"}{{#-last}} })}, {{/-last}}{{^-last}},{{/-last}}{{/enumValues}}{{^enumValues}}{"{{defaultValue}}"} })},{{/enumValues}}{{#-last}} }));{{/-last}}
{{/variables}}{{^variables}}QMap()));{{/variables}}
- {{#-last}}_serverConfigs.insert("{{nickname}}",serverConf);
- _serverIndices.insert("{{nickname}}",0);{{/-last}}
+ {{#-last}}_serverConfigs.insert("{{nickname}}", serverConf);
+ _serverIndices.insert("{{nickname}}", 0);{{/-last}}
{{/servers}}
{{/operation}}
{{/operations}}
@@ -224,7 +222,7 @@ QString {{classname}}::getParamStyleDelimiter(QString style, QString name, bool
{{#operations}}
{{#operation}}
-void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const QVariant &{{/required}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
+void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const ::{{cppNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
QString fullPath = QString(_serverConfigs["{{nickname}}"][_serverIndices.value("{{nickname}}")].URL()+"{{{path}}}");
{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}}
if(_apiKeys.contains("{{name}}")){
@@ -247,9 +245,8 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
b64.append(_username.toUtf8() + ":" + _password.toUtf8());
addHeaders("Authorization","Basic " + b64.toBase64());
}{{/isBasicBasic}}{{/authMethods}}
-
{{#pathParams}}
- {{^required}}if(!{{paramName}}.isNull()){{/required}}
+ {{^required}}if({{paramName}}.hasValue()){{/required}}
{
QString {{paramName}}PathParam("{");
{{paramName}}PathParam.append("{{baseName}}").append("}");
@@ -263,7 +260,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
{{^collectionFormat}}
{{^isPrimitiveType}}
QString paramString = (pathStyle == "matrix" && {{isExplode}}) ? pathPrefix : pathPrefix+"{{baseName}}"+pathSuffix;
- QJsonObject parameter = {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.asJsonObject();
+ QJsonObject parameter = {{paramName}}{{^required}}.value(){{/required}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
@@ -307,14 +304,14 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
{{/isPrimitiveType}}
{{#isPrimitiveType}}
QString paramString = (pathStyle == "matrix") ? pathPrefix+"{{baseName}}"+pathSuffix : pathPrefix;
- fullPath.replace({{paramName}}PathParam, paramString+QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}})));
+ fullPath.replace({{paramName}}PathParam, paramString+QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}})));
{{/isPrimitiveType}}
- {{/collectionFormat}}
- {{#collectionFormat}}
- if ({{{paramName}}}{{^required}}.value<{{{dataType}}}>(){{/required}}.size() > 0) {
+{{/collectionFormat}}
+{{#collectionFormat}}
+ if({{{paramName}}}{{^required}}.value(){{/required}}.size() > 0) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"{{baseName}}"+pathSuffix : pathPrefix;
qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (count > 0) {
fullPath.append(pathDelimiter);
}
@@ -325,13 +322,12 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
}
{{/collectionFormat}}
}
-
{{/pathParams}}
{{#hasQueryParams}}
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
{{/hasQueryParams}}
{{#queryParams}}
- {{^required}}if(!{{paramName}}.isNull()){{/required}}
+ {{^required}}if({{paramName}}.hasValue()){{/required}}
{
queryStyle = "{{style}}";
if(queryStyle == "")
@@ -346,7 +342,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
fullPath.append("?");
{{^isPrimitiveType}}
QString paramString = (queryStyle == "form" && {{isExplode}}) ? "" : (queryStyle == "form" && !({{isExplode}})) ? "{{baseName}}"+querySuffix : "";
- QJsonObject parameter = {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.asJsonObject();
+ QJsonObject parameter = {{paramName}}{{^required}}.value(){{/required}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
@@ -392,13 +388,13 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
}
fullPath.append(paramString);
{{/isPrimitiveType}}{{#isPrimitiveType}}
- fullPath.append(QUrl::toPercentEncoding("{{baseName}}")).append(querySuffix).append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}})));
- {{/isPrimitiveType}}
- {{/collectionFormat}}
- {{#collectionFormat}}
- if ({{{paramName}}}{{^required}}.value<{{{dataType}}}>(){{/required}}.size() > 0) {
+ fullPath.append(QUrl::toPercentEncoding("{{baseName}}")).append(querySuffix).append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}})));
+{{/isPrimitiveType}}
+{{/collectionFormat}}
+{{#collectionFormat}}
+ if({{{paramName}}}{{^required}}.value(){{/required}}.size() > 0) {
if (QString("{{collectionFormat}}").indexOf("multi") == 0) {
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (fullPath.indexOf("?") > 0)
fullPath.append(queryPrefix);
else
@@ -411,7 +407,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (count > 0) {
fullPath.append(({{isExplode}})? queryDelimiter : QUrl::toPercentEncoding(queryDelimiter));
}
@@ -424,7 +420,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (count > 0) {
fullPath.append("\t");
}
@@ -437,7 +433,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
@@ -450,7 +446,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
@@ -463,7 +459,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
else
fullPath.append("?").append(queryPrefix).append("{{baseName}}").append(querySuffix);
qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (count > 0) {
fullPath.append(queryDelimiter);
}
@@ -474,7 +470,6 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
}
{{/collectionFormat}}
}
-
{{/queryParams}}
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
@@ -493,39 +488,38 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
formSuffix = getParamStyleSuffix(formStyle);
formDelimiter = getParamStyleDelimiter(formStyle, "{{baseName}}", {{isExplode}});
{{/first}}
-
- {{^required}}if(!{{paramName}}.isNull()){{/required}}
+ {{^required}}if({{paramName}}.hasValue()){{/required}}
{
{{^isFile}}
- input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}));
+ input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}));
{{/isFile}}
{{#isFile}}
- input.add_file("{{baseName}}", {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.local_filename, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.request_filename, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.mime_type);
+ input.add_file("{{baseName}}", {{paramName}}{{^required}}.value(){{/required}}.local_filename, {{paramName}}{{^required}}.value(){{/required}}.request_filename, {{paramName}}{{^required}}.value(){{/required}}.mime_type);
{{/isFile}}
}
-
{{/formParams}}
{{#bodyParams}}
+ {{^required}}if({{paramName}}.hasValue()){{/required}}{
{{#isContainer}}
{{#isArray}}
- QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}).toArray());{{/isArray}}{{#isMap}}
- QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}).toObject());{{/isMap}}
- QByteArray bytes = doc.toJson();
- input.request_body.append(bytes);
+ QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}{{^required}}.value(){{/required}}).toArray());{{/isArray}}{{#isMap}}
+ QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}{{^required}}.value(){{/required}}).toObject());{{/isMap}}
+ QByteArray bytes = doc.toJson();
+ input.request_body.append(bytes);
{{/isContainer}}{{^isContainer}}{{#isString}}
- QByteArray output = {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.toUtf8();{{/isString}}{{#isByteArray}}QByteArray output({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}});{{/isByteArray}}{{^isString}}{{^isByteArray}}{{^isFile}}
- QByteArray output = {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.asJson().toUtf8();{{/isFile}}{{/isByteArray}}{{/isString}}{{#isFile}}{{#hasConsumes}}input.headers.insert("Content-Type", {{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}});{{/hasConsumes}}
- QByteArray output = {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.asByteArray();{{/isFile}}
- input.request_body.append(output);
+ QByteArray output = {{paramName}}{{^required}}.value(){{/required}}.toUtf8();{{/isString}}{{#isByteArray}}QByteArray output({{paramName}}{{^required}}.value(){{/required}});{{/isByteArray}}{{^isString}}{{^isByteArray}}{{^isFile}}
+ QByteArray output = {{paramName}}{{^required}}.value(){{/required}}.asJson().toUtf8();{{/isFile}}{{/isByteArray}}{{/isString}}{{#isFile}}{{#hasConsumes}}input.headers.insert("Content-Type", {{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}});{{/hasConsumes}}
+ QByteArray output = {{paramName}}{{^required}}.value(){{/required}}.asByteArray();{{/isFile}}
+ input.request_body.append(output);
{{/isContainer}}
-{{/bodyParams}}
+ }{{/bodyParams}}
{{#headerParams}}
- {{^required}}if(!{{paramName}}.isNull()){{/required}}
+ {{^required}}if({{paramName}}.hasValue()){{/required}}
{
{{^collectionFormat}}
{{^isPrimitiveType}}
QString headerString;
- QJsonObject parameter = {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.asJsonObject();
+ QJsonObject parameter = {{paramName}}{{^required}}.value(){{/required}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
@@ -567,34 +561,34 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
input.headers.insert("{{baseName}}", headerString);
{{/isPrimitiveType}}
{{#isPrimitiveType}}
- if (!::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}).isEmpty()) {
- input.headers.insert("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}));
+ if (!::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}).isEmpty()) {
+ input.headers.insert("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}));
}
{{/isPrimitiveType}}{{/collectionFormat}}{{#collectionFormat}}
QString headerString;
- if ({{{paramName}}}{{^required}}.value<{{{dataType}}}>(){{/required}}.size() > 0) {
- qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
- if (count > 0) {
- headerString.append(",");
+ if ({{{paramName}}}{{^required}}.value(){{/required}}.size() > 0) {
+ qint32 count = 0;
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
+ if (count > 0) {
+ headerString.append(",");
+ }
+ headerString.append(::{{cppNamespace}}::toStringValue(t));
+ count++;
}
- headerString.append(::{{cppNamespace}}::toStringValue(t));
- count++;
- }
- input.headers.insert("{{baseName}}", headerString);
+ input.headers.insert("{{baseName}}", headerString);
}
{{/collectionFormat}}
-}
+ }
{{/headerParams}}
{{#cookieParams}}
- {{^required}}if(!{{paramName}}.isNull()){{/required}}
+ {{^required}}if({{paramName}}.hasValue()){{/required}}
{
if(QString("{{style}}").indexOf("form") == 0){
{{^collectionFormat}}
{{^isPrimitiveType}}
{{^isExplode}}
QString cookieString = "{{baseName}}=";
- QJsonObject parameter = {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}.asJsonObject();
+ QJsonObject parameter = {{paramName}}{{^required}}.value(){{/required}}.asJsonObject();
qint32 count = 0;
foreach(const QString& key, parameter.keys()) {
if (count > 0) {
@@ -636,8 +630,8 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
{{/isExplode}}
{{/isPrimitiveType}}
{{#isPrimitiveType}}
- if (!::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}).isEmpty()) {
- input.headers.insert("Cookie", "{{baseName}}="+::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}));
+ if(!::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}).isEmpty()) {
+ input.headers.insert("Cookie", "{{baseName}}="+::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}));
}
{{/isPrimitiveType}}
{{/collectionFormat}}
@@ -646,7 +640,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
QString cookieString = "{{baseName}}=";
if ({{{paramName}}}.size() > 0) {
qint32 count = 0;
- foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value<{{{dataType}}}>(){{/required}}) {
+ foreach ({{{baseType}}} t, {{paramName}}{{^required}}.value(){{/required}}) {
if (count > 0) {
cookieString.append(",");
}
@@ -664,7 +658,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
connect(worker, &{{prefix}}HttpRequestWorker::on_execution_finished, this, &{{classname}}::{{nickname}}Callback);
connect(this, &{{classname}}::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren<{{prefix}}HttpRequestWorker>().count() == 0){
+ if(findChildren<{{prefix}}HttpRequestWorker*>().count() == 0){
emit allPendingRequestsCompleted();
}
});
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache
index ef0a61ff193..639f2f766ea 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache
@@ -2,6 +2,7 @@
#ifndef {{prefix}}_{{classname}}_H
#define {{prefix}}_{{classname}}_H
+#include "{{prefix}}Helpers.h"
#include "{{prefix}}HttpRequest.h"
#include "{{prefix}}ServerConfiguration.h"
@@ -13,7 +14,6 @@
#include
#include
#include
-#include
{{#cppNamespaceDeclarations}}
namespace {{this}} {
@@ -57,7 +57,7 @@ public:
{{/required}}
{{/allParams}}
*/{{/hasParams}}
- {{#isDeprecated}}Q_DECL_DEPRECATED {{/isDeprecated}}void {{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const QVariant &{{/required}}{{paramName}}{{^required}} = QVariant(){{/required}}{{^-last}}, {{/-last}}{{/allParams}});
+ {{#isDeprecated}}Q_DECL_DEPRECATED {{/isDeprecated}}void {{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const ::{{cppNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}{{^required}} = ::{{cppNamespace}}::OptionalParam<{{{dataType}}}>(){{/required}}{{^-last}}, {{/-last}}{{/allParams}});
{{/operation}}{{/operations}}
private:
@@ -86,7 +86,7 @@ signals:
{{#operations}}{{#operation}}
void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);{{/operation}}{{/operations}}
- void abortRequestsSignal();
+ void abortRequestsSignal();
void allPendingRequestsCompleted();
};
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache
index 1a91100adf9..1607aeed2e8 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache
@@ -11,7 +11,6 @@
#include
#include
#include
-#include
#include "{{prefix}}Enum.h"
#include "{{prefix}}HttpFileElement.h"
@@ -21,6 +20,27 @@
namespace {{this}} {
{{/cppNamespaceDeclarations}}
+template
+class OptionalParam {
+public:
+ T m_Value;
+ bool m_hasValue;
+public:
+ OptionalParam(){
+ m_hasValue = false;
+ }
+ OptionalParam(const T &val){
+ m_hasValue = true;
+ m_Value = val;
+ }
+ bool hasValue() const {
+ return m_hasValue;
+ }
+ T value() const{
+ return m_Value;
+ }
+};
+
bool setDateTimeFormat(const QString&);
template
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache
index 6629cf47cb1..c6ee2f08eb4 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache
@@ -27,8 +27,9 @@ public:
{{#operations}}{{#operation}}{{#description}}/* {{{description}}} */
{{/description}}bool {{operationIdCamelCase}}(const {{operationIdCamelCase}}Request& Request, const F{{operationIdCamelCase}}Delegate& Delegate = F{{operationIdCamelCase}}Delegate()) const;
{{/operation}}{{/operations}}
+
private:
- {{#operations}}{{#operation}}void On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate) const;
+ {{#operations}}{{#operation}}void On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate, int AutoRetryCount) const;
{{/operation}}{{/operations}}
bool IsValid() const;
void HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const;
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-header.mustache
index bd168101e38..2319c59b3fa 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-header.mustache
@@ -22,7 +22,7 @@ class {{dllapi}} {{classname}}::{{operationIdCamelCase}}Request : public Request
{
public:
virtual ~{{operationIdCamelCase}}Request() {}
- void SetupHttpRequest(const TSharedRef& HttpRequest) const final;
+ void SetupHttpRequest(const FHttpRequestRef& HttpRequest) const final;
FString ComputePath() const final;
{{#allParams}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache
index 3d23a248cf9..07b557157ea 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache
@@ -23,7 +23,7 @@ inline FString ToString(const {{classname}}::{{operationIdCamelCase}}Request::{{
{
{{#enumVars}}
case {{classname}}::{{operationIdCamelCase}}Request::{{{enumName}}}::{{name}}:
- return TEXT({{{value}}});
+ return TEXT("{{{value}}}");
{{/enumVars}}
}
{{/allowableValues}}
@@ -49,7 +49,7 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, {{classname
if (JsonValue->TryGetString(TmpValue))
{
static TMap StringToEnum = { {{#enumVars}}
- { TEXT({{{value}}}), {{classname}}::{{operationIdCamelCase}}Request::{{{enumName}}}::{{name}} },{{/enumVars}} };
+ { TEXT("{{{value}}}"), {{classname}}::{{operationIdCamelCase}}Request::{{{enumName}}}::{{name}} },{{/enumVars}} };
const auto Found = StringToEnum.Find(TmpValue);
if(Found)
@@ -109,7 +109,7 @@ FString {{classname}}::{{operationIdCamelCase}}Request::ComputePath() const
return Path;
}
-void {{classname}}::{{operationIdCamelCase}}Request::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void {{classname}}::{{operationIdCamelCase}}Request::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { {{#consumes}}TEXT("{{{mediaType}}}"){{^-last}}, {{/-last}}{{/consumes}} };
//static const TArray Produces = { {{#produces}}TEXT("{{{mediaType}}}"){{^-last}}, {{/-last}}{{/produces}} };
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache
index fe5e177d736..8a9b3854544 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache
@@ -96,7 +96,7 @@ bool {{classname}}::{{operationIdCamelCase}}(const {{operationIdCamelCase}}Reque
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -106,15 +106,26 @@ bool {{classname}}::{{operationIdCamelCase}}(const {{operationIdCamelCase}}Reque
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &{{classname}}::On{{operationIdCamelCase}}Response, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &{{classname}}::On{{operationIdCamelCase}}Response, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void {{classname}}::On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate) const
+void {{classname}}::On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate, int AutoRetryCount) const
{
{{operationIdCamelCase}}Response Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &{{classname}}::On{{operationIdCamelCase}}Response, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
{{/operation}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache
index 1750a6f8e95..eb178e890af 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache
@@ -22,8 +22,8 @@ typedef TSharedRef> JsonWriter;
class {{dllapi}} HttpFileInput
{
public:
- HttpFileInput(const TCHAR* InFilePath);
- HttpFileInput(const FString& InFilePath);
+ explicit HttpFileInput(const TCHAR* InFilePath);
+ explicit HttpFileInput(const FString& InFilePath);
// This will automatically set the content type if not already set
void SetFilePath(const TCHAR* InFilePath);
@@ -53,7 +53,7 @@ class HttpMultipartFormData
{
public:
void SetBoundary(const TCHAR* InBoundary);
- void SetupHttpRequest(const TSharedRef& HttpRequest);
+ void SetupHttpRequest(const FHttpRequestRef& HttpRequest);
void AddStringPart(const TCHAR* Name, const TCHAR* Data);
void AddJsonPart(const TCHAR* Name, const FString& JsonString);
@@ -268,11 +268,15 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, FString& Va
return false;
}
+{{dllapi}} bool ParseDateTime(const FString& DateTimeString, FDateTime& OutDateTime);
+
inline bool TryGetJsonValue(const TSharedPtr& JsonValue, FDateTime& Value)
{
FString TmpValue;
if (JsonValue->TryGetString(TmpValue))
- return FDateTime::Parse(TmpValue, Value);
+ {
+ return ParseDateTime(TmpValue, Value);
+ }
else
return false;
}
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-source.mustache
index ea97911bbd9..b2dc14f3578 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-source.mustache
@@ -70,7 +70,7 @@ const FString& HttpMultipartFormData::GetBoundary() const
return Boundary;
}
-void HttpMultipartFormData::SetupHttpRequest(const TSharedRef& HttpRequest)
+void HttpMultipartFormData::SetupHttpRequest(const FHttpRequestRef& HttpRequest)
{
if(HttpRequest->GetVerb() != TEXT("POST"))
{
@@ -183,6 +183,44 @@ void HttpMultipartFormData::AppendString(const TCHAR* Str)
FormData.Append((uint8*)utf8Str.Get(), utf8Str.Length());
}
+//////////////////////////////////////////////////////////////////////////
+
+bool ParseDateTime(const FString& DateTimeString, FDateTime& OutDateTime)
+{
+ // Iso8601 Format: DateTime: YYYY-mm-ddTHH:MM:SS(.sss)(Z|+hh:mm|+hhmm|-hh:mm|-hhmm)
+ {
+ // We cannot call directly FDateTime::ParseIso8601 because it does not allow for precision beyond the millisecond, but DateTimeString might have more digits
+ int32 DotIndex;
+ FString StringToParse = DateTimeString;
+ if (DateTimeString.FindChar('.', DotIndex))
+ {
+ int32 TimeZoneIndex;
+ if (DateTimeString.FindChar('Z', TimeZoneIndex) || DateTimeString.FindChar('+', TimeZoneIndex) || DateTimeString.FindChar('-', TimeZoneIndex))
+ {
+ // The string contains a time zone designator starting at TimeZoneIndex
+ if (TimeZoneIndex > DotIndex + 4)
+ {
+ // Trim to millisecond
+ StringToParse = DateTimeString.Left(DotIndex + 4) + DateTimeString.RightChop(TimeZoneIndex);
+ }
+ }
+ else
+ {
+ // the string does not contain a time zone designator, trim it to the millisecond
+ StringToParse = DateTimeString.Left(DotIndex + 4);
+ }
+ }
+
+ if (FDateTime::ParseIso8601(*StringToParse, OutDateTime))
+ return true;
+ }
+
+ if (FDateTime::ParseHttpDate(DateTimeString, OutDateTime))
+ return true;
+
+ return FDateTime::Parse(DateTimeString, OutDateTime);
+}
+
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache
index 94edaaf4327..31b0bdabd26 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache
@@ -25,8 +25,14 @@ class {{dllapi}} Request
{
public:
virtual ~Request() {}
- virtual void SetupHttpRequest(const TSharedRef& HttpRequest) const = 0;
+ virtual void SetupHttpRequest(const FHttpRequestRef& HttpRequest) const = 0;
virtual FString ComputePath() const = 0;
+
+ void SetAutoRetryCount(int InCount) { AutoRetryCount = InCount; }
+ int GetAutoRetryCount() const { return AutoRetryCount; }
+
+private:
+ int AutoRetryCount = 0;
};
class {{dllapi}} Response
@@ -38,6 +44,8 @@ public:
void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; }
bool IsSuccessful() const { return Successful; }
+ void AsyncRetry() const;
+
virtual void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode);
EHttpResponseCodes::Type GetHttpResponseCode() const { return ResponseCode; }
@@ -47,11 +55,15 @@ public:
void SetHttpResponse(const FHttpResponsePtr& InHttpResponse) { HttpResponse = InHttpResponse; }
const FHttpResponsePtr& GetHttpResponse() const { return HttpResponse; }
+ void SetHttpRequest(const FHttpRequestPtr& InHttpRequest) { HttpRequest = InHttpRequest; }
+ const FHttpRequestPtr& GetHttpRequest() const { return HttpRequest; }
+
private:
bool Successful;
EHttpResponseCodes::Type ResponseCode;
FString ResponseString;
FHttpResponsePtr HttpResponse;
+ FHttpRequestPtr HttpRequest;
};
{{#cppNamespaceDeclarations}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache
index 12decd77211..a5ab70a432f 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache
@@ -1,6 +1,8 @@
{{>licenseInfo}}
#include "{{modelNamePrefix}}BaseModel.h"
+#include "Async/Async.h"
+
{{#cppNamespaceDeclarations}}
namespace {{this}}
{
@@ -16,6 +18,15 @@ void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
}
}
+void Response::AsyncRetry() const
+{
+ // Unfortunately, it is currently usafe to call ProcessRequest() directly here.
+ // This is because the HttpManager will remove all references to this HttpRequest in FHttpManager::Tick including the new request we just added, instead of removing just one.
+ // This will lead to the request's destruction and eventually a crash.
+ // The only solution is therefore to ensure we are taking an extra reference to the request, and that the request is added after the queue is flushed.
+ Async(EAsyncExecution::TaskGraph, [AddRef = FHttpRequestPtr(GetHttpRequest())](){ AddRef->ProcessRequest(); });
+}
+
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/model-source.mustache
index f26df2ec50f..d084f8a8033 100644
--- a/modules/openapi-generator/src/main/resources/cpp-ue4/model-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-ue4/model-source.mustache
@@ -19,7 +19,7 @@ inline FString ToString(const {{classname}}::Values& Value)
{
{{#enumVars}}
case {{classname}}::Values::{{name}}:
- return TEXT({{{value}}});
+ return TEXT("{{{value}}}");
{{/enumVars}}
}
{{/allowableValues}}
@@ -45,7 +45,7 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, {{classname
if (JsonValue->TryGetString(TmpValue))
{
static TMap StringToEnum = { {{#enumVars}}
- { TEXT({{{value}}}), {{classname}}::Values::{{name}} },{{/enumVars}} };
+ { TEXT("{{{value}}}"), {{classname}}::Values::{{name}} },{{/enumVars}} };
const auto Found = StringToEnum.Find(TmpValue);
if(Found)
@@ -69,7 +69,7 @@ inline FString ToString(const {{classname}}::{{{enumName}}}& Value)
{
{{#enumVars}}
case {{classname}}::{{{enumName}}}::{{name}}:
- return TEXT({{{value}}});
+ return TEXT("{{{value}}}");
{{/enumVars}}
}
{{/allowableValues}}
@@ -95,7 +95,7 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, {{classname
if (JsonValue->TryGetString(TmpValue))
{
static TMap StringToEnum = { {{#enumVars}}
- { TEXT({{{value}}}), {{classname}}::{{{enumName}}}::{{name}} },{{/enumVars}} };
+ { TEXT("{{{value}}}"), {{classname}}::{{{enumName}}}::{{name}} },{{/enumVars}} };
const auto Found = StringToEnum.Find(TmpValue);
if(Found)
diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache
index 3414ccaf8b3..6d0e25d93f4 100644
--- a/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache
@@ -331,25 +331,40 @@ namespace {{packageName}}.Client
if (options.Data != null)
{
- if (options.HeaderParameters != null)
+ if (options.Data is Stream stream)
{
- var contentTypes = options.HeaderParameters["Content-Type"];
- if (contentTypes == null || contentTypes.Any(header => header.Contains("application/json")))
+ var contentType = "application/octet-stream";
+ if (options.HeaderParameters != null)
{
- request.RequestFormat = DataFormat.Json;
- }
- else
- {
- // TODO: Generated client user should add additional handlers. RestSharp only supports XML and JSON, with XML as default.
+ var contentTypes = options.HeaderParameters["Content-Type"];
+ contentType = contentTypes[0];
}
+
+ var bytes = ClientUtils.ReadAsBytes(stream);
+ request.AddParameter(contentType, bytes, ParameterType.RequestBody);
}
else
{
- // Here, we'll assume JSON APIs are more common. XML can be forced by adding produces/consumes to openapi spec explicitly.
- request.RequestFormat = DataFormat.Json;
- }
+ if (options.HeaderParameters != null)
+ {
+ var contentTypes = options.HeaderParameters["Content-Type"];
+ if (contentTypes == null || contentTypes.Any(header => header.Contains("application/json")))
+ {
+ request.RequestFormat = DataFormat.Json;
+ }
+ else
+ {
+ // TODO: Generated client user should add additional handlers. RestSharp only supports XML and JSON, with XML as default.
+ }
+ }
+ else
+ {
+ // Here, we'll assume JSON APIs are more common. XML can be forced by adding produces/consumes to openapi spec explicitly.
+ request.RequestFormat = DataFormat.Json;
+ }
- request.AddJsonBody(options.Data);
+ request.AddJsonBody(options.Data);
+ }
}
if (options.FileParameters != null)
diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache
index 9c6b01d52ef..ad2ca7ce4b5 100644
--- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache
@@ -24,6 +24,7 @@ using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs;
using System.Net.Http;
{{/useWebRequest}}
using System.Net.Http;
+using System.Net.Http.Headers;
{{#supportsRetry}}
using Polly;
{{/supportsRetry}}
@@ -214,6 +215,32 @@ namespace {{packageName}}.Client
{{/reUseHttpClient}}
}
+ /// Prepares multipart/form-data content
+ {{! TODO: Add handling of improper usage }}
+ HttpContent PrepareMultipartFormDataContent(RequestOptions options)
+ {
+ string boundary = "---------" + Guid.NewGuid().ToString().ToUpperInvariant();
+ var multipartContent = new MultipartFormDataContent(boundary);
+ foreach (var formParameter in options.FormParameters)
+ {
+ multipartContent.Add(new StringContent(formParameter.Value), formParameter.Key);
+ }
+
+ if (options.FileParameters != null && options.FileParameters.Count > 0)
+ {
+ foreach (var fileParam in options.FileParameters)
+ {
+ var fileStream = fileParam.Value as FileStream;
+ var fileStreamName = fileStream != null ? System.IO.Path.GetFileName(fileStream.Name) : null;
+ var content = new StreamContent(fileParam.Value);
+ content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
+ multipartContent.Add(content, fileParam.Key,
+ fileStreamName ?? "no_file_name_provided");
+ }
+ }
+ return multipartContent;
+ }
+
///
/// Provides all logic for constructing a new HttpRequestMessage.
/// At this point, all information for querying the service is known. Here, it is simply
@@ -270,52 +297,45 @@ namespace {{packageName}}.Client
List> contentList = new List>();
- if (options.FormParameters != null && options.FormParameters.Count > 0)
+ string contentType = null;
+ if (options.HeaderParameters != null && options.HeaderParameters.ContainsKey("Content-Type"))
{
- contentList.Add(new Tuple(new FormUrlEncodedContent(options.FormParameters), null, null));
+ var contentTypes = options.HeaderParameters["Content-Type"];
+ contentType = contentTypes.FirstOrDefault();
}
- if (options.Data != null)
+ {{!// TODO Add error handling in case of improper usage}}
+ if (contentType == "multipart/form-data")
{
- var serializer = new CustomJsonCodec(SerializerSettings, configuration);
- contentList.Add(
- new Tuple(new StringContent(serializer.Serialize(options.Data), new UTF8Encoding(), "application/json"), null, null));
+ request.Content = PrepareMultipartFormDataContent(options);
}
-
- if (options.FileParameters != null && options.FileParameters.Count > 0)
+ else if (contentType == "application/x-www-form-urlencoded")
{
- foreach (var fileParam in options.FileParameters)
- {
- var bytes = ClientUtils.ReadAsBytes(fileParam.Value);
- var fileStream = fileParam.Value as FileStream;
- contentList.Add(new Tuple(new ByteArrayContent(bytes), fileParam.Key,
- fileStream?.Name ?? "no_file_name_provided"));
- }
- }
-
- if (contentList.Count > 1)
- {
- string boundary = "---------" + Guid.NewGuid().ToString().ToUpperInvariant();
- var multipartContent = new MultipartFormDataContent(boundary);
- foreach (var content in contentList)
- {
- if(content.Item2 != null)
- {
- multipartContent.Add(content.Item1, content.Item2, content.Item3);
- }
- else
- {
- multipartContent.Add(content.Item1);
- }
- }
-
- request.Content = multipartContent;
+ request.Content = new FormUrlEncodedContent(options.FormParameters);
}
else
{
- request.Content = contentList.FirstOrDefault()?.Item1;
+ if (options.Data != null)
+ {
+ if (options.Data is Stream s)
+ {
+ contentType ??= "application/octet-stream";
+
+ var streamContent = new StreamContent(s);
+ streamContent.Headers.ContentType = new MediaTypeHeaderValue(contentType);
+ request.Content = streamContent;
+ }
+ else
+ {
+ var serializer = new CustomJsonCodec(SerializerSettings, configuration);
+ request.Content = new StringContent(serializer.Serialize(options.Data), new UTF8Encoding(),
+ "application/json");
+ }
+ }
}
+
+
// TODO provide an alternative that allows cookies per request instead of per API client
if (options.Cookies != null && options.Cookies.Count > 0)
{
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/README.mustache b/modules/openapi-generator/src/main/resources/dart-dio/README.mustache
index 332b31f4ae9..0b375af727d 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/README.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/README.mustache
@@ -51,15 +51,15 @@ Please follow the [installation procedure](#installation--usage) and then run th
import 'package:{{pubName}}/api.dart';
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
-var api_instance = new {{classname}}();
+final api = {{classname}}();
{{#allParams}}
-var {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
+final {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
{{/allParams}}
try {
- {{#returnType}}var result = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
+ {{#returnType}}final response = await {{/returnType}}api.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
{{#returnType}}
- print(result);
+ print(response);
{{/returnType}}
} catch (e) {
print("Exception when calling {{classname}}->{{operationId}}: $e\n");
@@ -73,12 +73,12 @@ All URIs are relative to *{{basePath}}*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
-{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
## Documentation For Models
-{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md)
+{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
{{/model}}{{/models}}
## Documentation For Authorization
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/api.mustache b/modules/openapi-generator/src/main/resources/dart-dio/api.mustache
index 024883ad99a..38f4deb96f8 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/api.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/api.mustache
@@ -108,7 +108,7 @@ class {{classname}} {
{{#returnType}}
{{#isResponseFile}}
- final {{{returnType}}} _responseData = _response.data;
+ final {{{returnType}}} _responseData = _response.data as {{{returnType}}};
{{/isResponseFile}}
{{^isResponseFile}}
{{#returnSimpleType}}
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/api_doc.mustache b/modules/openapi-generator/src/main/resources/dart-dio/api_doc.mustache
index cbaa61b75dd..1e28b16012e 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/api_doc.mustache
@@ -10,7 +10,7 @@ All URIs are relative to *{{basePath}}*
Method | HTTP request | Description
------------- | ------------- | -------------
-{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}
{{#operations}}
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/api_test.mustache b/modules/openapi-generator/src/main/resources/dart-dio/api_test.mustache
index a89ed2d3995..f4dd8e65fad 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/api_test.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/api_test.mustache
@@ -1,3 +1,4 @@
+{{>header}}
import 'package:{{pubName}}/api.dart';
import 'package:{{pubName}}/api/{{classFilename}}.dart';
import 'package:test/test.dart';
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/auth/auth.mustache b/modules/openapi-generator/src/main/resources/dart-dio/auth/auth.mustache
index e6dbe70849d..d3a11dfa0c0 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/auth/auth.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/auth/auth.mustache
@@ -2,10 +2,9 @@
import 'package:dio/dio.dart';
abstract class AuthInterceptor extends Interceptor {
- /*
- * Get auth information on given route for the given type
- * Can return null if type is not present on auth data or if route doesn't need authentication
- */
+ /// Get auth information on given route for the given type.
+ /// Can return an empty list if type is not present on auth data or
+ /// if route doesn't need authentication.
List> getAuthInfo(RequestOptions route, String type) {
if (route.extra.containsKey('secure')) {
final auth = route.extra['secure'] as List>;
diff --git a/modules/openapi-generator/src/main/resources/dart-dio/model_test.mustache b/modules/openapi-generator/src/main/resources/dart-dio/model_test.mustache
index 73a2ef0b7a6..e9aab10347e 100644
--- a/modules/openapi-generator/src/main/resources/dart-dio/model_test.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-dio/model_test.mustache
@@ -1,3 +1,4 @@
+{{>header}}
{{#models}}
{{#model}}
import 'package:{{pubName}}/model/{{classFilename}}.dart';
diff --git a/modules/openapi-generator/src/main/resources/dart/analysis_options.mustache b/modules/openapi-generator/src/main/resources/dart/analysis_options.mustache
deleted file mode 100644
index 518eb901a6f..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/analysis_options.mustache
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/api.mustache b/modules/openapi-generator/src/main/resources/dart/api.mustache
deleted file mode 100644
index 443dd53fc90..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/api.mustache
+++ /dev/null
@@ -1,117 +0,0 @@
-part of {{pubName}}.api;
-
-{{#operations}}
-
-
-class {{classname}} {
- final ApiClient apiClient;
-
- {{classname}}([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
-
- {{#operation}}
- /// {{summary}}
- ///
- /// {{notes}}
- {{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
- Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
-
- // verify required params are set
- {{#allParams}}
- {{#required}}
- if({{paramName}} == null) {
- throw new ApiException(400, "Missing required param: {{paramName}}");
- }
- {{/required}}
- {{/allParams}}
-
- // create path and map variables
- String path = "{{{path}}}".replaceAll("{format}","json"){{#pathParams}}.replaceAll("{" + "{{baseName}}" + "}", {{{paramName}}}.toString()){{/pathParams}};
-
- // query params
- List queryParams = [];
- Map headerParams = {};
- Map formParams = {};
- {{#queryParams}}
- {{^required}}
- if({{paramName}} != null) {
- {{/required}}
- queryParams.addAll(_convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
- {{^required}}
- }
- {{/required}}
- {{/queryParams}}
- {{#headerParams}}
- headerParams["{{baseName}}"] = {{paramName}};
- {{/headerParams}}
-
- List contentTypes = [{{#consumes}}"{{{mediaType}}}"{{^-last}},{{/-last}}{{/consumes}}];
-
- String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
- List authNames = [{{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}}];
-
- if(contentType.startsWith("multipart/form-data")) {
- bool hasFields = false;
- MultipartRequest mp = new MultipartRequest(null, null);
- {{#formParams}}
- {{^isFile}}
- if ({{paramName}} != null) {
- hasFields = true;
- mp.fields['{{baseName}}'] = parameterToString({{paramName}});
- }
- {{/isFile}}
- {{#isFile}}
- if ({{paramName}} != null) {
- hasFields = true;
- mp.fields['{{baseName}}'] = {{paramName}}.field;
- mp.files.add({{paramName}});
- }
- {{/isFile}}
- {{/formParams}}
- if(hasFields)
- postBody = mp;
- }
- else {
- {{#formParams}}
- {{^isFile}}
- if ({{paramName}} != null)
- formParams['{{baseName}}'] = parameterToString({{paramName}});
- {{/isFile}}
- {{/formParams}}
- }
-
- var response = await apiClient.invokeAPI(path,
- '{{httpMethod}}',
- queryParams,
- postBody,
- headerParams,
- formParams,
- contentType,
- authNames);
-
- if(response.statusCode >= 400) {
- throw new ApiException(response.statusCode, _decodeBodyBytes(response));
- } else if(response.body != null) {
- {{#isArray}}
- {{#returnType}}
- return (apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as List).map((item) => item as {{returnBaseType}}).toList();
- {{/returnType}}
- {{/isArray}}
- {{^isArray}}
- {{#isMap}}
- {{#returnType}}
- return new {{{returnType}}}.from(apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}'));
- {{/returnType}};
- {{/isMap}}
- {{^isMap}}
- {{#returnType}}
- return apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as {{{returnType}}};
- {{/returnType}}
- {{/isMap}}
- {{/isArray}}
- } else {
- return{{#returnType}} null{{/returnType}};
- }
- }
- {{/operation}}
-}
-{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/dart/api_client.mustache b/modules/openapi-generator/src/main/resources/dart/api_client.mustache
deleted file mode 100644
index 9bb3d59bc52..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/api_client.mustache
+++ /dev/null
@@ -1,170 +0,0 @@
-part of {{pubName}}.api;
-
-class QueryParam {
- String name;
- String value;
-
- QueryParam(this.name, this.value);
-}
-
-class ApiClient {
-
- String basePath;
- var client = new Client();
-
- Map _defaultHeaderMap = {};
- Map _authentications = {};
-
- final _RegList = new RegExp(r'^List<(.*)>$');
- final _RegMap = new RegExp(r'^Map$');
-
- ApiClient({this.basePath: "{{{basePath}}}"}) {
- // Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}
- _authentications['{{name}}'] = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}}
- _authentications['{{name}}'] = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}}
- _authentications['{{name}}'] = new OAuth();{{/isOAuth}}{{/authMethods}}
- {{#httpUserAgent}}addDefaultHeader('User-Agent', '{{{.}}}');{{/httpUserAgent}}
- }
-
- void addDefaultHeader(String key, String value) {
- _defaultHeaderMap[key] = value;
- }
-
- dynamic _deserialize(dynamic value, String targetType) {
- try {
- switch (targetType) {
- case 'String':
- return '$value';
- case 'int':
- return value is int ? value : int.parse('$value');
- case 'bool':
- return value is bool ? value : '$value'.toLowerCase() == 'true';
- case 'double':
- return value is double ? value : double.parse('$value');
- {{#models}}
- {{#model}}
- case '{{classname}}':
- {{#isEnum}}
- // Enclose the value in a list so that Dartson can use a transformer
- // to decode it.
- final listValue = [value];
- final List listResult = dson.map(listValue, []);
- return listResult[0];
- {{/isEnum}}
- {{^isEnum}}
- return new {{classname}}.fromJson(value);
- {{/isEnum}}
- {{/model}}
- {{/models}}
- default:
- {
- Match match;
- if (value is List &&
- (match = _RegList.firstMatch(targetType)) != null) {
- var newTargetType = match[1];
- return value.map((v) => _deserialize(v, newTargetType)).toList();
- } else if (value is Map &&
- (match = _RegMap.firstMatch(targetType)) != null) {
- var newTargetType = match[1];
- return new Map.fromIterables(value.keys,
- value.values.map((v) => _deserialize(v, newTargetType)));
- }
- }
- }
- } catch (e, stack) {
- throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
- }
- throw new ApiException(500, 'Could not find a suitable class for deserialization');
- }
-
- dynamic deserialize(String json, String targetType) {
- // Remove all spaces. Necessary for reg expressions as well.
- targetType = targetType.replaceAll(' ', '');
-
- if (targetType == 'String') return json;
-
- var decodedJson = JSON.decode(json);
- return _deserialize(decodedJson, targetType);
- }
-
- String serialize(Object obj) {
- String serialized = '';
- if (obj == null) {
- serialized = '';
- } else {
- serialized = JSON.encode(obj);
- }
- return serialized;
- }
-
- // We don't use a Map for queryParams.
- // If collectionFormat is 'multi' a key might appear multiple times.
- Future invokeAPI(String path,
- String method,
- Iterable queryParams,
- Object body,
- Map headerParams,
- Map formParams,
- String contentType,
- List authNames) async {
-
- _updateParamsForAuth(authNames, queryParams, headerParams);
-
- var ps = queryParams
- .where((p) => p.value != null)
- .map((p) => '${p.name}=${Uri.encodeQueryComponent(p.value)}');
-
- String queryString = ps.isNotEmpty ?
- '?' + ps.join('&') :
- '';
-
- String url = basePath + path + queryString;
-
- headerParams.addAll(_defaultHeaderMap);
- headerParams['Content-Type'] = contentType;
-
- if(body is MultipartRequest) {
- var request = new MultipartRequest(method, Uri.parse(url));
- request.fields.addAll(body.fields);
- request.files.addAll(body.files);
- request.headers.addAll(body.headers);
- request.headers.addAll(headerParams);
- var response = await client.send(request);
- return Response.fromStream(response);
- } else {
- var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
- switch(method) {
- case "POST":
- return client.post(url, headers: headerParams, body: msgBody);
- case "PUT":
- return client.put(url, headers: headerParams, body: msgBody);
- case "DELETE":
- return client.delete(url, headers: headerParams);
- case "PATCH":
- return client.patch(url, headers: headerParams, body: msgBody);
- case "HEAD":
- return client.head(url, headers: headerParams);
- default:
- return client.get(url, headers: headerParams);
- }
- }
- }
-
- /// Update query and header parameters based on authentication settings.
- /// @param authNames The authentications to apply
- void _updateParamsForAuth(List authNames, List queryParams, Map headerParams) {
- authNames.forEach((authName) {
- Authentication auth = _authentications[authName];
- if (auth == null) throw new ArgumentError("Authentication undefined: " + authName);
- auth.applyToParams(queryParams, headerParams);
- });
- }
-
- void setAccessToken(String accessToken) {
- _authentications.forEach((key, auth) {
- if (auth is OAuth) {
- auth.setAccessToken(accessToken);
- }
- });
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/api_exception.mustache b/modules/openapi-generator/src/main/resources/dart/api_exception.mustache
deleted file mode 100644
index b86af8d954c..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/api_exception.mustache
+++ /dev/null
@@ -1,23 +0,0 @@
-part of {{pubName}}.api;
-
-class ApiException implements Exception {
- int code = 0;
- String message = null;
- Exception innerException = null;
- StackTrace stackTrace = null;
-
- ApiException(this.code, this.message);
-
- ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
-
- String toString() {
- if (message == null) return "ApiException";
-
- if (innerException == null) {
- return "ApiException $code: $message";
- }
-
- return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
- stackTrace.toString();
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/api_helper.mustache b/modules/openapi-generator/src/main/resources/dart/api_helper.mustache
deleted file mode 100644
index 73b2585b1b4..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/api_helper.mustache
+++ /dev/null
@@ -1,64 +0,0 @@
-part of {{pubName}}.api;
-
-const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
-
-// port from Java version
-Iterable _convertParametersForCollectionFormat(
- String collectionFormat, String name, dynamic value) {
- var params = [];
-
- // preconditions
- if (name == null || name.isEmpty || value == null) return params;
-
- if (value is! List) {
- params.add(new QueryParam(name, parameterToString(value)));
- return params;
- }
-
- List values = value as List;
-
- // get the collection format
- collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
- ? "csv"
- : collectionFormat; // default: csv
-
- if (collectionFormat == "multi") {
- return values.map((v) => new QueryParam(name, parameterToString(v)));
- }
-
- String delimiter = _delimiters[collectionFormat] ?? ",";
-
- params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
- return params;
-}
-
-/// Format the given parameter object into string.
-String parameterToString(dynamic value) {
- if (value == null) {
- return '';
- } else if (value is DateTime) {
- return value.toUtc().toIso8601String();
- {{#models}}
- {{#model}}
- {{#isEnum}}
- } else if (value is {{classname}}) {
- return new {{classname}}TypeTransformer().encode(value).toString();
- {{/isEnum}}
- {{/model}}
- {{/models}}
- } else {
- return value.toString();
- }
-}
-
-/// Returns the decoded body by utf-8 if application/json with the given headers.
-/// Else, returns the decoded body by default algorithm of dart:http.
-/// Because avoid to text garbling when header only contains "application/json" without "; charset=utf-8".
-String _decodeBodyBytes(Response response) {
- var contentType = response.headers['content-type'];
- if (contentType != null && contentType.contains("application/json")) {
- return utf8.decode(response.bodyBytes);
- } else {
- return response.body;
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/api_test.mustache b/modules/openapi-generator/src/main/resources/dart/api_test.mustache
deleted file mode 100644
index f5211efaff2..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/api_test.mustache
+++ /dev/null
@@ -1,28 +0,0 @@
-import 'package:{{pubName}}/api.dart';
-import 'package:test/test.dart';
-
-{{#operations}}
-
-/// tests for {{classname}}
-void main() {
- var instance = new {{classname}}();
-
- group('tests for {{classname}}', () {
- {{#operation}}
- {{#summary}}
- // {{{.}}}
- //
- {{/summary}}
- {{#notes}}
- // {{{.}}}
- //
- {{/notes}}
- //{{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async
- test('test {{operationId}}', () async {
- // TODO
- });
-
- {{/operation}}
- });
-}
-{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/dart/apilib.mustache b/modules/openapi-generator/src/main/resources/dart/apilib.mustache
deleted file mode 100644
index 4d210cee600..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/apilib.mustache
+++ /dev/null
@@ -1,20 +0,0 @@
-library {{pubName}}.api;
-
-import 'dart:async';
-import 'dart:convert';
-import 'package:http/http.dart';
-
-part 'api_client.dart';
-part 'api_helper.dart';
-part 'api_exception.dart';
-part 'auth/authentication.dart';
-part 'auth/api_key_auth.dart';
-part 'auth/oauth.dart';
-part 'auth/http_basic_auth.dart';
-
-{{#apiInfo}}{{#apis}}part 'api/{{classFilename}}.dart';
-{{/apis}}{{/apiInfo}}
-{{#models}}{{#model}}part 'model/{{classFilename}}.dart';
-{{/model}}{{/models}}
-
-ApiClient defaultApiClient = new ApiClient();
diff --git a/modules/openapi-generator/src/main/resources/dart/auth/api_key_auth.mustache b/modules/openapi-generator/src/main/resources/dart/auth/api_key_auth.mustache
deleted file mode 100644
index 86bde8a90f5..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/auth/api_key_auth.mustache
+++ /dev/null
@@ -1,27 +0,0 @@
-part of {{pubName}}.api;
-
-class ApiKeyAuth implements Authentication {
-
- final String location;
- final String paramName;
- String apiKey;
- String apiKeyPrefix;
-
- ApiKeyAuth(this.location, this.paramName);
-
- @override
- void applyToParams(List queryParams, Map headerParams) {
- String value;
- if (apiKeyPrefix != null) {
- value = '$apiKeyPrefix $apiKey';
- } else {
- value = apiKey;
- }
-
- if (location == 'query' && value != null) {
- queryParams.add(new QueryParam(paramName, value));
- } else if (location == 'header' && value != null) {
- headerParams[paramName] = value;
- }
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/auth/authentication.mustache b/modules/openapi-generator/src/main/resources/dart/auth/authentication.mustache
deleted file mode 100644
index 40540bac530..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/auth/authentication.mustache
+++ /dev/null
@@ -1,7 +0,0 @@
-part of {{pubName}}.api;
-
-abstract class Authentication {
-
- /// Apply authentication settings to header and query params.
- void applyToParams(List queryParams, Map headerParams);
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/auth/http_basic_auth.mustache b/modules/openapi-generator/src/main/resources/dart/auth/http_basic_auth.mustache
deleted file mode 100644
index 4fbcb2321b6..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/auth/http_basic_auth.mustache
+++ /dev/null
@@ -1,14 +0,0 @@
-part of {{pubName}}.api;
-
-class HttpBasicAuth implements Authentication {
-
- String username;
- String password;
-
- @override
- void applyToParams(List queryParams, Map headerParams) {
- String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
- headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str));
- }
-
-}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/auth/oauth.mustache b/modules/openapi-generator/src/main/resources/dart/auth/oauth.mustache
deleted file mode 100644
index 5b96ecc9d7a..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/auth/oauth.mustache
+++ /dev/null
@@ -1,19 +0,0 @@
-part of {{pubName}}.api;
-
-class OAuth implements Authentication {
- String accessToken;
-
- OAuth({this.accessToken}) {
- }
-
- @override
- void applyToParams(List queryParams, Map headerParams) {
- if (accessToken != null) {
- headerParams["Authorization"] = "Bearer " + accessToken;
- }
- }
-
- void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/class.mustache b/modules/openapi-generator/src/main/resources/dart/class.mustache
deleted file mode 100644
index e2a99a92a5c..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/class.mustache
+++ /dev/null
@@ -1,96 +0,0 @@
-class {{classname}} {
- {{#vars}}
- {{#description}}/* {{{description}}} */{{/description}}
- {{^defaultValue}}{{{dataType}}} {{name}} = null;{{/defaultValue}}{{#defaultValue}}{{{dataType}}} {{name}} = {{defaultValue}};{{/defaultValue}}
- {{#allowableValues}}
- {{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
- {{/allowableValues}}
- {{/vars}}
- {{classname}}();
-
- @override
- String toString() {
- return '{{classname}}[{{#vars}}{{name}}=${{name}}, {{/vars}}]';
- }
-
- {{classname}}.fromJson(Map json) {
- if (json == null) return;
- {{#vars}}
- if (json['{{baseName}}'] == null) {
- {{name}} = null;
- } else {
- {{#isDateTime}}
- {{name}} = DateTime.parse(json['{{baseName}}']);
- {{/isDateTime}}
- {{#isDate}}
- {{name}} = DateTime.parse(json['{{baseName}}']);
- {{/isDate}}
- {{^isDateTime}}
- {{^isDate}}
- {{#complexType}}
- {{#isArray}}
- {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']);
- {{/isArray}}
- {{^isArray}}
- {{#isMap}}
- {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
- {{/isMap}}
- {{^isMap}}
- {{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
- {{/isMap}}
- {{/isArray}}
- {{/complexType}}
- {{^complexType}}
- {{#isArray}}
- {{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList();
- {{/isArray}}
- {{^isArray}}
- {{name}} = json['{{baseName}}'];
- {{/isArray}}
- {{/complexType}}
- {{/isDate}}
- {{/isDateTime}}
- }
- {{/vars}}
- }
-
- Map toJson() {
- return {
- {{#vars}}
- {{#isDateTime}}
- '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}
- {{/isDateTime}}
- {{#isDate}}
- '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}
- {{/isDate}}
- {{^isDateTime}}
- {{^isDate}}
- {{#complexType}}
- {{#isArray}}
- '{{baseName}}': {{name}} == null ? null : {{name}}.map((item) => item.toJson()).toList(){{^-last}},{{/-last}}
- {{/isArray}}
- {{^isArray}}
- '{{baseName}}': {{name}} == null ? null : {{name}}.toJson(){{^-last}},{{/-last}}
- {{/isArray}}
- {{/complexType}}
- {{^complexType}}
- '{{baseName}}': {{name}}{{^-last}},{{/-last}}
- {{/complexType}}
- {{/isDate}}
- {{/isDateTime}}
- {{/vars}}
- };
- }
-
- static List<{{classname}}> listFromJson(List json) {
- return json == null ? new List<{{classname}}>() : json.map((value) => new {{classname}}.fromJson(value)).toList();
- }
-
- static Map mapFromJson(Map> json) {
- var map = new Map();
- if (json != null && json.length > 0) {
- json.forEach((String key, Map value) => map[key] = new {{classname}}.fromJson(value));
- }
- return map;
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/enum.mustache b/modules/openapi-generator/src/main/resources/dart/enum.mustache
deleted file mode 100644
index d4a4d2b8d11..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/enum.mustache
+++ /dev/null
@@ -1,36 +0,0 @@
-@Entity()
-class {{classname}} {
- /// The underlying value of this enum member.
- final {{dataType}} value;
-
- const {{classname}}._internal(this.value);
-
- {{#allowableValues}}
- {{#enumVars}}
- {{#description}}
- /// {{description}}
- {{/description}}
- static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
- {{/enumVars}}
- {{/allowableValues}}
-}
-
-class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
-
- @override
- dynamic encode({{classname}} data) {
- return data.value;
- }
-
- @override
- {{classname}} decode(dynamic data) {
- switch (data) {
- {{#allowableValues}}
- {{#enumVars}}
- case {{{value}}}: return {{classname}}.{{{name}}};
- {{/enumVars}}
- {{/allowableValues}}
- default: throw('Unknown enum value to decode: $data');
- }
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/dart/git_push.sh.mustache
deleted file mode 100755
index 8b3f689c912..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/git_push.sh.mustache
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/sh
-# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
-#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
-
-git_user_id=$1
-git_repo_id=$2
-release_note=$3
-git_host=$4
-
-if [ "$git_host" = "" ]; then
- git_host="{{{gitHost}}}"
- echo "[INFO] No command line input provided. Set \$git_host to $git_host"
-fi
-
-if [ "$git_user_id" = "" ]; then
- git_user_id="{{{gitUserId}}}"
- echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
-fi
-
-if [ "$git_repo_id" = "" ]; then
- git_repo_id="{{{gitRepoId}}}"
- echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
-fi
-
-if [ "$release_note" = "" ]; then
- release_note="{{{releaseNote}}}"
- echo "[INFO] No command line input provided. Set \$release_note to $release_note"
-fi
-
-# Initialize the local directory as a Git repository
-git init
-
-# Adds the files in the local repository and stages them for commit.
-git add .
-
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
-git commit -m "$release_note"
-
-# Sets the new remote
-git_remote=`git remote`
-if [ "$git_remote" = "" ]; then # git remote not defined
-
- if [ "$GIT_TOKEN" = "" ]; then
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
- else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
- fi
-
-fi
-
-git pull origin master
-
-# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
-git push origin master 2>&1 | grep -v 'To https'
-
diff --git a/modules/openapi-generator/src/main/resources/dart/README.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/README.mustache
similarity index 62%
rename from modules/openapi-generator/src/main/resources/dart/README.mustache
rename to modules/openapi-generator/src/main/resources/dart/libraries/dio/README.mustache
index 18a67483913..454bd6ccdb9 100644
--- a/modules/openapi-generator/src/main/resources/dart/README.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/README.mustache
@@ -1,4 +1,4 @@
-# {{pubName}}
+# {{pubName}} (EXPERIMENTAL)
{{#appDescriptionWithNewLines}}
{{{appDescriptionWithNewLines}}}
{{/appDescriptionWithNewLines}}
@@ -19,7 +19,9 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Requirements
-Dart 1.20.0 or later OR Flutter 0.0.20 or later
+* Dart 2.12.0 or later OR Flutter 1.26.0 or later
+* Dio 4.0.0+
+* timemachine option currently **DOES NOT** support sound null-safety and may not work
## Installation & Usage
@@ -31,7 +33,7 @@ version: {{pubVersion}}
description: {{pubDescription}}
dependencies:
{{pubName}}:
- git: https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git
+ git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git
version: 'any'
```
@@ -43,48 +45,25 @@ dependencies:
path: /path/to/{{pubName}}
```
-## Tests
-
-TODO
-
## Getting Started
Please follow the [installation procedure](#installation--usage) and then run the following:
```dart
-import 'package:{{pubName}}/api.dart';
+import 'package:{{pubName}}/{{pubName}}.dart';
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
-{{#hasAuthMethods}}
-{{#authMethods}}
-{{#isBasic}}
-// TODO Configure HTTP basic authorization: {{{name}}}
-//{{pubName}}.api.Configuration.username = 'YOUR_USERNAME';
-//{{pubName}}.api.Configuration.password = 'YOUR_PASSWORD';
-{{/isBasic}}
-{{#isApiKey}}
-// TODO Configure API key authorization: {{{name}}}
-//{{pubName}}.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
-// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
-//{{pubName}}.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer";
-{{/isApiKey}}
-{{#isOAuth}}
-// TODO Configure OAuth2 access token for authorization: {{{name}}}
-//{{pubName}}.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
-{{/isOAuth}}
-{{/authMethods}}
-{{/hasAuthMethods}}
-var api_instance = new {{classname}}();
+final api = {{classname}}();
{{#allParams}}
-var {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
+final {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
{{/allParams}}
try {
- {{#returnType}}var result = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
+ {{#returnType}}final response = await {{/returnType}}api.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
{{#returnType}}
- print(result);
+ print(response);
{{/returnType}}
-} catch (e) {
+} catch on DioError (e) {
print("Exception when calling {{classname}}->{{operationId}}: $e\n");
}
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
@@ -96,12 +75,12 @@ All URIs are relative to *{{basePath}}*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
-{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
## Documentation For Models
-{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md)
+{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
{{/model}}{{/models}}
## Documentation For Authorization
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/analysis_options.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/analysis_options.mustache
new file mode 100644
index 00000000000..a611887d3ac
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/analysis_options.mustache
@@ -0,0 +1,9 @@
+analyzer:
+ language:
+ strict-inference: true
+ strict-raw-types: true
+ strong-mode:
+ implicit-dynamic: false
+ implicit-casts: false
+ exclude:
+ - test/*.dart
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache
new file mode 100644
index 00000000000..8deca6ce000
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache
@@ -0,0 +1,136 @@
+{{>header}}
+import 'dart:async';
+
+{{#useBuiltValue}}import 'package:built_value/serializer.dart';{{/useBuiltValue}}
+import 'package:dio/dio.dart';
+
+{{#operations}}
+{{#modelImports}}import 'package:{{pubName}}/src/model/{{.}}.dart';
+{{/modelImports}}
+{{#fullImports}}import '{{.}}';
+{{/fullImports}}
+
+class {{classname}} {
+
+ final Dio _dio;
+ {{#useBuiltValue}}
+
+ final Serializers _serializers;
+
+ {{/useBuiltValue}}
+ const {{classname}}(this._dio{{#useBuiltValue}}, this._serializers{{/useBuiltValue}});
+
+ {{#operation}}
+ /// {{{summary}}}
+ ///
+ /// {{{notes}}}
+ Future> {{nickname}}({ {{#allParams}}{{#isPathParam}}
+ required {{{dataType}}} {{paramName}},{{/isPathParam}}{{#isQueryParam}}
+ {{#required}}required {{/required}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}},{{/isQueryParam}}{{#isHeaderParam}}
+ {{#required}}required {{/required}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}},{{/isHeaderParam}}{{#isBodyParam}}
+ {{#required}}required {{/required}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}},{{/isBodyParam}}{{#isFormParam}}
+ {{#required}}required {{/required}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}},{{/isFormParam}}{{/allParams}}
+ CancelToken? cancelToken,
+ Map? headers,
+ Map? extra,
+ ValidateStatus? validateStatus,
+ ProgressCallback? onSendProgress,
+ ProgressCallback? onReceiveProgress,
+ }) async {
+ final _path = r'{{{path}}}'{{#pathParams}}.replaceAll('{' r'{{{baseName}}}' '}', {{{paramName}}}.toString()){{/pathParams}};
+ final _options = Options(
+ method: r'{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}',
+ {{#isResponseFile}}
+ responseType: ResponseType.bytes,
+ {{/isResponseFile}}
+ headers: {
+ {{#httpUserAgent}}
+ r'User-Agent': r'{{{.}}}',
+ {{/httpUserAgent}}
+ {{#headerParams}}
+ {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{baseName}}': {{paramName}},
+ {{/headerParams}}
+ ...?headers,
+ },
+ extra: {
+ 'secure': >[{{^hasAuthMethods}}],{{/hasAuthMethods}}{{#hasAuthMethods}}
+ {{#authMethods}}{
+ 'type': '{{type}}',
+ 'name': '{{name}}',{{#isApiKey}}
+ 'keyName': '{{keyParamName}}',
+ 'where': '{{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}',{{/isApiKey}}
+ },{{/authMethods}}
+ ],{{/hasAuthMethods}}
+ ...?extra,
+ },
+ contentType: [{{^hasConsumes}}
+ 'application/json',{{/hasConsumes}}{{#hasConsumes}}{{#consumes}}
+ '{{{mediaType}}}',{{/consumes}}{{/hasConsumes}}
+ ].first,
+ validateStatus: validateStatus,
+ );
+
+ final _queryParameters = {
+ {{#queryParams}}
+ {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{baseName}}': {{paramName}},
+ {{/queryParams}}
+ };
+ {{#hasBodyOrFormParams}}
+
+ dynamic _bodyData;
+
+ try {
+{{#useBuiltValue}}{{>serialization/built_value/serialize}}{{/useBuiltValue}}
+ } catch(error) {
+ throw DioError(
+ requestOptions: _options.compose(
+ _dio.options,
+ _path,
+ queryParameters: _queryParameters,
+ ),
+ type: DioErrorType.other,
+ error: error,
+ );
+ }
+ {{/hasBodyOrFormParams}}
+
+ final _response = await _dio.request(
+ _path,{{#hasBodyOrFormParams}}
+ data: _bodyData,{{/hasBodyOrFormParams}}
+ options: _options,
+ queryParameters: _queryParameters,
+ cancelToken: cancelToken,
+ onSendProgress: onSendProgress,
+ onReceiveProgress: onReceiveProgress,
+ );
+ {{#returnType}}
+
+ {{{returnType}}} _responseData;
+
+ try {
+{{#useBuiltValue}}{{>serialization/built_value/deserialize}}{{/useBuiltValue}}
+ } catch (error) {
+ throw DioError(
+ requestOptions: _response.requestOptions,
+ response: _response,
+ type: DioErrorType.other,
+ error: error,
+ );
+ }
+
+ return Response<{{{returnType}}}>(
+ data: _responseData,
+ headers: _response.headers,
+ isRedirect: _response.isRedirect,
+ requestOptions: _response.requestOptions,
+ redirects: _response.redirects,
+ statusCode: _response.statusCode,
+ statusMessage: _response.statusMessage,
+ extra: _response.extra,
+ );{{/returnType}}{{^returnType}}
+ return _response;{{/returnType}}
+ }
+
+ {{/operation}}
+}
+{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_client.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_client.mustache
new file mode 100644
index 00000000000..2c2fd45de88
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_client.mustache
@@ -0,0 +1,64 @@
+{{>header}}
+import 'package:dio/dio.dart';{{#useBuiltValue}}
+import 'package:built_value/serializer.dart';
+import 'package:{{pubName}}/src/serializers.dart';{{/useBuiltValue}}
+import 'package:{{pubName}}/src/auth/api_key_auth.dart';
+import 'package:{{pubName}}/src/auth/basic_auth.dart';
+import 'package:{{pubName}}/src/auth/oauth.dart';
+{{#apiInfo}}{{#apis}}import 'package:{{pubName}}/src/api/{{classFilename}}.dart';
+{{/apis}}{{/apiInfo}}
+class {{clientName}} {
+ static const String basePath = r'{{{basePath}}}';
+
+ final Dio dio;
+{{#useBuiltValue}}
+ final Serializers serializers;
+
+{{/useBuiltValue}}
+ {{clientName}}({
+ Dio? dio,{{#useBuiltValue}}
+ Serializers? serializers,{{/useBuiltValue}}
+ String? basePathOverride,
+ List? interceptors,
+ }) : {{#useBuiltValue}}this.serializers = serializers ?? standardSerializers,{{/useBuiltValue}}
+ this.dio = dio ??
+ Dio(BaseOptions(
+ baseUrl: basePathOverride ?? basePath,
+ connectTimeout: 5000,
+ receiveTimeout: 3000,
+ )) {
+ if (interceptors == null) {
+ this.dio.interceptors.addAll([
+ OAuthInterceptor(),
+ BasicAuthInterceptor(),
+ ApiKeyAuthInterceptor(),
+ ]);
+ } else {
+ this.dio.interceptors.addAll(interceptors);
+ }
+ }
+
+ void setOAuthToken(String name, String token) {
+ if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) {
+ (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens[name] = token;
+ }
+ }
+
+ void setBasicAuth(String name, String username, String password) {
+ if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) {
+ (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
+ }
+ }
+
+ void setApiKey(String name, String apiKey) {
+ if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) {
+ (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
+ }
+ }{{#apiInfo}}{{#apis}}
+
+ /// Get {{classname}} instance, base route and serializer can be overridden by a given but be careful,
+ /// by doing that all interceptors will not be executed
+ {{classname}} get{{classname}}() {
+ return {{classname}}(dio{{#useBuiltValue}}, serializers{{/useBuiltValue}});
+ }{{/apis}}{{/apiInfo}}
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/api_doc.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_doc.mustache
similarity index 70%
rename from modules/openapi-generator/src/main/resources/dart/api_doc.mustache
rename to modules/openapi-generator/src/main/resources/dart/libraries/dio/api_doc.mustache
index 0ebccc31c4f..1e28b16012e 100644
--- a/modules/openapi-generator/src/main/resources/dart/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_doc.mustache
@@ -10,7 +10,7 @@ All URIs are relative to *{{basePath}}*
Method | HTTP request | Description
------------- | ------------- | -------------
-{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}
{{#operations}}
@@ -29,25 +29,25 @@ import 'package:{{pubName}}/api.dart';
{{#authMethods}}
{{#isBasic}}
// TODO Configure HTTP basic authorization: {{{name}}}
-//{{pubName}}.api.Configuration.username = 'YOUR_USERNAME';
-//{{pubName}}.api.Configuration.password = 'YOUR_PASSWORD';
+//defaultApiClient.getAuthentication('{{{name}}}').username = 'YOUR_USERNAME'
+//defaultApiClient.getAuthentication('{{{name}}}').password = 'YOUR_PASSWORD';
{{/isBasic}}
{{#isApiKey}}
// TODO Configure API key authorization: {{{name}}}
-//{{pubName}}.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
+//defaultApiClient.getAuthentication('{{{name}}}').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
-//{{pubName}}.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer";
+//defaultApiClient.getAuthentication('{{{name}}}').apiKeyPrefix = 'Bearer';
{{/isApiKey}}
{{#isOAuth}}
// TODO Configure OAuth2 access token for authorization: {{{name}}}
-//{{pubName}}.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
+//defaultApiClient.getAuthentication('{{{name}}}').accessToken = 'YOUR_ACCESS_TOKEN';
{{/isOAuth}}
{{/authMethods}}
{{/hasAuthMethods}}
var api_instance = new {{classname}}();
{{#allParams}}
-var {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
+var {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}new {{{dataType}}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
{{/allParams}}
try {
@@ -56,7 +56,7 @@ try {
print(result);
{{/returnType}}
} catch (e) {
- print("Exception when calling {{classname}}->{{operationId}}: $e\n");
+ print('Exception when calling {{classname}}->{{operationId}}: $e\n');
}
```
@@ -64,7 +64,7 @@ try {
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
-{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
+{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{baseType}}.md){{/isPrimitiveType}}| {{{description}}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{{defaultValue}}}]{{/defaultValue}}
{{/allParams}}
### Return type
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_test.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_test.mustache
new file mode 100644
index 00000000000..056920d91aa
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_test.mustache
@@ -0,0 +1,28 @@
+import 'package:test/test.dart';
+import 'package:{{pubName}}/{{pubName}}.dart';
+
+{{#operations}}
+
+/// tests for {{{classname}}}
+void main() {
+ final instance = {{{clientName}}}().get{{{classname}}}();
+
+ group({{{classname}}}, () {
+ {{#operation}}
+ {{#summary}}
+ // {{{.}}}
+ //
+ {{/summary}}
+ {{#notes}}
+ // {{{.}}}
+ //
+ {{/notes}}
+ //{{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async
+ test('test {{{operationId}}}', () async {
+ // TODO
+ });
+
+ {{/operation}}
+ });
+}
+{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_util.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_util.mustache
new file mode 100644
index 00000000000..4cdc6bcea3c
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_util.mustache
@@ -0,0 +1,28 @@
+{{>header}}
+import 'dart:convert';
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+
+/// Format the given form parameter object into something that Dio can handle.
+/// Returns primitive or String.
+/// Returns List/Map if the value is BuildList/BuiltMap.
+dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
+ if (value == null) {
+ return '';
+ }
+ if (value is String || value is num || value is bool) {
+ return value;
+ }
+ final serialized = serializers.serialize(
+ value as Object,
+ specifiedType: type,
+ );
+ if (serialized is String) {
+ return serialized;
+ }
+ if (value is BuiltList || value is BuiltMap) {
+ return serialized;
+ }
+ return json.encode(serialized);
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/api_key_auth.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/api_key_auth.mustache
new file mode 100644
index 00000000000..7e57fd9ac92
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/api_key_auth.mustache
@@ -0,0 +1,27 @@
+{{>header}}
+
+import 'package:dio/dio.dart';
+import 'package:{{pubName}}/src/auth/auth.dart';
+
+class ApiKeyAuthInterceptor extends AuthInterceptor {
+ final Map apiKeys = {};
+
+ @override
+ void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
+ final authInfo = getAuthInfo(options, 'apiKey');
+ for (final info in authInfo) {
+ final authName = info['name'] as String;
+ final authKeyName = info['keyName'] as String;
+ final authWhere = info['where'] as String;
+ final apiKey = apiKeys[authName];
+ if (apiKey != null) {
+ if (authWhere == 'query') {
+ options.queryParameters[authKeyName] = apiKey;
+ } else {
+ options.headers[authKeyName] = apiKey;
+ }
+ }
+ }
+ super.onRequest(options, handler);
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/auth.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/auth.mustache
new file mode 100644
index 00000000000..7bce19a475a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/auth.mustache
@@ -0,0 +1,21 @@
+{{>header}}
+import 'package:dio/dio.dart';
+
+abstract class AuthInterceptor extends Interceptor {
+ /// Get auth information on given route for the given type.
+ /// Can return an empty list if type is not present on auth data or
+ /// if route doesn't need authentication.
+ List> getAuthInfo(RequestOptions route, String type) {
+ if (route.extra.containsKey('secure')) {
+ final auth = route.extra['secure'] as List>;
+ final results = >[];
+ for (final info in auth) {
+ if (info['type'] == type) {
+ results.add(info);
+ }
+ }
+ return results;
+ }
+ return [];
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/basic_auth.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/basic_auth.mustache
new file mode 100644
index 00000000000..f33e259647b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/basic_auth.mustache
@@ -0,0 +1,34 @@
+{{>header}}
+import 'dart:convert';
+
+import 'package:dio/dio.dart';
+import 'package:{{pubName}}/src/auth/auth.dart';
+
+class BasicAuthInfo {
+ final String username;
+ final String password;
+
+ const BasicAuthInfo(this.username, this.password);
+}
+
+class BasicAuthInterceptor extends AuthInterceptor {
+ final Map authInfo = {};
+
+ @override
+ void onRequest(
+ RequestOptions options,
+ RequestInterceptorHandler handler,
+ ) {
+ final metadataAuthInfo = getAuthInfo(options, 'basic');
+ for (final info in metadataAuthInfo) {
+ final authName = info['name'] as String;
+ final basicAuthInfo = authInfo[authName];
+ if (basicAuthInfo != null) {
+ final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}';
+ options.headers['Authorization'] = basicAuth;
+ break;
+ }
+ }
+ super.onRequest(options, handler);
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/oauth.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/oauth.mustache
new file mode 100644
index 00000000000..0f92cdba98c
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/oauth.mustache
@@ -0,0 +1,23 @@
+{{>header}}
+import 'package:dio/dio.dart';
+import 'package:{{pubName}}/src/auth/auth.dart';
+
+class OAuthInterceptor extends AuthInterceptor {
+ final Map tokens = {};
+
+ @override
+ void onRequest(
+ RequestOptions options,
+ RequestInterceptorHandler handler,
+ ) {
+ final authInfo = getAuthInfo(options, 'oauth');
+ for (final info in authInfo) {
+ final token = tokens[info['name']];
+ if (token != null) {
+ options.headers['Authorization'] = 'Bearer ${token}';
+ break;
+ }
+ }
+ super.onRequest(options, handler);
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/class.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/class.mustache
new file mode 100644
index 00000000000..da5ecb73525
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/class.mustache
@@ -0,0 +1 @@
+{{#useBuiltValue}}{{>serialization/built_value/class}}{{/useBuiltValue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/enum.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/enum.mustache
new file mode 100644
index 00000000000..6c20417e356
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/enum.mustache
@@ -0,0 +1 @@
+{{#useBuiltValue}}{{>serialization/built_value/enum}}{{/useBuiltValue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/gitignore.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/gitignore.mustache
similarity index 59%
rename from modules/openapi-generator/src/main/resources/dart/gitignore.mustache
rename to modules/openapi-generator/src/main/resources/dart/libraries/dio/gitignore.mustache
index 7c280441649..8092a49d515 100644
--- a/modules/openapi-generator/src/main/resources/dart/gitignore.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/gitignore.mustache
@@ -1,6 +1,7 @@
-# See https://www.dartlang.org/tools/private-files.html
+# See https://dart.dev/guides/libraries/private-files
# Files and directories created by pub
+.dart_tool/
.buildlog
.packages
.project
@@ -25,3 +26,12 @@ doc/api/
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
pubspec.lock
+
+# Don’t commit files and directories created by other development environments.
+# For example, if your development environment creates any of the following files,
+# consider putting them in a global ignore file:
+*.iml // IntelliJ
+*.ipr // IntelliJ
+*.iws // IntelliJ
+.idea/ // IntelliJ
+.DS_Store // Mac
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/header.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/header.mustache
new file mode 100644
index 00000000000..32c88287e5c
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/header.mustache
@@ -0,0 +1,3 @@
+//
+// AUTO-GENERATED FILE, DO NOT MODIFY!
+//
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/lib.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/lib.mustache
new file mode 100644
index 00000000000..ff543662653
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/lib.mustache
@@ -0,0 +1,11 @@
+{{>header}}
+export 'package:{{pubName}}/src/api.dart';
+export 'package:{{pubName}}/src/auth/api_key_auth.dart';
+export 'package:{{pubName}}/src/auth/basic_auth.dart';
+export 'package:{{pubName}}/src/auth/oauth.dart';
+{{#useBuiltValue}}export 'package:{{pubName}}/src/serializers.dart';{{/useBuiltValue}}
+
+{{#apiInfo}}{{#apis}}export 'package:{{pubName}}/src/api/{{classFilename}}.dart';
+{{/apis}}{{/apiInfo}}
+{{#models}}{{#model}}export 'package:{{pubName}}/src/model/{{classFilename}}.dart';
+{{/model}}{{/models}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/model.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/model.mustache
new file mode 100644
index 00000000000..5fdbb1b77c8
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/model.mustache
@@ -0,0 +1,9 @@
+{{>header}}
+{{#models}}
+ {{#model}}
+ {{#imports}}
+import '{{.}}';
+ {{/imports}}
+{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}{{>class}}{{/isEnum}}
+ {{/model}}
+{{/models}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/model_test.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/model_test.mustache
new file mode 100644
index 00000000000..eaa57022a41
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/model_test.mustache
@@ -0,0 +1,28 @@
+{{#models}}
+{{#model}}
+import 'package:test/test.dart';
+import 'package:{{pubName}}/{{pubName}}.dart';
+
+// tests for {{{classname}}}
+void main() {
+ {{^isEnum}}
+ {{! Due to required vars without default value we can not create a full instance here }}
+ final instance = {{{classname}}}Builder();
+ // TODO add properties to the builder and call build()
+ {{/isEnum}}
+
+ group({{{classname}}}, () {
+ {{#vars}}
+ {{#description}}
+ // {{{description}}}
+ {{/description}}
+ // {{{dataType}}} {{{name}}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
+ test('to test the property `{{{name}}}`', () async {
+ // TODO
+ });
+
+ {{/vars}}
+ });
+}
+{{/model}}
+{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/dart/object_doc.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/object_doc.mustache
similarity index 57%
rename from modules/openapi-generator/src/main/resources/dart/object_doc.mustache
rename to modules/openapi-generator/src/main/resources/dart/libraries/dio/object_doc.mustache
index 742952fef63..f2a52db11a4 100644
--- a/modules/openapi-generator/src/main/resources/dart/object_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/object_doc.mustache
@@ -8,7 +8,7 @@ import 'package:{{pubName}}/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
+{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{{description}}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{defaultValue}}}]{{/defaultValue}}
{{/vars}}
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache
new file mode 100644
index 00000000000..55234533fd0
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache
@@ -0,0 +1,23 @@
+name: {{pubName}}
+version: {{pubVersion}}
+description: {{pubDescription}}
+
+environment:
+ sdk: '>=2.12.0 <3.0.0'
+
+dependencies:
+ dio: '4.0.0-prev2'
+{{#useBuiltValue}}
+ built_value: '>=8.0.3 <9.0.0'
+ built_collection: '>=5.0.0 <6.0.0'
+{{/useBuiltValue}}
+{{#useDateLibTimeMachine}}
+ time_machine: ^0.9.16
+{{/useDateLibTimeMachine}}
+
+dev_dependencies:
+{{#useBuiltValue}}
+ built_value_generator: '>=8.0.3 <9.0.0'
+ build_runner: any
+{{/useBuiltValue}}
+ test: '>=1.16.0 <1.17.0'
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache
new file mode 100644
index 00000000000..f359b8d5a91
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache
@@ -0,0 +1,127 @@
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part '{{classFilename}}.g.dart';
+
+{{!
+ Classes with polymorphism or composition may generate unused imports,
+ these need to be ignored for said classes so that there are no lint errors.
+}}
+{{#parentModel}}// ignore_for_file: unused_import{{/parentModel}}
+
+abstract class {{classname}} implements Built<{{classname}}, {{classname}}Builder> {
+{{#vars}}
+ {{#description}}
+ /// {{{description}}}
+ {{/description}}
+ @BuiltValueField(wireName: r'{{baseName}}')
+ {{{datatypeWithEnum}}}{{#isNullable}}?{{/isNullable}}{{^isNullable}}{{^required}}?{{/required}}{{/isNullable}} get {{name}};
+ {{#allowableValues}}
+ // {{#min}}range from {{{min}}} to {{{max}}}{{/min}}{{^min}}enum {{name}}Enum { {{#values}} {{{.}}}, {{/values}} };{{/min}}
+ {{/allowableValues}}
+
+{{/vars}}
+ {{classname}}._();
+
+ static void _initializeBuilder({{{classname}}}Builder b) => b{{#vars}}{{#defaultValue}}
+ ..{{{name}}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/vars}};
+
+ factory {{classname}}([void updates({{classname}}Builder b)]) = _${{classname}};
+
+ @BuiltValueSerializer(custom: true)
+ static Serializer<{{classname}}> get serializer => _${{classname}}Serializer();
+}
+
+{{!
+ Generate a custom serializer in order to support combinations of required and nullable.
+ By default built_value does not serialize null fields.
+}}
+class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
+ @override
+ final Iterable types = const [{{classname}}, _${{classname}}];
+
+ @override
+ final String wireName = r'{{classname}}';
+
+ @override
+ Iterable serialize(Serializers serializers, {{{classname}}} object,
+ {FullType specifiedType = FullType.unspecified}) {
+ final result = [];
+ {{#vars}}
+ {{#required}}
+ {{!
+ A required property need to always be part of the serialized output.
+ When it is nullable, null is serialized, otherwise it is an error if it is null.
+ }}
+ result
+ ..add(r'{{baseName}}')
+ ..add({{#isNullable}}object.{{{name}}} == null ? null : {{/isNullable}}serializers.serialize(object.{{{name}}},
+ specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}));
+ {{/required}}
+ {{^required}}
+ if (object.{{{name}}} != null) {
+ {{! Non-required properties are only serialized if not null. }}
+ result
+ ..add(r'{{baseName}}')
+ ..add(serializers.serialize(object.{{{name}}},
+ specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}));
+ }
+ {{/required}}
+ {{/vars}}
+ return result;
+ }
+
+ @override
+ {{classname}} deserialize(Serializers serializers, Iterable serialized,
+ {FullType specifiedType = FullType.unspecified}) {
+ final result = {{classname}}Builder();
+
+ final iterator = serialized.iterator;
+ while (iterator.moveNext()) {
+ final key = iterator.current as String;
+ iterator.moveNext();
+ final Object? value = iterator.current;
+ switch (key) {
+ {{#vars}}
+ case r'{{baseName}}':
+ {{#isContainer}}
+ result.{{{name}}}.replace(serializers.deserialize(value,
+ specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
+ {{/isContainer}}
+ {{#isModel}}
+ result.{{{name}}}.replace(serializers.deserialize(value,
+ specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
+ {{/isModel}}
+ {{^isContainer}}
+ {{^isModel}}
+ result.{{{name}}} = serializers.deserialize(value,
+ specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
+ {{/isModel}}
+ {{/isContainer}}
+ break;
+ {{/vars}}
+ }
+ }
+ return result.build();
+ }
+}
+{{!
+ Generate an enum for any variables that are declared as inline enums
+ isEnum is only true for inline variables that are enums.
+ If an enum is declared as a definition, isEnum is false and the enum is generated from the
+ enum.mustache template.
+}}
+{{#vars}}
+ {{#isEnum}}
+ {{^isContainer}}
+
+{{>serialization/built_value/enum_inline}}
+ {{/isContainer}}
+ {{#isContainer}}
+ {{#mostInnerItems}}
+
+{{>serialization/built_value/enum_inline}}
+ {{/mostInnerItems}}
+ {{/isContainer}}
+ {{/isEnum}}
+{{/vars}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/deserialize.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/deserialize.mustache
new file mode 100644
index 00000000000..f2b33d868d2
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/deserialize.mustache
@@ -0,0 +1,24 @@
+ {{#isResponseFile}}
+ _responseData = _response.data as {{{returnType}}};
+ {{/isResponseFile}}
+ {{^isResponseFile}}
+ {{#returnSimpleType}}
+ {{#returnTypeIsPrimitive}}
+ _responseData = _response.data as {{{returnType}}};
+ {{/returnTypeIsPrimitive}}
+ {{^returnTypeIsPrimitive}}
+ const _responseType = FullType({{{returnType}}});
+ _responseData = _serializers.deserialize(
+ _response.data!,
+ specifiedType: _responseType,
+ ) as {{{returnType}}};
+ {{/returnTypeIsPrimitive}}
+ {{/returnSimpleType}}
+ {{^returnSimpleType}}
+ const _responseType = FullType(Built{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}{{#isMap}}Map{{/isMap}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{returnBaseType}}})]);
+ _responseData = _serializers.deserialize(
+ _response.data!,
+ specifiedType: _responseType,
+ ) as {{{returnType}}};
+ {{/returnSimpleType}}
+ {{/isResponseFile}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/enum.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/enum.mustache
new file mode 100644
index 00000000000..4e299b1faa3
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/enum.mustache
@@ -0,0 +1,33 @@
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/built_value.dart';
+import 'package:built_value/serializer.dart';
+
+part '{{classFilename}}.g.dart';
+
+class {{classname}} extends EnumClass {
+
+ {{#allowableValues}}
+ {{#enumVars}}
+ {{#description}}
+ /// {{{description}}}
+ {{/description}}
+ @BuiltValueEnumConst({{#isInteger}}wireNumber: {{{value}}}{{/isInteger}}{{^isInteger}}wireName: r{{{value}}}{{/isInteger}})
+ static const {{classname}} {{name}} = _${{name}};
+ {{/enumVars}}
+ {{/allowableValues}}
+
+ static Serializer<{{classname}}> get serializer => _${{#lambda.camelcase}}{{{classname}}}{{/lambda.camelcase}}Serializer;
+
+ const {{classname}}._(String name): super(name);
+
+ static BuiltSet<{{classname}}> get values => _$values;
+ static {{classname}} valueOf(String name) => _$valueOf(name);
+}
+
+/// Optionally, enum_class can generate a mixin to go with your enum for use
+/// with Angular. It exposes your enum constants as getters. So, if you mix it
+/// in to your Dart component class, the values become available to the
+/// corresponding Angular template.
+///
+/// Trigger mixin generation by writing a line like this one next to your enum.
+abstract class {{classname}}Mixin = Object with _${{classname}}Mixin;
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/enum_inline.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/enum_inline.mustache
new file mode 100644
index 00000000000..2d0c898cd3c
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/enum_inline.mustache
@@ -0,0 +1,19 @@
+class {{{enumName}}} extends EnumClass {
+
+ {{#allowableValues}}
+ {{#enumVars}}
+ {{#description}}
+ /// {{{description}}}
+ {{/description}}
+ @BuiltValueEnumConst({{#isInteger}}wireNumber: {{{value}}}{{/isInteger}}{{^isInteger}}wireName: r{{{value}}}{{/isInteger}})
+ static const {{{enumName}}} {{name}} = _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}_{{name}};
+ {{/enumVars}}
+ {{/allowableValues}}
+
+ static Serializer<{{{enumName}}}> get serializer => _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}Serializer;
+
+ const {{{enumName}}}._(String name): super(name);
+
+ static BuiltSet<{{{enumName}}}> get values => _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}Values;
+ static {{{enumName}}} valueOf(String name) => _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}ValueOf(name);
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/local_date_serializer.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/local_date_serializer.mustache
new file mode 100644
index 00000000000..68cfd5e31c6
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/local_date_serializer.mustache
@@ -0,0 +1,52 @@
+{{>header}}
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:time_machine/time_machine.dart';
+
+class OffsetDateSerializer implements PrimitiveSerializer {
+
+ const OffsetDateSerializer();
+
+ @override
+ Iterable get types => BuiltList([OffsetDate]);
+
+ @override
+ String get wireName => 'OffsetDate';
+
+ @override
+ OffsetDate deserialize(Serializers serializers, Object serialized,
+ {FullType specifiedType = FullType.unspecified}) {
+ final local = LocalDate.dateTime(DateTime.parse(serialized as String));
+ return OffsetDate(local, Offset(0));
+ }
+
+ @override
+ Object serialize(Serializers serializers, OffsetDate offsetDate,
+ {FullType specifiedType = FullType.unspecified}) {
+ return offsetDate.toString('yyyy-MM-dd');
+ }
+}
+
+class OffsetDateTimeSerializer implements PrimitiveSerializer {
+
+ const OffsetDateTimeSerializer();
+
+ @override
+ Iterable get types => BuiltList([OffsetDateTime]);
+
+ @override
+ String get wireName => 'OffsetDateTime';
+
+ @override
+ OffsetDateTime deserialize(Serializers serializers, Object serialized,
+ {FullType specifiedType = FullType.unspecified}) {
+ final local = LocalDateTime.dateTime(DateTime.parse(serialized as String));
+ return OffsetDateTime(local, Offset(0));
+ }
+
+ @override
+ Object serialize(Serializers serializers, OffsetDateTime offsetDateTime,
+ {FullType specifiedType = FullType.unspecified}) {
+ return offsetDateTime.toString();
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serialize.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serialize.mustache
new file mode 100644
index 00000000000..5794f34ad1a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serialize.mustache
@@ -0,0 +1,21 @@
+ {{#hasFormParams}}
+ _bodyData = {{#isMultipart}}FormData.fromMap({{/isMultipart}}{
+ {{#formParams}}
+ {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{{baseName}}}': {{#isFile}}MultipartFile.fromBytes({{{paramName}}}, filename: r'{{{baseName}}}'){{/isFile}}{{^isFile}}encodeFormParameter(_serializers, {{{paramName}}}, const FullType({{^isContainer}}{{{baseType}}}{{/isContainer}}{{#isContainer}}Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]{{/isContainer}})){{/isFile}},
+ {{/formParams}}
+ }{{#isMultipart}}){{/isMultipart}};
+ {{/hasFormParams}}
+ {{#bodyParam}}
+ {{#isPrimitiveType}}
+ _bodyData = {{paramName}};
+ {{/isPrimitiveType}}
+ {{^isPrimitiveType}}
+ {{#isContainer}}
+ const _type = FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]);
+ {{/isContainer}}
+ {{^isContainer}}
+ const _type = FullType({{{baseType}}});
+ {{/isContainer}}
+ _bodyData = {{^required}}{{paramName}} == null ? null : {{/required}}_serializers.serialize({{paramName}}, specifiedType: _type);
+ {{/isPrimitiveType}}
+ {{/bodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serializers.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serializers.mustache
new file mode 100644
index 00000000000..afca0bc138f
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serializers.mustache
@@ -0,0 +1,33 @@
+{{>header}}
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/json_object.dart';
+import 'package:built_value/serializer.dart';
+import 'package:built_value/standard_json_plugin.dart';
+{{#useDateLibCore}}import 'package:built_value/iso_8601_date_time_serializer.dart';{{/useDateLibCore}}
+{{#useDateLibTimeMachine}}import 'package:time_machine/time_machine.dart';
+import 'package:{{pubName}}/src/local_date_serializer.dart';{{/useDateLibTimeMachine}}
+{{#models}}{{#model}}import 'package:{{pubName}}/src/model/{{classFilename}}.dart';
+{{/model}}{{/models}}
+part 'serializers.g.dart';
+
+@SerializersFor([{{#models}}{{#model}}
+ {{classname}},{{/model}}{{/models}}
+])
+Serializers serializers = (_$serializers.toBuilder(){{#apiInfo}}{{#apis}}{{#serializers}}
+ ..addBuilderFactory(
+{{#isArray}}
+ const FullType(Built{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}, [FullType({{baseType}})]),
+ () => {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}Builder<{{baseType}}>(),
+{{/isArray}}
+{{#isMap}}
+ const FullType(BuiltMap, [FullType(String), FullType({{baseType}})]),
+ () => MapBuilder(),
+{{/isMap}}
+ ){{/serializers}}{{/apis}}{{/apiInfo}}{{#useDateLibTimeMachine}}
+ ..add(const OffsetDateSerializer())
+ ..add(const OffsetDateTimeSerializer()){{/useDateLibTimeMachine}}
+ ..add(Iso8601DateTimeSerializer()))
+ .build();
+
+Serializers standardSerializers =
+ (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
diff --git a/modules/openapi-generator/src/main/resources/dart/model.mustache b/modules/openapi-generator/src/main/resources/dart/model.mustache
deleted file mode 100644
index 37b030ab034..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/model.mustache
+++ /dev/null
@@ -1,12 +0,0 @@
-part of {{pubName}}.api;
-
-{{#models}}
-{{#model}}
-{{#isEnum}}
-{{>enum}}
-{{/isEnum}}
-{{^isEnum}}
-{{>class}}
-{{/isEnum}}
-{{/model}}
-{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/dart/model_test.mustache b/modules/openapi-generator/src/main/resources/dart/model_test.mustache
deleted file mode 100644
index b766bf143e7..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/model_test.mustache
+++ /dev/null
@@ -1,26 +0,0 @@
-{{#models}}
-{{#model}}
-import 'package:{{pubName}}/api.dart';
-import 'package:test/test.dart';
-
-// tests for {{classname}}
-void main() {
- var instance = new {{classname}}();
-
- group('test {{classname}}', () {
- {{#vars}}
- {{#description}}
- // {{{description}}}
- {{/description}}
- // {{{dataType}}} {{name}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
- test('to test the property `{{name}}`', () async {
- // TODO
- });
-
- {{/vars}}
-
- });
-
-}
-{{/model}}
-{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/dart/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart/pubspec.mustache
deleted file mode 100644
index 997448a9beb..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/pubspec.mustache
+++ /dev/null
@@ -1,7 +0,0 @@
-name: {{pubName}}
-version: {{pubVersion}}
-description: {{pubDescription}}
-dependencies:
- http: '>=0.11.1 <0.13.0'
-dev_dependencies:
- test: ^1.3.0
diff --git a/modules/openapi-generator/src/main/resources/dart/travis.mustache b/modules/openapi-generator/src/main/resources/dart/travis.mustache
deleted file mode 100644
index 82b19541fa4..00000000000
--- a/modules/openapi-generator/src/main/resources/dart/travis.mustache
+++ /dev/null
@@ -1,11 +0,0 @@
-# https://docs.travis-ci.com/user/languages/dart/
-#
-language: dart
-dart:
-# Install a specific stable release
-- "1.24.3"
-install:
-- pub get
-
-script:
-- pub run test
diff --git a/modules/openapi-generator/src/main/resources/dart2/api_doc.mustache b/modules/openapi-generator/src/main/resources/dart2/api_doc.mustache
index ba4c43fc972..b7e91eb72c8 100644
--- a/modules/openapi-generator/src/main/resources/dart2/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/api_doc.mustache
@@ -10,7 +10,7 @@ All URIs are relative to *{{{basePath}}}*
Method | HTTP request | Description
------------- | ------------- | -------------
-{{#operations}}{{#operation}}[**{{{operationId}}}**]({{{classname}}}.md#{{{operationId}}}) | **{{{httpMethod}}}** {{{path}}} | {{#summary}}{{{summary}}}{{/summary}}
+{{#operations}}{{#operation}}[**{{{operationId}}}**]({{{classname}}}.md#{{{operationIdLowerCase}}}) | **{{{httpMethod}}}** {{{path}}} | {{#summary}}{{{summary}}}{{/summary}}
{{/operation}}{{/operations}}
{{#operations}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/dart_constructor.mustache b/modules/openapi-generator/src/main/resources/dart2/dart_constructor.mustache
new file mode 100644
index 00000000000..af2f2a0e285
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart2/dart_constructor.mustache
@@ -0,0 +1,10 @@
+ /// Returns a new [{{{classname}}}] instance.
+ {{{classname}}}({
+ {{#vars}}
+ {{!
+ A field is @required in Dart when it is
+ required && !nullable && !defaultValue in OAS
+ }}
+ {{#required}}{{^isNullable}}{{^defaultValue}}@required {{/defaultValue}}{{/isNullable}}{{/required}}this.{{{name}}}{{^isNullable}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/isNullable}},
+ {{/vars}}
+ });
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/model.mustache b/modules/openapi-generator/src/main/resources/dart2/model.mustache
index 4bebe06e9e4..9c738da279b 100644
--- a/modules/openapi-generator/src/main/resources/dart2/model.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/model.mustache
@@ -3,10 +3,20 @@
{{#models}}
{{#model}}
{{#isEnum}}
-{{>enum}}
+{{#native_serialization}}
+{{>serialization/native/native_enum}}
+{{/native_serialization}}
+{{#json_serializable}}
+{{>serialization/json_serializable/json_serializable_enum}}
+{{/json_serializable}}
{{/isEnum}}
{{^isEnum}}
-{{>class}}
+{{#native_serialization}}
+{{>serialization/native/native_class}}
+{{/native_serialization}}
+{{#json_serializable}}
+{{>serialization/json_serializable/json_serializable_class}}
+{{/json_serializable}}
{{/isEnum}}
{{/model}}
{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/model_test.mustache b/modules/openapi-generator/src/main/resources/dart2/model_test.mustache
index 3537d6085d6..7de9c7b840e 100644
--- a/modules/openapi-generator/src/main/resources/dart2/model_test.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/model_test.mustache
@@ -1,3 +1,4 @@
+{{>header}}
{{#models}}
{{#model}}
import 'package:{{{pubName}}}/api.dart';
diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache
new file mode 100644
index 00000000000..3a9ff0362b3
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache
@@ -0,0 +1,70 @@
+@JsonSerializable(
+ checked: true,
+ createToJson: true,
+ disallowUnrecognizedKeys: true,
+ explicitToJson: true,
+)
+class {{{classname}}} {
+{{>dart_constructor}}
+
+{{#vars}}
+ {{#description}}
+ /// {{{description}}}
+ {{/description}}
+ {{^isEnum}}
+ {{#minimum}}
+ // minimum: {{{minimum}}}
+ {{/minimum}}
+ {{#maximum}}
+ // maximum: {{{maximum}}}
+ {{/maximum}}
+ {{/isEnum}}
+ {{^isBinary}}
+ @JsonKey(
+ {{#defaultValue}}defaultValue: {{{defaultValue}}},{{/defaultValue}}{{^defaultValue}}nullable: {{isNullable}},{{/defaultValue}}
+ name: r'{{{baseName}}}',
+ required: {{#required}}true{{/required}}{{^required}}false{{/required}},
+ )
+ {{/isBinary}}
+ {{#isBinary}}
+ @JsonKey(ignore: true)
+ {{/isBinary}}
+ {{{datatypeWithEnum}}} {{{name}}};
+
+{{/vars}}
+ @override
+ bool operator ==(Object other) => identical(this, other) || other is {{{classname}}} &&
+ {{#vars}}
+ other.{{{name}}} == {{{name}}}{{^-last}} &&{{/-last}}{{#-last}};{{/-last}}
+ {{/vars}}
+
+ @override
+ int get hashCode =>
+ {{#vars}}
+ ({{{name}}} == null ? 0 : {{{name}}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
+ {{/vars}}
+
+ factory {{{classname}}}.fromJson(Map json) => _${{{classname}}}FromJson(json);
+
+ Map toJson() => _${{{classname}}}ToJson(this);
+
+ @override
+ String toString() {
+ return toJson().toString();
+ }
+
+}
+{{#vars}}
+ {{#isEnum}}
+ {{^isContainer}}
+
+{{>serialization/json_serializable/json_serializable_enum_inline}}
+ {{/isContainer}}
+ {{#isContainer}}
+ {{#mostInnerItems}}
+
+{{>serialization/json_serializable/json_serializable_enum_inline}}
+ {{/mostInnerItems}}
+ {{/isContainer}}
+ {{/isEnum}}
+{{/vars}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum.mustache
new file mode 100644
index 00000000000..3fe458ab91f
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum.mustache
@@ -0,0 +1,7 @@
+enum {{{classname}}} {
+{{#allowableValues}}
+{{#enumVars}}
+ {{{name}}},
+{{/enumVars}}
+{{/allowableValues}}
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum_inline.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum_inline.mustache
new file mode 100644
index 00000000000..5249f86b398
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum_inline.mustache
@@ -0,0 +1,8 @@
+{{#description}}/// {{{description}}}{{/description}}
+enum {{{enumName}}} {
+{{#allowableValues}}
+{{#enumVars}}
+ {{{name}}},
+{{/enumVars}}
+{{/allowableValues}}
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
similarity index 80%
rename from modules/openapi-generator/src/main/resources/dart2/class.mustache
rename to modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
index f65bce93991..0e4520d3e98 100644
--- a/modules/openapi-generator/src/main/resources/dart2/class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
@@ -1,24 +1,6 @@
-{{#json_serializable}}
-@JsonSerializable(
- checked: true,
- createToJson: true,
- disallowUnrecognizedKeys: true,
- explicitToJson: true,
-)
-{{/json_serializable}}
class {{{classname}}} {
- /// Returns a new [{{{classname}}}] instance.
- {{{classname}}}({
- {{#vars}}
- {{!
- A field is @required in Dart when it is
- required && !nullable && !defaultValue in OAS
- }}
- {{#required}}{{^isNullable}}{{^defaultValue}}@required {{/defaultValue}}{{/isNullable}}{{/required}}this.{{{name}}}{{^isNullable}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/isNullable}},
- {{/vars}}
- });
+{{>dart_constructor}}
-{{^json_serializable}}
{{#vars}}
{{#description}}
/// {{{description}}}
@@ -34,34 +16,6 @@ class {{{classname}}} {
{{{datatypeWithEnum}}} {{{name}}};
{{/vars}}
-{{/json_serializable}}
-{{#json_serializable}}
-{{#vars}}
- {{#description}}
- /// {{{description}}}
- {{/description}}
- {{^isEnum}}
- {{#minimum}}
- // minimum: {{{minimum}}}
- {{/minimum}}
- {{#maximum}}
- // maximum: {{{maximum}}}
- {{/maximum}}
- {{/isEnum}}
- {{^isBinary}}
- @JsonKey(
- {{#defaultValue}}defaultValue: {{{defaultValue}}},{{/defaultValue}}{{^defaultValue}}nullable: {{isNullable}},{{/defaultValue}}
- name: r'{{{baseName}}}',
- required: {{#required}}true{{/required}}{{^required}}false{{/required}},
- )
- {{/isBinary}}
- {{#isBinary}}
- @JsonKey(ignore: true)
- {{/isBinary}}
- {{{datatypeWithEnum}}} {{{name}}};
-
-{{/vars}}
-{{/json_serializable}}
@override
bool operator ==(Object other) => identical(this, other) || other is {{{classname}}} &&
{{#vars}}
@@ -74,7 +28,6 @@ class {{{classname}}} {
({{{name}}} == null ? 0 : {{{name}}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
{{/vars}}
-{{^json_serializable}}
@override
String toString() => '{{{classname}}}[{{#vars}}{{{name}}}=${{{name}}}{{^-last}}, {{/-last}}{{/vars}}]';
@@ -256,30 +209,17 @@ class {{{classname}}} {
}
return map;
}
-{{/json_serializable}}
-{{#json_serializable}}
-
- factory {{{classname}}}.fromJson(Map json) => _${{{classname}}}FromJson(json);
-
- Map toJson() => _${{{classname}}}ToJson(this);
-
- @override
- String toString() {
- return toJson().toString();
- }
-
-{{/json_serializable}}
}
{{#vars}}
{{#isEnum}}
{{^isContainer}}
-{{>enum_inline}}
+{{>serialization/native/native_enum_inline}}
{{/isContainer}}
{{#isContainer}}
{{#mostInnerItems}}
-{{>enum_inline}}
+{{>serialization/native/native_enum_inline}}
{{/mostInnerItems}}
{{/isContainer}}
{{/isEnum}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/enum.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache
similarity index 91%
rename from modules/openapi-generator/src/main/resources/dart2/enum.mustache
rename to modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache
index 6035ec4897e..d3ba3f350a8 100644
--- a/modules/openapi-generator/src/main/resources/dart2/enum.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache
@@ -1,5 +1,4 @@
{{#description}}/// {{{description}}}{{/description}}
-{{^json_serializable}}
class {{{classname}}} {
/// Instantiate a new enum with the provided [value].
const {{{classname}}}._(this.value);
@@ -72,12 +71,4 @@ class {{{classname}}}TypeTransformer {
/// Singleton [{{{classname}}}TypeTransformer] instance.
static {{{classname}}}TypeTransformer _instance;
-}{{/json_serializable}}{{#json_serializable}}
-enum {{{classname}}} {
- {{#allowableValues}}
- {{#enumVars}}
- {{{name}}},
- {{/enumVars}}
- {{/allowableValues}}
-}
-{{/json_serializable}}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/enum_inline.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache
similarity index 92%
rename from modules/openapi-generator/src/main/resources/dart2/enum_inline.mustache
rename to modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache
index 2aebe1b2a91..d14c5a5648a 100644
--- a/modules/openapi-generator/src/main/resources/dart2/enum_inline.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache
@@ -1,5 +1,4 @@
{{#description}}/// {{{description}}}{{/description}}
-{{^json_serializable}}
class {{{enumName}}} {
/// Instantiate a new enum with the provided [value].
const {{{enumName}}}._(this.value);
@@ -72,11 +71,4 @@ class {{{enumName}}}TypeTransformer {
/// Singleton [{{{enumName}}}TypeTransformer] instance.
static {{{enumName}}}TypeTransformer _instance;
-}{{/json_serializable}}{{#json_serializable}}
-enum {{{enumName}}} {
-{{#allowableValues}}
-{{#enumVars}}
- {{{name}}},
-{{/enumVars}}
-{{/allowableValues}}
-}{{/json_serializable}}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/java-msf4j-server/queryParams.mustache b/modules/openapi-generator/src/main/resources/java-msf4j-server/queryParams.mustache
index a8e45cd5f78..51531c4d345 100644
--- a/modules/openapi-generator/src/main/resources/java-msf4j-server/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/java-msf4j-server/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}){{#defaultValue}} @DefaultValue({{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}){{^isContainer}}{{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}}{{/isContainer}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/java-pkmst/bodyParams.mustache b/modules/openapi-generator/src/main/resources/java-pkmst/bodyParams.mustache
index 7fef9ad2b6f..066600c49fc 100644
--- a/modules/openapi-generator/src/main/resources/java-pkmst/bodyParams.mustache
+++ b/modules/openapi-generator/src/main/resources/java-pkmst/bodyParams.mustache
@@ -1 +1 @@
-{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
+{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/java-pkmst/queryParams.mustache b/modules/openapi-generator/src/main/resources/java-pkmst/queryParams.mustache
index 97e90bafefe..bf20ec8ad16 100644
--- a/modules/openapi-generator/src/main/resources/java-pkmst/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/java-pkmst/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
index eebddf4b196..110b828a0b9 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
@@ -3,8 +3,8 @@
## Requires
{{#jvm}}
-* Kotlin 1.3.61
-* Gradle 4.9
+* Kotlin 1.4.30
+* Gradle 6.8.3
{{/jvm}}
{{#multiplatform}}
* Kotlin 1.3.50
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache
index 7e71248dd1c..415a8c25574 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache
@@ -2,12 +2,12 @@ group '{{groupId}}'
version '{{artifactVersion}}'
wrapper {
- gradleVersion = '6.8.2'
+ gradleVersion = '6.8.3'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
buildscript {
- ext.kotlin_version = '1.4.20'
+ ext.kotlin_version = '1.4.30'
{{#jvm-retrofit2}}
ext.retrofitVersion = '2.7.2'
{{/jvm-retrofit2}}
@@ -26,6 +26,9 @@ buildscript {
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ {{#kotlinx_serialization}}
+ classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
+ {{/kotlinx_serialization}}
}
}
@@ -36,6 +39,9 @@ apply plugin: 'kotlin-kapt'
{{#parcelizeModels}}
apply plugin: 'kotlin-parcelize'
{{/parcelizeModels}}
+{{#kotlinx_serialization}}
+apply plugin: 'kotlinx-serialization'
+{{/kotlinx_serialization}}
repositories {
maven { url "https://repo1.maven.org/maven2" }
@@ -62,10 +68,12 @@ dependencies {
{{/gson}}
{{#jackson}}
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
- compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.2"
- compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.2"
- compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.2"
+ compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1"
+ compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.1"
{{/jackson}}
+ {{#kotlinx_serialization}}
+ compile "org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0"
+ {{/kotlinx_serialization}}
{{#jvm-okhttp3}}
compile "com.squareup.okhttp3:okhttp:3.12.13"
{{/jvm-okhttp3}}
@@ -99,6 +107,9 @@ dependencies {
{{#moshi}}
compile "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
{{/moshi}}
+ {{#kotlinx_serialization}}
+ compile "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0"
+ {{/kotlinx_serialization}}
compile "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
{{/jvm-retrofit2}}
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2"
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
index 2dd048a74f5..b83b7aff952 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
@@ -15,6 +15,13 @@ import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
{{/discriminator}}
{{/jackson}}
+{{#kotlinx_serialization}}
+import {{#serializableModel}}kotlinx.serialization.Serializable as KSerializable{{/serializableModel}}{{^serializableModel}}kotlinx.serialization.Serializable{{/serializableModel}}
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Contextual
+{{#hasEnums}}
+{{/hasEnums}}
+{{/kotlinx_serialization}}
{{#parcelizeModels}}
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
@@ -38,7 +45,7 @@ import java.io.Serializable
{{#parcelizeModels}}
@Parcelize
{{/parcelizeModels}}
-{{#multiplatform}}@Serializable{{/multiplatform}}{{#moshi}}{{#moshiCodeGen}}@JsonClass(generateAdapter = true){{/moshiCodeGen}}{{/moshi}}{{#jackson}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{/jackson}}
+{{#multiplatform}}@Serializable{{/multiplatform}}{{#kotlinx_serialization}}{{#serializableModel}}@KSerializable{{/serializableModel}}{{^serializableModel}}@Serializable{{/serializableModel}}{{/kotlinx_serialization}}{{#moshi}}{{#moshiCodeGen}}@JsonClass(generateAdapter = true){{/moshiCodeGen}}{{/moshi}}{{#jackson}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{/jackson}}
{{#isDeprecated}}
@Deprecated(message = "This schema is deprecated.")
{{/isDeprecated}}
@@ -60,11 +67,10 @@ import java.io.Serializable
{{#vars}}
{{#isEnum}}
/**
- * {{{description}}}
- * Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
- */
- {{#multiplatform}}@Serializable(with = {{nameInCamelCase}}.Serializer::class){{/multiplatform}}
- {{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{{nameInCamelCase}}}(val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}){
+ * {{{description}}}
+ * Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
+ */
+ {{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{{nameInCamelCase}}}(val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}) {
{{#allowableValues}}
{{#enumVars}}
{{^multiplatform}}
@@ -77,16 +83,15 @@ import java.io.Serializable
{{#jackson}}
@JsonProperty(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/jackson}}
+ {{#kotlinx_serialization}}
+ @SerialName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
+ {{/kotlinx_serialization}}
{{/multiplatform}}
{{#multiplatform}}
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/multiplatform}}
{{/enumVars}}
{{/allowableValues}}
- {{#multiplatform}}
-
- {{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{nameInCamelCase}}>("{{nameInCamelCase}}", values(), values().map { it.value.toString() }.toTypedArray())
- {{/multiplatform}}
}
{{/isEnum}}
{{/vars}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
index b6d441ce4ab..deae3ebd5dc 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
@@ -11,8 +11,11 @@
{{#jackson}}
@field:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}")
{{/jackson}}
+ {{#kotlinx_serialization}}
+ {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}")
+ {{/kotlinx_serialization}}
{{/multiplatform}}
{{#deprecated}}
@Deprecated(message = "This property is deprecated.")
{{/deprecated}}
- {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isArray}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
+ {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache
index 35c9dda65cf..2c44be195c8 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache
@@ -11,8 +11,11 @@
{{#jackson}}
@field:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}")
{{/jackson}}
+ {{#kotlinx_serialization}}
+ {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}")
+ {{/kotlinx_serialization}}
{{/multiplatform}}
{{#deprecated}}
@Deprecated(message = "This property is deprecated.")
{{/deprecated}}
- {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isArray}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}
\ No newline at end of file
+ {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache
index f1a8b67eeff..88d6c278ea2 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache
@@ -8,6 +8,10 @@ import com.squareup.moshi.Json
{{#jackson}}
import com.fasterxml.jackson.annotation.JsonProperty
{{/jackson}}
+{{#kotlinx_serialization}}
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Serializable
+{{/kotlinx_serialization}}
{{/multiplatform}}
{{#multiplatform}}
import kotlinx.serialization.*
@@ -18,8 +22,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
* {{{description}}}
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
*/
-{{#multiplatform}}@Serializable(with = {{classname}}.Serializer::class){{/multiplatform}}
-{{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{classname}}(val value: {{{dataType}}}){
+{{#multiplatform}}@Serializable(with = {{classname}}.Serializer::class){{/multiplatform}}{{#kotlinx_serialization}}@Serializable(with = {{classname}}.Serializer::class){{/kotlinx_serialization}}
+{{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{classname}}(val value: {{{dataType}}}) {
{{#allowableValues}}{{#enumVars}}
{{^multiplatform}}
@@ -32,6 +36,9 @@ import kotlinx.serialization.internal.CommonEnumSerializer
{{#jackson}}
@JsonProperty(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}})
{{/jackson}}
+ {{#kotlinx_serialization}}
+ @SerialName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}})
+ {{/kotlinx_serialization}}
{{/multiplatform}}
{{#isArray}}
{{#isList}}
@@ -44,7 +51,6 @@ import kotlinx.serialization.internal.CommonEnumSerializer
{{^isArray}}
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/isArray}}
-
{{/enumVars}}{{/allowableValues}}
/**
@@ -54,8 +60,4 @@ import kotlinx.serialization.internal.CommonEnumSerializer
override fun toString(): String {
return value{{^isString}}.toString(){{/isString}}
}
-
-{{#multiplatform}}
- {{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{classname}}>("{{classname}}", values(), values().map { it.value.toString() }.toTypedArray())
-{{/multiplatform}}
}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/gradle-wrapper.jar b/modules/openapi-generator/src/main/resources/kotlin-client/gradle-wrapper.jar
new file mode 100644
index 00000000000..e708b1c023e
Binary files /dev/null and b/modules/openapi-generator/src/main/resources/kotlin-client/gradle-wrapper.jar differ
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/gradle-wrapper.properties.mustache
similarity index 80%
rename from modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/gradle-wrapper.properties.mustache
index ce3ca77db54..8cf6eb5ad22 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/gradle-wrapper.properties.mustache
@@ -1,6 +1,5 @@
-#Tue May 17 23:08:05 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/gradlew.bat.mustache
similarity index 66%
rename from modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/gradlew.bat.mustache
index 5f192121eb4..107acd32c4e 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/gradlew.bat.mustache
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,20 +24,23 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,34 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/gradlew.mustache
similarity index 64%
rename from modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/gradlew.mustache
index 9d82f789151..4f906e0c811 100755
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/gradlew.mustache
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,42 +22,6 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -60,8 +40,49 @@ cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -85,7 +106,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -134,27 +156,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/interface_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/interface_opt_var.mustache
index 35cfae01e12..6d23fb240a0 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/interface_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/interface_opt_var.mustache
@@ -11,5 +11,8 @@
{{#jackson}}
@get:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}")
{{/jackson}}
+ {{#kotlinx_serialization}}
+ {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}")
+ {{/kotlinx_serialization}}
{{/multiplatform}}
- {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isArray}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}?
\ No newline at end of file
+ {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}?
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/interface_req_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/interface_req_var.mustache
index 50a2a3d4fef..6b93d6189fa 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/interface_req_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/interface_req_var.mustache
@@ -11,5 +11,8 @@
{{#jackson}}
@get:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}")
{{/jackson}}
+ {{#kotlinx_serialization}}
+ {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}")
+ {{/kotlinx_serialization}}
{{/multiplatform}}
- {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isArray}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}
\ No newline at end of file
+ {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicBooleanAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicBooleanAdapter.kt.mustache
new file mode 100644
index 00000000000..e7409f3eca4
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicBooleanAdapter.kt.mustache
@@ -0,0 +1,21 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+import java.util.concurrent.atomic.AtomicBoolean
+
+@Serializer(forClass = AtomicBoolean::class)
+object AtomicBooleanAdapter : KSerializer {
+ override fun serialize(encoder: Encoder, value: AtomicBoolean) {
+ encoder.encodeBoolean(value.get())
+ }
+
+ override fun deserialize(decoder: Decoder): AtomicBoolean = AtomicBoolean(decoder.decodeBoolean())
+
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("AtomicBoolean", PrimitiveKind.BOOLEAN)
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicIntegerAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicIntegerAdapter.kt.mustache
new file mode 100644
index 00000000000..5b79c7e6c3a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicIntegerAdapter.kt.mustache
@@ -0,0 +1,21 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+import java.util.concurrent.atomic.AtomicInteger
+
+@Serializer(forClass = AtomicInteger::class)
+object AtomicIntegerAdapter : KSerializer {
+ override fun serialize(encoder: Encoder, value: AtomicInteger) {
+ encoder.encodeInt(value.get())
+ }
+
+ override fun deserialize(decoder: Decoder): AtomicInteger = AtomicInteger(decoder.decodeInt())
+
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("AtomicInteger", PrimitiveKind.INT)
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicLongAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicLongAdapter.kt.mustache
new file mode 100644
index 00000000000..ce91e34742d
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/AtomicLongAdapter.kt.mustache
@@ -0,0 +1,21 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+import java.util.concurrent.atomic.AtomicLong
+
+@Serializer(forClass = AtomicLong::class)
+object AtomicLongAdapter : KSerializer {
+ override fun serialize(encoder: Encoder, value: AtomicLong) {
+ encoder.encodeLong(value.get())
+ }
+
+ override fun deserialize(decoder: Decoder): AtomicLong = AtomicLong(decoder.decodeLong())
+
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("AtomicLong", PrimitiveKind.LONG)
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigDecimalAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigDecimalAdapter.kt.mustache
new file mode 100644
index 00000000000..5efc613a20e
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigDecimalAdapter.kt.mustache
@@ -0,0 +1,19 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+import java.math.BigDecimal
+
+@Serializer(forClass = BigDecimal::class)
+object BigDecimalAdapter : KSerializer {
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("BigDecimal", PrimitiveKind.STRING)
+
+ override fun deserialize(decoder: Decoder): BigDecimal = BigDecimal(decoder.decodeString())
+
+ override fun serialize(encoder: Encoder, value: BigDecimal) = encoder.encodeString(value.toPlainString())
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigIntegerAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigIntegerAdapter.kt.mustache
new file mode 100644
index 00000000000..bd2b4d3c8e9
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigIntegerAdapter.kt.mustache
@@ -0,0 +1,23 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+import java.math.BigInteger
+
+@Serializer(forClass = BigInteger::class)
+object BigIntegerAdapter : KSerializer {
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("BigInteger", PrimitiveKind.STRING)
+
+ override fun deserialize(decoder: Decoder): BigInteger {
+ return BigInteger(decoder.decodeString())
+ }
+
+ override fun serialize(encoder: Encoder, value: BigInteger) {
+ encoder.encodeString(value.toString())
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/DateAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/DateAdapter.kt.mustache
index 7e7e35b74bd..8756321c4e0 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/DateAdapter.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/DateAdapter.kt.mustache
@@ -1,14 +1,26 @@
package {{packageName}}.infrastructure
+{{#kotlinx_serialization}}
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+{{/kotlinx_serialization}}
+{{#gson}}
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
+{{/gson}}
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
+{{#gson}}
{{#nonPublicApi}}internal {{/nonPublicApi}}class DateAdapter(val formatter: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault())) : TypeAdapter() {
@Throws(IOException::class)
@@ -35,3 +47,21 @@ import java.util.Locale
}
}
}
+{{/gson}}
+{{#kotlinx_serialization}}
+
+@Serializer(forClass = Date::class)
+object DateAdapter : KSerializer {
+ private val df: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault())
+
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Date", PrimitiveKind.STRING)
+
+ override fun serialize(encoder: Encoder, value: Date) {
+ encoder.encodeString(df.format(value))
+ }
+
+ override fun deserialize(decoder: Decoder): Date {
+ return df.parse(decoder.decodeString())!!
+ }
+}
+{{/kotlinx_serialization}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateAdapter.kt.mustache
index 34de6bc3895..97b5fd66190 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateAdapter.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateAdapter.kt.mustache
@@ -11,6 +11,15 @@ import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
{{/gson}}
+{{#kotlinx_serialization}}
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+{{/kotlinx_serialization}}
{{^threetenbp}}
import java.time.LocalDate
import java.time.format.DateTimeFormatter
@@ -61,3 +70,17 @@ import org.threeten.bp.format.DateTimeFormatter
}
}
{{/gson}}
+{{#kotlinx_serialization}}
+@Serializer(forClass = LocalDate::class)
+object LocalDateAdapter : KSerializer {
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("LocalDate", PrimitiveKind.STRING)
+
+ override fun serialize(encoder: Encoder, value: LocalDate) {
+ encoder.encodeString(DateTimeFormatter.ISO_LOCAL_DATE.format(value))
+ }
+
+ override fun deserialize(decoder: Decoder): LocalDate {
+ return LocalDate.parse(decoder.decodeString(), DateTimeFormatter.ISO_LOCAL_DATE)
+ }
+}
+{{/kotlinx_serialization}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache
index 0935b0053e5..3608ddb0db5 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache
@@ -11,6 +11,15 @@ import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
{{/gson}}
+{{#kotlinx_serialization}}
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+{{/kotlinx_serialization}}
{{^threetenbp}}
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@@ -60,4 +69,18 @@ import org.threeten.bp.format.DateTimeFormatter
}
}
}
-{{/gson}}
\ No newline at end of file
+{{/gson}}
+{{#kotlinx_serialization}}
+@Serializer(forClass = LocalDateTime::class)
+object LocalDateTimeAdapter : KSerializer {
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("LocalDateTime", PrimitiveKind.STRING)
+
+ override fun serialize(encoder: Encoder, value: LocalDateTime) {
+ encoder.encodeString(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value))
+ }
+
+ override fun deserialize(decoder: Decoder): LocalDateTime {
+ return LocalDateTime.parse(decoder.decodeString(), DateTimeFormatter.ISO_LOCAL_DATE_TIME)
+ }
+}
+{{/kotlinx_serialization}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache
index fbcd16447ac..855b4c87df6 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache
@@ -11,6 +11,15 @@ import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
{{/gson}}
+{{#kotlinx_serialization}}
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+{{/kotlinx_serialization}}
{{^threetenbp}}
import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
@@ -60,4 +69,18 @@ import org.threeten.bp.format.DateTimeFormatter
}
}
}
-{{/gson}}
\ No newline at end of file
+{{/gson}}
+{{#kotlinx_serialization}}
+@Serializer(forClass = OffsetDateTime::class)
+object OffsetDateTimeAdapter : KSerializer {
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("OffsetDateTime", PrimitiveKind.STRING)
+
+ override fun serialize(encoder: Encoder, value: OffsetDateTime) {
+ encoder.encodeString(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value))
+ }
+
+ override fun deserialize(decoder: Decoder): OffsetDateTime {
+ return OffsetDateTime.parse(decoder.decodeString(), DateTimeFormatter.ISO_OFFSET_DATE_TIME)
+ }
+}
+{{/kotlinx_serialization}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache
index 3074614db75..e9ed019095e 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache
@@ -24,12 +24,32 @@ import java.util.UUID
{{#jackson}}
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
-import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
{{/jackson}}
import java.util.Date
+{{#kotlinx_serialization}}
+import java.math.BigDecimal
+import java.math.BigInteger
+{{^threetenbp}}
+import java.time.LocalDate
+import java.time.LocalDateTime
+import java.time.OffsetDateTime
+{{/threetenbp}}
+{{#threetenbp}}
+import org.threeten.bp.LocalDate
+import org.threeten.bp.LocalDateTime
+import org.threeten.bp.OffsetDateTime
+{{/threetenbp}}
+import java.util.UUID
+import kotlinx.serialization.json.Json
+import kotlinx.serialization.modules.SerializersModule
+import java.net.URI
+import java.net.URL
+import java.util.concurrent.atomic.AtomicBoolean
+import java.util.concurrent.atomic.AtomicInteger
+import java.util.concurrent.atomic.AtomicLong
+{{/kotlinx_serialization}}
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer {
{{#moshi}}
@@ -65,9 +85,29 @@ import java.util.Date
{{#jackson}}
@JvmStatic
val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper()
- .registerModule(Jdk8Module())
- .registerModule(JavaTimeModule())
+ .findAndRegisterModules()
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT)
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
{{/jackson}}
+{{#kotlinx_serialization}}
+ @JvmStatic
+ val kotlinSerializationAdapters = SerializersModule {
+ contextual(BigDecimal::class, BigDecimalAdapter)
+ contextual(BigInteger::class, BigIntegerAdapter)
+ contextual(Date::class, DateAdapter)
+ contextual(LocalDate::class, LocalDateAdapter)
+ contextual(LocalDateTime::class, LocalDateTimeAdapter)
+ contextual(OffsetDateTime::class, OffsetDateTimeAdapter)
+ contextual(UUID::class, UUIDAdapter)
+ contextual(AtomicInteger::class, AtomicIntegerAdapter)
+ contextual(AtomicLong::class, AtomicLongAdapter)
+ contextual(AtomicBoolean::class, AtomicBooleanAdapter)
+ contextual(URI::class, UriAdapter)
+ contextual(URL::class, UrlAdapter)
+ contextual(StringBuilder::class, StringBuilderAdapter)
+ }
+
+ @JvmStatic
+ val jvmJson: Json by lazy { Json { serializersModule = kotlinSerializationAdapters } }
+{{/kotlinx_serialization}}
}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/StringBuilderAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/StringBuilderAdapter.kt.mustache
new file mode 100644
index 00000000000..4b428095a7e
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/StringBuilderAdapter.kt.mustache
@@ -0,0 +1,20 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+
+@Serializer(forClass = StringBuilder::class)
+object StringBuilderAdapter : KSerializer {
+ override fun serialize(encoder: Encoder, value: StringBuilder) {
+ encoder.encodeString(value.toString())
+ }
+
+ override fun deserialize(decoder: Decoder): StringBuilder = StringBuilder(decoder.decodeString())
+
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("StringBuilder", PrimitiveKind.STRING)
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/URIAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/URIAdapter.kt.mustache
new file mode 100644
index 00000000000..0225ccf549b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/URIAdapter.kt.mustache
@@ -0,0 +1,21 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+import java.net.URI
+
+@Serializer(forClass = URI::class)
+object UriAdapter : KSerializer {
+ override fun serialize(encoder: Encoder, value: URI) {
+ encoder.encodeString(value.toASCIIString())
+ }
+
+ override fun deserialize(decoder: Decoder): URI = URI(decoder.decodeString())
+
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("URI", PrimitiveKind.STRING)
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/URLAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/URLAdapter.kt.mustache
new file mode 100644
index 00000000000..7105c43b72b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/URLAdapter.kt.mustache
@@ -0,0 +1,21 @@
+package {{packageName}}.infrastructure
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+import java.net.URL
+
+@Serializer(forClass = URL::class)
+object UrlAdapter : KSerializer {
+ override fun serialize(encoder: Encoder, value: URL) {
+ encoder.encodeString(value.toExternalForm())
+ }
+
+ override fun deserialize(decoder: Decoder): URL = URL(decoder.decodeString())
+
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("URL", PrimitiveKind.STRING)
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/UUIDAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/UUIDAdapter.kt.mustache
index a1ebc2cfced..9781ff529cc 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/UUIDAdapter.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/UUIDAdapter.kt.mustache
@@ -1,9 +1,21 @@
package {{packageName}}.infrastructure
+{{#kotlinx_serialization}}
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializer
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.descriptors.PrimitiveKind
+import kotlinx.serialization.descriptors.SerialDescriptor
+{{/kotlinx_serialization}}
+{{#moshi}}
import com.squareup.moshi.FromJson
import com.squareup.moshi.ToJson
+{{/moshi}}
import java.util.UUID
+{{#moshi}}
{{#nonPublicApi}}internal {{/nonPublicApi}}class UUIDAdapter {
@ToJson
fun toJson(uuid: UUID) = uuid.toString()
@@ -11,3 +23,18 @@ import java.util.UUID
@FromJson
fun fromJson(s: String) = UUID.fromString(s)
}
+{{/moshi}}
+{{#kotlinx_serialization}}
+@Serializer(forClass = UUID::class)
+object UUIDAdapter : KSerializer {
+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("UUID", PrimitiveKind.STRING)
+
+ override fun serialize(encoder: Encoder, value: UUID) {
+ encoder.encodeString(value.toString())
+ }
+
+ override fun deserialize(decoder: Decoder): UUID {
+ return UUID.fromString(decoder.decodeString())
+ }
+}
+{{/kotlinx_serialization}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/proguard-rules.pro.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/proguard-rules.pro.mustache
new file mode 100644
index 00000000000..8b56c506d01
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/proguard-rules.pro.mustache
@@ -0,0 +1,11 @@
+-keepattributes *Annotation*, InnerClasses
+-dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations
+
+# kotlinx-serialization-json specific. Add this if you have java.lang.NoClassDefFoundError kotlinx.serialization.json.JsonObjectSerializer
+-keepclassmembers class kotlinx.serialization.json.** { *** Companion; }
+-keepclasseswithmembers class kotlinx.serialization.json.** { kotlinx.serialization.KSerializer serializer(...); }
+
+# project specific.
+-keep,includedescriptorclasses class {{modelPackage}}.**$$serializer { *; }
+-keepclassmembers class {{modelPackage}}.** { *** Companion; }
+-keepclasseswithmembers class {{modelPackage}}.** { kotlinx.serialization.KSerializer serializer(...); }
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache
index cfc573b9f82..0d834b1e55c 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache
@@ -148,10 +148,13 @@ import org.threeten.bp.OffsetTime
{{#jackson}}
MediaType.parse(mediaType), Serializer.jacksonObjectMapper.writeValueAsString(content)
{{/jackson}}
+ {{#kotlinx_serialization}}
+ MediaType.parse(mediaType), Serializer.jvmJson.decodeFromString(content)
+ {{/kotlinx_serialization}}
)
{{/jvm-okhttp3}}
{{#jvm-okhttp4}}
- mediaType == JsonMediaType -> {{#moshi}}Serializer.moshi.adapter(T::class.java).toJson(content){{/moshi}}{{#gson}}Serializer.gson.toJson(content, T::class.java){{/gson}}{{#jackson}}Serializer.jacksonObjectMapper.writeValueAsString(content){{/jackson}}.toRequestBody(
+ mediaType == JsonMediaType -> {{#moshi}}Serializer.moshi.adapter(T::class.java).toJson(content){{/moshi}}{{#gson}}Serializer.gson.toJson(content, T::class.java){{/gson}}{{#jackson}}Serializer.jacksonObjectMapper.writeValueAsString(content){{/jackson}}{{#kotlinx_serialization}}Serializer.jvmJson.decodeFromString(content){{/kotlinx_serialization}}.toRequestBody(
mediaType.toMediaTypeOrNull()
)
{{/jvm-okhttp4}}
@@ -358,6 +361,9 @@ import org.threeten.bp.OffsetTime
{{#jackson}}
return Serializer.jacksonObjectMapper.writeValueAsString(value).replace("\"", "")
{{/jackson}}
+ {{#kotlinx_serialization}}
+ return Serializer.jvmJson.encodeToString(value).replace("\"", "")
+ {{/kotlinx_serialization}}
{{/toJson}}
{{^toJson}}
return value.toString()
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache
index 692d7ac2038..66e77122a81 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache
@@ -45,10 +45,16 @@ import com.squareup.moshi.Moshi
import retrofit2.converter.moshi.MoshiConverterFactory
{{/moshi}}
+{{#kotlinx_serialization}}
+import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
+import {{packageName}}.infrastructure.Serializer.jvmJson
+import okhttp3.MediaType.Companion.toMediaType
+{{/kotlinx_serialization}}
+
{{#nonPublicApi}}internal {{/nonPublicApi}}class ApiClient(
private var baseUrl: String = defaultBasePath,
- private val okHttpClientBuilder: OkHttpClient.Builder? = null,
- private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
+ private val okHttpClientBuilder: OkHttpClient.Builder? = null{{^kotlinx_serialization}},
+ private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder{{/kotlinx_serialization}},
private val okHttpClient : OkHttpClient? = null
) {
private val apiAuthorizations = mutableMapOf()
@@ -72,6 +78,9 @@ import retrofit2.converter.moshi.MoshiConverterFactory
{{#moshi}}
.addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build()))
{{/moshi}}
+ {{#kotlinx_serialization}}
+ .addConverterFactory(jvmJson.asConverterFactory("application/json".toMediaType()))
+ {{/kotlinx_serialization}}
}
private val clientBuilder: OkHttpClient.Builder by lazy {
@@ -98,9 +107,9 @@ import retrofit2.converter.moshi.MoshiConverterFactory
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
- serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
+ {{^kotlinx_serialization}}serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,{{/kotlinx_serialization}}
authNames: Array
- ) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
+ ) : this(baseUrl, okHttpClientBuilder{{^kotlinx_serialization}}, serializerBuilder{{/kotlinx_serialization}}) {
authNames.forEach { authName ->
val auth = when (authName) {
{{#authMethods}}"{{name}}" -> {{#isBasic}}{{#isBasicBasic}}HttpBasicAuth(){{/isBasicBasic}}{{#isBasicBearer}}HttpBearerAuth("{{scheme}}"){{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"){{/isApiKey}}{{#isOAuth}}OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"){{/isOAuth}}{{/authMethods}}
@@ -116,11 +125,11 @@ import retrofit2.converter.moshi.MoshiConverterFactory
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
- serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
+ {{^kotlinx_serialization}}serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,{{/kotlinx_serialization}}
authName: String,
username: String,
password: String
- ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
+ ) : this(baseUrl, okHttpClientBuilder, {{^kotlinx_serialization}}serializerBuilder, {{/kotlinx_serialization}}arrayOf(authName)) {
setCredentials(username, password)
}
@@ -129,10 +138,10 @@ import retrofit2.converter.moshi.MoshiConverterFactory
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
- serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
+ {{^kotlinx_serialization}}serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,{{/kotlinx_serialization}}
authName: String,
bearerToken: String
- ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
+ ) : this(baseUrl, okHttpClientBuilder, {{^kotlinx_serialization}}serializerBuilder, {{/kotlinx_serialization}}arrayOf(authName)) {
setBearerToken(bearerToken)
}
@@ -143,13 +152,13 @@ import retrofit2.converter.moshi.MoshiConverterFactory
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
- serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
+ {{^kotlinx_serialization}}serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,{{/kotlinx_serialization}}
authName: String,
clientId: String,
secret: String,
username: String,
password: String
- ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
+ ) : this(baseUrl, okHttpClientBuilder, {{^kotlinx_serialization}}serializerBuilder, {{/kotlinx_serialization}}arrayOf(authName)) {
getTokenEndPoint()
?.setClientId(clientId)
?.setClientSecret(secret)
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ResponseExt.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ResponseExt.kt.mustache
index bacdc391a69..a5edf4ee809 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ResponseExt.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ResponseExt.kt.mustache
@@ -16,7 +16,7 @@ inline fun Response<*>.getErrorResponse(serializerBuilder: Moshi.Bui
val serializer = serializerBuilder.build()
val parser = serializer.adapter(T::class.java)
val response = errorBody()?.string()
- if(response != null) {
+ if (response != null) {
return parser.fromJson(response)
}
return null
@@ -27,7 +27,7 @@ inline fun Response<*>.getErrorResponse(serializerBuilder: Moshi.Bui
inline fun Response<*>.getErrorResponse(serializerBuilder: GsonBuilder = Serializer.gsonBuilder): T? {
val serializer = serializerBuilder.create()
val reader = errorBody()?.charStream()
- if(reader != null) {
+ if (reader != null) {
return serializer.fromJson(reader, T::class.java)
}
return null
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar
deleted file mode 100644
index 2c6137b8789..00000000000
Binary files a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar and /dev/null differ
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/pom.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/pom.mustache
new file mode 100644
index 00000000000..be6fb120855
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/pom.mustache
@@ -0,0 +1,47 @@
+
+ 4.0.0
+ {{groupId}}
+ {{artifactId}}
+ {{artifactVersion}}
+ {{appName}}
+ pom
+
+
+
+ maven-dependency-plugin
+
+
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+
+ bundle-test
+ integration-test
+
+ exec
+
+
+ /bin/bash
+
+ gradlew
+ build
+
+
+
+
+
+
+
+
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/queryParams.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/queryParams.mustache
index e769fa0ce08..53686e7b82f 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-spring/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{/swaggerAnnotations}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) {{paramName}}: {{>optionalDataType}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{/swaggerAnnotations}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) {{paramName}}: {{>optionalDataType}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
index 41299d8cebf..43c8d17fadc 100644
--- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
@@ -8,7 +8,7 @@ edition = "2018"
serde = "^1.0"
serde_derive = "^1.0"
serde_json = "^1.0"
-url = "1.5"
+url = "^2.2"
{{#hyper}}
hyper = "~0.11"
serde_yaml = "0.7"
diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache
index 6e6ff043969..974bc54bd10 100644
--- a/modules/openapi-generator/src/main/resources/rust/model.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/model.mustache
@@ -9,30 +9,42 @@
{{#isEnum}}
/// {{{description}}}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
-pub enum {{classname}} {
+pub enum {{{classname}}} {
{{#allowableValues}}
{{#enumVars}}
#[serde(rename = "{{{value}}}")]
- {{name}},
+ {{{name}}},
{{/enumVars}}{{/allowableValues}}
}
+
+impl ToString for {{{classname}}} {
+ fn to_string(&self) -> String {
+ match self {
+ {{#allowableValues}}
+ {{#enumVars}}
+ Self::{{{name}}} => String::from("{{{value}}}"),
+ {{/enumVars}}
+ {{/allowableValues}}
+ }
+ }
+}
{{/isEnum}}
{{!-- for schemas that have a discriminator --}}
{{#discriminator}}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "{{{vendorExtensions.x-tag-name}}}")]
-pub enum {{classname}} {
+pub enum {{{classname}}} {
{{#vendorExtensions}}
{{#x-mapped-models}}
#[serde(rename="{{mappingName}}")]
- {{modelName}} {
+ {{{modelName}}} {
{{#vars}}
{{#description}}
/// {{{description}}}
{{/description}}
#[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})]
- {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
+ {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{#isModel}}Box<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
{{/vars}}
},
{{/x-mapped-models}}
@@ -51,7 +63,7 @@ pub struct {{{classname}}} {
/// {{{description}}}
{{/description}}
#[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})]
- pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
+ pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isModel}}Box<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
{{/vars}}
}
@@ -62,7 +74,7 @@ impl {{{classname}}} {
pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
{{{classname}}} {
{{#vars}}
- {{{name}}}{{^required}}{{#isArray}}: None{{/isArray}}{{#isMap}}: None{{/isMap}}{{^isContainer}}: None{{/isContainer}}{{/required}},
+ {{{name}}}{{^required}}{{#isArray}}: None{{/isArray}}{{#isMap}}: None{{/isMap}}{{^isContainer}}: None{{/isContainer}}{{/required}}{{#required}}{{#isModel}}: Box::new({{{name}}}){{/isModel}}{{/required}},
{{/vars}}
}
}
@@ -75,11 +87,11 @@ impl {{{classname}}} {
{{#isEnum}}
/// {{{description}}}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
-pub enum {{enumName}} {
+pub enum {{{enumName}}} {
{{#allowableValues}}
{{#enumVars}}
#[serde(rename = "{{{value}}}")]
- {{name}},
+ {{{name}}},
{{/enumVars}}
{{/allowableValues}}
}
diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
index 977f0b6edbc..8ff7ce8d99e 100644
--- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
@@ -17,7 +17,7 @@ pub struct {{{operationIdCamelCase}}}Params {
{{#description}}
/// {{{.}}}
{{/description}}
- pub {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}},{{/-last}}
+ pub {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}crate::models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}},{{/-last}}
{{#-last}}
}
@@ -88,7 +88,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/vendorExtensions.x-group-parameters}}
{{^vendorExtensions.x-group-parameters}}
-pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> {
+pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}crate::models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> {
{{/vendorExtensions.x-group-parameters}}
let local_var_client = &configuration.client;
diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache
index 2c9b243a6d3..339be6bcced 100644
--- a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache
@@ -2,6 +2,7 @@
use reqwest;
+#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
pub user_agent: Option,
@@ -15,6 +16,7 @@ pub struct Configuration {
pub type BasicAuth = (String, Option);
+#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option,
pub key: String,
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
index f103f744f0a..17c5864fe00 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
@@ -3075,4 +3075,203 @@ public class DefaultCodegenTest {
// does not have vars because the inline schema was extracted into a component ref
assertEquals(co.responses.get(0).getHasVars(), false);
}
+
+ @Test
+ public void testHasRequiredInModel() {
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_8906.yaml");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ codegen.setOpenAPI(openAPI);
+ codegen.setDisallowAdditionalPropertiesIfNotPresent(false);
+
+ Schema sc;
+ CodegenModel cm;
+
+ List modelNamesWithoutRequired = Arrays.asList(
+ "EmptyObject",
+ "ObjectWithOptionalB",
+ "AnyTypeNoPropertiesNoRequired",
+ "AnyTypeHasPropertiesNoRequired",
+ "AnyTypeNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ObjectNoPropertiesNoRequired",
+ "ObjectHasPropertiesNoRequired",
+ "ObjectNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedNoAllofPropsNoPropertiesNoRequired",
+ "ComposedNoAllofPropsHasPropertiesNoRequired",
+ "ComposedNoAllofPropsNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofOptPropNoPropertiesNoRequired",
+ "ComposedHasAllofOptPropHasPropertiesNoRequired",
+ "ComposedHasAllofOptPropNoPropertiesHasRequired" // TODO: hasRequired should be true, fix this
+ );
+ for (String modelName : modelNamesWithoutRequired) {
+ sc = openAPI.getComponents().getSchemas().get(modelName);
+ cm = codegen.fromModel(modelName, sc);
+ assertEquals(cm.getHasRequired(), false);
+ }
+
+ List modelNamesWithRequired = Arrays.asList(
+ "AnyTypeHasPropertiesHasRequired",
+ "ObjectHasPropertiesHasRequired",
+ "ComposedNoAllofPropsHasPropertiesHasRequired",
+ "ComposedHasAllofOptPropHasPropertiesHasRequired",
+ "ComposedHasAllofReqPropNoPropertiesNoRequired", // TODO: hasRequired should be false, fix this
+ "ComposedHasAllofReqPropHasPropertiesNoRequired", // TODO: hasRequired should be false, fix this
+ "ComposedHasAllofReqPropNoPropertiesHasRequired",
+ "ComposedHasAllofReqPropHasPropertiesHasRequired"
+ );
+ for (String modelName : modelNamesWithRequired) {
+ sc = openAPI.getComponents().getSchemas().get(modelName);
+ cm = codegen.fromModel(modelName, sc);
+ assertEquals(cm.getHasRequired(), true);
+ }
+ }
+
+ @Test
+ public void testHasRequiredInProperties() {
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_8906.yaml");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ codegen.setOpenAPI(openAPI);
+ codegen.setDisallowAdditionalPropertiesIfNotPresent(false);
+
+ String modelName = "CodegenPropertiesModel";
+ Schema sc = openAPI.getComponents().getSchemas().get(modelName);
+ CodegenModel cm = codegen.fromModel(modelName, sc);
+
+ HashSet modelNamesWithoutRequired = new HashSet(Arrays.asList(
+ "EmptyObject",
+ "ObjectWithOptionalB",
+ "AnyTypeNoPropertiesNoRequired",
+ "AnyTypeHasPropertiesNoRequired",
+ "AnyTypeNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "AnyTypeHasPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ObjectNoPropertiesNoRequired",
+ "ObjectHasPropertiesNoRequired", // Note: this is extracted into another component and is a ref
+ "ObjectNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedNoAllofPropsNoPropertiesNoRequired",
+ "ComposedNoAllofPropsHasPropertiesNoRequired",
+ "ComposedNoAllofPropsNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofOptPropNoPropertiesNoRequired",
+ "ComposedHasAllofOptPropHasPropertiesNoRequired",
+ "ComposedHasAllofOptPropNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ObjectHasPropertiesHasRequired", // False because this is extracted into another component and is a ref
+ "ComposedNoAllofPropsHasPropertiesHasRequired", // False because this is extracted into another component and is a ref
+ "ComposedHasAllofOptPropHasPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofReqPropNoPropertiesNoRequired",
+ "ComposedHasAllofReqPropHasPropertiesNoRequired",
+ "ComposedHasAllofReqPropNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofReqPropHasPropertiesHasRequired" // TODO: hasRequired should be true, fix this
+ ));
+ HashSet modelNamesWithRequired = new HashSet(Arrays.asList(
+ ));
+ for (CodegenProperty var : cm.getVars()) {
+ boolean hasRequired = var.getHasRequired();
+ if (modelNamesWithoutRequired.contains(var.name)) {
+ assertEquals(hasRequired, false);
+ } else if (modelNamesWithRequired.contains(var.name)) {
+ assertEquals(hasRequired, true);
+ } else {
+ // All variables must be in the above sets
+ assertEquals(true, false);
+ }
+ }
+ }
+
+ @Test
+ public void testHasRequiredInParameters() {
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_8906.yaml");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ codegen.setOpenAPI(openAPI);
+ codegen.setDisallowAdditionalPropertiesIfNotPresent(false);
+
+ String path = "/schemasInQueryParamsAndResponses";
+ Operation operation = openAPI.getPaths().get(path).getPost();
+ CodegenOperation co = codegen.fromOperation(path, "POST", operation, null);
+
+ HashSet modelNamesWithoutRequired = new HashSet(Arrays.asList(
+ "EmptyObject",
+ "ObjectWithOptionalB",
+ "AnyTypeNoPropertiesNoRequired",
+ "AnyTypeHasPropertiesNoRequired",
+ "AnyTypeNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "AnyTypeHasPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ObjectNoPropertiesNoRequired",
+ "ObjectHasPropertiesNoRequired", // Note: this is extracted into another component and is a ref
+ "ObjectNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedNoAllofPropsNoPropertiesNoRequired",
+ "ComposedNoAllofPropsHasPropertiesNoRequired",
+ "ComposedNoAllofPropsNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofOptPropNoPropertiesNoRequired",
+ "ComposedHasAllofOptPropHasPropertiesNoRequired",
+ "ComposedHasAllofOptPropNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ObjectHasPropertiesHasRequired", // False because this is extracted into another component and is a ref
+ "ComposedNoAllofPropsHasPropertiesHasRequired", // False because this is extracted into another component and is a ref
+ "ComposedHasAllofOptPropHasPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofReqPropNoPropertiesNoRequired",
+ "ComposedHasAllofReqPropHasPropertiesNoRequired",
+ "ComposedHasAllofReqPropNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofReqPropHasPropertiesHasRequired" // TODO: hasRequired should be true, fix this
+ ));
+ HashSet modelNamesWithRequired = new HashSet(Arrays.asList(
+ ));
+ for (CodegenParameter param : co.pathParams) {
+ boolean hasRequired = param.getHasRequired();
+ if (modelNamesWithoutRequired.contains(param.baseName)) {
+ assertEquals(hasRequired, false);
+ } else if (modelNamesWithRequired.contains(param.baseName)) {
+ assertEquals(hasRequired, true);
+ } else {
+ // All variables must be in the above sets
+ assertEquals(true, false);
+ }
+ }
+ }
+
+ @Test
+ public void testHasRequiredInResponses() {
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_8906.yaml");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ codegen.setOpenAPI(openAPI);
+ codegen.setDisallowAdditionalPropertiesIfNotPresent(false);
+
+ String path = "/schemasInQueryParamsAndResponses";
+ Operation operation = openAPI.getPaths().get(path).getPost();
+ CodegenOperation co = codegen.fromOperation(path, "POST", operation, null);
+
+ HashSet modelNamesWithoutRequired = new HashSet(Arrays.asList(
+ "EmptyObject",
+ "ObjectWithOptionalB",
+ "AnyTypeNoPropertiesNoRequired",
+ "AnyTypeHasPropertiesNoRequired",
+ "AnyTypeNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "AnyTypeHasPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ObjectNoPropertiesNoRequired",
+ "ObjectHasPropertiesNoRequired", // Note: this is extracted into another component and is a ref
+ "ObjectNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedNoAllofPropsNoPropertiesNoRequired",
+ "ComposedNoAllofPropsHasPropertiesNoRequired",
+ "ComposedNoAllofPropsNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofOptPropNoPropertiesNoRequired",
+ "ComposedHasAllofOptPropHasPropertiesNoRequired",
+ "ComposedHasAllofOptPropNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ObjectHasPropertiesHasRequired", // False because this is extracted into another component and is a ref
+ "ComposedNoAllofPropsHasPropertiesHasRequired", // False because this is extracted into another component and is a ref
+ "ComposedHasAllofOptPropHasPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofReqPropNoPropertiesNoRequired",
+ "ComposedHasAllofReqPropHasPropertiesNoRequired",
+ "ComposedHasAllofReqPropNoPropertiesHasRequired", // TODO: hasRequired should be true, fix this
+ "ComposedHasAllofReqPropHasPropertiesHasRequired" // TODO: hasRequired should be true, fix this
+ ));
+ HashSet modelNamesWithRequired = new HashSet(Arrays.asList(
+ ));
+ for (CodegenResponse cr : co.responses) {
+ boolean hasRequired = cr.getHasRequired();
+ if (modelNamesWithoutRequired.contains(cr.message)) {
+ assertEquals(hasRequired, false);
+ } else if (modelNamesWithRequired.contains(cr.message)) {
+ assertEquals(hasRequired, true);
+ } else {
+ // All variables must be in the above sets
+ assertEquals(true, false);
+ }
+ }
+ }
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java
index 7a22776af35..4baa1b4ed78 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java
@@ -462,7 +462,7 @@ public class DefaultGeneratorTest {
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 20);
+ Assert.assertEquals(files.size(), 24);
// Generator should report a library templated file as a generated file
TestUtils.ensureContainsFile(files, output, "src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt");
@@ -504,7 +504,7 @@ public class DefaultGeneratorTest {
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 20);
+ Assert.assertEquals(files.size(), 24);
// Generator should report README.md as a generated file
TestUtils.ensureContainsFile(files, output, "README.md");
@@ -569,7 +569,7 @@ public class DefaultGeneratorTest {
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 20);
+ Assert.assertEquals(files.size(), 24);
// Generator should report a library templated file as a generated file
TestUtils.ensureContainsFile(files, output, "src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt");
@@ -623,7 +623,7 @@ public class DefaultGeneratorTest {
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 20);
+ Assert.assertEquals(files.size(), 24);
// Generator should report README.md as a generated file
TestUtils.ensureContainsFile(files, output, "README.md");
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientCodegenTest.java
similarity index 98%
rename from modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioClientCodegenTest.java
rename to modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientCodegenTest.java
index 24eb454be8e..0e57791ce2f 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientCodegenTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.openapitools.codegen.dartdio;
+package org.openapitools.codegen.dart.dio;
import java.io.BufferedReader;
import java.io.FileInputStream;
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientOptionsTest.java
similarity index 98%
rename from modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioClientOptionsTest.java
rename to modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientOptionsTest.java
index 8f1a3abcd4b..478d243580e 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientOptionsTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.openapitools.codegen.dartdio;
+package org.openapitools.codegen.dart.dio;
import org.openapitools.codegen.AbstractOptionsTest;
import org.openapitools.codegen.CodegenConfig;
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioModelTest.java
similarity index 99%
rename from modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioModelTest.java
rename to modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioModelTest.java
index 7aac98353d6..adc15af5100 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioModelTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioModelTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.openapitools.codegen.dartdio;
+package org.openapitools.codegen.dart.dio;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextClientCodegenTest.java
new file mode 100644
index 00000000000..61622224bfd
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextClientCodegenTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2021 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.dart.dio;
+
+import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.languages.DartDioClientCodegen;
+import org.openapitools.codegen.languages.DartDioNextClientCodegen;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class DartDioNextClientCodegenTest {
+
+ @Test
+ public void testInitialConfigValues() throws Exception {
+ final DartDioNextClientCodegen codegen = new DartDioNextClientCodegen();
+ codegen.processOpts();
+
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
+ Assert.assertEquals(codegen.isHideGenerationTimestamp(), true);
+ }
+
+ @Test
+ public void testSettersForConfigValues() throws Exception {
+ final DartDioClientCodegen codegen = new DartDioClientCodegen();
+ codegen.setHideGenerationTimestamp(false);
+ codegen.processOpts();
+
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
+ Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
+ }
+
+ @Test
+ public void testAdditionalPropertiesPutForConfigValues() throws Exception {
+ final DartDioClientCodegen codegen = new DartDioClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
+ codegen.processOpts();
+
+ Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
+ Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
+ }
+
+ @Test
+ public void testKeywords() throws Exception {
+ final DartDioClientCodegen codegen = new DartDioClientCodegen();
+
+ List reservedWordsList = new ArrayList();
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/main/resources/dart/dart-keywords.txt"), Charset.forName("UTF-8")));
+ while(reader.ready()) { reservedWordsList.add(reader.readLine()); }
+ reader.close();
+ } catch (Exception e) {
+ String errorString = String.format(Locale.ROOT, "Error reading dart keywords: %s", e);
+ Assert.fail(errorString, e);
+ }
+
+ Assert.assertEquals(reservedWordsList.size() > 20, true);
+ Assert.assertEquals(codegen.reservedWords().size() == reservedWordsList.size(), true);
+ for(String keyword : reservedWordsList) {
+ // reserved words are stored in lowercase
+ Assert.assertEquals(codegen.reservedWords().contains(keyword.toLowerCase(Locale.ROOT)), true, String.format(Locale.ROOT, "%s, part of %s, was not found in %s", keyword, reservedWordsList, codegen.reservedWords().toString()));
+ }
+ }
+
+}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextClientOptionsTest.java
new file mode 100644
index 00000000000..f2237e4fbaa
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextClientOptionsTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2021 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.dart.dio;
+
+import org.openapitools.codegen.AbstractOptionsTest;
+import org.openapitools.codegen.CodegenConfig;
+import org.openapitools.codegen.languages.DartDioNextClientCodegen;
+import org.openapitools.codegen.options.DartDioNextClientOptionsProvider;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class DartDioNextClientOptionsTest extends AbstractOptionsTest {
+ private DartDioNextClientCodegen clientCodegen = mock(DartDioNextClientCodegen.class, mockSettings);
+
+ public DartDioNextClientOptionsTest() {
+ super(new DartDioNextClientOptionsProvider());
+ }
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ protected void verifyOptions() {
+ verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(DartDioNextClientOptionsProvider.SORT_PARAMS_VALUE));
+ verify(clientCodegen).setPubLibrary(DartDioNextClientOptionsProvider.PUB_LIBRARY_VALUE);
+ verify(clientCodegen).setPubName(DartDioNextClientOptionsProvider.PUB_NAME_VALUE);
+ verify(clientCodegen).setPubVersion(DartDioNextClientOptionsProvider.PUB_VERSION_VALUE);
+ verify(clientCodegen).setPubDescription(DartDioNextClientOptionsProvider.PUB_DESCRIPTION_VALUE);
+ verify(clientCodegen).setPubAuthor(DartDioNextClientOptionsProvider.PUB_AUTHOR_VALUE);
+ verify(clientCodegen).setPubAuthorEmail(DartDioNextClientOptionsProvider.PUB_AUTHOR_EMAIL_VALUE);
+ verify(clientCodegen).setPubHomepage(DartDioNextClientOptionsProvider.PUB_HOMEPAGE_VALUE);
+ verify(clientCodegen).setSourceFolder(DartDioNextClientOptionsProvider.SOURCE_FOLDER_VALUE);
+ verify(clientCodegen).setUseEnumExtension(Boolean.parseBoolean(DartDioNextClientOptionsProvider.USE_ENUM_EXTENSION));
+ verify(clientCodegen).setDateLibrary(DartDioNextClientCodegen.DATE_LIBRARY_DEFAULT);
+ verify(clientCodegen).setLibrary(DartDioNextClientCodegen.SERIALIZATION_LIBRARY_DEFAULT);
+ }
+}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextModelTest.java
new file mode 100644
index 00000000000..928647ae681
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioNextModelTest.java
@@ -0,0 +1,494 @@
+/*
+ * Copyright 2021 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.dart.dio;
+
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.media.*;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.languages.DartDioNextClientCodegen;
+import org.openapitools.codegen.languages.DartDioNextClientCodegen;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("static-method")
+public class DartDioNextModelTest {
+
+ @Test(description = "convert a simple model")
+ public void simpleModelTest() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("id", new IntegerSchema())
+ .addProperties("name", new StringSchema())
+ .addProperties("createdAt", new DateTimeSchema())
+ .addRequiredItem("id")
+ .addRequiredItem("name");
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
+ codegen.setOpenAPI(openAPI);
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 3);
+ // {{imports}} is not used in template
+ //Assert.assertEquals(cm.imports.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "id");
+ Assert.assertEquals(property1.dataType, "int");
+ Assert.assertEquals(property1.name, "id");
+ Assert.assertNull(property1.defaultValue);
+ Assert.assertEquals(property1.baseType, "int");
+ Assert.assertTrue(property1.required);
+ Assert.assertTrue(property1.isPrimitiveType);
+ Assert.assertFalse(property1.isContainer);
+
+ final CodegenProperty property2 = cm.vars.get(1);
+ Assert.assertEquals(property2.baseName, "name");
+ Assert.assertEquals(property2.dataType, "String");
+ Assert.assertEquals(property2.name, "name");
+ Assert.assertNull(property2.defaultValue);
+ Assert.assertEquals(property2.baseType, "String");
+ Assert.assertTrue(property2.required);
+ Assert.assertTrue(property2.isPrimitiveType);
+ Assert.assertFalse(property2.isContainer);
+
+ final CodegenProperty property3 = cm.vars.get(2);
+ Assert.assertEquals(property3.baseName, "createdAt");
+ Assert.assertEquals(property3.complexType, "DateTime");
+ Assert.assertEquals(property3.dataType, "DateTime");
+ Assert.assertEquals(property3.name, "createdAt");
+ Assert.assertNull(property3.defaultValue);
+ Assert.assertEquals(property3.baseType, "DateTime");
+ Assert.assertFalse(property3.required);
+ Assert.assertFalse(property3.isContainer);
+ }
+
+ @Test(description = "convert a simple dart-dit model with datelibrary")
+ public void simpleModelWithTimeMachineTest() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("id", new IntegerSchema())
+ .addProperties("name", new StringSchema())
+ .addProperties("createdAt", new DateTimeSchema())
+ .addProperties("birthDate", new DateSchema())
+ .addRequiredItem("id")
+ .addRequiredItem("name");
+
+ final DartDioNextClientCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(DartDioNextClientCodegen.DATE_LIBRARY, DartDioNextClientCodegen.DATE_LIBRARY_TIME_MACHINE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 4);
+ // {{imports}} is not used in template
+ //Assert.assertEquals(cm.imports.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "id");
+ Assert.assertEquals(property1.dataType, "int");
+ Assert.assertEquals(property1.name, "id");
+ Assert.assertNull(property1.defaultValue);
+ Assert.assertEquals(property1.baseType, "int");
+ Assert.assertTrue(property1.required);
+ Assert.assertTrue(property1.isPrimitiveType);
+ Assert.assertFalse(property1.isContainer);
+
+ final CodegenProperty property2 = cm.vars.get(1);
+ Assert.assertEquals(property2.baseName, "name");
+ Assert.assertEquals(property2.dataType, "String");
+ Assert.assertEquals(property2.name, "name");
+ Assert.assertNull(property2.defaultValue);
+ Assert.assertEquals(property2.baseType, "String");
+ Assert.assertTrue(property2.required);
+ Assert.assertTrue(property2.isPrimitiveType);
+ Assert.assertFalse(property2.isContainer);
+
+ final CodegenProperty property3 = cm.vars.get(2);
+ Assert.assertEquals(property3.baseName, "createdAt");
+ Assert.assertEquals(property3.complexType, "OffsetDateTime");
+ Assert.assertEquals(property3.dataType, "OffsetDateTime");
+ Assert.assertEquals(property3.name, "createdAt");
+ Assert.assertNull(property3.defaultValue);
+ Assert.assertEquals(property3.baseType, "OffsetDateTime");
+ Assert.assertFalse(property3.required);
+ Assert.assertFalse(property3.isContainer);
+
+ final CodegenProperty property4 = cm.vars.get(3);
+ Assert.assertEquals(property4.baseName, "birthDate");
+ Assert.assertEquals(property4.complexType, "OffsetDate");
+ Assert.assertEquals(property4.dataType, "OffsetDate");
+ Assert.assertEquals(property4.name, "birthDate");
+ Assert.assertNull(property4.defaultValue);
+ Assert.assertEquals(property4.baseType, "OffsetDate");
+ Assert.assertFalse(property4.required);
+ Assert.assertFalse(property4.isContainer);
+ }
+
+ @Test(description = "convert a model with list property")
+ public void listPropertyTest() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("id", new IntegerSchema())
+ .addProperties("urls", new ArraySchema()
+ .items(new StringSchema()))
+ .addRequiredItem("id");
+
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 2);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "id");
+ Assert.assertEquals(property1.dataType, "int");
+ Assert.assertEquals(property1.name, "id");
+ Assert.assertNull(property1.defaultValue);
+ Assert.assertEquals(property1.baseType, "int");
+ Assert.assertTrue(property1.required);
+ Assert.assertTrue(property1.isPrimitiveType);
+ Assert.assertFalse(property1.isContainer);
+
+ final CodegenProperty property2 = cm.vars.get(1);
+ Assert.assertEquals(property2.baseName, "urls");
+ Assert.assertEquals(property2.dataType, "BuiltList");
+ Assert.assertEquals(property2.name, "urls");
+ Assert.assertEquals(property2.baseType, "BuiltList");
+ Assert.assertEquals(property2.containerType, "array");
+ Assert.assertFalse(property2.required);
+ Assert.assertTrue(property2.isPrimitiveType);
+ Assert.assertTrue(property2.isContainer);
+ }
+
+ @Test(description = "convert a model with set property")
+ public void setPropertyTest() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("id", new IntegerSchema())
+ .addProperties("urls", new ArraySchema().items(new StringSchema()).uniqueItems(true))
+ .addRequiredItem("id");
+
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 2);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "id");
+ Assert.assertEquals(property1.dataType, "int");
+ Assert.assertEquals(property1.name, "id");
+ Assert.assertNull(property1.defaultValue);
+ Assert.assertEquals(property1.baseType, "int");
+ Assert.assertTrue(property1.required);
+ Assert.assertTrue(property1.isPrimitiveType);
+ Assert.assertFalse(property1.isContainer);
+
+ final CodegenProperty property2 = cm.vars.get(1);
+ Assert.assertEquals(property2.baseName, "urls");
+ Assert.assertEquals(property2.dataType, "BuiltSet");
+ Assert.assertEquals(property2.name, "urls");
+ Assert.assertEquals(property2.baseType, "BuiltSet");
+ Assert.assertEquals(property2.containerType, "set");
+ Assert.assertFalse(property2.required);
+ Assert.assertTrue(property2.isPrimitiveType);
+ Assert.assertTrue(property2.isContainer);
+ }
+
+ @Test(description = "convert a model with a map property")
+ public void mapPropertyTest() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("translations", new MapSchema()
+ .additionalProperties(new StringSchema()))
+ .addRequiredItem("id");
+
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "translations");
+ Assert.assertEquals(property1.dataType, "BuiltMap");
+ Assert.assertEquals(property1.name, "translations");
+ Assert.assertEquals(property1.baseType, "BuiltMap");
+ Assert.assertEquals(property1.containerType, "map");
+ Assert.assertFalse(property1.required);
+ Assert.assertTrue(property1.isContainer);
+ Assert.assertTrue(property1.isPrimitiveType);
+ }
+
+ @Test(description = "convert a model with complex property")
+ public void complexPropertyTest() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("children", new Schema().$ref("#/definitions/Children"));
+
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "children");
+ Assert.assertEquals(property1.dataType, "Children");
+ Assert.assertEquals(property1.name, "children");
+ Assert.assertEquals(property1.baseType, "Children");
+ Assert.assertFalse(property1.required);
+ Assert.assertFalse(property1.isContainer);
+ }
+
+ @Test(description = "convert a model with complex list property")
+ public void complexListProperty() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("children", new ArraySchema()
+ .items(new Schema().$ref("#/definitions/Children")));
+
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "children");
+ Assert.assertEquals(property1.dataType, "BuiltList");
+ Assert.assertEquals(property1.name, "children");
+ Assert.assertEquals(property1.baseType, "BuiltList");
+ Assert.assertEquals(property1.containerType, "array");
+ Assert.assertFalse(property1.required);
+ Assert.assertTrue(property1.isContainer);
+ }
+
+ @Test(description = "convert a model with complex map property")
+ public void complexMapSchema() {
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("children", new MapSchema()
+ .additionalProperties(new Schema().$ref("#/definitions/Children")));
+
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "children");
+ Assert.assertEquals(property1.complexType, "Children");
+ Assert.assertEquals(property1.dataType, "BuiltMap");
+ Assert.assertEquals(property1.name, "children");
+ Assert.assertEquals(property1.baseType, "BuiltMap");
+ Assert.assertEquals(property1.containerType, "map");
+ Assert.assertFalse(property1.required);
+ Assert.assertTrue(property1.isContainer);
+ }
+
+ @Test(description = "convert an array model")
+ public void arrayModelTest() {
+ final Schema model = new ArraySchema()
+ .items(new Schema().$ref("#/definitions/Children"))
+ .description("an array model");
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
+ codegen.setOpenAPI(openAPI);
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(model.getDescription(), "an array model");
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertTrue(cm.isArray);
+ Assert.assertEquals(cm.description, "an array model");
+ Assert.assertEquals(cm.vars.size(), 0);
+ }
+
+ @Test(description = "convert a map model")
+ public void mapModelTest() {
+ final Schema model = new Schema()
+ .description("a map model")
+ .additionalProperties(new Schema().$ref("#/definitions/Children"));
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
+ codegen.setOpenAPI(openAPI);
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a map model");
+ Assert.assertEquals(cm.vars.size(), 0);
+ }
+
+ @DataProvider(name = "modelNames")
+ public static Object[][] modelNames() {
+ return new Object[][] {
+ {"EnumClass", "ModelEnumClass"},
+ {"JsonObject", "ModelJsonObject"},
+ // OffsetDate is valid without timemachine date library
+ {"OffsetDate", "OffsetDate"},
+ };
+ }
+
+ @Test(dataProvider = "modelNames", description = "correctly prefix reserved model names")
+ public void modelNameTest(String name, String expectedName) {
+ OpenAPI openAPI = TestUtils.createOpenAPI();
+ final Schema model = new Schema();
+
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.processOpts();
+
+ codegen.setOpenAPI(openAPI);
+
+ final CodegenModel cm = codegen.fromModel(name, model);
+
+ Assert.assertEquals(cm.name, name);
+ Assert.assertEquals(cm.classname, expectedName);
+ }
+
+ @DataProvider(name = "modelNamesTimemachine")
+ public static Object[][] modelNamesTimemachine() {
+ return new Object[][] {
+ {"EnumClass", "ModelEnumClass"},
+ {"JsonObject", "ModelJsonObject"},
+ // OffsetDate is not valid with timemachine date library
+ {"OffsetDate", "ModelOffsetDate"},
+ };
+ }
+
+ @Test(dataProvider = "modelNamesTimemachine", description = "correctly prefix reserved model names")
+ public void modelNameTestTimemachine(String name, String expectedName) {
+ OpenAPI openAPI = TestUtils.createOpenAPI();
+ final Schema model = new Schema();
+ final DartDioNextClientCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(DartDioNextClientCodegen.DATE_LIBRARY, DartDioNextClientCodegen.DATE_LIBRARY_TIME_MACHINE);
+ codegen.processOpts();
+ codegen.setOpenAPI(openAPI);
+ final CodegenModel cm = codegen.fromModel(name, model);
+
+ Assert.assertEquals(cm.name, name);
+ Assert.assertEquals(cm.classname, expectedName);
+ }
+
+ @Test(description = "correctly generate collection default values")
+ public void collectionDefaultValues() {
+ final ArraySchema array = new ArraySchema();
+ array.setDefault("[]");
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("arrayNoDefault", new ArraySchema())
+ .addProperties("arrayEmptyDefault", array)
+ .addProperties("mapNoDefault", new MapSchema());
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_BUILT_VALUE);
+ codegen.setOpenAPI(TestUtils.createOpenAPIWithOneSchema("sample", model));
+ codegen.processOpts();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ final CodegenProperty arrayNoDefault = cm.vars.get(0);
+ Assert.assertEquals(arrayNoDefault.name, "arrayNoDefault");
+ Assert.assertNull(arrayNoDefault.defaultValue);
+
+ final CodegenProperty arrayEmptyDefault = cm.vars.get(1);
+ Assert.assertEquals(arrayEmptyDefault.name, "arrayEmptyDefault");
+ Assert.assertEquals(arrayEmptyDefault.defaultValue, "ListBuilder()");
+
+ final CodegenProperty mapNoDefault = cm.vars.get(2);
+ Assert.assertEquals(mapNoDefault.name, "mapNoDefault");
+ Assert.assertNull(mapNoDefault.defaultValue);
+ }
+
+ @Test(description = "correctly generate date/datetime default values, currently null")
+ public void dateDefaultValues() {
+ final DateSchema date = new DateSchema();
+ date.setDefault("2021-01-01");
+ final DateTimeSchema dateTime = new DateTimeSchema();
+ dateTime.setDefault("2021-01-01T14:00:00Z");
+ final Schema model = new Schema()
+ .description("a sample model")
+ .addProperties("date", date)
+ .addProperties("dateTime", dateTime)
+ .addProperties("mapNoDefault", new MapSchema());
+ final DefaultCodegen codegen = new DartDioNextClientCodegen();
+ OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
+ codegen.setOpenAPI(openAPI);
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ final CodegenProperty dateDefault = cm.vars.get(0);
+ Assert.assertEquals(dateDefault.name, "date");
+ Assert.assertNull(dateDefault.defaultValue);
+
+ final CodegenProperty dateTimeDefault = cm.vars.get(1);
+ Assert.assertEquals(dateTimeDefault.name, "dateTime");
+ Assert.assertNull(dateTimeDefault.defaultValue);
+ }
+}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioClientOptionsProvider.java
index 89186805c9c..fa6bb3eeadb 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioClientOptionsProvider.java
@@ -31,7 +31,7 @@ public class DartDioClientOptionsProvider implements OptionsProvider {
public static final String PUB_LIBRARY_VALUE = "openapi.api";
public static final String PUB_NAME_VALUE = "openapi";
public static final String PUB_VERSION_VALUE = "1.0.0-SNAPSHOT";
- public static final String PUB_DESCRIPTION_VALUE = "OpenAPI API client dart";
+ public static final String PUB_DESCRIPTION_VALUE = "OpenAPI API client dart-dio";
public static final String SOURCE_FOLDER_VALUE = "src";
public static final String USE_ENUM_EXTENSION = "true";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioNextClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioNextClientOptionsProvider.java
new file mode 100644
index 00000000000..b03f2a97214
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioNextClientOptionsProvider.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2021 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.options;
+
+import com.google.common.collect.ImmutableMap;
+import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.languages.DartDioNextClientCodegen;
+
+import java.util.Map;
+
+public class DartDioNextClientOptionsProvider implements OptionsProvider {
+ public static final String SORT_PARAMS_VALUE = "true";
+ public static final String SORT_MODEL_PROPERTIES_VALUE = "false";
+ public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
+ public static final String PUB_LIBRARY_VALUE = "openapi.api";
+ public static final String PUB_NAME_VALUE = "openapi";
+ public static final String PUB_VERSION_VALUE = "1.0.0-SNAPSHOT";
+ public static final String PUB_DESCRIPTION_VALUE = "OpenAPI API client dart-dio";
+ public static final String SOURCE_FOLDER_VALUE = "src";
+ public static final String USE_ENUM_EXTENSION = "true";
+ public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
+ public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
+ public static final String PUB_AUTHOR_VALUE = "Author";
+ public static final String PUB_AUTHOR_EMAIL_VALUE = "author@homepage";
+ public static final String PUB_HOMEPAGE_VALUE = "Homepage";
+
+ @Override
+ public String getLanguage() {
+ return "dart-dio-next";
+ }
+
+ @Override
+ public Map createOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
+ .put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, SORT_MODEL_PROPERTIES_VALUE)
+ .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
+ .put(DartDioNextClientCodegen.PUB_LIBRARY, PUB_LIBRARY_VALUE)
+ .put(DartDioNextClientCodegen.PUB_NAME, PUB_NAME_VALUE)
+ .put(DartDioNextClientCodegen.PUB_VERSION, PUB_VERSION_VALUE)
+ .put(DartDioNextClientCodegen.PUB_DESCRIPTION, PUB_DESCRIPTION_VALUE)
+ .put(DartDioNextClientCodegen.PUB_AUTHOR, PUB_AUTHOR_VALUE)
+ .put(DartDioNextClientCodegen.PUB_AUTHOR_EMAIL, PUB_AUTHOR_EMAIL_VALUE)
+ .put(DartDioNextClientCodegen.PUB_HOMEPAGE, PUB_HOMEPAGE_VALUE)
+ .put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioNextClientCodegen.SERIALIZATION_LIBRARY_DEFAULT)
+ .put(DartDioNextClientCodegen.DATE_LIBRARY, DartDioNextClientCodegen.DATE_LIBRARY_DEFAULT)
+ .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
+ .put(DartDioNextClientCodegen.USE_ENUM_EXTENSION, USE_ENUM_EXTENSION)
+ .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
+ .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)
+ .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true")
+ .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true")
+ .build();
+ }
+
+ @Override
+ public boolean isServer() {
+ return false;
+ }
+}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5ClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5ClientCodegenTest.java
index 28a3c2684a1..f505c221cbd 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5ClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5ClientCodegenTest.java
@@ -185,4 +185,37 @@ public class Swift5ClientCodegenTest {
}
}
+ @Test(description = "Bug example code generation 2", enabled = true)
+ public void crashSwift5ExampleCodeGenerationStackOverflowBug_2Test() throws IOException {
+ //final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/bugs/Swift5CodeGenerationStackOverflow#2966.yaml");
+ Path target = Files.createTempDirectory("test");
+ File output = target.toFile();
+ try {
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName("swift5")
+ .setValidateSpec(false)
+// .setInputSpec("http://localhost:8080/api/openapi.yaml")
+ .setInputSpec("src/test/resources/bugs/Swift5CodeGenarationBug2.yaml")
+ //.setInputSpec("http://localhost:8080/api/openapi.yaml")
+ .setEnablePostProcessFile(true)
+ .setOutputDir(target.toAbsolutePath().toString());
+
+ final ClientOptInput clientOptInput = configurator.toClientOptInput();
+ DefaultGenerator generator = new DefaultGenerator(false);
+
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.API_DOCS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.ENABLE_POST_PROCESS_FILE, "true");
+
+ List files = generator.opts(clientOptInput).generate();
+ Assert.assertTrue(files.size() > 0, "No files generated");
+ } finally {
+ output.delete();
+ }
+ }
+
}
diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml
new file mode 100644
index 00000000000..1ddd33b4c7d
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml
@@ -0,0 +1,124 @@
+openapi: 3.0.1
+info:
+ title: toto
+ version: 1.0.0
+ description: desc
+servers:
+ - url: "/"
+ description: "/"
+tags:
+ - name: verify-default-value
+ description: verify-default-value
+paths:
+ /test-headers:
+ get:
+ tags:
+ - verify-default-value
+ summary: test headers
+ description: desc
+ operationId: headersTest
+ parameters:
+ - name: headerNumber
+ in: header
+ schema:
+ type: number
+ default: 11.2
+ - name: headerString
+ in: header
+ schema:
+ type: string
+ default: qwerty
+ - name: headerStringWrapped
+ in: header
+ schema:
+ type: string
+ default: 'qwerty'
+ - name: headerStringQuotes
+ in: header
+ schema:
+ type: string
+ default: qwerty"with quotes" test
+ - name: headerStringQuotesWrapped
+ in: header
+ schema:
+ type: string
+ default: 'qwerty"with quotes" test'
+ - name: headerBoolean
+ in: header
+ schema:
+ type: boolean
+ default: true
+ responses:
+ default:
+ description: default response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/TestResponse'
+ /test-query-params:
+ get:
+ tags:
+ - verify-default-value
+ summary: test query params
+ description: desc
+ operationId: queryParamsTest
+ parameters:
+ - name: queryNumber
+ in: query
+ schema:
+ type: number
+ default: 11.2
+ - name: queryString
+ in: query
+ schema:
+ type: string
+ default: qwerty
+ - name: queryStringWrapped
+ in: query
+ schema:
+ type: string
+ default: 'qwerty'
+ - name: queryStringQuotes
+ in: query
+ schema:
+ type: string
+ default: qwerty"with quotes" test
+ - name: queryStringQuotesWrapped
+ in: query
+ schema:
+ type: string
+ default: 'qwerty"with quotes" test'
+ - name: queryBoolean
+ in: query
+ schema:
+ type: boolean
+ default: true
+ responses:
+ default:
+ description: default response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/TestResponse'
+
+components:
+ schemas:
+ TestResponse:
+ type: object
+ properties:
+ id:
+ type: integer
+ stringField:
+ type: string
+ default: asd
+ numberField:
+ type: number
+ default: 11
+ booleanField:
+ type: boolean
+ default: true
+ required:
+ - id
+ - stringField
+ - numberField
+ - booleanField
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_8906.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_8906.yaml
new file mode 100644
index 00000000000..10056087574
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/issue_8906.yaml
@@ -0,0 +1,586 @@
+openapi: 3.0.1
+info:
+ title: OpenAPI Petstore
+ description: "for schemas with properties and required ensure correct hasVars, hasRequired, vars, and requiredVars"
+ license:
+ name: Apache-2.0
+ url: https://www.apache.org/licenses/LICENSE-2.0.html
+ version: 1.0.0
+servers:
+ - url: http://petstore.swagger.io:80/v2
+tags: []
+paths:
+ /schemasInQueryParamsAndResponses:
+ post:
+ operationId: schemasInQueryParams
+ parameters:
+ - name: AnyTypeNoPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ description: "NoPropertiesNoRequired"
+ - name: AnyTypeHasPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ properties:
+ a:
+ type: string
+ - name: AnyTypeNoPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ required:
+ - a
+ - name: AnyTypeHasPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ - name: ObjectNoPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ type: object
+ - name: ObjectHasPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ type: object
+ properties:
+ a:
+ type: string
+ - name: ObjectNoPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ type: object
+ required:
+ - a
+ - name: ObjectHasPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ - name: ComposedNoAllofPropsNoPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ - name: ComposedNoAllofPropsHasPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ properties:
+ a:
+ type: string
+ - name: ComposedNoAllofPropsNoPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ required:
+ - a
+ - name: ComposedNoAllofPropsHasPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ - name: ComposedHasAllofOptPropNoPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ - name: ComposedHasAllofOptPropHasPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ properties:
+ a:
+ type: string
+ - name: ComposedHasAllofOptPropNoPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ required:
+ - a
+ - name: ComposedHasAllofOptPropHasPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ - name: ComposedHasAllofReqPropNoPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ - name: ComposedHasAllofReqPropHasPropertiesNoRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ properties:
+ a:
+ type: string
+ - name: ComposedHasAllofReqPropNoPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ required:
+ - a
+ - name: ComposedHasAllofReqPropHasPropertiesHasRequired
+ in: query
+ required: true
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: string
+ required: true
+ responses:
+ 200:
+ description: AnyTypeNoPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ description: "NoPropertiesNoRequired"
+ 201:
+ description: AnyTypeHasPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ properties:
+ a:
+ type: string
+ 202:
+ description: AnyTypeNoPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ required:
+ - a
+ 203:
+ description: AnyTypeHasPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ 210:
+ description: ObjectNoPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ type: object
+ 211:
+ description: ObjectHasPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ a:
+ type: string
+ 212:
+ description: ObjectNoPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - a
+ 213:
+ description: ObjectHasPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ 220:
+ description: ComposedNoAllofPropsNoPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ 221:
+ description: ComposedNoAllofPropsHasPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ properties:
+ a:
+ type: string
+ 222:
+ description: ComposedNoAllofPropsNoPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ required:
+ - a
+ 223:
+ description: ComposedNoAllofPropsHasPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ 230:
+ description: ComposedHasAllofOptPropNoPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ 231:
+ description: ComposedHasAllofOptPropHasPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ properties:
+ a:
+ type: string
+ 232:
+ description: ComposedHasAllofOptPropNoPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ required:
+ - a
+ 233:
+ description: ComposedHasAllofOptPropHasPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ 240:
+ description: ComposedHasAllofReqPropNoPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ 241:
+ description: ComposedHasAllofReqPropHasPropertiesNoRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ properties:
+ a:
+ type: string
+ 242:
+ description: ComposedHasAllofReqPropNoPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ required:
+ - a
+ 243:
+ description: ComposedHasAllofReqPropHasPropertiesHasRequired
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ required:
+ - a
+ properties:
+ a:
+ type: string
+components:
+ schemas:
+ EmptyObject:
+ type: object
+ ObjectWithOptionalB:
+ type: object
+ properties:
+ b:
+ type: string
+ ObjectWithRequiredB:
+ type: object
+ properties:
+ b:
+ type: string
+ required:
+ - b
+ AnyTypeNoPropertiesNoRequired:
+ description: "NoPropertiesNoRequired"
+ AnyTypeHasPropertiesNoRequired:
+ properties:
+ a:
+ type: string
+ AnyTypeNoPropertiesHasRequired:
+ required:
+ - a
+ AnyTypeHasPropertiesHasRequired:
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ObjectNoPropertiesNoRequired:
+ type: object
+ ObjectHasPropertiesNoRequired:
+ type: object
+ properties:
+ a:
+ type: string
+ ObjectNoPropertiesHasRequired:
+ type: object
+ required:
+ - a
+ ObjectHasPropertiesHasRequired:
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ComposedNoAllofPropsNoPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ ComposedNoAllofPropsHasPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ properties:
+ a:
+ type: string
+ ComposedNoAllofPropsNoPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ required:
+ - a
+ ComposedNoAllofPropsHasPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ComposedHasAllofOptPropNoPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ ComposedHasAllofOptPropHasPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ properties:
+ a:
+ type: string
+ ComposedHasAllofOptPropNoPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ required:
+ - a
+ ComposedHasAllofOptPropHasPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ComposedHasAllofReqPropNoPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ ComposedHasAllofReqPropHasPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ properties:
+ a:
+ type: string
+ ComposedHasAllofReqPropNoPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ required:
+ - a
+ ComposedHasAllofReqPropHasPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ CodegenPropertiesModel:
+ description: "this model lets us check CodegenProperty.vars/requiredVars/hasVars/hasRequired"
+ type: object
+ properties:
+ AnyTypeNoPropertiesNoRequired:
+ description: "NoPropertiesNoRequired"
+ AnyTypeHasPropertiesNoRequired:
+ properties:
+ a:
+ type: string
+ AnyTypeNoPropertiesHasRequired:
+ required:
+ - a
+ AnyTypeHasPropertiesHasRequired:
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ObjectNoPropertiesNoRequired:
+ type: object
+ ObjectHasPropertiesNoRequired:
+ type: object
+ properties:
+ a:
+ type: string
+ ObjectNoPropertiesHasRequired:
+ type: object
+ required:
+ - a
+ ObjectHasPropertiesHasRequired:
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ComposedNoAllofPropsNoPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ ComposedNoAllofPropsHasPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ properties:
+ a:
+ type: string
+ ComposedNoAllofPropsNoPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ required:
+ - a
+ ComposedNoAllofPropsHasPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/EmptyObject'
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ComposedHasAllofOptPropNoPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ ComposedHasAllofOptPropHasPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ properties:
+ a:
+ type: string
+ ComposedHasAllofOptPropNoPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ required:
+ - a
+ ComposedHasAllofOptPropHasPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithOptionalB'
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ ComposedHasAllofReqPropNoPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ ComposedHasAllofReqPropHasPropertiesNoRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ properties:
+ a:
+ type: string
+ ComposedHasAllofReqPropNoPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ required:
+ - a
+ ComposedHasAllofReqPropHasPropertiesHasRequired:
+ allOf:
+ - $ref: '#/components/schemas/ObjectWithRequiredB'
+ type: object
+ required:
+ - a
+ properties:
+ a:
+ type: string
+ securitySchemes: {}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index 75479284fb6..843298825ab 100644
--- a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -1146,6 +1146,13 @@ components:
type: array
items:
$ref: '#/components/schemas/User'
+ examples:
+ simple-list:
+ summary: Simple list example
+ description: Should not get into code examples
+ value:
+ - username: foo
+ - username: bar
description: List of user object
required: true
Client:
diff --git a/modules/openapi-generator/src/test/resources/bugs/Swift5CodeGenarationBug2.yaml b/modules/openapi-generator/src/test/resources/bugs/Swift5CodeGenarationBug2.yaml
new file mode 100644
index 00000000000..de5d6bba3e2
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/bugs/Swift5CodeGenarationBug2.yaml
@@ -0,0 +1,101 @@
+openapi: 3.0.1
+info:
+ title: XXX
+ description: Das ist jetzt der erste OpenAPI 3.0 Endpoint
+ contact:
+ email: XXX.XXX@XXX.de
+ version: "1.0"
+paths:
+ /api/v1/petresource/pet:
+ post:
+ tags:
+ - v1/petresource
+ summary: Save a Pet.
+ description: Save a Pet.
+ operationId: savePet
+ requestBody:
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/Pet'
+ responses:
+ default:
+ description: PetResponse
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Pet'
+ /api/v1/petresource/petstore:
+ post:
+ tags:
+ - v1/petresource
+ summary: Save a Petstore.
+ description: Save a Petstore.
+ operationId: savePetStore
+ requestBody:
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/PetStore'
+ responses:
+ default:
+ description: PetStore
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/PetStore'
+components:
+ schemas:
+ Cat:
+ required:
+ - type
+ type: object
+ description: Cat
+ allOf:
+ - $ref: '#/components/schemas/Pet'
+ - type: object
+ properties:
+ catFood:
+ type: string
+ Dog:
+ required:
+ - type
+ type: object
+ description: Dog
+ allOf:
+ - $ref: '#/components/schemas/Pet'
+ - type: object
+ properties:
+ dogFood:
+ type: string
+ Pet:
+ required:
+ - type
+ type: object
+ properties:
+ name:
+ type: string
+ description: Name
+ store:
+ $ref: '#/components/schemas/PetStore'
+ mother:
+ $ref: '#/components/schemas/Pet'
+ father:
+ $ref: '#/components/schemas/Pet'
+ type:
+ type: string
+ description: Type Diskriminator
+ description: Base Pet
+ discriminator:
+ propertyName: type
+ mapping:
+ Dog: '#/components/schemas/Dog'
+ Cat: '#/components/schemas/Cat'
+ PetStore:
+ type: object
+ properties:
+ pets:
+ type: array
+ items:
+ $ref: '#/components/schemas/Pet'
+ description: PetStore
diff --git a/pom.xml b/pom.xml
index ed996232d8a..43df9232bc8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1251,6 +1251,7 @@
samples/server/petstore/jaxrs/jersey2
samples/server/petstore/jaxrs/jersey2-useTags
samples/server/petstore/spring-mvc
+ samples/server/petstore/spring-mvc-default-value
samples/server/petstore/spring-mvc-j8-async
samples/server/petstore/spring-mvc-j8-localdatetime
@@ -1282,6 +1283,7 @@
samples/server/petstore/jaxrs-resteasy/eap-joda
samples/server/petstore/jaxrs-resteasy/eap-java8
samples/server/petstore/jaxrs-resteasy/joda
+ samples/server/petstore/jaxrs-resteasy/default-value
samples/client/petstore/dart-dio/petstore_client_lib
samples/openapi3/client/petstore/dart-dio/petstore_client_lib
samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake
+ samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake
samples/client/petstore/dart-jaguar/openapi
samples/client/petstore/dart-jaguar/flutter_petstore/openapi
diff --git a/samples/client/petstore/android/volley/.openapi-generator/FILES b/samples/client/petstore/android/volley/.openapi-generator/FILES
new file mode 100644
index 00000000000..2b570751c94
--- /dev/null
+++ b/samples/client/petstore/android/volley/.openapi-generator/FILES
@@ -0,0 +1,40 @@
+.gitignore
+README.md
+build.gradle
+docs/ApiResponse.md
+docs/Category.md
+docs/Order.md
+docs/Pet.md
+docs/PetApi.md
+docs/StoreApi.md
+docs/Tag.md
+docs/User.md
+docs/UserApi.md
+git_push.sh
+gradle/wrapper/gradle-wrapper.jar
+gradle/wrapper/gradle-wrapper.properties
+gradlew
+gradlew.bat
+pom.xml
+src/main/AndroidManifest.xml
+src/main/java/org/openapitools/client/ApiException.java
+src/main/java/org/openapitools/client/ApiInvoker.java
+src/main/java/org/openapitools/client/JsonUtil.java
+src/main/java/org/openapitools/client/Pair.java
+src/main/java/org/openapitools/client/api/PetApi.java
+src/main/java/org/openapitools/client/api/StoreApi.java
+src/main/java/org/openapitools/client/api/UserApi.java
+src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
+src/main/java/org/openapitools/client/auth/Authentication.java
+src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
+src/main/java/org/openapitools/client/model/ApiResponse.java
+src/main/java/org/openapitools/client/model/Category.java
+src/main/java/org/openapitools/client/model/Order.java
+src/main/java/org/openapitools/client/model/Pet.java
+src/main/java/org/openapitools/client/model/Tag.java
+src/main/java/org/openapitools/client/model/User.java
+src/main/java/org/openapitools/client/request/DeleteRequest.java
+src/main/java/org/openapitools/client/request/GetRequest.java
+src/main/java/org/openapitools/client/request/PatchRequest.java
+src/main/java/org/openapitools/client/request/PostRequest.java
+src/main/java/org/openapitools/client/request/PutRequest.java
diff --git a/samples/client/petstore/android/volley/.openapi-generator/VERSION b/samples/client/petstore/android/volley/.openapi-generator/VERSION
index afa63656064..c30f0ec2be7 100644
--- a/samples/client/petstore/android/volley/.openapi-generator/VERSION
+++ b/samples/client/petstore/android/volley/.openapi-generator/VERSION
@@ -1 +1 @@
-4.0.0-SNAPSHOT
\ No newline at end of file
+5.1.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/client/petstore/android/volley/README.md b/samples/client/petstore/android/volley/README.md
index c2fca9e2b9e..d4f8c7a7f17 100644
--- a/samples/client/petstore/android/volley/README.md
+++ b/samples/client/petstore/android/volley/README.md
@@ -49,8 +49,8 @@ At first generate the JAR by executing:
Then manually install the following JARs:
-* target/petstore-android-volley-1.0.0.jar
-* target/lib/*.jar
+- target/petstore-android-volley-1.0.0.jar
+- target/lib/*.jar
## Getting Started
@@ -64,9 +64,9 @@ public class PetApiExample {
public static void main(String[] args) {
PetApi apiInstance = new PetApi();
- Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
+ Pet body = new Pet(); // Pet | Pet object that needs to be added to the store
try {
- apiInstance.addPet(pet);
+ apiInstance.addPet(body);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#addPet");
e.printStackTrace();
@@ -120,11 +120,13 @@ Authentication schemes defined for the API:
### api_key
- **Type**: API key
+
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth
+
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
diff --git a/samples/client/petstore/android/volley/build.gradle b/samples/client/petstore/android/volley/build.gradle
index b3a4c135c03..afa1d97884d 100644
--- a/samples/client/petstore/android/volley/build.gradle
+++ b/samples/client/petstore/android/volley/build.gradle
@@ -3,17 +3,22 @@ project.version = '1.0.0'
buildscript {
repositories {
- mavenCentral()
+ mavenLocal()
+ google()
+ maven {
+ url 'https://dl.google.com/dl/android/maven2'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.+'
+ classpath 'com.android.tools.build:gradle:3.2.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
allprojects {
repositories {
+ google()
jcenter()
}
}
@@ -24,7 +29,7 @@ apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 25
- buildToolsVersion '25.0.2'
+ buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
@@ -33,14 +38,15 @@ android {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
+ lintOptions {
+ abortOnError false
+ }
// Rename the aar correctly
libraryVariants.all { variant ->
- variant.outputs.each { output ->
- def outputFile = output.outputFile
- if (outputFile != null && outputFile.name.endsWith('.aar')) {
- def fileName = "${project.name}-${variant.baseName}-${version}.aar"
- output.outputFile = new File(outputFile.parent, fileName)
+ variant.outputs.all { output ->
+ if (outputFile != null && outputFileName.endsWith('.aar')) {
+ outputFileName = "${archivesBaseName}-${version}.aar"
}
}
}
@@ -50,29 +56,24 @@ android {
}
}
-
ext {
- swagger_annotations_version = "1.5.0"
- gson_version = "2.3.1"
- httpmime_version = "4.5.2"
- httpcore_version = "4.4.4"
- httpclient_version = "4.3.3"
- volley_version = "1.0.0"
- junit_version = "4.13"
- robolectric_version = "3.0"
- concurrent_unit_version = "0.4.2"
+ swagger_annotations_version = "1.6.2"
+ gson_version = "2.8.6"
+ httpmime_version = "4.5.13"
+ volley_version = "1.2.0"
+ junit_version = "4.13.2"
+ robolectric_version = "4.5.1"
+ concurrent_unit_version = "0.4.6"
}
dependencies {
- compile "io.swagger:swagger-annotations:$swagger_annotations_version"
- compile "com.google.code.gson:gson:$gson_version"
- compile "org.apache.httpcomponents:httpcore:$httpcore_version"
- compile "org.apache.httpcomponents:httpmime:$httpmime_version"
- compile "org.apache.httpcomponents:httpclient-android:$httpclient_version"
- compile "com.android.volley:volley:${volley_version}"
- testCompile "junit:junit:$junit_version"
- testCompile "org.robolectric:robolectric:${robolectric_version}"
- testCompile "net.jodah:concurrentunit:${concurrent_unit_version}"
+ implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
+ implementation "com.google.code.gson:gson:$gson_version"
+ implementation "org.apache.httpcomponents:httpmime:$httpmime_version"
+ implementation "com.android.volley:volley:${volley_version}"
+ testImplementation "junit:junit:$junit_version"
+ testImplementation "org.robolectric:robolectric:${robolectric_version}"
+ testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}"
}
afterEvaluate {
diff --git a/samples/client/petstore/android/volley/docs/ApiResponse.md b/samples/client/petstore/android/volley/docs/ApiResponse.md
index 1c17767c2b7..a169bf232e1 100644
--- a/samples/client/petstore/android/volley/docs/ApiResponse.md
+++ b/samples/client/petstore/android/volley/docs/ApiResponse.md
@@ -1,7 +1,9 @@
+
# ApiResponse
## Properties
+
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **Integer** | | [optional]
@@ -10,3 +12,4 @@ Name | Type | Description | Notes
+
diff --git a/samples/client/petstore/android/volley/docs/Category.md b/samples/client/petstore/android/volley/docs/Category.md
index e2df0803278..53c9fedc8bc 100644
--- a/samples/client/petstore/android/volley/docs/Category.md
+++ b/samples/client/petstore/android/volley/docs/Category.md
@@ -1,7 +1,9 @@
+
# Category
## Properties
+
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Long** | | [optional]
@@ -9,3 +11,4 @@ Name | Type | Description | Notes
+
diff --git a/samples/client/petstore/android/volley/docs/Order.md b/samples/client/petstore/android/volley/docs/Order.md
index 5746ce97fad..f49e8704e08 100644
--- a/samples/client/petstore/android/volley/docs/Order.md
+++ b/samples/client/petstore/android/volley/docs/Order.md
@@ -1,7 +1,9 @@
+
# Order
## Properties
+
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Long** | | [optional]
@@ -12,10 +14,11 @@ Name | Type | Description | Notes
**complete** | **Boolean** | | [optional]
-
## Enum: StatusEnum
+
Name | Value
---- | -----
+
diff --git a/samples/client/petstore/android/volley/docs/Pet.md b/samples/client/petstore/android/volley/docs/Pet.md
index a4daa24feb6..72e3338dfb8 100644
--- a/samples/client/petstore/android/volley/docs/Pet.md
+++ b/samples/client/petstore/android/volley/docs/Pet.md
@@ -1,7 +1,9 @@
+
# Pet
## Properties
+
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Long** | | [optional]
@@ -12,10 +14,11 @@ Name | Type | Description | Notes
**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional]
-
## Enum: StatusEnum
+
Name | Value
---- | -----
+
diff --git a/samples/client/petstore/android/volley/docs/PetApi.md b/samples/client/petstore/android/volley/docs/PetApi.md
index 7cf076f29c5..4f91f08bc47 100644
--- a/samples/client/petstore/android/volley/docs/PetApi.md
+++ b/samples/client/petstore/android/volley/docs/PetApi.md
@@ -14,21 +14,23 @@ Method | HTTP request | Description
[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
-
-# **addPet**
-> addPet(pet)
+
+## addPet
+
+> addPet(body)
Add a new pet to the store
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
PetApi apiInstance = new PetApi();
-Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
+Pet body = new Pet(); // Pet | Pet object that needs to be added to the store
try {
- apiInstance.addPet(pet);
+ apiInstance.addPet(body);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#addPet");
e.printStackTrace();
@@ -37,9 +39,10 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
+ **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@@ -51,16 +54,18 @@ null (empty response body)
### HTTP request headers
- - **Content-Type**: application/json, application/xml
- - **Accept**: Not defined
+- **Content-Type**: application/json, application/xml
+- **Accept**: Not defined
+
+
+## deletePet
-
-# **deletePet**
> deletePet(petId, apiKey)
Deletes a pet
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
@@ -78,6 +83,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Long**| Pet id to delete | [default to null]
@@ -93,11 +99,12 @@ null (empty response body)
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
+
+
+## findPetsByStatus
-
-# **findPetsByStatus**
> List<Pet> findPetsByStatus(status)
Finds Pets by status
@@ -105,6 +112,7 @@ Finds Pets by status
Multiple status values can be provided with comma separated strings
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
@@ -122,6 +130,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [default to null] [enum: available, pending, sold]
@@ -136,11 +145,12 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+- **Content-Type**: Not defined
+- **Accept**: application/xml, application/json
+
+
+## findPetsByTags
-
-# **findPetsByTags**
> List<Pet> findPetsByTags(tags)
Finds Pets by tags
@@ -148,6 +158,7 @@ Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
@@ -165,6 +176,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**List<String>**](String.md)| Tags to filter by | [default to null]
@@ -179,11 +191,12 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+- **Content-Type**: Not defined
+- **Accept**: application/xml, application/json
+
+
+## getPetById
-
-# **getPetById**
> Pet getPetById(petId)
Find pet by ID
@@ -191,6 +204,7 @@ Find pet by ID
Returns a single pet
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
@@ -208,6 +222,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Long**| ID of pet to return | [default to null]
@@ -222,24 +237,26 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+- **Content-Type**: Not defined
+- **Accept**: application/xml, application/json
-
-# **updatePet**
-> updatePet(pet)
+
+## updatePet
+
+> updatePet(body)
Update an existing pet
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
PetApi apiInstance = new PetApi();
-Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
+Pet body = new Pet(); // Pet | Pet object that needs to be added to the store
try {
- apiInstance.updatePet(pet);
+ apiInstance.updatePet(body);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#updatePet");
e.printStackTrace();
@@ -248,9 +265,10 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
+ **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@@ -262,16 +280,18 @@ null (empty response body)
### HTTP request headers
- - **Content-Type**: application/json, application/xml
- - **Accept**: Not defined
+- **Content-Type**: application/json, application/xml
+- **Accept**: Not defined
+
+
+## updatePetWithForm
-
-# **updatePetWithForm**
> updatePetWithForm(petId, name, status)
Updates a pet in the store with form data
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
@@ -290,6 +310,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Long**| ID of pet that needs to be updated | [default to null]
@@ -306,16 +327,18 @@ null (empty response body)
### HTTP request headers
- - **Content-Type**: application/x-www-form-urlencoded
- - **Accept**: Not defined
+- **Content-Type**: application/x-www-form-urlencoded
+- **Accept**: Not defined
+
+
+## uploadFile
-
-# **uploadFile**
> ApiResponse uploadFile(petId, additionalMetadata, file)
uploads an image
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.PetApi;
@@ -335,6 +358,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Long**| ID of pet to update | [default to null]
@@ -351,6 +375,6 @@ Name | Type | Description | Notes
### HTTP request headers
- - **Content-Type**: multipart/form-data
- - **Accept**: application/json
+- **Content-Type**: multipart/form-data
+- **Accept**: application/json
diff --git a/samples/client/petstore/android/volley/docs/StoreApi.md b/samples/client/petstore/android/volley/docs/StoreApi.md
index b768ad5ba98..d2229bfd71f 100644
--- a/samples/client/petstore/android/volley/docs/StoreApi.md
+++ b/samples/client/petstore/android/volley/docs/StoreApi.md
@@ -10,8 +10,9 @@ Method | HTTP request | Description
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
-
-# **deleteOrder**
+
+## deleteOrder
+
> deleteOrder(orderId)
Delete purchase order by ID
@@ -19,6 +20,7 @@ Delete purchase order by ID
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.StoreApi;
@@ -35,6 +37,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **String**| ID of the order that needs to be deleted | [default to null]
@@ -49,11 +52,12 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
+
+
+## getInventory
-
-# **getInventory**
> Map<String, Integer> getInventory()
Returns pet inventories by status
@@ -61,6 +65,7 @@ Returns pet inventories by status
Returns a map of status codes to quantities
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.StoreApi;
@@ -76,6 +81,7 @@ try {
```
### Parameters
+
This endpoint does not need any parameter.
### Return type
@@ -88,11 +94,12 @@ This endpoint does not need any parameter.
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/json
+- **Content-Type**: Not defined
+- **Accept**: application/json
+
+
+## getOrderById
-
-# **getOrderById**
> Order getOrderById(orderId)
Find purchase order by ID
@@ -100,6 +107,7 @@ Find purchase order by ID
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.StoreApi;
@@ -117,6 +125,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **Long**| ID of pet that needs to be fetched | [default to null]
@@ -131,24 +140,26 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+- **Content-Type**: Not defined
+- **Accept**: application/xml, application/json
-
-# **placeOrder**
-> Order placeOrder(order)
+
+## placeOrder
+
+> Order placeOrder(body)
Place an order for a pet
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.StoreApi;
StoreApi apiInstance = new StoreApi();
-Order order = new Order(); // Order | order placed for purchasing the pet
+Order body = new Order(); // Order | order placed for purchasing the pet
try {
- Order result = apiInstance.placeOrder(order);
+ Order result = apiInstance.placeOrder(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling StoreApi#placeOrder");
@@ -158,9 +169,10 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **order** | [**Order**](Order.md)| order placed for purchasing the pet |
+ **body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type
@@ -172,6 +184,6 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+- **Content-Type**: Not defined
+- **Accept**: application/xml, application/json
diff --git a/samples/client/petstore/android/volley/docs/Tag.md b/samples/client/petstore/android/volley/docs/Tag.md
index de6814b55d5..b540cab453f 100644
--- a/samples/client/petstore/android/volley/docs/Tag.md
+++ b/samples/client/petstore/android/volley/docs/Tag.md
@@ -1,7 +1,9 @@
+
# Tag
## Properties
+
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Long** | | [optional]
@@ -9,3 +11,4 @@ Name | Type | Description | Notes
+
diff --git a/samples/client/petstore/android/volley/docs/User.md b/samples/client/petstore/android/volley/docs/User.md
index 8b6753dd284..5e51c05150c 100644
--- a/samples/client/petstore/android/volley/docs/User.md
+++ b/samples/client/petstore/android/volley/docs/User.md
@@ -1,7 +1,9 @@
+
# User
## Properties
+
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Long** | | [optional]
@@ -15,3 +17,4 @@ Name | Type | Description | Notes
+
diff --git a/samples/client/petstore/android/volley/docs/UserApi.md b/samples/client/petstore/android/volley/docs/UserApi.md
index e5a16428112..4c54ee4c77c 100644
--- a/samples/client/petstore/android/volley/docs/UserApi.md
+++ b/samples/client/petstore/android/volley/docs/UserApi.md
@@ -14,23 +14,25 @@ Method | HTTP request | Description
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
-
-# **createUser**
-> createUser(user)
+
+## createUser
+
+> createUser(body)
Create user
This can only be done by the logged in user.
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
UserApi apiInstance = new UserApi();
-User user = new User(); // User | Created user object
+User body = new User(); // User | Created user object
try {
- apiInstance.createUser(user);
+ apiInstance.createUser(body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#createUser");
e.printStackTrace();
@@ -39,9 +41,10 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **user** | [**User**](User.md)| Created user object |
+ **body** | [**User**](User.md)| Created user object |
### Return type
@@ -53,24 +56,26 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
-
-# **createUsersWithArrayInput**
-> createUsersWithArrayInput(user)
+
+## createUsersWithArrayInput
+
+> createUsersWithArrayInput(body)
Creates list of users with given input array
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
UserApi apiInstance = new UserApi();
-List user = Arrays.asList(new List()); // List | List of user object
+List body = Arrays.asList(new User()); // List | List of user object
try {
- apiInstance.createUsersWithArrayInput(user);
+ apiInstance.createUsersWithArrayInput(body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#createUsersWithArrayInput");
e.printStackTrace();
@@ -79,9 +84,10 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **user** | [**List<User>**](List.md)| List of user object |
+ **body** | [**List<User>**](User.md)| List of user object |
### Return type
@@ -93,24 +99,26 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
-
-# **createUsersWithListInput**
-> createUsersWithListInput(user)
+
+## createUsersWithListInput
+
+> createUsersWithListInput(body)
Creates list of users with given input array
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
UserApi apiInstance = new UserApi();
-List user = Arrays.asList(new List()); // List | List of user object
+List body = Arrays.asList(new User()); // List | List of user object
try {
- apiInstance.createUsersWithListInput(user);
+ apiInstance.createUsersWithListInput(body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#createUsersWithListInput");
e.printStackTrace();
@@ -119,9 +127,10 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **user** | [**List<User>**](List.md)| List of user object |
+ **body** | [**List<User>**](User.md)| List of user object |
### Return type
@@ -133,11 +142,12 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
+
+
+## deleteUser
-
-# **deleteUser**
> deleteUser(username)
Delete user
@@ -145,6 +155,7 @@ Delete user
This can only be done by the logged in user.
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
@@ -161,6 +172,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be deleted | [default to null]
@@ -175,16 +187,18 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
+
+
+## getUserByName
-
-# **getUserByName**
> User getUserByName(username)
Get user by user name
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
@@ -202,6 +216,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to null]
@@ -216,16 +231,18 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+- **Content-Type**: Not defined
+- **Accept**: application/xml, application/json
+
+
+## loginUser
-
-# **loginUser**
> String loginUser(username, password)
Logs user into the system
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
@@ -244,6 +261,7 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | [default to null]
@@ -259,16 +277,18 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+- **Content-Type**: Not defined
+- **Accept**: application/xml, application/json
+
+
+## logoutUser
-
-# **logoutUser**
> logoutUser()
Logs out current logged in user session
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
@@ -283,6 +303,7 @@ try {
```
### Parameters
+
This endpoint does not need any parameter.
### Return type
@@ -295,27 +316,29 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
-
-# **updateUser**
-> updateUser(username, user)
+
+## updateUser
+
+> updateUser(username, body)
Updated user
This can only be done by the logged in user.
### Example
+
```java
// Import classes:
//import org.openapitools.client.api.UserApi;
UserApi apiInstance = new UserApi();
String username = null; // String | name that need to be deleted
-User user = new User(); // User | Updated user object
+User body = new User(); // User | Updated user object
try {
- apiInstance.updateUser(username, user);
+ apiInstance.updateUser(username, body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#updateUser");
e.printStackTrace();
@@ -324,10 +347,11 @@ try {
### Parameters
+
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null]
- **user** | [**User**](User.md)| Updated user object |
+ **body** | [**User**](User.md)| Updated user object |
### Return type
@@ -339,6 +363,6 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: Not defined
+- **Content-Type**: Not defined
+- **Accept**: Not defined
diff --git a/samples/client/petstore/android/volley/git_push.sh b/samples/client/petstore/android/volley/git_push.sh
index 0f406ef7878..ced3be2b0c7 100644
--- a/samples/client/petstore/android/volley/git_push.sh
+++ b/samples/client/petstore/android/volley/git_push.sh
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="github.com"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,5 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
+
diff --git a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar
index 87b738cbd05..e708b1c023e 100644
Binary files a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar and b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties
index e496c054f69..4d9ca164914 100644
--- a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties
+++ b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/samples/client/petstore/android/volley/gradlew b/samples/client/petstore/android/volley/gradlew
old mode 100644
new mode 100755
index af6708ff229..4f906e0c811
--- a/samples/client/petstore/android/volley/gradlew
+++ b/samples/client/petstore/android/volley/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m"'
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/samples/client/petstore/android/volley/gradlew.bat b/samples/client/petstore/android/volley/gradlew.bat
index f9553162f12..107acd32c4e 100644
--- a/samples/client/petstore/android/volley/gradlew.bat
+++ b/samples/client/petstore/android/volley/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/samples/client/petstore/android/volley/pom.xml b/samples/client/petstore/android/volley/pom.xml
index 800d148e4df..98bff7edf8d 100644
--- a/samples/client/petstore/android/volley/pom.xml
+++ b/samples/client/petstore/android/volley/pom.xml
@@ -11,15 +11,11 @@
swagger-annotations
${swagger-annotations-version}
+
- org.apache.httpcomponents
- httpcore
- ${httpcomponents-httpcore-version}
-
-
- org.apache.httpcomponents
- httpclient-android
- ${httpcomponents-httpclient-version}
+ com.google.code.findbugs
+ jsr305
+ 3.0.2
org.apache.httpcomponents
@@ -57,9 +53,7 @@
1.5.8
- 4.4.4
4.5.2
- 4.3.3
2.6.2
1.0.19
4.1.1.4
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java
index 70f3b77ceea..2f57c83eeb7 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java
index 2e7ab447cf3..9ff0422de5f 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/JsonUtil.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/JsonUtil.java
index 3cdc69558e3..c52b2dcd70d 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/JsonUtil.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/JsonUtil.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/Pair.java
index e8f34f395f8..d358fcf66b4 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/Pair.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/Pair.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java
index f90cf9d21e3..a80910cd4c8 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -60,15 +60,15 @@ public class PetApi {
/**
* Add a new pet to the store
*
- * @param pet Pet object that needs to be added to the store
+ * @param body Pet object that needs to be added to the store
* @return void
*/
- public void addPet (Pet pet) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
- Object postBody = pet;
- // verify the required parameter 'pet' is set
- if (pet == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'pet' when calling addPet",
- new ApiException(400, "Missing the required parameter 'pet' when calling addPet"));
+ public void addPet (Pet body) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = body;
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling addPet",
+ new ApiException(400, "Missing the required parameter 'body' when calling addPet"));
}
// create path and map variables
@@ -124,15 +124,15 @@ public class PetApi {
/**
* Add a new pet to the store
*
- * @param pet Pet object that needs to be added to the store
+ * @param body Pet object that needs to be added to the store
*/
- public void addPet (Pet pet, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
- Object postBody = pet;
+ public void addPet (Pet body, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
+ Object postBody = body;
- // verify the required parameter 'pet' is set
- if (pet == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'pet' when calling addPet",
- new ApiException(400, "Missing the required parameter 'pet' when calling addPet"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling addPet",
+ new ApiException(400, "Missing the required parameter 'body' when calling addPet"));
}
// create path and map variables
@@ -696,15 +696,15 @@ public class PetApi {
/**
* Update an existing pet
*
- * @param pet Pet object that needs to be added to the store
+ * @param body Pet object that needs to be added to the store
* @return void
*/
- public void updatePet (Pet pet) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
- Object postBody = pet;
- // verify the required parameter 'pet' is set
- if (pet == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'pet' when calling updatePet",
- new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"));
+ public void updatePet (Pet body) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = body;
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling updatePet",
+ new ApiException(400, "Missing the required parameter 'body' when calling updatePet"));
}
// create path and map variables
@@ -760,15 +760,15 @@ public class PetApi {
/**
* Update an existing pet
*
- * @param pet Pet object that needs to be added to the store
+ * @param body Pet object that needs to be added to the store
*/
- public void updatePet (Pet pet, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
- Object postBody = pet;
+ public void updatePet (Pet body, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
+ Object postBody = body;
- // verify the required parameter 'pet' is set
- if (pet == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'pet' when calling updatePet",
- new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling updatePet",
+ new ApiException(400, "Missing the required parameter 'body' when calling updatePet"));
}
// create path and map variables
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/StoreApi.java
index 3da1f3f7689..fd69b757348 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/StoreApi.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/StoreApi.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -425,15 +425,15 @@ public class StoreApi {
/**
* Place an order for a pet
*
- * @param order order placed for purchasing the pet
+ * @param body order placed for purchasing the pet
* @return Order
*/
- public Order placeOrder (Order order) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
- Object postBody = order;
- // verify the required parameter 'order' is set
- if (order == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'order' when calling placeOrder",
- new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"));
+ public Order placeOrder (Order body) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = body;
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling placeOrder",
+ new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"));
}
// create path and map variables
@@ -487,15 +487,15 @@ public class StoreApi {
/**
* Place an order for a pet
*
- * @param order order placed for purchasing the pet
+ * @param body order placed for purchasing the pet
*/
- public void placeOrder (Order order, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
- Object postBody = order;
+ public void placeOrder (Order body, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
+ Object postBody = body;
- // verify the required parameter 'order' is set
- if (order == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'order' when calling placeOrder",
- new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling placeOrder",
+ new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"));
}
// create path and map variables
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/UserApi.java
index ce88777ae1c..edec8bce95e 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/UserApi.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/UserApi.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -59,15 +59,15 @@ public class UserApi {
/**
* Create user
* This can only be done by the logged in user.
- * @param user Created user object
+ * @param body Created user object
* @return void
*/
- public void createUser (User user) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
- Object postBody = user;
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling createUser",
- new ApiException(400, "Missing the required parameter 'user' when calling createUser"));
+ public void createUser (User body) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = body;
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling createUser",
+ new ApiException(400, "Missing the required parameter 'body' when calling createUser"));
}
// create path and map variables
@@ -121,15 +121,15 @@ public class UserApi {
/**
* Create user
* This can only be done by the logged in user.
- * @param user Created user object
+ * @param body Created user object
*/
- public void createUser (User user, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
- Object postBody = user;
+ public void createUser (User body, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
+ Object postBody = body;
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling createUser",
- new ApiException(400, "Missing the required parameter 'user' when calling createUser"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling createUser",
+ new ApiException(400, "Missing the required parameter 'body' when calling createUser"));
}
// create path and map variables
@@ -182,15 +182,15 @@ public class UserApi {
/**
* Creates list of users with given input array
*
- * @param user List of user object
+ * @param body List of user object
* @return void
*/
- public void createUsersWithArrayInput (List user) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
- Object postBody = user;
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling createUsersWithArrayInput",
- new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"));
+ public void createUsersWithArrayInput (List body) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = body;
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling createUsersWithArrayInput",
+ new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"));
}
// create path and map variables
@@ -244,15 +244,15 @@ public class UserApi {
/**
* Creates list of users with given input array
*
- * @param user List of user object
+ * @param body List of user object
*/
- public void createUsersWithArrayInput (List user, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
- Object postBody = user;
+ public void createUsersWithArrayInput (List body, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
+ Object postBody = body;
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling createUsersWithArrayInput",
- new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling createUsersWithArrayInput",
+ new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"));
}
// create path and map variables
@@ -305,15 +305,15 @@ public class UserApi {
/**
* Creates list of users with given input array
*
- * @param user List of user object
+ * @param body List of user object
* @return void
*/
- public void createUsersWithListInput (List user) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
- Object postBody = user;
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling createUsersWithListInput",
- new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"));
+ public void createUsersWithListInput (List body) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = body;
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling createUsersWithListInput",
+ new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"));
}
// create path and map variables
@@ -367,15 +367,15 @@ public class UserApi {
/**
* Creates list of users with given input array
*
- * @param user List of user object
+ * @param body List of user object
*/
- public void createUsersWithListInput (List user, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
- Object postBody = user;
+ public void createUsersWithListInput (List body, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
+ Object postBody = body;
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling createUsersWithListInput",
- new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling createUsersWithListInput",
+ new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"));
}
// create path and map variables
@@ -933,20 +933,20 @@ public class UserApi {
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
- * @param user Updated user object
+ * @param body Updated user object
* @return void
*/
- public void updateUser (String username, User user) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
- Object postBody = user;
+ public void updateUser (String username, User body) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = body;
// verify the required parameter 'username' is set
if (username == null) {
VolleyError error = new VolleyError("Missing the required parameter 'username' when calling updateUser",
new ApiException(400, "Missing the required parameter 'username' when calling updateUser"));
}
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling updateUser",
- new ApiException(400, "Missing the required parameter 'user' when calling updateUser"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling updateUser",
+ new ApiException(400, "Missing the required parameter 'body' when calling updateUser"));
}
// create path and map variables
@@ -1000,20 +1000,20 @@ public class UserApi {
/**
* Updated user
* This can only be done by the logged in user.
- * @param username name that need to be deleted * @param user Updated user object
+ * @param username name that need to be deleted * @param body Updated user object
*/
- public void updateUser (String username, User user, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
- Object postBody = user;
+ public void updateUser (String username, User body, final Response.Listener responseListener, final Response.ErrorListener errorListener) {
+ Object postBody = body;
// verify the required parameter 'username' is set
if (username == null) {
VolleyError error = new VolleyError("Missing the required parameter 'username' when calling updateUser",
new ApiException(400, "Missing the required parameter 'username' when calling updateUser"));
}
- // verify the required parameter 'user' is set
- if (user == null) {
- VolleyError error = new VolleyError("Missing the required parameter 'user' when calling updateUser",
- new ApiException(400, "Missing the required parameter 'user' when calling updateUser"));
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ VolleyError error = new VolleyError("Missing the required parameter 'body' when calling updateUser",
+ new ApiException(400, "Missing the required parameter 'body' when calling updateUser"));
}
// create path and map variables
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
index b15bbd4de9d..fe6364d3172 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/Authentication.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/Authentication.java
index 7ea7f36402c..2eec51b72b9 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/Authentication.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/Authentication.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
index 8b66fa17216..1226b62d5b2 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/ApiResponse.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/ApiResponse.java
index 00254f1548a..82d2c303135 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/ApiResponse.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/ApiResponse.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Category.java
index cd1473811a1..25016438a56 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Category.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Category.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Order.java
index 6d4ba799ea4..b5958b2eb65 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Order.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Order.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Pet.java
index 71026c8fdc4..b8fa5f5b48c 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Pet.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Pet.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Tag.java
index dd37b76de2f..c61264d3c9c 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Tag.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/Tag.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/User.java
index 268f152e1d5..757cc8fed0a 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/User.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/model/User.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/DeleteRequest.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/DeleteRequest.java
index d4143bbe63d..387e52f102c 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/DeleteRequest.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/DeleteRequest.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/GetRequest.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/GetRequest.java
index 4c87ff45bd7..dd2c824098c 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/GetRequest.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/GetRequest.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PatchRequest.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PatchRequest.java
index 909c4ea18a0..4f97af9d06d 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PatchRequest.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PatchRequest.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PostRequest.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PostRequest.java
index 229891e581d..dd4c40ddc85 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PostRequest.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PostRequest.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PutRequest.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PutRequest.java
index 70da15b48d9..877d4855c44 100644
--- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PutRequest.java
+++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/request/PutRequest.java
@@ -2,7 +2,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
- * OpenAPI spec version: 1.0.0
+ * The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
diff --git a/samples/client/petstore/c/.openapi-generator/FILES b/samples/client/petstore/c/.openapi-generator/FILES
index 0bfa6c555b1..4f49546590e 100644
--- a/samples/client/petstore/c/.openapi-generator/FILES
+++ b/samples/client/petstore/c/.openapi-generator/FILES
@@ -5,6 +5,15 @@ api/StoreAPI.c
api/StoreAPI.h
api/UserAPI.c
api/UserAPI.h
+docs/PetAPI.md
+docs/StoreAPI.md
+docs/UserAPI.md
+docs/api_response.md
+docs/category.md
+docs/order.md
+docs/pet.md
+docs/tag.md
+docs/user.md
external/cJSON.c
external/cJSON.h
external/cJSON.licence
diff --git a/samples/client/petstore/c/README.md b/samples/client/petstore/c/README.md
index 0059cc47da8..23d10c8bb18 100644
--- a/samples/client/petstore/c/README.md
+++ b/samples/client/petstore/c/README.md
@@ -58,6 +58,66 @@ Once compiled, you can run it with ``` ./main ```
Note: You don't need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
+## Documentation for API Endpoints
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Category | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+*PetAPI* | [**PetAPI_addPet**](docs/PetAPI.md#PetAPI_addPet) | **POST** /pet | Add a new pet to the store
+*PetAPI* | [**PetAPI_deletePet**](docs/PetAPI.md#PetAPI_deletePet) | **DELETE** /pet/{petId} | Deletes a pet
+*PetAPI* | [**PetAPI_findPetsByStatus**](docs/PetAPI.md#PetAPI_findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
+*PetAPI* | [**PetAPI_findPetsByTags**](docs/PetAPI.md#PetAPI_findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
+*PetAPI* | [**PetAPI_getPetById**](docs/PetAPI.md#PetAPI_getPetById) | **GET** /pet/{petId} | Find pet by ID
+*PetAPI* | [**PetAPI_updatePet**](docs/PetAPI.md#PetAPI_updatePet) | **PUT** /pet | Update an existing pet
+*PetAPI* | [**PetAPI_updatePetWithForm**](docs/PetAPI.md#PetAPI_updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
+*PetAPI* | [**PetAPI_uploadFile**](docs/PetAPI.md#PetAPI_uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
+*StoreAPI* | [**StoreAPI_deleteOrder**](docs/StoreAPI.md#StoreAPI_deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
+*StoreAPI* | [**StoreAPI_getInventory**](docs/StoreAPI.md#StoreAPI_getInventory) | **GET** /store/inventory | Returns pet inventories by status
+*StoreAPI* | [**StoreAPI_getOrderById**](docs/StoreAPI.md#StoreAPI_getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
+*StoreAPI* | [**StoreAPI_placeOrder**](docs/StoreAPI.md#StoreAPI_placeOrder) | **POST** /store/order | Place an order for a pet
+*UserAPI* | [**UserAPI_createUser**](docs/UserAPI.md#UserAPI_createUser) | **POST** /user | Create user
+*UserAPI* | [**UserAPI_createUsersWithArrayInput**](docs/UserAPI.md#UserAPI_createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
+*UserAPI* | [**UserAPI_createUsersWithListInput**](docs/UserAPI.md#UserAPI_createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
+*UserAPI* | [**UserAPI_deleteUser**](docs/UserAPI.md#UserAPI_deleteUser) | **DELETE** /user/{username} | Delete user
+*UserAPI* | [**UserAPI_getUserByName**](docs/UserAPI.md#UserAPI_getUserByName) | **GET** /user/{username} | Get user by user name
+*UserAPI* | [**UserAPI_loginUser**](docs/UserAPI.md#UserAPI_loginUser) | **GET** /user/login | Logs user into the system
+*UserAPI* | [**UserAPI_logoutUser**](docs/UserAPI.md#UserAPI_logoutUser) | **GET** /user/logout | Logs out current logged in user session
+*UserAPI* | [**UserAPI_updateUser**](docs/UserAPI.md#UserAPI_updateUser) | **PUT** /user/{username} | Updated user
+
+
+## Documentation for Models
+
+ - [api_response_t](docs/api_response.md)
+ - [category_t](docs/category.md)
+ - [order_t](docs/order.md)
+ - [pet_t](docs/pet.md)
+ - [tag_t](docs/tag.md)
+ - [user_t](docs/user.md)
+
+
+## Documentation for Authorization
+
+
+### api_key
+
+- **Type**: API key
+
+- **API key parameter name**: api_key
+- **Location**: HTTP header
+
+
+### petstore_auth
+
+
+- **Type**: OAuth
+- **Flow**: implicit
+- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
+- **Scopes**:
+ - write:pets: modify pets in your account
+ - read:pets: read your pets
+
+
## Author
diff --git a/samples/client/petstore/c/docs/PetAPI.md b/samples/client/petstore/c/docs/PetAPI.md
new file mode 100644
index 00000000000..1033f2e8edd
--- /dev/null
+++ b/samples/client/petstore/c/docs/PetAPI.md
@@ -0,0 +1,255 @@
+# PetAPI
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**PetAPI_addPet**](PetAPI.md#PetAPI_addPet) | **POST** /pet | Add a new pet to the store
+[**PetAPI_deletePet**](PetAPI.md#PetAPI_deletePet) | **DELETE** /pet/{petId} | Deletes a pet
+[**PetAPI_findPetsByStatus**](PetAPI.md#PetAPI_findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
+[**PetAPI_findPetsByTags**](PetAPI.md#PetAPI_findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
+[**PetAPI_getPetById**](PetAPI.md#PetAPI_getPetById) | **GET** /pet/{petId} | Find pet by ID
+[**PetAPI_updatePet**](PetAPI.md#PetAPI_updatePet) | **PUT** /pet | Update an existing pet
+[**PetAPI_updatePetWithForm**](PetAPI.md#PetAPI_updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
+[**PetAPI_uploadFile**](PetAPI.md#PetAPI_uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
+
+
+# **PetAPI_addPet**
+```c
+// Add a new pet to the store
+//
+void PetAPI_addPet(apiClient_t *apiClient, pet_t * body);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**body** | **[pet_t](pet.md) \*** | Pet object that needs to be added to the store |
+
+### Return type
+
+void
+
+### Authorization
+
+[petstore_auth](../README.md#petstore_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json, application/xml
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **PetAPI_deletePet**
+```c
+// Deletes a pet
+//
+void PetAPI_deletePet(apiClient_t *apiClient, long petId, char * api_key);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**petId** | **long** | Pet id to delete |
+**api_key** | **char \*** | | [optional]
+
+### Return type
+
+void
+
+### Authorization
+
+[petstore_auth](../README.md#petstore_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **PetAPI_findPetsByStatus**
+```c
+// Finds Pets by status
+//
+// Multiple status values can be provided with comma separated strings
+//
+list_t* PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t * status);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**status** | **[list_t](char.md) \*** | Status values that need to be considered for filter |
+
+### Return type
+
+[list_t](pet.md) *
+
+
+### Authorization
+
+[petstore_auth](../README.md#petstore_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/xml, application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **PetAPI_findPetsByTags**
+```c
+// Finds Pets by tags
+//
+// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+//
+list_t* PetAPI_findPetsByTags(apiClient_t *apiClient, list_t * tags);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**tags** | **[list_t](char.md) \*** | Tags to filter by |
+
+### Return type
+
+[list_t](pet.md) *
+
+
+### Authorization
+
+[petstore_auth](../README.md#petstore_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/xml, application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **PetAPI_getPetById**
+```c
+// Find pet by ID
+//
+// Returns a single pet
+//
+pet_t* PetAPI_getPetById(apiClient_t *apiClient, long petId);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**petId** | **long** | ID of pet to return |
+
+### Return type
+
+[pet_t](pet.md) *
+
+
+### Authorization
+
+[api_key](../README.md#api_key)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/xml, application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **PetAPI_updatePet**
+```c
+// Update an existing pet
+//
+void PetAPI_updatePet(apiClient_t *apiClient, pet_t * body);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**body** | **[pet_t](pet.md) \*** | Pet object that needs to be added to the store |
+
+### Return type
+
+void
+
+### Authorization
+
+[petstore_auth](../README.md#petstore_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json, application/xml
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **PetAPI_updatePetWithForm**
+```c
+// Updates a pet in the store with form data
+//
+void PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId, char * name, char * status);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**petId** | **long** | ID of pet that needs to be updated |
+**name** | **char \*** | Updated name of the pet | [optional]
+**status** | **char \*** | Updated status of the pet | [optional]
+
+### Return type
+
+void
+
+### Authorization
+
+[petstore_auth](../README.md#petstore_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: application/x-www-form-urlencoded
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **PetAPI_uploadFile**
+```c
+// uploads an image
+//
+api_response_t* PetAPI_uploadFile(apiClient_t *apiClient, long petId, char * additionalMetadata, binary_t* file);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**petId** | **long** | ID of pet to update |
+**additionalMetadata** | **char \*** | Additional data to pass to server | [optional]
+**file** | **binary_t*** | file to upload | [optional]
+
+### Return type
+
+[api_response_t](api_response.md) *
+
+
+### Authorization
+
+[petstore_auth](../README.md#petstore_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: multipart/form-data
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/c/docs/StoreAPI.md b/samples/client/petstore/c/docs/StoreAPI.md
new file mode 100644
index 00000000000..c4ff3767735
--- /dev/null
+++ b/samples/client/petstore/c/docs/StoreAPI.md
@@ -0,0 +1,135 @@
+# StoreAPI
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**StoreAPI_deleteOrder**](StoreAPI.md#StoreAPI_deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
+[**StoreAPI_getInventory**](StoreAPI.md#StoreAPI_getInventory) | **GET** /store/inventory | Returns pet inventories by status
+[**StoreAPI_getOrderById**](StoreAPI.md#StoreAPI_getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
+[**StoreAPI_placeOrder**](StoreAPI.md#StoreAPI_placeOrder) | **POST** /store/order | Place an order for a pet
+
+
+# **StoreAPI_deleteOrder**
+```c
+// Delete purchase order by ID
+//
+// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+//
+void StoreAPI_deleteOrder(apiClient_t *apiClient, char * orderId);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**orderId** | **char \*** | ID of the order that needs to be deleted |
+
+### Return type
+
+void
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **StoreAPI_getInventory**
+```c
+// Returns pet inventories by status
+//
+// Returns a map of status codes to quantities
+//
+list_t* StoreAPI_getInventory(apiClient_t *apiClient);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+
+### Return type
+
+
+
+list_t*
+
+
+
+### Authorization
+
+[api_key](../README.md#api_key)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **StoreAPI_getOrderById**
+```c
+// Find purchase order by ID
+//
+// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+//
+order_t* StoreAPI_getOrderById(apiClient_t *apiClient, long orderId);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**orderId** | **long** | ID of pet that needs to be fetched |
+
+### Return type
+
+[order_t](order.md) *
+
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/xml, application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **StoreAPI_placeOrder**
+```c
+// Place an order for a pet
+//
+order_t* StoreAPI_placeOrder(apiClient_t *apiClient, order_t * body);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**body** | **[order_t](order.md) \*** | order placed for purchasing the pet |
+
+### Return type
+
+[order_t](order.md) *
+
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/xml, application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/c/docs/UserAPI.md b/samples/client/petstore/c/docs/UserAPI.md
new file mode 100644
index 00000000000..21ecbdc39f1
--- /dev/null
+++ b/samples/client/petstore/c/docs/UserAPI.md
@@ -0,0 +1,250 @@
+# UserAPI
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**UserAPI_createUser**](UserAPI.md#UserAPI_createUser) | **POST** /user | Create user
+[**UserAPI_createUsersWithArrayInput**](UserAPI.md#UserAPI_createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
+[**UserAPI_createUsersWithListInput**](UserAPI.md#UserAPI_createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
+[**UserAPI_deleteUser**](UserAPI.md#UserAPI_deleteUser) | **DELETE** /user/{username} | Delete user
+[**UserAPI_getUserByName**](UserAPI.md#UserAPI_getUserByName) | **GET** /user/{username} | Get user by user name
+[**UserAPI_loginUser**](UserAPI.md#UserAPI_loginUser) | **GET** /user/login | Logs user into the system
+[**UserAPI_logoutUser**](UserAPI.md#UserAPI_logoutUser) | **GET** /user/logout | Logs out current logged in user session
+[**UserAPI_updateUser**](UserAPI.md#UserAPI_updateUser) | **PUT** /user/{username} | Updated user
+
+
+# **UserAPI_createUser**
+```c
+// Create user
+//
+// This can only be done by the logged in user.
+//
+void UserAPI_createUser(apiClient_t *apiClient, user_t * body);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**body** | **[user_t](user.md) \*** | Created user object |
+
+### Return type
+
+void
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **UserAPI_createUsersWithArrayInput**
+```c
+// Creates list of users with given input array
+//
+void UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t * body);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**body** | **[list_t](user.md) \*** | List of user object |
+
+### Return type
+
+void
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **UserAPI_createUsersWithListInput**
+```c
+// Creates list of users with given input array
+//
+void UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t * body);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**body** | **[list_t](user.md) \*** | List of user object |
+
+### Return type
+
+void
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **UserAPI_deleteUser**
+```c
+// Delete user
+//
+// This can only be done by the logged in user.
+//
+void UserAPI_deleteUser(apiClient_t *apiClient, char * username);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**username** | **char \*** | The name that needs to be deleted |
+
+### Return type
+
+void
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **UserAPI_getUserByName**
+```c
+// Get user by user name
+//
+user_t* UserAPI_getUserByName(apiClient_t *apiClient, char * username);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**username** | **char \*** | The name that needs to be fetched. Use user1 for testing. |
+
+### Return type
+
+[user_t](user.md) *
+
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/xml, application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **UserAPI_loginUser**
+```c
+// Logs user into the system
+//
+char* UserAPI_loginUser(apiClient_t *apiClient, char * username, char * password);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**username** | **char \*** | The user name for login |
+**password** | **char \*** | The password for login in clear text |
+
+### Return type
+
+char*
+
+
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/xml, application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **UserAPI_logoutUser**
+```c
+// Logs out current logged in user session
+//
+void UserAPI_logoutUser(apiClient_t *apiClient);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+
+### Return type
+
+void
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **UserAPI_updateUser**
+```c
+// Updated user
+//
+// This can only be done by the logged in user.
+//
+void UserAPI_updateUser(apiClient_t *apiClient, char * username, user_t * body);
+```
+
+### Parameters
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+**apiClient** | **apiClient_t \*** | context containing the client configuration |
+**username** | **char \*** | name that need to be deleted |
+**body** | **[user_t](user.md) \*** | Updated user object |
+
+### Return type
+
+void
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/c/docs/api_response.md b/samples/client/petstore/c/docs/api_response.md
new file mode 100644
index 00000000000..a6c518ad1fd
--- /dev/null
+++ b/samples/client/petstore/c/docs/api_response.md
@@ -0,0 +1,12 @@
+# api_response_t
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**code** | **int** | | [optional]
+**type** | **char \*** | | [optional]
+**message** | **char \*** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/c/docs/category.md b/samples/client/petstore/c/docs/category.md
new file mode 100644
index 00000000000..33db81b7968
--- /dev/null
+++ b/samples/client/petstore/c/docs/category.md
@@ -0,0 +1,11 @@
+# category_t
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**id** | **long** | | [optional]
+**name** | **char \*** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/c/docs/order.md b/samples/client/petstore/c/docs/order.md
new file mode 100644
index 00000000000..4e213afcb1c
--- /dev/null
+++ b/samples/client/petstore/c/docs/order.md
@@ -0,0 +1,15 @@
+# order_t
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**id** | **long** | | [optional]
+**pet_id** | **long** | | [optional]
+**quantity** | **int** | | [optional]
+**ship_date** | **char \*** | | [optional]
+**status** | **openapi_petstore_order_STATUS_e** | Order Status | [optional]
+**complete** | **int** | | [optional] [default to false]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/c/docs/pet.md b/samples/client/petstore/c/docs/pet.md
new file mode 100644
index 00000000000..44fbf8a3839
--- /dev/null
+++ b/samples/client/petstore/c/docs/pet.md
@@ -0,0 +1,15 @@
+# pet_t
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**id** | **long** | | [optional]
+**category** | [**category_t**](category.md) \* | | [optional]
+**name** | **char \*** | |
+**photo_urls** | **list_t \*** | |
+**tags** | [**list_t**](tag.md) \* | | [optional]
+**status** | **openapi_petstore_pet_STATUS_e** | pet status in the store | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/c/docs/tag.md b/samples/client/petstore/c/docs/tag.md
new file mode 100644
index 00000000000..f3c1ea1e48b
--- /dev/null
+++ b/samples/client/petstore/c/docs/tag.md
@@ -0,0 +1,11 @@
+# tag_t
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**id** | **long** | | [optional]
+**name** | **char \*** | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/c/docs/user.md b/samples/client/petstore/c/docs/user.md
new file mode 100644
index 00000000000..3b9219c158b
--- /dev/null
+++ b/samples/client/petstore/c/docs/user.md
@@ -0,0 +1,17 @@
+# user_t
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**id** | **long** | | [optional]
+**username** | **char \*** | | [optional]
+**first_name** | **char \*** | | [optional]
+**last_name** | **char \*** | | [optional]
+**email** | **char \*** | | [optional]
+**password** | **char \*** | | [optional]
+**phone** | **char \*** | | [optional]
+**user_status** | **int** | User Status | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/cpp-qt5/PetStore/PetApiTests.cpp b/samples/client/petstore/cpp-qt5/PetStore/PetApiTests.cpp
index cbc735d8d81..f27d76e8ed1 100644
--- a/samples/client/petstore/cpp-qt5/PetStore/PetApiTests.cpp
+++ b/samples/client/petstore/cpp-qt5/PetStore/PetApiTests.cpp
@@ -217,6 +217,7 @@ void PetApiTests::updatePetWithFormTest() {
// fetch it
bool petUpdated2 = false;
connect(&api, &PFXPetApi::getPetByIdSignal, [&](PFXPet pet) {
+ Q_UNUSED(pet);
petUpdated2 = true;
// QVERIFY(pet.getName().compare(QString("gorilla")) == 0);
QTimer::singleShot(0, &loop, &QEventLoop::quit);
diff --git a/samples/client/petstore/cpp-qt5/client/PFXHelpers.h b/samples/client/petstore/cpp-qt5/client/PFXHelpers.h
index 20b4a6f5e15..ef468c1217e 100644
--- a/samples/client/petstore/cpp-qt5/client/PFXHelpers.h
+++ b/samples/client/petstore/cpp-qt5/client/PFXHelpers.h
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include "PFXEnum.h"
#include "PFXHttpFileElement.h"
@@ -29,6 +28,27 @@
namespace test_namespace {
+template
+class OptionalParam {
+public:
+ T m_Value;
+ bool m_hasValue;
+public:
+ OptionalParam(){
+ m_hasValue = false;
+ }
+ OptionalParam(const T &val){
+ m_hasValue = true;
+ m_Value = val;
+ }
+ bool hasValue() const {
+ return m_hasValue;
+ }
+ T value() const{
+ return m_Value;
+ }
+};
+
bool setDateTimeFormat(const QString&);
template
diff --git a/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp
index 0f647d74c01..136f71708ba 100644
--- a/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp
+++ b/samples/client/petstore/cpp-qt5/client/PFXPetApi.cpp
@@ -10,7 +10,6 @@
*/
#include "PFXPetApi.h"
-#include "PFXHelpers.h"
#include "PFXServerConfiguration.h"
#include
#include
@@ -29,7 +28,6 @@ PFXPetApi::~PFXPetApi() {
}
void PFXPetApi::initializeServerConfigs(){
-
//Default server
QList defaultConf = QList();
//varying endpoint server
@@ -38,22 +36,22 @@ void PFXPetApi::initializeServerConfigs(){
QUrl("http://petstore.swagger.io/v2"),
"No description provided",
QMap()));
- _serverConfigs.insert("addPet",defaultConf);
- _serverIndices.insert("addPet",0);
- _serverConfigs.insert("deletePet",defaultConf);
- _serverIndices.insert("deletePet",0);
- _serverConfigs.insert("findPetsByStatus",defaultConf);
- _serverIndices.insert("findPetsByStatus",0);
- _serverConfigs.insert("findPetsByTags",defaultConf);
- _serverIndices.insert("findPetsByTags",0);
- _serverConfigs.insert("getPetById",defaultConf);
- _serverIndices.insert("getPetById",0);
- _serverConfigs.insert("updatePet",defaultConf);
- _serverIndices.insert("updatePet",0);
- _serverConfigs.insert("updatePetWithForm",defaultConf);
- _serverIndices.insert("updatePetWithForm",0);
- _serverConfigs.insert("uploadFile",defaultConf);
- _serverIndices.insert("uploadFile",0);
+ _serverConfigs.insert("addPet", defaultConf);
+ _serverIndices.insert("addPet", 0);
+ _serverConfigs.insert("deletePet", defaultConf);
+ _serverIndices.insert("deletePet", 0);
+ _serverConfigs.insert("findPetsByStatus", defaultConf);
+ _serverIndices.insert("findPetsByStatus", 0);
+ _serverConfigs.insert("findPetsByTags", defaultConf);
+ _serverIndices.insert("findPetsByTags", 0);
+ _serverConfigs.insert("getPetById", defaultConf);
+ _serverIndices.insert("getPetById", 0);
+ _serverConfigs.insert("updatePet", defaultConf);
+ _serverIndices.insert("updatePet", 0);
+ _serverConfigs.insert("updatePetWithForm", defaultConf);
+ _serverIndices.insert("updatePetWithForm", 0);
+ _serverConfigs.insert("uploadFile", defaultConf);
+ _serverIndices.insert("uploadFile", 0);
}
/**
@@ -225,21 +223,22 @@ QString PFXPetApi::getParamStyleDelimiter(QString style, QString name, bool isEx
void PFXPetApi::addPet(const PFXPet &body) {
QString fullPath = QString(_serverConfigs["addPet"][_serverIndices.value("addPet")].URL()+"/pet");
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
+ {
- QByteArray output = body.asJson().toUtf8();
- input.request_body.append(output);
+ QByteArray output = body.asJson().toUtf8();
+ input.request_body.append(output);
+ }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -269,10 +268,9 @@ void PFXPetApi::addPetCallback(PFXHttpRequestWorker *worker) {
}
}
-void PFXPetApi::deletePet(const qint64 &pet_id, const QVariant &api_key) {
+void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::OptionalParam &api_key) {
QString fullPath = QString(_serverConfigs["deletePet"][_serverIndices.value("deletePet")].URL()+"/pet/{petId}");
-
{
QString pet_idPathParam("{");
@@ -287,24 +285,24 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const QVariant &api_key) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "DELETE");
- if(!api_key.isNull())
+
+ if(api_key.hasValue())
{
- if (!::test_namespace::toStringValue(api_key.value()).isEmpty()) {
- input.headers.insert("api_key", ::test_namespace::toStringValue(api_key.value()));
+ if (!::test_namespace::toStringValue(api_key.value()).isEmpty()) {
+ input.headers.insert("api_key", ::test_namespace::toStringValue(api_key.value()));
+ }
}
- }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::deletePetCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -337,7 +335,6 @@ void PFXPetApi::deletePetCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::findPetsByStatus(const QList &status) {
QString fullPath = QString(_serverConfigs["findPetsByStatus"][_serverIndices.value("findPetsByStatus")].URL()+"/pet/findByStatus");
-
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
{
@@ -347,7 +344,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) {
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "status", false);
- if (status.size() > 0) {
+ if(status.size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach (QString t, status) {
if (fullPath.indexOf("?") > 0)
@@ -424,18 +421,18 @@ void PFXPetApi::findPetsByStatus(const QList &status) {
}
}
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByStatusCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -478,7 +475,6 @@ void PFXPetApi::findPetsByStatusCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::findPetsByTags(const QList &tags) {
QString fullPath = QString(_serverConfigs["findPetsByTags"][_serverIndices.value("findPetsByTags")].URL()+"/pet/findByTags");
-
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
{
@@ -488,7 +484,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) {
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "tags", false);
- if (tags.size() > 0) {
+ if(tags.size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach (QString t, tags) {
if (fullPath.indexOf("?") > 0)
@@ -565,18 +561,18 @@ void PFXPetApi::findPetsByTags(const QList &tags) {
}
}
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByTagsCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -623,7 +619,6 @@ void PFXPetApi::getPetById(const qint64 &pet_id) {
addHeaders("api_key",_apiKeys.find("api_key").value());
}
-
{
QString pet_idPathParam("{");
@@ -638,18 +633,18 @@ void PFXPetApi::getPetById(const qint64 &pet_id) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::getPetByIdCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -683,21 +678,22 @@ void PFXPetApi::getPetByIdCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::updatePet(const PFXPet &body) {
QString fullPath = QString(_serverConfigs["updatePet"][_serverIndices.value("updatePet")].URL()+"/pet");
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "PUT");
+ {
- QByteArray output = body.asJson().toUtf8();
- input.request_body.append(output);
+ QByteArray output = body.asJson().toUtf8();
+ input.request_body.append(output);
+ }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -727,10 +723,9 @@ void PFXPetApi::updatePetCallback(PFXHttpRequestWorker *worker) {
}
}
-void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QVariant &name, const QVariant &status) {
+void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace::OptionalParam &name, const ::test_namespace::OptionalParam &status) {
QString fullPath = QString(_serverConfigs["updatePetWithForm"][_serverIndices.value("updatePetWithForm")].URL()+"/pet/{petId}");
-
{
QString pet_idPathParam("{");
@@ -745,22 +740,18 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QVariant &name, co
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
-
- if(!name.isNull())
+ if(name.hasValue())
{
- input.add_var("name", ::test_namespace::toStringValue(name.value()));
+ input.add_var("name", ::test_namespace::toStringValue(name.value()));
}
-
-
- if(!status.isNull())
+ if(status.hasValue())
{
- input.add_var("status", ::test_namespace::toStringValue(status.value()));
+ input.add_var("status", ::test_namespace::toStringValue(status.value()));
}
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
@@ -768,7 +759,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QVariant &name, co
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetWithFormCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -798,10 +789,9 @@ void PFXPetApi::updatePetWithFormCallback(PFXHttpRequestWorker *worker) {
}
}
-void PFXPetApi::uploadFile(const qint64 &pet_id, const QVariant &additional_metadata, const QVariant &file) {
+void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::OptionalParam &additional_metadata, const ::test_namespace::OptionalParam &file) {
QString fullPath = QString(_serverConfigs["uploadFile"][_serverIndices.value("uploadFile")].URL()+"/pet/{petId}/uploadImage");
-
{
QString pet_idPathParam("{");
@@ -816,22 +806,18 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const QVariant &additional_meta
QString paramString = (pathStyle == "matrix") ? pathPrefix+"petId"+pathSuffix : pathPrefix;
fullPath.replace(pet_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
-
- if(!additional_metadata.isNull())
+ if(additional_metadata.hasValue())
{
- input.add_var("additionalMetadata", ::test_namespace::toStringValue(additional_metadata.value()));
+ input.add_var("additionalMetadata", ::test_namespace::toStringValue(additional_metadata.value()));
}
-
-
- if(!file.isNull())
+ if(file.hasValue())
{
- input.add_file("file", file.value().local_filename, file.value().request_filename, file.value().mime_type);
+ input.add_file("file", file.value().local_filename, file.value().request_filename, file.value().mime_type);
}
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
@@ -839,7 +825,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const QVariant &additional_meta
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::uploadFileCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
diff --git a/samples/client/petstore/cpp-qt5/client/PFXPetApi.h b/samples/client/petstore/cpp-qt5/client/PFXPetApi.h
index 0f99801fc3e..2c4d472306b 100644
--- a/samples/client/petstore/cpp-qt5/client/PFXPetApi.h
+++ b/samples/client/petstore/cpp-qt5/client/PFXPetApi.h
@@ -12,6 +12,7 @@
#ifndef PFX_PFXPetApi_H
#define PFX_PFXPetApi_H
+#include "PFXHelpers.h"
#include "PFXHttpRequest.h"
#include "PFXServerConfiguration.h"
@@ -25,7 +26,6 @@
#include
#include
#include
-#include
namespace test_namespace {
@@ -66,7 +66,7 @@ public:
* @param[in] pet_id qint64 [required]
* @param[in] api_key QString [optional]
*/
- void deletePet(const qint64 &pet_id, const QVariant &api_key = QVariant());
+ void deletePet(const qint64 &pet_id, const ::test_namespace::OptionalParam &api_key = ::test_namespace::OptionalParam());
/**
* @param[in] status QList [required]
@@ -93,14 +93,14 @@ public:
* @param[in] name QString [optional]
* @param[in] status QString [optional]
*/
- void updatePetWithForm(const qint64 &pet_id, const QVariant &name = QVariant(), const QVariant &status = QVariant());
+ void updatePetWithForm(const qint64 &pet_id, const ::test_namespace::OptionalParam &name = ::test_namespace::OptionalParam(), const ::test_namespace::OptionalParam &status = ::test_namespace::OptionalParam());
/**
* @param[in] pet_id qint64 [required]
* @param[in] additional_metadata QString [optional]
* @param[in] file PFXHttpFileElement [optional]
*/
- void uploadFile(const qint64 &pet_id, const QVariant &additional_metadata = QVariant(), const QVariant &file = QVariant());
+ void uploadFile(const qint64 &pet_id, const ::test_namespace::OptionalParam &additional_metadata = ::test_namespace::OptionalParam(), const ::test_namespace::OptionalParam &file = ::test_namespace::OptionalParam());
private:
@@ -164,7 +164,7 @@ signals:
void updatePetWithFormSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void uploadFileSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
- void abortRequestsSignal();
+ void abortRequestsSignal();
void allPendingRequestsCompleted();
};
diff --git a/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp b/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp
index b9babe1495a..723af6e80c2 100644
--- a/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp
+++ b/samples/client/petstore/cpp-qt5/client/PFXStoreApi.cpp
@@ -10,7 +10,6 @@
*/
#include "PFXStoreApi.h"
-#include "PFXHelpers.h"
#include "PFXServerConfiguration.h"
#include
#include
@@ -29,7 +28,6 @@ PFXStoreApi::~PFXStoreApi() {
}
void PFXStoreApi::initializeServerConfigs(){
-
//Default server
QList defaultConf = QList();
//varying endpoint server
@@ -38,14 +36,14 @@ void PFXStoreApi::initializeServerConfigs(){
QUrl("http://petstore.swagger.io/v2"),
"No description provided",
QMap()));
- _serverConfigs.insert("deleteOrder",defaultConf);
- _serverIndices.insert("deleteOrder",0);
- _serverConfigs.insert("getInventory",defaultConf);
- _serverIndices.insert("getInventory",0);
- _serverConfigs.insert("getOrderById",defaultConf);
- _serverIndices.insert("getOrderById",0);
- _serverConfigs.insert("placeOrder",defaultConf);
- _serverIndices.insert("placeOrder",0);
+ _serverConfigs.insert("deleteOrder", defaultConf);
+ _serverIndices.insert("deleteOrder", 0);
+ _serverConfigs.insert("getInventory", defaultConf);
+ _serverIndices.insert("getInventory", 0);
+ _serverConfigs.insert("getOrderById", defaultConf);
+ _serverIndices.insert("getOrderById", 0);
+ _serverConfigs.insert("placeOrder", defaultConf);
+ _serverIndices.insert("placeOrder", 0);
}
/**
@@ -217,7 +215,6 @@ QString PFXStoreApi::getParamStyleDelimiter(QString style, QString name, bool is
void PFXStoreApi::deleteOrder(const QString &order_id) {
QString fullPath = QString(_serverConfigs["deleteOrder"][_serverIndices.value("deleteOrder")].URL()+"/store/order/{orderId}");
-
{
QString order_idPathParam("{");
@@ -232,18 +229,18 @@ void PFXStoreApi::deleteOrder(const QString &order_id) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"orderId"+pathSuffix : pathPrefix;
fullPath.replace(order_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "DELETE");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::deleteOrderCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -280,18 +277,18 @@ void PFXStoreApi::getInventory() {
addHeaders("api_key",_apiKeys.find("api_key").value());
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getInventoryCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -334,7 +331,6 @@ void PFXStoreApi::getInventoryCallback(PFXHttpRequestWorker *worker) {
void PFXStoreApi::getOrderById(const qint64 &order_id) {
QString fullPath = QString(_serverConfigs["getOrderById"][_serverIndices.value("getOrderById")].URL()+"/store/order/{orderId}");
-
{
QString order_idPathParam("{");
@@ -349,18 +345,18 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"orderId"+pathSuffix : pathPrefix;
fullPath.replace(order_idPathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getOrderByIdCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -394,21 +390,22 @@ void PFXStoreApi::getOrderByIdCallback(PFXHttpRequestWorker *worker) {
void PFXStoreApi::placeOrder(const PFXOrder &body) {
QString fullPath = QString(_serverConfigs["placeOrder"][_serverIndices.value("placeOrder")].URL()+"/store/order");
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
+ {
- QByteArray output = body.asJson().toUtf8();
- input.request_body.append(output);
+ QByteArray output = body.asJson().toUtf8();
+ input.request_body.append(output);
+ }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::placeOrderCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
diff --git a/samples/client/petstore/cpp-qt5/client/PFXStoreApi.h b/samples/client/petstore/cpp-qt5/client/PFXStoreApi.h
index 8508e14cfb0..7f0fa92b27b 100644
--- a/samples/client/petstore/cpp-qt5/client/PFXStoreApi.h
+++ b/samples/client/petstore/cpp-qt5/client/PFXStoreApi.h
@@ -12,6 +12,7 @@
#ifndef PFX_PFXStoreApi_H
#define PFX_PFXStoreApi_H
+#include "PFXHelpers.h"
#include "PFXHttpRequest.h"
#include "PFXServerConfiguration.h"
@@ -24,7 +25,6 @@
#include
#include
#include
-#include
namespace test_namespace {
@@ -116,7 +116,7 @@ signals:
void getOrderByIdSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void placeOrderSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
- void abortRequestsSignal();
+ void abortRequestsSignal();
void allPendingRequestsCompleted();
};
diff --git a/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp b/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp
index 9c6259c575f..1ea5c6e602d 100644
--- a/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp
+++ b/samples/client/petstore/cpp-qt5/client/PFXUserApi.cpp
@@ -10,7 +10,6 @@
*/
#include "PFXUserApi.h"
-#include "PFXHelpers.h"
#include "PFXServerConfiguration.h"
#include
#include
@@ -29,7 +28,6 @@ PFXUserApi::~PFXUserApi() {
}
void PFXUserApi::initializeServerConfigs(){
-
//Default server
QList defaultConf = QList();
//varying endpoint server
@@ -38,22 +36,22 @@ void PFXUserApi::initializeServerConfigs(){
QUrl("http://petstore.swagger.io/v2"),
"No description provided",
QMap()));
- _serverConfigs.insert("createUser",defaultConf);
- _serverIndices.insert("createUser",0);
- _serverConfigs.insert("createUsersWithArrayInput",defaultConf);
- _serverIndices.insert("createUsersWithArrayInput",0);
- _serverConfigs.insert("createUsersWithListInput",defaultConf);
- _serverIndices.insert("createUsersWithListInput",0);
- _serverConfigs.insert("deleteUser",defaultConf);
- _serverIndices.insert("deleteUser",0);
- _serverConfigs.insert("getUserByName",defaultConf);
- _serverIndices.insert("getUserByName",0);
- _serverConfigs.insert("loginUser",defaultConf);
- _serverIndices.insert("loginUser",0);
- _serverConfigs.insert("logoutUser",defaultConf);
- _serverIndices.insert("logoutUser",0);
- _serverConfigs.insert("updateUser",defaultConf);
- _serverIndices.insert("updateUser",0);
+ _serverConfigs.insert("createUser", defaultConf);
+ _serverIndices.insert("createUser", 0);
+ _serverConfigs.insert("createUsersWithArrayInput", defaultConf);
+ _serverIndices.insert("createUsersWithArrayInput", 0);
+ _serverConfigs.insert("createUsersWithListInput", defaultConf);
+ _serverIndices.insert("createUsersWithListInput", 0);
+ _serverConfigs.insert("deleteUser", defaultConf);
+ _serverIndices.insert("deleteUser", 0);
+ _serverConfigs.insert("getUserByName", defaultConf);
+ _serverIndices.insert("getUserByName", 0);
+ _serverConfigs.insert("loginUser", defaultConf);
+ _serverIndices.insert("loginUser", 0);
+ _serverConfigs.insert("logoutUser", defaultConf);
+ _serverIndices.insert("logoutUser", 0);
+ _serverConfigs.insert("updateUser", defaultConf);
+ _serverIndices.insert("updateUser", 0);
}
/**
@@ -225,21 +223,22 @@ QString PFXUserApi::getParamStyleDelimiter(QString style, QString name, bool isE
void PFXUserApi::createUser(const PFXUser &body) {
QString fullPath = QString(_serverConfigs["createUser"][_serverIndices.value("createUser")].URL()+"/user");
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
+ {
- QByteArray output = body.asJson().toUtf8();
- input.request_body.append(output);
+ QByteArray output = body.asJson().toUtf8();
+ input.request_body.append(output);
+ }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -272,21 +271,22 @@ void PFXUserApi::createUserCallback(PFXHttpRequestWorker *worker) {
void PFXUserApi::createUsersWithArrayInput(const QList &body) {
QString fullPath = QString(_serverConfigs["createUsersWithArrayInput"][_serverIndices.value("createUsersWithArrayInput")].URL()+"/user/createWithArray");
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
- QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
- QByteArray bytes = doc.toJson();
- input.request_body.append(bytes);
+ {
+ QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
+ QByteArray bytes = doc.toJson();
+ input.request_body.append(bytes);
+ }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithArrayInputCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -319,21 +319,22 @@ void PFXUserApi::createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker)
void PFXUserApi::createUsersWithListInput(const QList &body) {
QString fullPath = QString(_serverConfigs["createUsersWithListInput"][_serverIndices.value("createUsersWithListInput")].URL()+"/user/createWithList");
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
- QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
- QByteArray bytes = doc.toJson();
- input.request_body.append(bytes);
+ {
+ QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
+ QByteArray bytes = doc.toJson();
+ input.request_body.append(bytes);
+ }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithListInputCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -366,7 +367,6 @@ void PFXUserApi::createUsersWithListInputCallback(PFXHttpRequestWorker *worker)
void PFXUserApi::deleteUser(const QString &username) {
QString fullPath = QString(_serverConfigs["deleteUser"][_serverIndices.value("deleteUser")].URL()+"/user/{username}");
-
{
QString usernamePathParam("{");
@@ -381,18 +381,18 @@ void PFXUserApi::deleteUser(const QString &username) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"username"+pathSuffix : pathPrefix;
fullPath.replace(usernamePathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "DELETE");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::deleteUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -425,7 +425,6 @@ void PFXUserApi::deleteUserCallback(PFXHttpRequestWorker *worker) {
void PFXUserApi::getUserByName(const QString &username) {
QString fullPath = QString(_serverConfigs["getUserByName"][_serverIndices.value("getUserByName")].URL()+"/user/{username}");
-
{
QString usernamePathParam("{");
@@ -440,18 +439,18 @@ void PFXUserApi::getUserByName(const QString &username) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"username"+pathSuffix : pathPrefix;
fullPath.replace(usernamePathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::getUserByNameCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -485,7 +484,6 @@ void PFXUserApi::getUserByNameCallback(PFXHttpRequestWorker *worker) {
void PFXUserApi::loginUser(const QString &username, const QString &password) {
QString fullPath = QString(_serverConfigs["loginUser"][_serverIndices.value("loginUser")].URL()+"/user/login");
-
QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
{
@@ -502,7 +500,6 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) {
fullPath.append(QUrl::toPercentEncoding("username")).append(querySuffix).append(QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
}
-
{
queryStyle = "";
@@ -518,18 +515,18 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) {
fullPath.append(QUrl::toPercentEncoding("password")).append(querySuffix).append(QUrl::toPercentEncoding(::test_namespace::toStringValue(password)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::loginUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -564,18 +561,18 @@ void PFXUserApi::loginUserCallback(PFXHttpRequestWorker *worker) {
void PFXUserApi::logoutUser() {
QString fullPath = QString(_serverConfigs["logoutUser"][_serverIndices.value("logoutUser")].URL()+"/user/logout");
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "GET");
+
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::logoutUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
@@ -608,7 +605,6 @@ void PFXUserApi::logoutUserCallback(PFXHttpRequestWorker *worker) {
void PFXUserApi::updateUser(const QString &username, const PFXUser &body) {
QString fullPath = QString(_serverConfigs["updateUser"][_serverIndices.value("updateUser")].URL()+"/user/{username}");
-
{
QString usernamePathParam("{");
@@ -623,21 +619,22 @@ void PFXUserApi::updateUser(const QString &username, const PFXUser &body) {
QString paramString = (pathStyle == "matrix") ? pathPrefix+"username"+pathSuffix : pathPrefix;
fullPath.replace(usernamePathParam, paramString+QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
}
-
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
worker->setTimeOut(_timeOut);
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "PUT");
+ {
- QByteArray output = body.asJson().toUtf8();
- input.request_body.append(output);
+ QByteArray output = body.asJson().toUtf8();
+ input.request_body.append(output);
+ }
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::updateUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ if(findChildren().count() == 0){
emit allPendingRequestsCompleted();
}
});
diff --git a/samples/client/petstore/cpp-qt5/client/PFXUserApi.h b/samples/client/petstore/cpp-qt5/client/PFXUserApi.h
index fca34c30aec..ab974de0622 100644
--- a/samples/client/petstore/cpp-qt5/client/PFXUserApi.h
+++ b/samples/client/petstore/cpp-qt5/client/PFXUserApi.h
@@ -12,6 +12,7 @@
#ifndef PFX_PFXUserApi_H
#define PFX_PFXUserApi_H
+#include "PFXHelpers.h"
#include "PFXHttpRequest.h"
#include "PFXServerConfiguration.h"
@@ -24,7 +25,6 @@
#include
#include
#include
-#include
namespace test_namespace {
@@ -158,7 +158,7 @@ signals:
void logoutUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void updateUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
- void abortRequestsSignal();
+ void abortRequestsSignal();
void allPendingRequestsCompleted();
};
diff --git a/samples/client/petstore/cpp-ue4/.openapi-generator/VERSION b/samples/client/petstore/cpp-ue4/.openapi-generator/VERSION
index d99e7162d01..c30f0ec2be7 100644
--- a/samples/client/petstore/cpp-ue4/.openapi-generator/VERSION
+++ b/samples/client/petstore/cpp-ue4/.openapi-generator/VERSION
@@ -1 +1 @@
-5.0.0-SNAPSHOT
\ No newline at end of file
+5.1.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp
index b8b5bd778a7..b277e257028 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp
@@ -12,6 +12,8 @@
#include "OpenAPIBaseModel.h"
+#include "Async/Async.h"
+
namespace OpenAPI
{
@@ -25,4 +27,13 @@ void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
}
}
+void Response::AsyncRetry() const
+{
+ // Unfortunately, it is currently usafe to call ProcessRequest() directly here.
+ // This is because the HttpManager will remove all references to this HttpRequest in FHttpManager::Tick including the new request we just added, instead of removing just one.
+ // This will lead to the request's destruction and eventually a crash.
+ // The only solution is therefore to ensure we are taking an extra reference to the request, and that the request is added after the queue is flushed.
+ Async(EAsyncExecution::TaskGraph, [AddRef = FHttpRequestPtr(GetHttpRequest())](){ AddRef->ProcessRequest(); });
+}
+
}
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIHelpers.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIHelpers.cpp
index 7361ddf5fe3..4b6e1627c14 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIHelpers.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIHelpers.cpp
@@ -79,7 +79,7 @@ const FString& HttpMultipartFormData::GetBoundary() const
return Boundary;
}
-void HttpMultipartFormData::SetupHttpRequest(const TSharedRef& HttpRequest)
+void HttpMultipartFormData::SetupHttpRequest(const FHttpRequestRef& HttpRequest)
{
if(HttpRequest->GetVerb() != TEXT("POST"))
{
@@ -192,4 +192,42 @@ void HttpMultipartFormData::AppendString(const TCHAR* Str)
FormData.Append((uint8*)utf8Str.Get(), utf8Str.Length());
}
+//////////////////////////////////////////////////////////////////////////
+
+bool ParseDateTime(const FString& DateTimeString, FDateTime& OutDateTime)
+{
+ // Iso8601 Format: DateTime: YYYY-mm-ddTHH:MM:SS(.sss)(Z|+hh:mm|+hhmm|-hh:mm|-hhmm)
+ {
+ // We cannot call directly FDateTime::ParseIso8601 because it does not allow for precision beyond the millisecond, but DateTimeString might have more digits
+ int32 DotIndex;
+ FString StringToParse = DateTimeString;
+ if (DateTimeString.FindChar('.', DotIndex))
+ {
+ int32 TimeZoneIndex;
+ if (DateTimeString.FindChar('Z', TimeZoneIndex) || DateTimeString.FindChar('+', TimeZoneIndex) || DateTimeString.FindChar('-', TimeZoneIndex))
+ {
+ // The string contains a time zone designator starting at TimeZoneIndex
+ if (TimeZoneIndex > DotIndex + 4)
+ {
+ // Trim to millisecond
+ StringToParse = DateTimeString.Left(DotIndex + 4) + DateTimeString.RightChop(TimeZoneIndex);
+ }
+ }
+ else
+ {
+ // the string does not contain a time zone designator, trim it to the millisecond
+ StringToParse = DateTimeString.Left(DotIndex + 4);
+ }
+ }
+
+ if (FDateTime::ParseIso8601(*StringToParse, OutDateTime))
+ return true;
+ }
+
+ if (FDateTime::ParseHttpDate(DateTimeString, OutDateTime))
+ return true;
+
+ return FDateTime::Parse(DateTimeString, OutDateTime);
+}
+
}
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp
index 5e5602316f7..68a0d933aca 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp
@@ -103,7 +103,7 @@ bool OpenAPIPetApi::AddPet(const AddPetRequest& Request, const FAddPetDelegate&
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -113,15 +113,26 @@ bool OpenAPIPetApi::AddPet(const AddPetRequest& Request, const FAddPetDelegate&
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnAddPetResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnAddPetResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FAddPetDelegate Delegate) const
+void OpenAPIPetApi::OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FAddPetDelegate Delegate, int AutoRetryCount) const
{
AddPetResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnAddPetResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetDelegate& Delegate /*= FDeletePetDelegate()*/) const
@@ -129,7 +140,7 @@ bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetD
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -139,15 +150,26 @@ bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetD
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnDeletePetResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnDeletePetResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeletePetDelegate Delegate) const
+void OpenAPIPetApi::OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeletePetDelegate Delegate, int AutoRetryCount) const
{
DeletePetResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnDeletePetResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, const FFindPetsByStatusDelegate& Delegate /*= FFindPetsByStatusDelegate()*/) const
@@ -155,7 +177,7 @@ bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, con
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -165,15 +187,26 @@ bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, con
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByStatusResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByStatusResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByStatusDelegate Delegate) const
+void OpenAPIPetApi::OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByStatusDelegate Delegate, int AutoRetryCount) const
{
FindPetsByStatusResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByStatusResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const FFindPetsByTagsDelegate& Delegate /*= FFindPetsByTagsDelegate()*/) const
@@ -181,7 +214,7 @@ bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const F
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -191,15 +224,26 @@ bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const F
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByTagsResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByTagsResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByTagsDelegate Delegate) const
+void OpenAPIPetApi::OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByTagsDelegate Delegate, int AutoRetryCount) const
{
FindPetsByTagsResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByTagsResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetByIdDelegate& Delegate /*= FGetPetByIdDelegate()*/) const
@@ -207,7 +251,7 @@ bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetBy
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -217,15 +261,26 @@ bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetBy
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnGetPetByIdResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnGetPetByIdResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetPetByIdDelegate Delegate) const
+void OpenAPIPetApi::OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetPetByIdDelegate Delegate, int AutoRetryCount) const
{
GetPetByIdResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnGetPetByIdResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetDelegate& Delegate /*= FUpdatePetDelegate()*/) const
@@ -233,7 +288,7 @@ bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetD
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -243,15 +298,26 @@ bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetD
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetDelegate Delegate) const
+void OpenAPIPetApi::OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetDelegate Delegate, int AutoRetryCount) const
{
UpdatePetResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, const FUpdatePetWithFormDelegate& Delegate /*= FUpdatePetWithFormDelegate()*/) const
@@ -259,7 +325,7 @@ bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, c
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -269,15 +335,26 @@ bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, c
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetWithFormResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetWithFormResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetWithFormDelegate Delegate) const
+void OpenAPIPetApi::OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetWithFormDelegate Delegate, int AutoRetryCount) const
{
UpdatePetWithFormResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetWithFormResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFileDelegate& Delegate /*= FUploadFileDelegate()*/) const
@@ -285,7 +362,7 @@ bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFi
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -295,15 +372,26 @@ bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFi
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUploadFileResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUploadFileResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIPetApi::OnUploadFileResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUploadFileDelegate Delegate) const
+void OpenAPIPetApi::OnUploadFileResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUploadFileDelegate Delegate, int AutoRetryCount) const
{
UploadFileResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUploadFileResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
}
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApiOperations.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApiOperations.cpp
index 988a9496b14..92a954d22b3 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApiOperations.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApiOperations.cpp
@@ -29,7 +29,7 @@ FString OpenAPIPetApi::AddPetRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::AddPetRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::AddPetRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { TEXT("application/json"), TEXT("application/xml") };
//static const TArray Produces = { };
@@ -89,7 +89,7 @@ FString OpenAPIPetApi::DeletePetRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::DeletePetRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::DeletePetRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { };
@@ -191,7 +191,7 @@ FString OpenAPIPetApi::FindPetsByStatusRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::FindPetsByStatusRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::FindPetsByStatusRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { TEXT("application/xml"), TEXT("application/json") };
@@ -244,7 +244,7 @@ FString OpenAPIPetApi::FindPetsByTagsRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::FindPetsByTagsRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::FindPetsByTagsRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { TEXT("application/xml"), TEXT("application/json") };
@@ -296,7 +296,7 @@ FString OpenAPIPetApi::GetPetByIdRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::GetPetByIdRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::GetPetByIdRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { TEXT("application/xml"), TEXT("application/json") };
@@ -347,7 +347,7 @@ FString OpenAPIPetApi::UpdatePetRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::UpdatePetRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::UpdatePetRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { TEXT("application/json"), TEXT("application/xml") };
//static const TArray Produces = { };
@@ -413,7 +413,7 @@ FString OpenAPIPetApi::UpdatePetWithFormRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::UpdatePetWithFormRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::UpdatePetWithFormRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { TEXT("application/x-www-form-urlencoded") };
//static const TArray Produces = { };
@@ -487,7 +487,7 @@ FString OpenAPIPetApi::UploadFileRequest::ComputePath() const
return Path;
}
-void OpenAPIPetApi::UploadFileRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIPetApi::UploadFileRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { TEXT("multipart/form-data") };
//static const TArray Produces = { TEXT("application/json") };
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp
index 293034324c4..32000a95907 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp
@@ -103,7 +103,7 @@ bool OpenAPIStoreApi::DeleteOrder(const DeleteOrderRequest& Request, const FDele
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -113,15 +113,26 @@ bool OpenAPIStoreApi::DeleteOrder(const DeleteOrderRequest& Request, const FDele
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnDeleteOrderResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnDeleteOrderResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIStoreApi::OnDeleteOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteOrderDelegate Delegate) const
+void OpenAPIStoreApi::OnDeleteOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteOrderDelegate Delegate, int AutoRetryCount) const
{
DeleteOrderResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnDeleteOrderResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIStoreApi::GetInventory(const GetInventoryRequest& Request, const FGetInventoryDelegate& Delegate /*= FGetInventoryDelegate()*/) const
@@ -129,7 +140,7 @@ bool OpenAPIStoreApi::GetInventory(const GetInventoryRequest& Request, const FGe
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -139,15 +150,26 @@ bool OpenAPIStoreApi::GetInventory(const GetInventoryRequest& Request, const FGe
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetInventoryResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetInventoryResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIStoreApi::OnGetInventoryResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetInventoryDelegate Delegate) const
+void OpenAPIStoreApi::OnGetInventoryResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetInventoryDelegate Delegate, int AutoRetryCount) const
{
GetInventoryResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetInventoryResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIStoreApi::GetOrderById(const GetOrderByIdRequest& Request, const FGetOrderByIdDelegate& Delegate /*= FGetOrderByIdDelegate()*/) const
@@ -155,7 +177,7 @@ bool OpenAPIStoreApi::GetOrderById(const GetOrderByIdRequest& Request, const FGe
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -165,15 +187,26 @@ bool OpenAPIStoreApi::GetOrderById(const GetOrderByIdRequest& Request, const FGe
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetOrderByIdResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetOrderByIdResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIStoreApi::OnGetOrderByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetOrderByIdDelegate Delegate) const
+void OpenAPIStoreApi::OnGetOrderByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetOrderByIdDelegate Delegate, int AutoRetryCount) const
{
GetOrderByIdResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetOrderByIdResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIStoreApi::PlaceOrder(const PlaceOrderRequest& Request, const FPlaceOrderDelegate& Delegate /*= FPlaceOrderDelegate()*/) const
@@ -181,7 +214,7 @@ bool OpenAPIStoreApi::PlaceOrder(const PlaceOrderRequest& Request, const FPlaceO
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -191,15 +224,26 @@ bool OpenAPIStoreApi::PlaceOrder(const PlaceOrderRequest& Request, const FPlaceO
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnPlaceOrderResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnPlaceOrderResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIStoreApi::OnPlaceOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FPlaceOrderDelegate Delegate) const
+void OpenAPIStoreApi::OnPlaceOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FPlaceOrderDelegate Delegate, int AutoRetryCount) const
{
PlaceOrderResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnPlaceOrderResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
}
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApiOperations.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApiOperations.cpp
index 9f3c059d923..1c5efb37559 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApiOperations.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApiOperations.cpp
@@ -33,7 +33,7 @@ FString OpenAPIStoreApi::DeleteOrderRequest::ComputePath() const
return Path;
}
-void OpenAPIStoreApi::DeleteOrderRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIStoreApi::DeleteOrderRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { };
@@ -81,7 +81,7 @@ FString OpenAPIStoreApi::GetInventoryRequest::ComputePath() const
return Path;
}
-void OpenAPIStoreApi::GetInventoryRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIStoreApi::GetInventoryRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { TEXT("application/json") };
@@ -130,7 +130,7 @@ FString OpenAPIStoreApi::GetOrderByIdRequest::ComputePath() const
return Path;
}
-void OpenAPIStoreApi::GetOrderByIdRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIStoreApi::GetOrderByIdRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { TEXT("application/xml"), TEXT("application/json") };
@@ -181,7 +181,7 @@ FString OpenAPIStoreApi::PlaceOrderRequest::ComputePath() const
return Path;
}
-void OpenAPIStoreApi::PlaceOrderRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIStoreApi::PlaceOrderRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { TEXT("application/xml"), TEXT("application/json") };
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp
index 68a6888c669..9fdd937b3b9 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp
@@ -103,7 +103,7 @@ bool OpenAPIUserApi::CreateUser(const CreateUserRequest& Request, const FCreateU
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -113,15 +113,26 @@ bool OpenAPIUserApi::CreateUser(const CreateUserRequest& Request, const FCreateU
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUserResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUserResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnCreateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUserDelegate Delegate) const
+void OpenAPIUserApi::OnCreateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUserDelegate Delegate, int AutoRetryCount) const
{
CreateUserResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUserResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIUserApi::CreateUsersWithArrayInput(const CreateUsersWithArrayInputRequest& Request, const FCreateUsersWithArrayInputDelegate& Delegate /*= FCreateUsersWithArrayInputDelegate()*/) const
@@ -129,7 +140,7 @@ bool OpenAPIUserApi::CreateUsersWithArrayInput(const CreateUsersWithArrayInputRe
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -139,15 +150,26 @@ bool OpenAPIUserApi::CreateUsersWithArrayInput(const CreateUsersWithArrayInputRe
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithArrayInputResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithArrayInputResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnCreateUsersWithArrayInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithArrayInputDelegate Delegate) const
+void OpenAPIUserApi::OnCreateUsersWithArrayInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithArrayInputDelegate Delegate, int AutoRetryCount) const
{
CreateUsersWithArrayInputResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithArrayInputResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIUserApi::CreateUsersWithListInput(const CreateUsersWithListInputRequest& Request, const FCreateUsersWithListInputDelegate& Delegate /*= FCreateUsersWithListInputDelegate()*/) const
@@ -155,7 +177,7 @@ bool OpenAPIUserApi::CreateUsersWithListInput(const CreateUsersWithListInputRequ
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -165,15 +187,26 @@ bool OpenAPIUserApi::CreateUsersWithListInput(const CreateUsersWithListInputRequ
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithListInputResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithListInputResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnCreateUsersWithListInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithListInputDelegate Delegate) const
+void OpenAPIUserApi::OnCreateUsersWithListInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithListInputDelegate Delegate, int AutoRetryCount) const
{
CreateUsersWithListInputResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithListInputResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIUserApi::DeleteUser(const DeleteUserRequest& Request, const FDeleteUserDelegate& Delegate /*= FDeleteUserDelegate()*/) const
@@ -181,7 +214,7 @@ bool OpenAPIUserApi::DeleteUser(const DeleteUserRequest& Request, const FDeleteU
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -191,15 +224,26 @@ bool OpenAPIUserApi::DeleteUser(const DeleteUserRequest& Request, const FDeleteU
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnDeleteUserResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnDeleteUserResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnDeleteUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteUserDelegate Delegate) const
+void OpenAPIUserApi::OnDeleteUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteUserDelegate Delegate, int AutoRetryCount) const
{
DeleteUserResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnDeleteUserResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIUserApi::GetUserByName(const GetUserByNameRequest& Request, const FGetUserByNameDelegate& Delegate /*= FGetUserByNameDelegate()*/) const
@@ -207,7 +251,7 @@ bool OpenAPIUserApi::GetUserByName(const GetUserByNameRequest& Request, const FG
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -217,15 +261,26 @@ bool OpenAPIUserApi::GetUserByName(const GetUserByNameRequest& Request, const FG
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnGetUserByNameResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnGetUserByNameResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnGetUserByNameResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetUserByNameDelegate Delegate) const
+void OpenAPIUserApi::OnGetUserByNameResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetUserByNameDelegate Delegate, int AutoRetryCount) const
{
GetUserByNameResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnGetUserByNameResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIUserApi::LoginUser(const LoginUserRequest& Request, const FLoginUserDelegate& Delegate /*= FLoginUserDelegate()*/) const
@@ -233,7 +288,7 @@ bool OpenAPIUserApi::LoginUser(const LoginUserRequest& Request, const FLoginUser
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -243,15 +298,26 @@ bool OpenAPIUserApi::LoginUser(const LoginUserRequest& Request, const FLoginUser
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLoginUserResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLoginUserResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnLoginUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLoginUserDelegate Delegate) const
+void OpenAPIUserApi::OnLoginUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLoginUserDelegate Delegate, int AutoRetryCount) const
{
LoginUserResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLoginUserResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIUserApi::LogoutUser(const LogoutUserRequest& Request, const FLogoutUserDelegate& Delegate /*= FLogoutUserDelegate()*/) const
@@ -259,7 +325,7 @@ bool OpenAPIUserApi::LogoutUser(const LogoutUserRequest& Request, const FLogoutU
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -269,15 +335,26 @@ bool OpenAPIUserApi::LogoutUser(const LogoutUserRequest& Request, const FLogoutU
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLogoutUserResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLogoutUserResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnLogoutUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLogoutUserDelegate Delegate) const
+void OpenAPIUserApi::OnLogoutUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLogoutUserDelegate Delegate, int AutoRetryCount) const
{
LogoutUserResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLogoutUserResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
bool OpenAPIUserApi::UpdateUser(const UpdateUserRequest& Request, const FUpdateUserDelegate& Delegate /*= FUpdateUserDelegate()*/) const
@@ -285,7 +362,7 @@ bool OpenAPIUserApi::UpdateUser(const UpdateUserRequest& Request, const FUpdateU
if (!IsValid())
return false;
- TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();
+ FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(*(Url + Request.ComputePath()));
for(const auto& It : AdditionalHeaderParams)
@@ -295,15 +372,26 @@ bool OpenAPIUserApi::UpdateUser(const UpdateUserRequest& Request, const FUpdateU
Request.SetupHttpRequest(HttpRequest);
- HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnUpdateUserResponse, Delegate);
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnUpdateUserResponse, Delegate, Request.GetAutoRetryCount());
return HttpRequest->ProcessRequest();
}
-void OpenAPIUserApi::OnUpdateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdateUserDelegate Delegate) const
+void OpenAPIUserApi::OnUpdateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdateUserDelegate Delegate, int AutoRetryCount) const
{
UpdateUserResponse Response;
+ Response.SetHttpRequest(HttpRequest);
+
HandleResponse(HttpResponse, bSucceeded, Response);
- Delegate.ExecuteIfBound(Response);
+
+ if(!Response.IsSuccessful() && AutoRetryCount > 0)
+ {
+ HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnUpdateUserResponse, Delegate, AutoRetryCount - 1);
+ Response.AsyncRetry();
+ }
+ else
+ {
+ Delegate.ExecuteIfBound(Response);
+ }
}
}
diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApiOperations.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApiOperations.cpp
index 5a698d4fa5c..7352577a79e 100644
--- a/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApiOperations.cpp
+++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApiOperations.cpp
@@ -29,7 +29,7 @@ FString OpenAPIUserApi::CreateUserRequest::ComputePath() const
return Path;
}
-void OpenAPIUserApi::CreateUserRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIUserApi::CreateUserRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { };
@@ -86,7 +86,7 @@ FString OpenAPIUserApi::CreateUsersWithArrayInputRequest::ComputePath() const
return Path;
}
-void OpenAPIUserApi::CreateUsersWithArrayInputRequest::SetupHttpRequest(const TSharedRef& HttpRequest) const
+void OpenAPIUserApi::CreateUsersWithArrayInputRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray Consumes = { };
//static const TArray Produces = { };
@@ -143,7 +143,7 @@ FString OpenAPIUserApi::CreateUsersWithListInputRequest::ComputePath() const
return Path;
}
-void OpenAPIUserApi::CreateUsersWithListInputRequest::SetupHttpRequest(const TSharedRef