diff --git a/.github/workflows/check-supported-versions.yaml b/.github/workflows/check-supported-versions.yaml
index 430b0ea815c..56992b9811e 100644
--- a/.github/workflows/check-supported-versions.yaml
+++ b/.github/workflows/check-supported-versions.yaml
@@ -26,6 +26,7 @@ jobs:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
+ distribution: 'adopt'
java-version: ${{ matrix.java }}
- uses: actions/cache@v2.1.5
diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml
index 98f191f2c9c..d991e052a7d 100644
--- a/.github/workflows/sonar.yml
+++ b/.github/workflows/sonar.yml
@@ -16,6 +16,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
+ distribution: 'adopt'
java-version: 11
- name: Compile with Maven
run: mvn -B -q clean install jacoco:report
diff --git a/CI/.drone.yml b/CI/.drone.yml
index 037fb654724..032d64b9e15 100644
--- a/CI/.drone.yml
+++ b/CI/.drone.yml
@@ -1,6 +1,5 @@
kind: pipeline
name: default
-
steps:
# test Java 11 HTTP client
- name: java11-test
@@ -53,4 +52,12 @@ steps:
- name: haskell-client-test
image: haskell:8.6.5
commands:
- - (cd samples/client/petstore/haskell-http-client/ && stack --install-ghc --no-haddock-deps haddock --fast && stack test --fast)
+ - (cd samples/client/petstore/haskell-http-client/ && stack --allow-different-user --install-ghc --no-haddock-deps haddock --fast && stack --allow-different-user test --fast)
+# test erlang client and server
+- name: erlang
+ image: erlang:alpine
+ commands:
+ - (cd samples/client/petstore/erlang-client && rebar3 compile)
+ - (cd samples/client/petstore/erlang-proper && rebar3 compile)
+ # comment out as the tests pass locally but not in the CI
+ #- (cd samples/server/petstore/erlang-server && rebar3 compile)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 30258ec9fd6..0fe833163af 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -48,6 +48,7 @@ Code change should conform to the programming style guide of the respective lang
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
- C++: https://google.github.io/styleguide/cppguide.html
- C++ (Tizen): https://wiki.tizen.org/Native_Platform_Coding_Idiom_and_Style_Guide#C.2B.2B_Coding_Style
+- C++ (Unreal Engine 4): https://docs.unrealengine.com/en-US/ProductionPipelines/DevelopmentSetup/CodingStandard/index.html
- Clojure: https://github.com/bbatsov/clojure-style-guide
- Crystal: https://crystal-lang.org/reference/conventions/coding_style.html
- Dart: https://www.dartlang.org/guides/language/effective-dart/style
diff --git a/README.md b/README.md
index c27f86b1531..97e01df1c97 100644
--- a/README.md
+++ b/README.md
@@ -9,27 +9,17 @@
-[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`5.1.1`):
+[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`5.2.0`):
[](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)
[](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)
-[](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)
@@ -120,9 +110,8 @@ 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.2.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.1 (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) |
+| 5.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.2.0-SNAPSHOT/) | Jun/Jul 2021 | Minor release with breaking changes (with fallback) |
+| [5.1.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.1.1) (latest stable release) | 07.05.2021 | Patch release (enhancements, bug fixes, etc) |
| [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
@@ -179,16 +168,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.1.0/openapi-generator-cli-5.1.0.jar`
+JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar`
For **Mac/Linux** users:
```sh
-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
+wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.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.1.0/openapi-generator-cli-5.1.0.jar
+Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@@ -413,7 +402,7 @@ openapi-generator-cli version
To use a specific version of "openapi-generator-cli"
```sh
-openapi-generator-cli version-manager set 5.1.0
+openapi-generator-cli version-manager set 5.1.1
```
Or install it as dev-dependency:
@@ -437,7 +426,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.1.0/openapi-generator-cli-5.1.0.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.1/openapi-generator-cli-5.1.1.jar)
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
@@ -562,7 +551,7 @@ When code is generated from this project, it shall be considered **AS IS** and o
### [3.5 - IDE Integration](#table-of-contents)
-Here is a list of community-conitributed IDE plug-ins that integrate with OpenAPI Generator:
+Here is a list of community-contributed IDE plug-ins that integrate with OpenAPI Generator:
- Eclipse: [Codewind OpenAPI Tools for Eclipse](https://www.eclipse.org/codewind/open-api-tools-for-eclipse.html) by [IBM](https://www.ibm.com)
- IntelliJ IDEA: [OpenAPI Generator](https://plugins.jetbrains.com/plugin/8433-openapi-generator) by [Jim Schubert](https://jimschubert.us/#/)
@@ -666,6 +655,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [Twitter](https://twitter.com)
- [unblu inc.](https://www.unblu.com/)
- [Veamly](https://www.veamly.com/)
+- [VMWare](https://www.vmware.com/)
- [wbt-solutions](https://www.wbt-solutions.de/)
- [Woleet](https://www.woleet.io/)
- [WSO2](https://wso2.com/)
@@ -821,8 +811,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2021-03-28 - [Trying out NestJS part 4: Generate Typescript clients from OpenAPI documents](https://dev.to/arnaudcortisse/trying-out-nestjs-part-4-generate-typescript-clients-from-openapi-documents-28mk) by [Arnaud Cortisse](https://dev.to/arnaudcortisse)
- 2021-03-31 - [Open API Server Implementation Using OpenAPI Generator](https://www.baeldung.com/java-openapi-generator-server) at [Baeldung](https://www.baeldung.com/)
- 2021-03-31 - [使用OpenAPI Generator實現Open API Server](https://www.1ju.org/article/java-openapi-generator-server) at [億聚網](https://www.1ju.org/)
-- 2022-04-19 - [Introducing Twilio’s OpenAPI Specification Beta](https://www.twilio.com/blog/introducing-twilio-open-api-specification-beta) by [GARETH PAUL JONES](https://www.twilio.com/blog/author/gpj) at [Twilio Blog](https://www.twilio.com/blog)
-- 2022-04-22 - [Leveraging OpenApi strengths in a Micro-Service environment](https://medium.com/unibuddy-technology-blog/leveraging-openapi-strengths-in-a-micro-service-environment-3d7f9e7c26ff) by Nicolas Jellab at [Unibuddy Technology Blog](https://medium.com/unibuddy-technology-blog)
+- 2021-04-19 - [Introducing Twilio’s OpenAPI Specification Beta](https://www.twilio.com/blog/introducing-twilio-open-api-specification-beta) by [GARETH PAUL JONES](https://www.twilio.com/blog/author/gpj) at [Twilio Blog](https://www.twilio.com/blog)
+- 2021-04-22 - [Leveraging OpenApi strengths in a Micro-Service environment](https://medium.com/unibuddy-technology-blog/leveraging-openapi-strengths-in-a-micro-service-environment-3d7f9e7c26ff) by Nicolas Jellab at [Unibuddy Technology Blog](https://medium.com/unibuddy-technology-blog)
## [6 - About Us](#table-of-contents)
diff --git a/bin/configs/other/cpp-pistache-server-cpp-pistache.yaml b/bin/configs/cpp-pistache-server-cpp-pistache.yaml
similarity index 100%
rename from bin/configs/other/cpp-pistache-server-cpp-pistache.yaml
rename to bin/configs/cpp-pistache-server-cpp-pistache.yaml
diff --git a/bin/configs/kotlin-json-request-string.yaml b/bin/configs/kotlin-json-request-string.yaml
index 8f1dade28c9..375622ae5df 100644
--- a/bin/configs/kotlin-json-request-string.yaml
+++ b/bin/configs/kotlin-json-request-string.yaml
@@ -5,3 +5,4 @@ templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
requestDateConverter: toString
artifactId: kotlin-petstore-json-request-string
+ parcelizeModels: true
diff --git a/bin/configs/ktorm-schema.yaml b/bin/configs/ktorm-schema.yaml
index aff895cb279..d3c5beb9a33 100644
--- a/bin/configs/ktorm-schema.yaml
+++ b/bin/configs/ktorm-schema.yaml
@@ -1,7 +1,7 @@
generatorName: ktorm-schema
outputDir: samples/schema/petstore/ktorm
-inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/ktorm-schema
additionalProperties:
hideGenerationTimestamp: true
- importModelPackageName: org.openapitools.client.models
\ No newline at end of file
+ importModelPackageName: org.openapitools.client.models
diff --git a/bin/configs/nim.yaml b/bin/configs/nim.yaml
index 136a92764c3..13a27a6b764 100644
--- a/bin/configs/nim.yaml
+++ b/bin/configs/nim.yaml
@@ -1,6 +1,6 @@
generatorName: nim
outputDir: samples/client/petstore/nim
-inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/nim-client
additionalProperties:
packageName: petstore
diff --git a/docs/contributing.md b/docs/contributing.md
index a791b0d6f1b..fe325ae17e1 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -52,6 +52,7 @@ Code change should conform to the programming style guide of the respective lang
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
- C++: https://google.github.io/styleguide/cppguide.html
- C++ (Tizen): https://wiki.tizen.org/Native_Platform_Coding_Idiom_and_Style_Guide#C.2B.2B_Coding_Style
+- C++ (Unreal Engine 4): https://docs.unrealengine.com/en-US/ProductionPipelines/DevelopmentSetup/CodingStandard/index.html
- Clojure: https://github.com/bbatsov/clojure-style-guide
- Crystal: https://crystal-lang.org/reference/conventions/coding_style.html
- Dart: https://www.dartlang.org/guides/language/effective-dart/style
diff --git a/docs/generators.md b/docs/generators.md
index 521bdc3dbf0..6cb063b2230 100644
--- a/docs/generators.md
+++ b/docs/generators.md
@@ -106,6 +106,7 @@ The following generators are available:
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
* [jaxrs-spec](generators/jaxrs-spec.md)
* [kotlin-server](generators/kotlin-server.md)
+* [kotlin-server-deprecated (deprecated)](generators/kotlin-server-deprecated.md)
* [kotlin-spring](generators/kotlin-spring.md)
* [kotlin-vertx (beta)](generators/kotlin-vertx.md)
* [nodejs-express-server (beta)](generators/nodejs-express-server.md)
diff --git a/docs/generators/README.md b/docs/generators/README.md
index 6510770e47a..a8ac9c9310c 100644
--- a/docs/generators/README.md
+++ b/docs/generators/README.md
@@ -91,6 +91,7 @@ The following generators are available:
* [jaxrs-resteasy-eap](jaxrs-resteasy-eap.md)
* [jaxrs-spec](jaxrs-spec.md)
* [kotlin-server](kotlin-server.md)
+* [kotlin-server-deprecated](kotlin-server-deprecated.md)
* [kotlin-spring](kotlin-spring.md)
* [kotlin-vertx (beta)](kotlin-vertx.md)
* [nodejs-express-server (beta)](nodejs-express-server.md)
diff --git a/docs/generators/aspnetcore.md b/docs/generators/aspnetcore.md
index 0a30830099f..99f0b789bdc 100644
--- a/docs/generators/aspnetcore.md
+++ b/docs/generators/aspnetcore.md
@@ -7,9 +7,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
-|aspnetCoreVersion|ASP.NET Core version: 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)| |3.1|
-|buildTarget|Target to build an application or library| |program|
-|classModifier|Class Modifier for controller classes: Empty string or abstract.| ||
+|aspnetCoreVersion|ASP.NET Core version: 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)|
- **2.0**
- ASP.NET Core 2.0
- **2.1**
- ASP.NET Core 2.1
- **2.2**
- ASP.NET Core 2.2
- **3.0**
- ASP.NET Core 3.0
- **3.1**
- ASP.NET Core 3.1
- **5.0**
- ASP.NET Core 5.0
|3.1|
+|buildTarget|Target to build an application or library|
- **program**
- Generate code for a standalone server
- **library**
- Generate code for a server abstract class library
|program|
+|classModifier|Class Modifier for controller classes: Empty string or abstract.|
- ****
- Keep class default with no modifier
- **abstract**
- Make class abstract
||
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_2|
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
|enumValueSuffix|Suffix that will be appended to all enum values.| |Enum|
@@ -17,10 +17,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|isLibrary|Is the build a library| |false|
|licenseName|The name of the license| |NoLicense|
|licenseUrl|The URL of the license| |http://localhost|
-|modelClassModifier|Model Class Modifier can be nothing or partial| |partial|
+|modelClassModifier|Model Class Modifier can be nothing or partial|
- ****
- Keep model class default with no modifier
- **partial**
- Make model class partial
|partial|
|newtonsoftVersion|Version for Microsoft.AspNetCore.Mvc.NewtonsoftJson for ASP.NET Core 3.0+| |3.0.0|
|operationIsAsync|Set methods to async or sync (default).| |false|
-|operationModifier|Operation Modifier can be virtual or abstract| |virtual|
+|operationModifier|Operation Modifier can be virtual or abstract|
- **virtual**
- Keep method virtual
- **abstract**
- Make method abstract
|virtual|
|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|
@@ -32,7 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src|
-|swashbuckleVersion|Swashbuckle version: 3.0.0, 4.0.0, 5.0.0| |3.0.0|
+|swashbuckleVersion|Swashbuckle version: 3.0.0, 4.0.0, 5.0.0|
- **3.0.0**
- Swashbuckle 3.0.0
- **4.0.0**
- Swashbuckle 4.0.0
- **5.0.0**
- Swashbuckle 5.0.0
|3.0.0|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useDefaultRouting|Use default routing for the ASP.NET Core version.| |true|
diff --git a/docs/generators/kotlin-server-deprecated.md b/docs/generators/kotlin-server-deprecated.md
new file mode 100644
index 00000000000..5499354747c
--- /dev/null
+++ b/docs/generators/kotlin-server-deprecated.md
@@ -0,0 +1,214 @@
+---
+title: Config Options for kotlin-server-deprecated
+sidebar_label: kotlin-server-deprecated
+---
+
+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 |
+| ------ | ----------- | ------ | ------- |
+|apiSuffix|suffix for api classes| |Api|
+|artifactId|Generated artifact id (name of jar).| |kotlin-server-deprecated|
+|artifactVersion|Generated artifact's package version.| |1.0.0|
+|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
+|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|
+|featureCORS|Ktor by default provides an interceptor for implementing proper support for Cross-Origin Resource Sharing (CORS). See enable-cors.org.| |false|
+|featureCompression|Adds ability to compress outgoing content using gzip, deflate or custom encoder and thus reduce size of the response.| |true|
+|featureConditionalHeaders|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |false|
+|featureHSTS|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |true|
+|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
+|library|library template (sub-template)|
- **ktor**
- ktor framework
|ktor|
+|modelMutable|Create mutable models| |false|
+|packageName|Generated artifact package name.| |org.openapitools.server|
+|parcelizeModels|toggle "@Parcelize" for generated models| |null|
+|serializableModel|boolean - toggle "implements Serializable" for generated models| |null|
+|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson' or 'jackson'| |moshi|
+|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |null|
+|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |null|
+|sourceFolder|source folder for generated code| |src/main/kotlin|
+
+## IMPORT MAPPING
+
+| Type/Alias | Imports |
+| ---------- | ------- |
+|BigDecimal|java.math.BigDecimal|
+|Date|java.time.LocalDate|
+|DateTime|java.time.OffsetDateTime|
+|File|java.io.File|
+|LocalDate|java.time.LocalDate|
+|LocalDateTime|java.time.LocalDateTime|
+|LocalTime|java.time.LocalTime|
+|Timestamp|java.sql.Timestamp|
+|URI|java.net.URI|
+|UUID|java.util.UUID|
+
+
+## INSTANTIATION TYPES
+
+| Type/Alias | Instantiated By |
+| ---------- | --------------- |
+|array|kotlin.collections.ArrayList|
+|list|kotlin.collections.ArrayList|
+|map|kotlin.collections.HashMap|
+
+
+## LANGUAGE PRIMITIVES
+
+
+- kotlin.Array
+- kotlin.Boolean
+- kotlin.Byte
+- kotlin.ByteArray
+- kotlin.Char
+- kotlin.Double
+- kotlin.Float
+- kotlin.Int
+- kotlin.Long
+- kotlin.Short
+- kotlin.String
+- kotlin.collections.List
+- kotlin.collections.Map
+- kotlin.collections.Set
+
+
+## RESERVED WORDS
+
+
+- as
+- break
+- class
+- continue
+- do
+- else
+- false
+- for
+- fun
+- if
+- in
+- interface
+- is
+- null
+- object
+- package
+- return
+- super
+- this
+- throw
+- true
+- try
+- typealias
+- typeof
+- val
+- var
+- when
+- while
+
+
+## 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/kotlin-server.md b/docs/generators/kotlin-server.md
index ecaf99a294f..b45dc3ffb4d 100644
--- a/docs/generators/kotlin-server.md
+++ b/docs/generators/kotlin-server.md
@@ -16,6 +16,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|featureCompression|Adds ability to compress outgoing content using gzip, deflate or custom encoder and thus reduce size of the response.| |true|
|featureConditionalHeaders|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |false|
|featureHSTS|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |true|
+|featureLocations|Generates routes in a typed way, for both: constructing URLs and reading the parameters.| |true|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|library|library template (sub-template)|
- **ktor**
- ktor framework
|ktor|
|modelMutable|Create mutable models| |false|
diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md
index ef76c9af691..f4b0aceeb60 100644
--- a/docs/generators/kotlin.md
+++ b/docs/generators/kotlin.md
@@ -16,6 +16,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|library|Library template (sub-template) to use|
- **jvm-okhttp4**
- [DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.
- **jvm-okhttp3**
- Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.
- **jvm-retrofit2**
- Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.
- **multiplatform**
- Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.
|jvm-okhttp4|
|modelMutable|Create mutable models| |false|
+|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|packageName|Generated artifact package name.| |org.openapitools.client|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|requestDateConverter|JVM-Option. Defines in how to handle date-time objects that are used for a request (as query or parameter)|
- **toJson**
- [DEFAULT] Date formater option using a json converter.
- **toString**
- Use the 'toString'-method of the date-time object to retrieve the related string representation.
|toJson|
diff --git a/docs/generators/scala-sttp.md b/docs/generators/scala-sttp.md
index 5f0c9f7e6ad..77891a59141 100644
--- a/docs/generators/scala-sttp.md
+++ b/docs/generators/scala-sttp.md
@@ -13,8 +13,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|dateLibrary|Option. Date library to use|
- **joda**
- Joda (for legacy app)
- **java8**
- Java 8 native JSR310 (prefered for JDK 1.8+)
|java8|
|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|
-|jodaTimeVersion|The version of joda-time library| |2.10.6|
-|json4sVersion|The version of json4s library| |3.6.8|
+|jodaTimeVersion|The version of joda-time library| |2.10.10|
+|json4sVersion|The version of json4s library| |3.6.11|
|jsonLibrary|Json library to use. Possible values are: json4s and circe.| |json4s|
|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|
|mainPackage|Top-level package name, which defines 'apiPackage', 'modelPackage', 'invokerPackage'| |org.openapitools.client|
@@ -25,7 +25,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|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|
-|sttpClientVersion|The version of sttp client| |2.2.0|
+|sttpClientVersion|The version of sttp client| |2.2.9|
## IMPORT MAPPING
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 a52fa88609a..f7c24196331 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
@@ -199,14 +199,14 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
aspnetCoreVersion.addEnum("5.0", "ASP.NET Core 5.0");
aspnetCoreVersion.setDefault("3.1");
aspnetCoreVersion.setOptValue(aspnetCoreVersion.getDefault());
- addOption(aspnetCoreVersion.getOpt(), aspnetCoreVersion.getDescription(), aspnetCoreVersion.getOptValue());
+ cliOptions.add(aspnetCoreVersion);
swashbuckleVersion.addEnum("3.0.0", "Swashbuckle 3.0.0");
swashbuckleVersion.addEnum("4.0.0", "Swashbuckle 4.0.0");
swashbuckleVersion.addEnum("5.0.0", "Swashbuckle 5.0.0");
swashbuckleVersion.setDefault("3.0.0");
swashbuckleVersion.setOptValue(swashbuckleVersion.getDefault());
- addOption(swashbuckleVersion.getOpt(), swashbuckleVersion.getDescription(), swashbuckleVersion.getOptValue());
+ cliOptions.add(swashbuckleVersion);
// CLI Switches
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
@@ -261,19 +261,19 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
classModifier.addEnum("abstract", "Make class abstract");
classModifier.setDefault("");
classModifier.setOptValue(classModifier.getDefault());
- addOption(classModifier.getOpt(), classModifier.getDescription(), classModifier.getOptValue());
+ cliOptions.add(classModifier);
operationModifier.addEnum("virtual", "Keep method virtual");
operationModifier.addEnum("abstract", "Make method abstract");
operationModifier.setDefault("virtual");
operationModifier.setOptValue(operationModifier.getDefault());
- addOption(operationModifier.getOpt(), operationModifier.getDescription(), operationModifier.getOptValue());
+ cliOptions.add(operationModifier);
buildTarget.addEnum("program", "Generate code for a standalone server");
buildTarget.addEnum("library", "Generate code for a server abstract class library");
buildTarget.setDefault("program");
buildTarget.setOptValue(buildTarget.getDefault());
- addOption(buildTarget.getOpt(), buildTarget.getDescription(), buildTarget.getOptValue());
+ cliOptions.add(buildTarget);
addSwitch(GENERATE_BODY,
"Generates method body.",
@@ -292,7 +292,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
modelClassModifier.addEnum("partial", "Make model class partial");
modelClassModifier.setDefault("partial");
modelClassModifier.setOptValue(modelClassModifier.getDefault());
- addOption(modelClassModifier.getOpt(), modelClassModifier.getDescription(), modelClassModifier.getOptValue());
+ cliOptions.add(modelClassModifier);
}
@Override
@@ -592,6 +592,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
private void setBuildTarget() {
setCliOption(buildTarget);
if ("library".equals(buildTarget.getOptValue())) {
+ LOGGER.warn("buildTarget is {} so changing default isLibrary to true", buildTarget.getOptValue());
isLibrary = true;
projectSdk = SDK_LIB;
additionalProperties.put(CLASS_MODIFIER, "abstract");
@@ -636,7 +637,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
private void setUseSwashbuckle() {
if (isLibrary) {
- LOGGER.warn("buildTarget is " + buildTarget.getOptValue() + " so changing default isLibrary to false ");
+ LOGGER.warn("isLibrary is true so changing default useSwashbuckle to false");
useSwashbuckle = false;
} else {
useSwashbuckle = true;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java
index bf49fd425e0..3064af52c20 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java
@@ -128,6 +128,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
typeMapping.put("boolean", "bool");
typeMapping.put("array", "std::vector");
typeMapping.put("map", "std::map");
+ typeMapping.put("set", "std::vector");
typeMapping.put("file", "std::string");
typeMapping.put("object", "Object");
typeMapping.put("binary", "std::string");
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 72646d58cd7..3ff2429d99d 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
@@ -61,6 +61,8 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
public static final String REQUEST_DATE_CONVERTER = "requestDateConverter";
public static final String COLLECTION_TYPE = "collectionType";
+ public static final String MOSHI_CODE_GEN = "moshiCodeGen";
+
protected static final String VENDOR_EXTENSION_BASE_NAME_LITERAL = "x-base-name-literal";
protected String dateLibrary = DateLibrary.JAVA8.value;
@@ -204,6 +206,8 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA2, "Whether to use the RxJava2 adapter with the retrofit2 library."));
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA3, "Whether to use the RxJava3 adapter with the retrofit2 library."));
cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines adapter with the retrofit2 library."));
+
+ cliOptions.add(CliOption.newBoolean(MOSHI_CODE_GEN, "Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info."));
}
public CodegenType getTag() {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
index d4d9902da7f..0c182417c94 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
@@ -42,15 +42,17 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
private Boolean hstsFeatureEnabled = true;
private Boolean corsFeatureEnabled = false;
private Boolean compressionFeatureEnabled = true;
+ private Boolean locationsFeatureEnabled = true;
- // This is here to potentially warn the user when an option is not supoprted by the target framework.
+ // This is here to potentially warn the user when an option is not supported by the target framework.
private Map
> optionsSupportedPerFramework = new ImmutableMap.Builder>()
.put(Constants.KTOR, Arrays.asList(
Constants.AUTOMATIC_HEAD_REQUESTS,
Constants.CONDITIONAL_HEADERS,
Constants.HSTS,
Constants.CORS,
- Constants.COMPRESSION
+ Constants.COMPRESSION,
+ Constants.LOCATIONS
))
.build();
@@ -85,6 +87,8 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
artifactId = "kotlin-server";
packageName = "org.openapitools.server";
+ typeMapping.put("array", "kotlin.collections.List");
+
// cliOptions default redefinition need to be updated
updateOption(CodegenConstants.ARTIFACT_ID, this.artifactId);
updateOption(CodegenConstants.PACKAGE_NAME, this.packageName);
@@ -110,6 +114,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
addSwitch(Constants.HSTS, Constants.HSTS_DESC, getHstsFeatureEnabled());
addSwitch(Constants.CORS, Constants.CORS_DESC, getCorsFeatureEnabled());
addSwitch(Constants.COMPRESSION, Constants.COMPRESSION_DESC, getCompressionFeatureEnabled());
+ addSwitch(Constants.LOCATIONS, Constants.LOCATIONS_DESC, getLocationsFeatureEnabled());
}
public Boolean getAutoHeadFeatureEnabled() {
@@ -156,6 +161,14 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
this.hstsFeatureEnabled = hstsFeatureEnabled;
}
+ public Boolean getLocationsFeatureEnabled() {
+ return locationsFeatureEnabled;
+ }
+
+ public void setLocationsFeatureEnabled(Boolean locationsFeatureEnabled) {
+ this.locationsFeatureEnabled = locationsFeatureEnabled;
+ }
+
public String getName() {
return "kotlin-server";
}
@@ -209,6 +222,12 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
additionalProperties.put(Constants.COMPRESSION, getCompressionFeatureEnabled());
}
+ if (additionalProperties.containsKey(Constants.LOCATIONS)) {
+ setLocationsFeatureEnabled(convertPropertyToBooleanAndWriteBack(Constants.LOCATIONS));
+ } else {
+ additionalProperties.put(Constants.LOCATIONS, getLocationsFeatureEnabled());
+ }
+
boolean generateApis = additionalProperties.containsKey(CodegenConstants.GENERATE_APIS) && (Boolean) additionalProperties.get(CodegenConstants.GENERATE_APIS);
String packageFolder = (sourceFolder + File.separator + packageName).replace(".", File.separator);
String resourcesFolder = "src/main/resources"; // not sure this can be user configurable.
@@ -223,7 +242,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("AppMain.kt.mustache", packageFolder, "AppMain.kt"));
supportingFiles.add(new SupportingFile("Configuration.kt.mustache", packageFolder, "Configuration.kt"));
- if (generateApis) {
+ if (generateApis && locationsFeatureEnabled) {
supportingFiles.add(new SupportingFile("Paths.kt.mustache", packageFolder, "Paths.kt"));
}
@@ -247,6 +266,8 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
public final static String CORS_DESC = "Ktor by default provides an interceptor for implementing proper support for Cross-Origin Resource Sharing (CORS). See enable-cors.org.";
public final static String COMPRESSION = "featureCompression";
public final static String COMPRESSION_DESC = "Adds ability to compress outgoing content using gzip, deflate or custom encoder and thus reduce size of the response.";
+ public final static String LOCATIONS = "featureLocations";
+ public final static String LOCATIONS_DESC = "Generates routes in a typed way, for both: constructing URLs and reading the parameters.";
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
new file mode 100644
index 00000000000..84cee1d2aa9
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
@@ -0,0 +1,270 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ * Copyright 2018 SmartBear Software
+ *
+ * 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.ImmutableMap;
+import org.apache.commons.lang3.StringUtils;
+import org.openapitools.codegen.CliOption;
+import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.CodegenType;
+import org.openapitools.codegen.SupportingFile;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
+import org.openapitools.codegen.meta.features.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+
+public class KotlinServerDeprecatedCodegen extends AbstractKotlinCodegen {
+
+ public static final String DEFAULT_LIBRARY = Constants.KTOR;
+ private final Logger LOGGER = LoggerFactory.getLogger(KotlinServerDeprecatedCodegen.class);
+ private Boolean autoHeadFeatureEnabled = true;
+ private Boolean conditionalHeadersFeatureEnabled = false;
+ private Boolean hstsFeatureEnabled = true;
+ private Boolean corsFeatureEnabled = false;
+ private Boolean compressionFeatureEnabled = true;
+
+ // This is here to potentially warn the user when an option is not supported by the target framework.
+ private Map> optionsSupportedPerFramework = new ImmutableMap.Builder>()
+ .put(Constants.KTOR, Arrays.asList(
+ Constants.AUTOMATIC_HEAD_REQUESTS,
+ Constants.CONDITIONAL_HEADERS,
+ Constants.HSTS,
+ Constants.CORS,
+ Constants.COMPRESSION
+ ))
+ .build();
+
+ /**
+ * Constructs an instance of `KotlinServerDeprecatedCodegen`.
+ */
+ public KotlinServerDeprecatedCodegen() {
+ super();
+
+ modifyFeatureSet(features -> features
+ .includeDocumentationFeatures(DocumentationFeature.Readme)
+ .wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML))
+ .securityFeatures(EnumSet.of(
+ SecurityFeature.BasicAuth,
+ SecurityFeature.ApiKey,
+ SecurityFeature.OAuth2_Implicit
+ ))
+ .excludeGlobalFeatures(
+ GlobalFeature.XMLStructureDefinitions,
+ GlobalFeature.Callbacks,
+ GlobalFeature.LinkObjects,
+ GlobalFeature.ParameterStyling
+ )
+ .excludeSchemaSupportFeatures(
+ SchemaSupportFeature.Polymorphism
+ )
+ .excludeParameterFeatures(
+ ParameterFeature.Cookie
+ )
+ );
+
+ generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
+ .stability(Stability.DEPRECATED)
+ .build();
+
+ artifactId = "kotlin-server-deprecated";
+ packageName = "org.openapitools.server";
+
+ // cliOptions default redefinition need to be updated
+ updateOption(CodegenConstants.ARTIFACT_ID, this.artifactId);
+ updateOption(CodegenConstants.PACKAGE_NAME, this.packageName);
+
+ outputFolder = "generated-code" + File.separator + "kotlin-server-deprecated";
+ modelTemplateFiles.put("model.mustache", ".kt");
+ apiTemplateFiles.put("api.mustache", ".kt");
+ embeddedTemplateDir = templateDir = "kotlin-server-deprecated";
+ apiPackage = packageName + ".apis";
+ modelPackage = packageName + ".models";
+
+ supportedLibraries.put(Constants.KTOR, "ktor framework");
+
+ // TODO: Configurable server engine. Defaults to netty in build.gradle.
+ CliOption library = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC);
+ library.setDefault(DEFAULT_LIBRARY);
+ library.setEnum(supportedLibraries);
+
+ cliOptions.add(library);
+
+ addSwitch(Constants.AUTOMATIC_HEAD_REQUESTS, Constants.AUTOMATIC_HEAD_REQUESTS_DESC, getAutoHeadFeatureEnabled());
+ addSwitch(Constants.CONDITIONAL_HEADERS, Constants.CONDITIONAL_HEADERS_DESC, getConditionalHeadersFeatureEnabled());
+ addSwitch(Constants.HSTS, Constants.HSTS_DESC, getHstsFeatureEnabled());
+ addSwitch(Constants.CORS, Constants.CORS_DESC, getCorsFeatureEnabled());
+ addSwitch(Constants.COMPRESSION, Constants.COMPRESSION_DESC, getCompressionFeatureEnabled());
+ }
+
+ public Boolean getAutoHeadFeatureEnabled() {
+ return autoHeadFeatureEnabled;
+ }
+
+ public void setAutoHeadFeatureEnabled(Boolean autoHeadFeatureEnabled) {
+ this.autoHeadFeatureEnabled = autoHeadFeatureEnabled;
+ }
+
+ public Boolean getCompressionFeatureEnabled() {
+ return compressionFeatureEnabled;
+ }
+
+ public void setCompressionFeatureEnabled(Boolean compressionFeatureEnabled) {
+ this.compressionFeatureEnabled = compressionFeatureEnabled;
+ }
+
+ public Boolean getConditionalHeadersFeatureEnabled() {
+ return conditionalHeadersFeatureEnabled;
+ }
+
+ public void setConditionalHeadersFeatureEnabled(Boolean conditionalHeadersFeatureEnabled) {
+ this.conditionalHeadersFeatureEnabled = conditionalHeadersFeatureEnabled;
+ }
+
+ public Boolean getCorsFeatureEnabled() {
+ return corsFeatureEnabled;
+ }
+
+ public void setCorsFeatureEnabled(Boolean corsFeatureEnabled) {
+ this.corsFeatureEnabled = corsFeatureEnabled;
+ }
+
+ public String getHelp() {
+ return "Generates a Kotlin server (Ktor v1.1.3). IMPORTANT: this generator has been deprecated." +
+ " Please migrate to `kotlin-server` which supports Ktor v1.5.2+.";
+ }
+
+ public Boolean getHstsFeatureEnabled() {
+ return hstsFeatureEnabled;
+ }
+
+ public void setHstsFeatureEnabled(Boolean hstsFeatureEnabled) {
+ this.hstsFeatureEnabled = hstsFeatureEnabled;
+ }
+
+ public String getName() {
+ return "kotlin-server-deprecated";
+ }
+
+ public CodegenType getTag() {
+ return CodegenType.SERVER;
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+
+ if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) {
+ this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY));
+ }
+
+ // set default library to "ktor"
+ if (StringUtils.isEmpty(library)) {
+ this.setLibrary(DEFAULT_LIBRARY);
+ additionalProperties.put(CodegenConstants.LIBRARY, DEFAULT_LIBRARY);
+ LOGGER.info("`library` option is empty. Default to " + DEFAULT_LIBRARY);
+ }
+
+ if (additionalProperties.containsKey(Constants.AUTOMATIC_HEAD_REQUESTS)) {
+ setAutoHeadFeatureEnabled(convertPropertyToBooleanAndWriteBack(Constants.AUTOMATIC_HEAD_REQUESTS));
+ } else {
+ additionalProperties.put(Constants.AUTOMATIC_HEAD_REQUESTS, getAutoHeadFeatureEnabled());
+ }
+
+ if (additionalProperties.containsKey(Constants.CONDITIONAL_HEADERS)) {
+ setConditionalHeadersFeatureEnabled(convertPropertyToBooleanAndWriteBack(Constants.CONDITIONAL_HEADERS));
+ } else {
+ additionalProperties.put(Constants.CONDITIONAL_HEADERS, getConditionalHeadersFeatureEnabled());
+ }
+
+ if (additionalProperties.containsKey(Constants.HSTS)) {
+ setHstsFeatureEnabled(convertPropertyToBooleanAndWriteBack(Constants.HSTS));
+ } else {
+ additionalProperties.put(Constants.HSTS, getHstsFeatureEnabled());
+ }
+
+ if (additionalProperties.containsKey(Constants.CORS)) {
+ setCorsFeatureEnabled(convertPropertyToBooleanAndWriteBack(Constants.CORS));
+ } else {
+ additionalProperties.put(Constants.CORS, getCorsFeatureEnabled());
+ }
+
+ if (additionalProperties.containsKey(Constants.COMPRESSION)) {
+ setCompressionFeatureEnabled(convertPropertyToBooleanAndWriteBack(Constants.COMPRESSION));
+ } else {
+ additionalProperties.put(Constants.COMPRESSION, getCompressionFeatureEnabled());
+ }
+
+ boolean generateApis = additionalProperties.containsKey(CodegenConstants.GENERATE_APIS) && (Boolean) additionalProperties.get(CodegenConstants.GENERATE_APIS);
+ String packageFolder = (sourceFolder + File.separator + packageName).replace(".", File.separator);
+ String resourcesFolder = "src/main/resources"; // not sure this can be user configurable.
+
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+ supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
+
+ supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
+ supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
+ supportingFiles.add(new SupportingFile("gradle.properties", "", "gradle.properties"));
+
+ supportingFiles.add(new SupportingFile("AppMain.kt.mustache", packageFolder, "AppMain.kt"));
+ supportingFiles.add(new SupportingFile("Configuration.kt.mustache", packageFolder, "Configuration.kt"));
+
+ if (generateApis) {
+ supportingFiles.add(new SupportingFile("Paths.kt.mustache", packageFolder, "Paths.kt"));
+ }
+
+ supportingFiles.add(new SupportingFile("application.conf.mustache", resourcesFolder, "application.conf"));
+ supportingFiles.add(new SupportingFile("logback.xml", resourcesFolder, "logback.xml"));
+
+ final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", File.separator);
+
+ supportingFiles.add(new SupportingFile("ApiKeyAuth.kt.mustache", infrastructureFolder, "ApiKeyAuth.kt"));
+ }
+
+ public static class Constants {
+ public final static String KTOR = "ktor";
+ public final static String AUTOMATIC_HEAD_REQUESTS = "featureAutoHead";
+ public final static String AUTOMATIC_HEAD_REQUESTS_DESC = "Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.";
+ public final static String CONDITIONAL_HEADERS = "featureConditionalHeaders";
+ public final static String CONDITIONAL_HEADERS_DESC = "Avoid sending content if client already has same content, by checking ETag or LastModified properties.";
+ public final static String HSTS = "featureHSTS";
+ public final static String HSTS_DESC = "Avoid sending content if client already has same content, by checking ETag or LastModified properties.";
+ public final static String CORS = "featureCORS";
+ public final static String CORS_DESC = "Ktor by default provides an interceptor for implementing proper support for Cross-Origin Resource Sharing (CORS). See enable-cors.org.";
+ public final static String COMPRESSION = "featureCompression";
+ public final static String COMPRESSION_DESC = "Adds ability to compress outgoing content using gzip, deflate or custom encoder and thus reduce size of the response.";
+ }
+
+ @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's contributed by Jim Schubert (https://github.com/jimschubert)#");
+ System.out.println("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
+ System.out.println("################################################################################");
+ }
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java
index 138e9bf9c1d..a5e293c9879 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java
@@ -166,8 +166,8 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
- supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
+ supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("reference.mustache", resourcesFolder, "reference.conf"));
final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
supportingFiles.add(new SupportingFile("apiRequest.mustache", invokerFolder, "ApiRequest.scala"));
@@ -175,6 +175,7 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
supportingFiles.add(new SupportingFile("requests.mustache", invokerFolder, "requests.scala"));
supportingFiles.add(new SupportingFile("apiSettings.mustache", invokerFolder, "ApiSettings.scala"));
final String apiFolder = (sourceFolder + File.separator + apiPackage).replace(".", File.separator);
+ supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties"));
supportingFiles.add(new SupportingFile("enumsSerializers.mustache", apiFolder, "EnumsSerializers.scala"));
supportingFiles.add(new SupportingFile("serializers.mustache", invokerFolder, "Serializers.scala"));
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java
index 701be93e47d..18ad2632440 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttpClientCodegen.java
@@ -37,20 +37,22 @@ import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
private static final StringProperty STTP_CLIENT_VERSION = new StringProperty("sttpClientVersion", "The version of " +
- "sttp client", "2.2.0");
+ "sttp client", "2.2.9");
private static final BooleanProperty USE_SEPARATE_ERROR_CHANNEL = new BooleanProperty("separateErrorChannel",
"Whether to return response as " +
"F[Either[ResponseError[ErrorType], ReturnType]]] or to flatten " +
"response's error raising them through enclosing monad (F[ReturnType]).", true);
private static final StringProperty JODA_TIME_VERSION = new StringProperty("jodaTimeVersion", "The version of " +
- "joda-time library", "2.10.6");
+ "joda-time library", "2.10.10");
private static final StringProperty JSON4S_VERSION = new StringProperty("json4sVersion", "The version of json4s " +
- "library", "3.6.8");
+ "library", "3.6.11");
private static final StringProperty CIRCE_VERSION = new StringProperty("circeVersion", "The version of circe " +
"library", "0.13.0");
private static final JsonLibraryProperty JSON_LIBRARY_PROPERTY = new JsonLibraryProperty();
@@ -179,8 +181,17 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
@Override
public String encodePath(String input) {
- String result = super.encodePath(input);
- return result.replace("{", "${");
+ String path = super.encodePath(input);
+
+ // The parameter names in the URI must be converted to the same case as
+ // the method parameter.
+ StringBuffer buf = new StringBuffer(path.length());
+ Matcher matcher = Pattern.compile("[{](.*?)[}]").matcher(path);
+ while (matcher.find()) {
+ matcher.appendReplacement(buf, "\\${" + toParamName(matcher.group(0)) + "}");
+ }
+ matcher.appendTail(buf);
+ return buf.toString();
}
@Override
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache
index a14047e7998..8979b10a7f8 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache
@@ -10,8 +10,8 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.24",
- "com.squareup.okhttp3" % "okhttp" % "3.14.7",
- "com.squareup.okhttp3" % "logging-interceptor" % "3.14.7",
+ "com.squareup.okhttp3" % "okhttp" % "4.9.1",
+ "com.squareup.okhttp3" % "logging-interceptor" % "4.9.1",
"com.google.code.gson" % "gson" % "2.8.6",
"org.apache.commons" % "commons-lang3" % "3.10",
{{#hasOAuthMethods}}
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 0fe89ccb026..6491013f5a8 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
@@ -59,6 +59,9 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TimeZone;
+
+import javax.annotation.Nullable;
+
{{#jsr310}}
{{#threetenbp}}
import org.threeten.bp.OffsetDateTime;
@@ -98,12 +101,47 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
private final WebClient webClient;
private final DateFormat dateFormat;
+ private final ObjectMapper objectMapper;
private Map authentications;
public ApiClient() {
this.dateFormat = createDefaultDateFormat();
+ this.objectMapper = createDefaultObjectMapper(this.dateFormat);
+ this.webClient = buildWebClient(this.objectMapper);
+ this.init();
+ }
+
+ public ApiClient(WebClient webClient) {
+ this(Optional.ofNullable(webClient).orElseGet(() -> buildWebClient()), createDefaultDateFormat());
+ }
+
+ public ApiClient(ObjectMapper mapper, DateFormat format) {
+ this(buildWebClient(mapper.copy()), format);
+ }
+
+ public ApiClient(WebClient webClient, ObjectMapper mapper, DateFormat format) {
+ this(Optional.ofNullable(webClient).orElseGet(() -> buildWebClient(mapper.copy())), format);
+ }
+
+ private ApiClient(WebClient webClient, DateFormat format) {
+ this.webClient = webClient;
+ this.dateFormat = format;
+ this.objectMapper = createDefaultObjectMapper(format);
+ this.init();
+ }
+
+ public static DateFormat createDefaultDateFormat() {
+ DateFormat dateFormat = new RFC3339DateFormat();
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return dateFormat;
+ }
+
+ public static ObjectMapper createDefaultObjectMapper(@Nullable DateFormat dateFormat) {
+ if (null == dateFormat) {
+ dateFormat = createDefaultDateFormat();
+ }
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(dateFormat);
mapper.registerModule(new JavaTimeModule());
@@ -112,29 +150,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
JsonNullableModule jnm = new JsonNullableModule();
mapper.registerModule(jnm);
{{/openApiNullable}}
-
- this.webClient = buildWebClient(mapper);
- this.init();
- }
-
- public ApiClient(ObjectMapper mapper, DateFormat format) {
- this(buildWebClient(mapper.copy()), format);
- }
-
- public ApiClient(WebClient webClient, ObjectMapper mapper, DateFormat format) {
- this(Optional.ofNullable(webClient).orElseGet(() ->buildWebClient(mapper.copy())), format);
- }
-
- private ApiClient(WebClient webClient, DateFormat format) {
- this.webClient = webClient;
- this.dateFormat = format;
- this.init();
- }
-
- public DateFormat createDefaultDateFormat() {
- DateFormat dateFormat = new RFC3339DateFormat();
- dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- return dateFormat;
+ return mapper;
}
protected void init() {
@@ -149,20 +165,45 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
/**
- * Build the WebClient used to make HTTP requests.
+ * Build the WebClientBuilder used to make WebClient.
+ * @param mapper ObjectMapper used for serialize/deserialize
* @return WebClient
*/
- public static WebClient buildWebClient(ObjectMapper mapper) {
+ public static WebClient.Builder buildWebClientBuilder(ObjectMapper mapper) {
ExchangeStrategies strategies = ExchangeStrategies
.builder()
.codecs(clientDefaultCodecsConfigurer -> {
clientDefaultCodecsConfigurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(mapper, MediaType.APPLICATION_JSON));
clientDefaultCodecsConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(mapper, MediaType.APPLICATION_JSON));
}).build();
- WebClient.Builder webClient = WebClient.builder().exchangeStrategies(strategies);
- return webClient.build();
+ WebClient.Builder webClientBuilder = WebClient.builder().exchangeStrategies(strategies);
+ return webClientBuilder;
}
+ /**
+ * Build the WebClientBuilder used to make WebClient.
+ * @return WebClient
+ */
+ public static WebClient.Builder buildWebClientBuilder() {
+ return buildWebClientBuilder(createDefaultObjectMapper(null));
+ }
+
+ /**
+ * Build the WebClient used to make HTTP requests.
+ * @param mapper ObjectMapper used for serialize/deserialize
+ * @return WebClient
+ */
+ public static WebClient buildWebClient(ObjectMapper mapper) {
+ return buildWebClientBuilder(mapper).build();
+ }
+
+ /**
+ * Build the WebClient used to make HTTP requests.
+ * @return WebClient
+ */
+ public static WebClient buildWebClient() {
+ return buildWebClientBuilder(createDefaultObjectMapper(null)).build();
+ }
/**
* Get the current base path
@@ -352,6 +393,22 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return dateFormat.format(date);
}
+ /**
+ * Get the ObjectMapper used to make HTTP requests.
+ * @return ObjectMapper objectMapper
+ */
+ public ObjectMapper getObjectMapper() {
+ return objectMapper;
+ }
+
+ /**
+ * Get the WebClient used to make HTTP requests.
+ * @return WebClient webClient
+ */
+ public WebClient getWebClient() {
+ return webClient;
+ }
+
/**
* Format the given parameter object into string.
* @param param the object to convert
@@ -655,10 +712,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
// collectionFormat is assumed to be "csv" by default
- if(collectionFormat == null) {
- collectionFormat = CollectionFormat.CSV;
- }
+ if(collectionFormat == null) {
+ collectionFormat = CollectionFormat.CSV;
+ }
- return collectionFormat.collectionToString(values);
+ return collectionFormat.collectionToString(values);
}
}
diff --git a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache
index 35bff5b9687..ccfed6298ec 100644
--- a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache
+++ b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache
@@ -36,7 +36,6 @@ export type FetchArgs = {
options: {};
}
-
/**
*
* @export
@@ -79,12 +78,12 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
{{/summary}}
* @throws {RequiredError}
*/
- {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: RequestOptions): FetchArgs {
+ {{operationId}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: RequestOptions): FetchArgs {
{{#allParams}}
{{#required}}
// verify required parameter '{{paramName}}' is not null or undefined
if ({{paramName}} === null || {{paramName}} === undefined) {
- throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
+ throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{operationId}}.');
}
{{/required}}
{{/allParams}}
@@ -104,16 +103,16 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
{{#isKeyInHeader}}
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
- ? configuration.apiKey("{{keyParamName}}")
- : configuration.apiKey;
+ ? configuration.apiKey("{{keyParamName}}")
+ : configuration.apiKey;
localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue;
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
- ? configuration.apiKey("{{keyParamName}}")
- : configuration.apiKey;
+ ? configuration.apiKey("{{keyParamName}}")
+ : configuration.apiKey;
localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue;
}
{{/isKeyInQuery}}
@@ -127,9 +126,9 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
{{#isOAuth}}
// oauth required
if (configuration && configuration.accessToken) {
- const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
- ? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
- : configuration.accessToken;
+ const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
+ ? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
+ : configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
{{/isOAuth}}
@@ -142,7 +141,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
localVarQueryParameter['{{baseName}}'] = {{paramName}};
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
- localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
+ localVarQueryParameter['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
{{/isCollectionFormatMulti}}
}
{{/isArray}}
@@ -166,7 +165,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
{{#headerParams}}
{{#isArray}}
if ({{paramName}}) {
- localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
+ localVarHeaderParameter['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
}
{{/isArray}}
{{^isArray}}
@@ -185,7 +184,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
})
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
- localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
+ localVarFormParams.set('{{baseName}}', {{#uniqueItems}}Array.from({{/uniqueItems}}{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
{{/isCollectionFormatMulti}}
}
{{/isArray}}
@@ -227,7 +226,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
};
export type {{classname}}Type = { {{#operation}}
- {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>,
+ {{operationId}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>,
{{/operation}}
}
@@ -247,8 +246,8 @@ export const {{classname}} = function(configuration?: Configuration, fetch: Fetc
{{/summary}}
* @throws {RequiredError}
*/
- {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions = {}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
- const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
+ {{operationId}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions = {}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
+ const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}options);
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response{{#returnType}}.json(){{/returnType}};
@@ -260,6 +259,7 @@ export const {{classname}} = function(configuration?: Configuration, fetch: Fetc
{{/operation}}
}
};
+
{{/operations}}{{/apis}}{{/apiInfo}}
export type ApiTypes = { {{#apiInfo}}{{#apis}}{{#operations}}
{{classname}}: {{classname}}Type,
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 87ab2b5e352..4226cade162 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
@@ -44,6 +44,7 @@ org.openapitools.codegen.languages.GraphQLNodeJSExpressServerCodegen
org.openapitools.codegen.languages.GroovyClientCodegen
org.openapitools.codegen.languages.KotlinClientCodegen
org.openapitools.codegen.languages.KotlinServerCodegen
+org.openapitools.codegen.languages.KotlinServerDeprecatedCodegen
org.openapitools.codegen.languages.KotlinSpringServerCodegen
org.openapitools.codegen.languages.KotlinVertxServerCodegen
org.openapitools.codegen.languages.KtormSchemaCodegen
diff --git a/modules/openapi-generator/src/main/resources/bash/client.mustache b/modules/openapi-generator/src/main/resources/bash/client.mustache
index ff63a39c600..3f5dcc0e291 100644
--- a/modules/openapi-generator/src/main/resources/bash/client.mustache
+++ b/modules/openapi-generator/src/main/resources/bash/client.mustache
@@ -979,7 +979,7 @@ case $key in
body_parameters[${body_key}]=${body_value}
fi
;;
- +\([^=]\):*)
+ +([^=]):*)
# Parse header arguments and convert them into curl
# only after the operation argument
if [[ "$operation" ]]; then
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache
index 7beb0990a96..f614d478e96 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache
@@ -14,24 +14,21 @@
#include
#include
{{^hasModelImport}}#include {{/hasModelImport}}
+#include
{{#imports}}{{{import}}}
{{/imports}}
-{{#apiNamespaceDeclarations}}
-namespace {{this}} {
-{{/apiNamespaceDeclarations}}
-
-{{#hasModelImport}}
-using namespace {{modelNamespace}};{{/hasModelImport}}
+namespace {{apiNamespace}}
+{
class {{declspec}} {{classname}} {
public:
- {{classname}}(std::shared_ptr);
- virtual ~{{classname}}() {}
+ explicit {{classname}}(const std::shared_ptr& rtr);
+ virtual ~{{classname}}() = default;
void init();
- const std::string base = "{{basePathWithoutHost}}";
+ static const std::string base;
private:
void setupRoutes();
@@ -41,9 +38,21 @@ private:
{{/operation}}
void {{classnameSnakeLowerCase}}_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
- std::shared_ptr router;
- {{#operation}}
+ const std::shared_ptr router;
+ ///
+ /// Helper function to handle unexpected Exceptions during Parameter parsing and validation.
+ /// May be overriden to return custom error formats.
+ ///
+ virtual std::pair handleParsingException(const std::exception& ex) const noexcept;
+
+ ///
+ /// Helper function to handle unexpected Exceptions during processing of the request in handler functions.
+ /// May be overriden to return custom error formats.
+ ///
+ virtual std::pair handleOperationException(const std::exception& ex) const noexcept;
+
+ {{#operation}}
///
/// {{summary}}
///
@@ -54,7 +63,7 @@ private:
{{#allParams}}
/// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
{{/allParams}}
- virtual void {{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0;
+ virtual void {{operationIdSnakeCase}}({{#allParams}}const {{#isModel}}{{modelNamespace}}::{{/isModel}}{{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0;
{{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
{{^vendorExtensions.x-codegen-pistache-is-parsing-supported}}
virtual void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
@@ -63,9 +72,7 @@ private:
};
-{{#apiNamespaceDeclarations}}
-}
-{{/apiNamespaceDeclarations}}
+} // namespace {{apiNamespace}}
#endif /* {{classname}}_H_ */
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache
index 18ff119ae20..bd20c1bdf5a 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache
@@ -22,17 +22,16 @@
{{#imports}}{{{import}}}
{{/imports}}
-{{#apiNamespaceDeclarations}}
-namespace {{this}} {
-{{/apiNamespaceDeclarations}}
+namespace {{apiNamespace}}
+{
{{#hasModelImport}}
using namespace {{modelNamespace}};{{/hasModelImport}}
class {{classname}}Impl : public {{apiNamespace}}::{{classname}} {
public:
- {{classname}}Impl(std::shared_ptr);
- ~{{classname}}Impl() {}
+ explicit {{classname}}Impl(const std::shared_ptr& rtr);
+ ~{{classname}}Impl() override = default;
{{#operation}}
{{#vendorExtensions.x-codegen-pistache-is-parsing-supported}}
@@ -45,11 +44,9 @@ public:
};
-{{#apiNamespaceDeclarations}}
-}
-{{/apiNamespaceDeclarations}}
+} // namespace {{apiNamespace}}
{{/operations}}
-#endif
\ No newline at end of file
+#endif
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache
index e5517bb487c..2e25a8034b3 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache
@@ -10,9 +10,10 @@ namespace {{this}} {
{{#hasModelImport}}
using namespace {{modelNamespace}};{{/hasModelImport}}
-{{classname}}Impl::{{classname}}Impl(std::shared_ptr rtr)
+{{classname}}Impl::{{classname}}Impl(const std::shared_ptr& rtr)
: {{classname}}(rtr)
- { }
+{
+}
{{#operation}}
{{#vendorExtensions.x-codegen-pistache-is-parsing-supported}}
@@ -31,4 +32,4 @@ void {{classname}}Impl::{{operationIdSnakeCase}}(const Pistache::Rest::Request &
}
{{/apiNamespaceDeclarations}}
-{{/operations}}
\ No newline at end of file
+{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache
index 9225a5610c7..9814ba0cd62 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache
@@ -4,16 +4,18 @@
#include "{{classname}}.h"
#include "{{prefix}}Helpers.h"
-{{#apiNamespaceDeclarations}}
-namespace {{this}} {
-{{/apiNamespaceDeclarations}}
+namespace {{apiNamespace}}
+{
using namespace {{helpersNamespace}};
{{#hasModelImport}}
using namespace {{modelNamespace}};{{/hasModelImport}}
-{{classname}}::{{classname}}(std::shared_ptr rtr) {
- router = rtr;
+const std::string {{classname}}::base = "{{basePathWithoutHost}}";
+
+{{classname}}::{{classname}}(const std::shared_ptr& rtr)
+ : router(rtr)
+{
}
void {{classname}}::init() {
@@ -31,8 +33,26 @@ void {{classname}}::setupRoutes() {
router->addCustomHandler(Routes::bind(&{{classname}}::{{classnameSnakeLowerCase}}_default_handler, this));
}
+std::pair {{classname}}::handleParsingException(const std::exception& ex) const noexcept
+{
+ try {
+ throw ex;
+ } catch (nlohmann::detail::exception &e) {
+ return std::make_pair(Pistache::Http::Code::Bad_Request, e.what());
+ } catch ({{helpersNamespace}}::ValidationException &e) {
+ return std::make_pair(Pistache::Http::Code::Bad_Request, e.what());
+ }
+}
+
+std::pair {{classname}}::handleOperationException(const std::exception& ex) const noexcept
+{
+ return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what());
+}
+
{{#operation}}
void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Request &{{#hasParams}}request{{/hasParams}}, Pistache::Http::ResponseWriter response) {
+ try {
+
{{#vendorExtensions.x-codegen-pistache-is-parsing-supported}}
{{#hasPathParams}}
// Getting the path params
@@ -71,32 +91,40 @@ void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Reque
{{#hasBodyParam}}
{{#bodyParam}}
{{^isPrimitiveType}}
- nlohmann::json::parse(request.body()).get_to({{paramName}});
+ nlohmann::json::parse(request.body()).get_to({{paramName}});
+ {{paramName}}.validate();
{{/isPrimitiveType}}
{{#isPrimitiveType}}
- {{paramName}} = request.body();
+ {{paramName}} = request.body();
{{/isPrimitiveType}}
+ } catch (std::exception &e) {
+ const std::pair errorInfo = this->handleParsingException(e);
+ response.send(errorInfo.first, errorInfo.second);
+ return;
+ }
+
+ try {
{{/bodyParam}}
{{/hasBodyParam}}
- this->{{operationIdSnakeCase}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}response);
+ this->{{operationIdSnakeCase}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}response);
{{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
{{^vendorExtensions.x-codegen-pistache-is-parsing-supported}}
try {
this->{{operationIdSnakeCase}}(request, response);
{{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
- } catch (nlohmann::detail::exception &e) {
- //send a 400 error
- response.send(Pistache::Http::Code::Bad_Request, e.what());
- return;
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast(e.code()), e.what());
return;
} catch (std::exception &e) {
- //send a 500 error
- response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
+ const std::pair errorInfo = this->handleOperationException(e);
+ response.send(errorInfo.first, errorInfo.second);
return;
}
+ } catch (std::exception &e) {
+ response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
+ }
+
}
{{/operation}}
@@ -104,8 +132,6 @@ void {{classname}}::{{classnameSnakeLowerCase}}_default_handler(const Pistache::
response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist");
}
-{{#apiNamespaceDeclarations}}
-}
-{{/apiNamespaceDeclarations}}
+} // namespace {{apiNamespace}}
{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache
index c39cca04fe1..d3489fad402 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache
@@ -14,16 +14,80 @@
#include
#include