Compare commits

..

16 Commits

Author SHA1 Message Date
William Cheng 448c460517 Merge branch 'client-multipart-support' of https://github.com/condorcorde/openapi-generator into condorcorde-client-multipart-support 2024-04-07 20:58:18 +08:00
condorcorde 50e083b79c Merge branch 'client-multipart-support' of https://github.com/condorcorde/openapi-generator into client-multipart-support 2024-04-07 11:38:54 +02:00
condorcorde 5d7a70a972 Tabs removed 2024-04-07 11:37:34 +02:00
condorcorde a43128d300 Merge branch 'OpenAPITools:master' into client-multipart-support 2024-04-07 10:03:03 +02:00
condorcorde b14ff289b6 Update api_client.mustache 2024-04-06 21:00:28 +02:00
condorcorde a636968b22 Update api_client.nustache 2024-04-06 15:56:25 +02:00
condorcorde 7860c654d2 Merge branch 'OpenAPITools:master' into client-multipart-support 2024-04-06 11:21:30 +02:00
condorcorde a9227a94dc Update api_client.mustache 2024-04-06 11:20:38 +02:00
condorcorde 0bc3d55664 Merge branch 'client-multipart-support' of https://github.com/condorcorde/openapi-generator into client-multipart-support 2024-04-05 20:09:40 +02:00
condorcorde 4edda2e4ad Merge branch 'OpenAPITools:master' into client-multipart-support 2024-04-05 20:06:49 +02:00
condorcorde 6e7d9677ba Corrections after petstore tests 2024-04-05 20:04:35 +02:00
condorcorde 74994ed30a Merge branch 'OpenAPITools:master' into client-multipart-support 2024-04-05 10:18:07 +02:00
condorcorde 8dc1c81c68 Set $Multipart 2024-04-04 22:05:40 +02:00
condorcorde 3af8d66f84 Update ApiClient.ps1 2024-04-04 19:22:27 +02:00
condorcorde b5868cedc7 Further code optimization 2024-04-04 18:02:12 +02:00
condorcorde 5f122f806b Support multipart requests 2024-04-04 17:53:29 +02:00
7464 changed files with 11815 additions and 58817 deletions
+1 -16
View File
@@ -140,23 +140,8 @@ jobs:
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target
- name: Delete samples that are entirely generated
run: |
rm -rf samples/client/petstore/csharp/generichost/net8/AllOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net8/FormModels
rm -rf samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
rm -rf samples/client/petstore/csharp/generichost/net8/OneOf
rm -rf samples/client/petstore/csharp/generichost/net8/Petstore
rm -rf samples/client/petstore/csharp/generichost/net8/SourceGeneration
rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
rm -rf samples/client/petstore/csharp/generichost/standard2.0/Petstore
- name: Generate samples
run: |
bash bin/generate-samples.sh
# when a sample is deleted, you have to generate it twice for all files to get created
bash bin/generate-samples.sh
run: bash bin/generate-samples.sh
- name: Verify git status
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
@@ -73,7 +73,6 @@ jobs:
- samples/client/petstore/java/resttemplate-swagger2/
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/
- samples/client/others/java/okhttp-gson-oneOf/
- samples/client/echo_api/java/okhttp-gson-user-defined-templates/
- samples/client/others/java/resttemplate-useAbstractionForFiles/
- samples/client/others/java/webclient-useAbstractionForFiles/
- samples/client/others/java/jersey2-oneOf-duplicates/
-3
View File
@@ -4,11 +4,9 @@ on:
push:
paths:
- samples/server/petstore/php-symfony/SymfonyBundle-php/**
- samples/server/petstore/php-flight/**
pull_request:
paths:
- samples/server/petstore/php-symfony/SymfonyBundle-php/**
- samples/server/petstore/php-flight/**
jobs:
build:
name: Build PHP projects
@@ -19,7 +17,6 @@ jobs:
sample:
# servers
- samples/server/petstore/php-symfony/SymfonyBundle-php/
- samples/server/petstore/php-flight/
steps:
- uses: actions/checkout@v4
- name: Setup PHP with tools
-1
View File
@@ -32,7 +32,6 @@ jobs:
- samples/server/petstore/scalatra
- samples/server/petstore/scala-finch # cannot be tested with jdk11
- samples/server/petstore/scala-http4s-server
- samples/server/petstore/scala-cask
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
-5
View File
@@ -85,11 +85,6 @@ samples/client/petstore/cpp-restsdk/CMakeCache.txt
samples/client/petstore/cpp-restsdk/CMakeFiles/
samples/client/petstore/cpp-restsdk/Makefile
samples/client/petstore/cpp-restsdk/cmake_install.cmake
samples/client/petstore/cpp-restsdk/client/CMakeFiles
samples/client/petstore/cpp-restsdk/client/Makefile
samples/client/petstore/cpp-restsdk/client/cmake_install.cmake
samples/client/petstore/cpp-restsdk/client/CppRestPetstoreClientConfig.cmake
samples/client/petstore/cpp-restsdk/client/CMakeCache.txt
#Java/Android
**/.gradle
+2 -22
View File
@@ -31,7 +31,7 @@ Please file the pull request against the correct branch, e.g. `master` for non-b
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
### Templates
@@ -84,26 +84,6 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master
- For language-specified vendor extension, put it in the form of `x-{lang}-{extension-name}`. e.g. `x-objc-operation-id`, `x-java-feign-retry-limit`
- For a list of existing vendor extensions in use, please refer to https://github.com/openapitools/openapi-generator/wiki/Vendor-Extensions. If you've added new vendor extensions as part of your PR, please update the wiki page.
### Building
The `openapi-generator-cli` can be built using the following command. This will generate the `openapi-generator-cli.jar` in the `modules/openapi-generator-cli/target` directory without running the tests and generating the Javadocs.
```shell
./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true
```
Or on Windows:
```shell
mvnw.cmd clean install -DskipTests -Dmaven.javadoc.skip=true
```
The binary can run via `java -jar`. For example:
```shell
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help
```
### Testing
To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen)
@@ -132,5 +112,5 @@ See [OpenAPI Tools wiki](https://github.com/OpenAPITools/openapi-generator/wiki/
- File a PR with meaningful title, description and commit messages
- Make sure the option "Allow edits from maintainers" in the PR is selected so that the maintainers can update your PRs with minor fixes, if needed.
- Recommended git settings
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
- To close an issue (e.g. issue 1542) automatically after a PR is merged, use keywords "fix", "close", "resolve" in the PR description, e.g. `fix #1542`. (Ref: [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
+8 -12
View File
@@ -15,7 +15,7 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.6.0`):
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.5.0`):
[![Build Status](https://api.travis-ci.com/OpenAPITools/openapi-generator.svg?branch=master&status=passed)](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
@@ -61,7 +61,7 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
[<img src="https://openapi-generator.tech/img/companies/bumpsh.png" width="128" height="128">](https://bump.sh/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/bileto.png" width="128" height="128">](https://www.bileto.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/bairesdev.png" width="128" height="128">](https://www.bairesdev.com/sponsoring-open-source-projects/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/dmtech.jpeg" width="128" height="128">](https://www.dmtech.de/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/dmtech.jpeg" width="128" height="128">](https://www.dm-jobs.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/adyen.png" width="128" height="128">](https://adyen.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/fornex.png" width="128" height="128">](https://fornex.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/alloyautomation.png" width="128" height="128">](https://runalloy.com/signup?utm_source=github&utm_medium=referral&utm_campaign=1524_openapigenerator)
@@ -85,7 +85,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| | Languages/Frameworks |
| -------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **N4JS**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient, pekko), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (9.x - 17.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** ([Flight](https://docs.flightphp.com/), Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Postman Collection**, **Protocol Buffer**, **WSDL** |
@@ -126,8 +126,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 7.6.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.6.0-SNAPSHOT/) | 17.54.2024 | Minor release with breaking changes (with fallback) |
| [7.5.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.5.0) (latest stable release) | 17.04.2024 | Minor release with breaking changes (with fallback) |
| 7.5.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.5.0-SNAPSHOT/) | 12.04.2024 | Minor release with breaking changes (with fallback) |
| [7.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.4.0) (latest stable release) | 11.03.2024 | Minor release with breaking changes (with fallback) |
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 11.05.2023 | Minor release with breaking changes (with fallback) |
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | 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) |
@@ -190,16 +190,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.5.0/openapi-generator-cli-7.5.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar`
For **Mac/Linux** users:
```sh
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.5.0/openapi-generator-cli-7.5.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.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/7.5.0/openapi-generator-cli-7.5.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@@ -705,7 +705,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [REST United](https://restunited.com)
- [Robocorp](https://www.robocorp.com)
- [Robotinfra](https://www.robotinfra.com)
- [SearchApi](https://www.searchapi.io/)
- [SmartHR](https://smarthr.co.jp/)
- [Sony Interactive Entertainment](https://www.sie.com/en/index.html)
- [Splitit](https://www.splitit.com/)
@@ -932,7 +931,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2023-12-10 - [UnityでOpenAPI Generatorを使う](https://www.youtube.com/watch?v=CbNwKVV5LRM) by [Soup Tori](https://www.youtube.com/@souptori8417)
- 2024-03-04 - [Generating TypeScript Types with OpenAPI for REST API Consumption](https://www.pullrequest.com/blog/generating-typescript-types-with-openapi-for-rest-api-consumption/) by [PullRequest](https://www.pullrequest.com/)
- 2024-03-07 - [Fully typed Web Apps with OpenAPI (Part 1)](https://medium.com/@gfox1984/fully-typed-web-apps-with-openapi-part-1-595d55766670) by [Guillaume Renard](https://medium.com/@gfox1984)
- 2024-03-08 - [Laravel OpenAPIによる "辛くない" スキーマ駆動開発](https://fortee.jp/phperkaigi-2024/proposal/9e2e6c38-d078-4efa-99b4-83ebf9033b34) by [KentarouTakeda](https://twitter.com/KentarouTakeda)
## [6 - About Us](#table-of-contents)
@@ -1092,7 +1090,6 @@ Here is a list of template creators:
* Kotlin (Vertx): @Wooyme
* Kotlin (JAX-RS): @anttileppa
* NodeJS Express: @YishTish
* PHP Flight: @daniel-sc
* PHP Laravel: @renepardon
* PHP Lumen: @abcsun
* PHP Mezzio (with Path Handler): @Articus
@@ -1105,7 +1102,6 @@ Here is a list of template creators:
* Ruby on Rails 5: @zlx
* Rust (rust-server): @metaswitch
* Scala Akka: @Bouillie
* Scala Cask: @aaronp
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Scala Lagom: @gmkumar2005
* Scala Play: @adigerber
@@ -8,5 +8,4 @@ additionalProperties:
serializationLibrary: jackson
artifactId: microprofile-rest-client-3-jackson-with-xml
configKey: petstore
microprofileRestClientVersion: "3.0"
hideGenerationTimestamp: true
microprofileRestClientVersion: "3.0"
@@ -7,5 +7,4 @@ additionalProperties:
serializationLibrary: jackson
artifactId: microprofile-rest-client-3-jackson
configKey: petstore
microprofileRestClientVersion: "3.0"
hideGenerationTimestamp: true
microprofileRestClientVersion: "3.0"
+1 -2
View File
@@ -9,5 +9,4 @@ additionalProperties:
useOneOfDiscriminatorLookup: "true"
disallowAdditionalPropertiesIfNotPresent: false
annotationLibrary: "swagger1"
openapiNormalizer:
SET_TAGS_FOR_ALL_OPERATIONS: common
@@ -1,17 +0,0 @@
generatorName: java
outputDir: samples/client/echo_api/java/okhttp-gson-user-defined-templates
library: okhttp-gson
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: "true"
files:
README.md:
destinationFilename: info.md
api_doc.mustache:
templateType: APIDocs
destinationFilename: Documentation.md
pojo.mustache:
templateType: Model
folder: modelCopy
destinationFilename: .java
@@ -1,15 +0,0 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec-quarkus-mutiny
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
artifactId: jaxrs-spec-petstore-server
serializableModel: "true"
hideGenerationTimestamp: "true"
implicitHeadersRegex: (api_key|enum_header_string)
generateBuilders: "true"
useMicroProfileOpenAPIAnnotations: "true"
useAsync: "true"
useMutiny: "true"
library: "quarkus"
dateLibrary: "java8-localdatetime"
@@ -12,4 +12,4 @@ additionalProperties:
enumPropertyNaming: UPPERCASE
serializationLibrary: gson
openapiNormalizer:
SIMPLIFY_ONEOF_ANYOF: false
SIMPLIFY_ONEOF_ANYOF=false
@@ -12,4 +12,4 @@ additionalProperties:
enumPropertyNaming: UPPERCASE
serializationLibrary: gson
openapiNormalizer:
SIMPLIFY_ONEOF_ANYOF: false
SIMPLIFY_ONEOF_ANYOF=false
@@ -7,6 +7,4 @@ additionalProperties:
hideGenerationTimestamp: "true"
packageName: petstore-with-fake-endpoints-models-for-testing
publishRustRegistry: crates-io
globalProperties:
skipFormModel: false
enablePostProcessFile: true
enablePostProcessFile: true
@@ -6,6 +6,4 @@ generateAliasAsModel: true
additionalProperties:
hideGenerationTimestamp: "true"
packageName: petstore
globalProperties:
skipFormModel: false
enablePostProcessFile: true
-6
View File
@@ -1,6 +0,0 @@
generatorName: php-flight
outputDir: samples/server/petstore/php-flight
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/php-flight
additionalProperties:
hideGenerationTimestamp: "true"
-13
View File
@@ -1,13 +0,0 @@
generatorName: scala-cask
outputDir: samples/server/petstore/scala-cask
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/scala-cask
additionalProperties:
hideGenerationTimestamp: "true"
artifactId: scala-cask-petstore
groupId: "cask.groupId"
package: "sample.cask"
modelPackage: "sample.cask.model"
apiPackage: "sample.cask.api"
gitRepoId: "sample-cask-repo"
gitUserId: "sample-cask-user"
+1 -1
View File
@@ -10,7 +10,7 @@
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java"
sha256: db505f7801fef62c13a08a8e9ca1fc4c5c947ab46b46f12943139d353feacf17
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java"
sha256: 8210bdaf06aae8dc46521515a8a0ef10e48c980fadd3efd95313e6c806f409c2
sha256: c479b587cf0d51fa550eb81d33b277081807b87dc28649027d1164224c25ad0a
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java"
sha256: 0d64cdc11809a7b5b952ccdad2bd91bd0045b3894d6fabf3e368fa0be12b8217
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/PetTest.java"
+2 -22
View File
@@ -35,7 +35,7 @@ Please file the pull request against the correct branch, e.g. `master` for non-b
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
### Templates
@@ -88,26 +88,6 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master
- For language-specified vendor extension, put it in the form of `x-{lang}-{extension-name}`. e.g. `x-objc-operation-id`, `x-java-feign-retry-limit`
- For a list of existing vendor extensions in use, please refer to https://github.com/openapitools/openapi-generator/wiki/Vendor-Extensions. If you've added new vendor extensions as part of your PR, please update the wiki page.
### Building
The `openapi-generator-cli` can be built using the following command. This will generate the `openapi-generator-cli.jar` in the `modules/openapi-generator-cli/target` directory without running the tests and generating the Javadocs.
```shell
./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true
```
Or on Windows:
```shell
mvnw.cmd clean install -DskipTests -Dmaven.javadoc.skip=true
```
The binary can run via `java -jar`. For example:
```shell
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help
```
### Testing
To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen)
@@ -136,5 +116,5 @@ See [OpenAPI Tools wiki](https://github.com/OpenAPITools/openapi-generator/wiki/
- File a PR with meaningful title, description and commit messages
- Make sure the option "Allow edits from maintainers" in the PR is selected so that the maintainers can update your PRs with minor fixes, if needed.
- Recommended git settings
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
- To close an issue (e.g. issue 1542) automatically after a PR is merged, use keywords "fix", "close", "resolve" in the PR description, e.g. `fix #1542`. (Ref: [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
-2
View File
@@ -304,8 +304,6 @@ You can use also `config.yml` with following equivalent example:
apiPackage: "petstore"
```
Another example of config file can be found in [modules/openapi-generator/src/test/resources/sampleConfig.json](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/sampleConfig.json)
Supported config options can be different per language. Running `config-help -g {lang}` will show available options.
**These options are applied via configuration file (e.g. config.json or config.yml) or by passing them with `-p {optionName}={optionValue}`**. (If `-p {optionName}` does not work, please open a [ticket](https://github.com/openapitools/openapi-generator/issues/new) and we'll look into it)
-2
View File
@@ -120,7 +120,6 @@ The following generators are available:
* [kotlin-spring](generators/kotlin-spring.md)
* [kotlin-vertx (beta)](generators/kotlin-vertx.md)
* [nodejs-express-server (beta)](generators/nodejs-express-server.md)
* [php-flight (experimental)](generators/php-flight.md)
* [php-laravel](generators/php-laravel.md)
* [php-lumen](generators/php-lumen.md)
* [php-mezzio-ph](generators/php-mezzio-ph.md)
@@ -135,7 +134,6 @@ The following generators are available:
* [rust-axum (beta)](generators/rust-axum.md)
* [rust-server](generators/rust-server.md)
* [scala-akka-http-server (beta)](generators/scala-akka-http-server.md)
* [scala-cask](generators/scala-cask.md)
* [scala-finch](generators/scala-finch.md)
* [scala-http4s-server](generators/scala-http4s-server.md)
* [scala-lagom-server](generators/scala-lagom-server.md)
+1 -2
View File
@@ -32,7 +32,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Type/Alias | Imports |
| ---------- | ------- |
|AnyType|#include &quot;AnyType.h&quot;|
|HttpContent|#include &quot;HttpContent.h&quot;|
|Object|#include &quot;Object.h&quot;|
|std::map|#include &lt;map&gt;|
@@ -185,7 +184,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|Uuid|✗|
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType||OAS2,OAS3
|AnyType||OAS2,OAS3
|Object|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
-1
View File
@@ -22,7 +22,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|enumClassPrefix|Prefix enum with class name| |false|
|generateInterfaces|Generate interfaces for api classes| |false|
|generateMarshalJSON|Generate MarshalJSON method| |true|
|generateUnmarshalJSON|Generate UnmarshalJSON method| |true|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|packageName|Go package name (convention: lowercase).| |openapi|
-1
View File
@@ -135,7 +135,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -174,7 +174,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -128,7 +128,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -130,7 +130,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -132,7 +132,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -153,7 +153,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -153,7 +153,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -138,7 +138,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -139,7 +139,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -142,7 +142,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -132,7 +132,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -132,7 +132,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -135,7 +135,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -132,7 +132,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
+1 -2
View File
@@ -47,7 +47,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|dynamicOperations|Generate operations dynamically at runtime from an OAS| |false|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|errorObjectType|Error Object type. (This option is for okhttp-gson only)| |null|
|errorObjectType|Error Object type. (This option is for okhttp-gson-next-gen only)| |null|
|generateClientAsBean|For resttemplate, configure whether to create `ApiClient.java` and Apis clients as bean (with `@Component` annotation).| |false|
|gradleProperties|Append additional Gradle properties to the gradle.properties file| |null|
|groupId|groupId in generated pom.xml| |org.openapitools|
@@ -164,7 +164,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-2
View File
@@ -78,7 +78,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useBeanValidation|Use BeanValidation API annotations| |true|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useMicroProfileOpenAPIAnnotations|Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.| |false|
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|useTags|use tags for creating interface and controller classnames| |false|
@@ -147,7 +146,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -137,7 +137,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -160,7 +160,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -155,7 +155,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -138,7 +138,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -139,7 +139,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-1
View File
@@ -138,7 +138,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-2
View File
@@ -78,7 +78,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useBeanValidation|Use BeanValidation API annotations| |true|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useMicroProfileOpenAPIAnnotations|Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.| |false|
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|useTags|use tags for creating interface and controller classnames| |false|
@@ -147,7 +146,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
-270
View File
@@ -1,270 +0,0 @@
---
title: Documentation for the php-flight Generator
---
## METADATA
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | php-flight | pass this to the generate command after -g |
| generator stability | EXPERIMENTAL | |
| generator type | SERVER | |
| generator language | PHP | |
| generator default templating engine | mustache | |
| helpTxt | Generates a PHP Flight Framework server library. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|apiPackage|package for generated api classes| |null|
|artifactUrl|artifact URL in generated pom.xml| |null|
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|developerOrganization|developer organization in generated pom.xml| |null|
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|true|
|licenseName|The name of the license| |null|
|modelPackage|package for generated models| |null|
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|srcBasePath|The directory to serve as source root.| |null|
|variableNamingConvention|naming convention of variable name, e.g. camelCase.| |camelCase|
## IMPORT MAPPING
| Type/Alias | Imports |
| ---------- | ------- |
## INSTANTIATION TYPES
| Type/Alias | Instantiated By |
| ---------- | --------------- |
|array|array|
|map|array|
## LANGUAGE PRIMITIVES
<ul class="column-ul">
<li>\DateTime</li>
<li>\SplFileObject</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>float</li>
<li>int</li>
<li>integer</li>
<li>mixed</li>
<li>number</li>
<li>object</li>
<li>string</li>
<li>void</li>
</ul>
## RESERVED WORDS
<ul class="column-ul">
<li>__halt_compiler</li>
<li>_header_accept</li>
<li>_tempbody</li>
<li>abstract</li>
<li>and</li>
<li>array</li>
<li>as</li>
<li>break</li>
<li>callable</li>
<li>case</li>
<li>catch</li>
<li>class</li>
<li>clone</li>
<li>const</li>
<li>continue</li>
<li>declare</li>
<li>default</li>
<li>die</li>
<li>do</li>
<li>echo</li>
<li>else</li>
<li>elseif</li>
<li>empty</li>
<li>enddeclare</li>
<li>endfor</li>
<li>endforeach</li>
<li>endif</li>
<li>endswitch</li>
<li>endwhile</li>
<li>eval</li>
<li>exit</li>
<li>extends</li>
<li>final</li>
<li>for</li>
<li>foreach</li>
<li>formparams</li>
<li>function</li>
<li>global</li>
<li>goto</li>
<li>headerparams</li>
<li>httpbody</li>
<li>if</li>
<li>implements</li>
<li>include</li>
<li>include_once</li>
<li>instanceof</li>
<li>insteadof</li>
<li>interface</li>
<li>isset</li>
<li>list</li>
<li>namespace</li>
<li>new</li>
<li>or</li>
<li>print</li>
<li>private</li>
<li>protected</li>
<li>public</li>
<li>queryparams</li>
<li>require</li>
<li>require_once</li>
<li>resourcepath</li>
<li>return</li>
<li>static</li>
<li>switch</li>
<li>throw</li>
<li>trait</li>
<li>try</li>
<li>unset</li>
<li>use</li>
<li>var</li>
<li>while</li>
<li>xor</li>
</ul>
## 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
|Uuid|✗|
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3
|Object|✓|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
|allOf|✗|OAS2,OAS3
|anyOf|✗|OAS3
|oneOf|✗|OAS3
|not|✗|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
|SignatureAuth|✗|OAS3
|AWSV4Signature|✗|ToolingExtension
### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✗|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3
-262
View File
@@ -1,262 +0,0 @@
---
title: Documentation for the scala-cask Generator
---
## METADATA
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | scala-cask | pass this to the generate command after -g |
| generator stability | STABLE | |
| generator type | SERVER | |
| generator language | Scala | |
| generator default templating engine | mustache | |
| helpTxt | Generates a scala-cask server. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|apiPackage|package for generated api classes| |null|
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |null|
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename. If not provided, uses the version from the OpenAPI specification file. If that's also not present, uses the default value of the artifactVersion option.| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for JDK 1.8+)</dd></dl>|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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|gitRepoId|Git repo ID, e.g. openapi-generator.| |null|
|gitUserId|Git user ID, e.g. openapitools.| |null|
|groupId|groupId in generated pom.xml| |null|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|true|
|modelPackage|package for generated models| |null|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|packageName|packageDescription| |null|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|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|
## IMPORT MAPPING
| Type/Alias | Imports |
| ---------- | ------- |
|Array|java.util.List|
|ArrayList|java.util.ArrayList|
|Date|java.util.Date|
|DateTime|org.joda.time.*|
|File|java.io.File|
|HashMap|java.util.HashMap|
|ListBuffer|scala.collection.mutable.ListBuffer|
|ListSet|scala.collection.immutable.ListSet|
|LocalDate|org.joda.time.*|
|LocalDateTime|org.joda.time.*|
|LocalTime|org.joda.time.*|
|Seq|scala.collection.immutable.Seq|
|Set|scala.collection.immutable.Set|
|Timestamp|java.sql.Timestamp|
|URI|java.net.URI|
|UUID|java.util.UUID|
## INSTANTIATION TYPES
| Type/Alias | Instantiated By |
| ---------- | --------------- |
|set|Set|
## LANGUAGE PRIMITIVES
<ul class="column-ul">
<li>Any</li>
<li>Array</li>
<li>Boolean</li>
<li>Byte</li>
<li>Double</li>
<li>Float</li>
<li>Int</li>
<li>List</li>
<li>Long</li>
<li>Map</li>
<li>Object</li>
<li>Seq</li>
<li>String</li>
<li>boolean</li>
</ul>
## RESERVED WORDS
<ul class="column-ul">
<li>abstract</li>
<li>assert</li>
<li>boolean</li>
<li>break</li>
<li>byte</li>
<li>case</li>
<li>catch</li>
<li>char</li>
<li>class</li>
<li>const</li>
<li>continue</li>
<li>default</li>
<li>do</li>
<li>double</li>
<li>else</li>
<li>enum</li>
<li>extends</li>
<li>final</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>goto</li>
<li>if</li>
<li>implements</li>
<li>import</li>
<li>instanceof</li>
<li>int</li>
<li>interface</li>
<li>long</li>
<li>native</li>
<li>new</li>
<li>package</li>
<li>private</li>
<li>protected</li>
<li>public</li>
<li>return</li>
<li>short</li>
<li>static</li>
<li>strictfp</li>
<li>super</li>
<li>switch</li>
<li>synchronized</li>
<li>this</li>
<li>throw</li>
<li>throws</li>
<li>transient</li>
<li>try</li>
<li>type</li>
<li>void</li>
<li>volatile</li>
<li>while</li>
</ul>
## 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
|Uuid|✗|
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3
|Object|✓|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
|allOf|✗|OAS2,OAS3
|anyOf|✗|OAS3
|oneOf|✗|OAS3
|not|✗|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
|SignatureAuth|✗|OAS3
|AWSV4Signature|✗|ToolingExtension
### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3
-1
View File
@@ -167,7 +167,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS
<ul class="column-ul">
<li>_</li>
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
+1 -1
View File
@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
@@ -515,11 +515,11 @@ public class Generate extends OpenApiGeneratorCommand {
applyModelNameMappingsKvpList(modelNameMappings, configurator);
applyEnumNameMappingsKvpList(enumNameMappings, configurator);
applyOperationIdNameMappingsKvpList(operationIdNameMappings, configurator);
applyOpenapiNormalizerKvpList(openapiNormalizer, configurator);
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
applyTypeMappingsKvpList(typeMappings, configurator);
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
applyOpenapiGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
applyOpenAPIGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
applyServerVariablesKvpList(serverVariableOverrides, configurator);
+1 -1
View File
@@ -6,7 +6,7 @@
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
@@ -321,7 +321,7 @@ public final class GeneratorSettings implements Serializable {
*
* @return a map of rules
*/
public Map<String, String> getOpenapiNormalizer() {
public Map<String, String> getOpenAPINormalizer() {
return openapiNormalizer;
}
@@ -346,7 +346,7 @@ public final class GeneratorSettings implements Serializable {
*
* @return the openapi generator ignore list
*/
public Set<String> getOpenapiGeneratorIgnoreList() {
public Set<String> getOpenAPIGeneratorIgnoreList() {
return openapiGeneratorIgnoreList;
}
@@ -614,14 +614,14 @@ public final class GeneratorSettings implements Serializable {
if (copy.getOperationIdNameMappings() != null) {
builder.operationIdNameMappings.putAll(copy.getOperationIdNameMappings());
}
if (copy.getOpenapiNormalizer() != null) {
builder.openapiNormalizer.putAll(copy.getOpenapiNormalizer());
if (copy.getOpenAPINormalizer() != null) {
builder.openapiNormalizer.putAll(copy.getOpenAPINormalizer());
}
if (copy.getLanguageSpecificPrimitives() != null) {
builder.languageSpecificPrimitives.addAll(copy.getLanguageSpecificPrimitives());
}
if (copy.getOpenapiGeneratorIgnoreList() != null) {
builder.openapiGeneratorIgnoreList.addAll(copy.getOpenapiGeneratorIgnoreList());
if (copy.getOpenAPIGeneratorIgnoreList() != null) {
builder.openapiGeneratorIgnoreList.addAll(copy.getOpenAPIGeneratorIgnoreList());
}
if (copy.getReservedWordsMappings() != null) {
builder.reservedWordsMappings.putAll(copy.getReservedWordsMappings());
@@ -1152,7 +1152,7 @@ public final class GeneratorSettings implements Serializable {
* @param openapiNormalizer the {@code openapiNormalizer} to set
* @return a reference to this Builder
*/
public Builder withOpenapiNormalizer(Map<String, String> openapiNormalizer) {
public Builder withOpenAPINormalizer(Map<String, String> openapiNormalizer) {
this.openapiNormalizer = openapiNormalizer;
return this;
}
@@ -1164,7 +1164,7 @@ public final class GeneratorSettings implements Serializable {
* @param value The value of the OpenAPI normalizer rule
* @return a reference to this Builder
*/
public Builder withOpenapiNormalizer(String key, String value) {
public Builder withOpenAPINormalizer(String key, String value) {
if (this.openapiNormalizer == null) {
this.openapiNormalizer = new HashMap<>();
}
@@ -1203,7 +1203,7 @@ public final class GeneratorSettings implements Serializable {
* @param openapiGeneratorIgnoreList the {@code openapiGeneratorIgnoreList} to set
* @return a reference to this Builder
*/
public Builder withOpenapiGeneratorIgnoreList(Set<String> openapiGeneratorIgnoreList) {
public Builder withOpenAPIGeneratorIgnoreList(Set<String> openapiGeneratorIgnoreList) {
this.openapiGeneratorIgnoreList = openapiGeneratorIgnoreList;
return this;
}
@@ -1214,7 +1214,7 @@ public final class GeneratorSettings implements Serializable {
* @param value The value of entry to set
* @return a reference to this Builder
*/
public Builder withOpenapiGeneratorIgnoreList(String value) {
public Builder withOpenAPIGeneratorIgnoreList(String value) {
if (this.openapiGeneratorIgnoreList == null) {
this.openapiGeneratorIgnoreList = new HashSet<>();
}
@@ -1390,9 +1390,9 @@ public final class GeneratorSettings implements Serializable {
Objects.equals(getModelNameMappings(), that.getModelNameMappings()) &&
Objects.equals(getEnumNameMappings(), that.getEnumNameMappings()) &&
Objects.equals(getOperationIdNameMappings(), that.getOperationIdNameMappings()) &&
Objects.equals(getOpenapiNormalizer(), that.getOpenapiNormalizer()) &&
Objects.equals(getOpenAPINormalizer(), that.getOpenAPINormalizer()) &&
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
Objects.equals(getOpenapiGeneratorIgnoreList(), that.getOpenapiGeneratorIgnoreList()) &&
Objects.equals(getOpenAPIGeneratorIgnoreList(), that.getOpenAPIGeneratorIgnoreList()) &&
Objects.equals(getReservedWordsMappings(), that.getReservedWordsMappings()) &&
Objects.equals(getGitHost(), that.getGitHost()) &&
Objects.equals(getGitUserId(), that.getGitUserId()) &&
@@ -1428,9 +1428,9 @@ public final class GeneratorSettings implements Serializable {
getModelNameMappings(),
getEnumNameMappings(),
getOperationIdNameMappings(),
getOpenapiNormalizer(),
getOpenAPINormalizer(),
getLanguageSpecificPrimitives(),
getOpenapiGeneratorIgnoreList(),
getOpenAPIGeneratorIgnoreList(),
getReservedWordsMappings(),
getGitHost(),
getGitUserId(),
@@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
[source,group]
----
plugins {
id "org.openapi.generator" version "7.5.0"
id "org.openapi.generator" version "7.2.0"
}
----
@@ -1,5 +1,5 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.6.0-SNAPSHOT
openApiGeneratorVersion=7.5.0-SNAPSHOT
# /RELEASE_VERSION
# BEGIN placeholders
@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
@@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.6.0-SNAPSHOT
openApiGeneratorVersion=7.5.0-SNAPSHOT
# /RELEASE_VERSION
@@ -887,7 +887,7 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
if (openapiNormalizer.isPresent) {
openapiNormalizer.get().forEach { entry ->
configurator.addOpenapiNormalizer(entry.key, entry.value)
configurator.addOpenAPINormalizer(entry.key, entry.value)
}
}
@@ -917,7 +917,7 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
if (openapiGeneratorIgnoreList.isPresent) {
openapiGeneratorIgnoreList.get().forEach {
configurator.addOpenapiGeneratorIgnoreList(it)
configurator.addOpenAPIGeneratorIgnoreList(it)
}
}
@@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.5.0</version>
<version>7.2.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -15,7 +15,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -19,7 +19,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>
@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -20,7 +20,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -5,7 +5,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
@@ -829,7 +829,7 @@ public class CodeGenMojo extends AbstractMojo {
// Retained for backwards-compatibility with configOptions -> openapi-normalizer
if (openapiNormalizer == null && configOptions.containsKey("openapi-normalizer")) {
applyOpenapiNormalizerKvp(configOptions.get("openapi-normalizer").toString(),
applyOpenAPINormalizerKvp(configOptions.get("openapi-normalizer").toString(),
configurator);
}
@@ -846,7 +846,7 @@ public class CodeGenMojo extends AbstractMojo {
// Retained for backwards-compatibility with configOptions -> openapi-generator-ignore-list
if (openapiGeneratorIgnoreList == null && configOptions.containsKey("openapi-generator-ignore-list")) {
applyOpenapiGeneratorIgnoreListCsv(configOptions
applyOpenAPIGeneratorIgnoreListCsv(configOptions
.get("openapi-generator-ignore-list").toString(), configurator);
}
@@ -919,7 +919,7 @@ public class CodeGenMojo extends AbstractMojo {
// Apply OpenAPI normalizer rules
if (openapiNormalizer != null && (configOptions == null || !configOptions.containsKey("openapi-normalizer"))) {
applyOpenapiNormalizerKvpList(openapiNormalizer, configurator);
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
}
// Apply Type Mappings
@@ -936,7 +936,7 @@ public class CodeGenMojo extends AbstractMojo {
// Apply Language Specific Primitives
if (openapiGeneratorIgnoreList != null
&& (configOptions == null || !configOptions.containsKey("openapi-generator-ignore-list"))) {
applyOpenapiGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
applyOpenAPIGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
}
// Apply Additional Properties
+1 -1
View File
@@ -54,4 +54,4 @@ The `GENERATOR_HOST` variable is used here to ensure download links generated by
## Environment
`GENERATOR_HOST` can be set to force the scheme/host/port used for download link generation. In most cases, this environment variable is not
necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback.
necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback.
+1 -1
View File
@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
+1 -1
View File
@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.6.0-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
@@ -358,8 +358,8 @@ public interface CodegenConfig {
boolean getAddSuffixToDuplicateOperationNicknames();
boolean getUseOpenapiNormalizer();
boolean getUseOpenAPINormalizer();
Set<String> getOpenapiGeneratorIgnoreList();
Set<String> getOpenAPIGeneratorIgnoreList();
}
@@ -442,8 +442,6 @@ public class CodegenConstants {
public static final String GENERATE_MARSHAL_JSON = "generateMarshalJSON";
public static final String GENERATE_MARSHAL_JSON_DESC = "Generate MarshalJSON method";
public static final String GENERATE_UNMARSHAL_JSON = "generateUnmarshalJSON";
public static final String GENERATE_UNMARSHAL_JSON_DESC = "Generate UnmarshalJSON method";
public static final String MAX_ATTEMPTS_FOR_RETRY = "maxAttemptsForRetry";
public static final String WAIT_TIME_OF_THREAD = "waitTimeMillis";
@@ -707,7 +707,7 @@ public class DefaultCodegen implements CodegenConfig {
* Removes importToRemove from the imports of objs, if present.
* This is useful to remove imports that are already present in operations-related template files, to avoid importing the same thing twice.
*
* @param objs imports will be removed from this objs' imports collection
* @param objs imports will be removed from this objs' imports collection
* @param importToRemove the import statement to be removed
*/
protected void removeImport(OperationsMap objs, String importToRemove) {
@@ -2302,7 +2302,7 @@ public class DefaultCodegen implements CodegenConfig {
* Any non-null value will cause {{#defaultValue} check to pass.
*
* @param codegenProperty Codegen Property
* @param schema Parameter schema
* @param schema Parameter schema
* @return string presentation of the default value of the parameter
*/
public String toDefaultParameterValue(CodegenProperty codegenProperty, Schema<?> schema) {
@@ -2329,7 +2329,7 @@ public class DefaultCodegen implements CodegenConfig {
* Return null if you do NOT want a default value.
* Any non-null value will cause {{#defaultValue} check to pass.
*
* @param schema Property schema
* @param schema Property schema
* @param codegenProperty Codegen property
* @return string presentation of the default value of the property
*/
@@ -2372,6 +2372,7 @@ public class DefaultCodegen implements CodegenConfig {
}
protected Schema<?> getSchemaAdditionalProperties(Schema schema) {
Schema<?> inner = ModelUtils.getAdditionalProperties(schema);
if (inner == null) {
@@ -3008,7 +3009,6 @@ public class DefaultCodegen implements CodegenConfig {
/**
* A method that allows generators to pre-process test example payloads
* This can be useful if one needs to change how values like null in string are represented
*
* @param data the test data payload
* @return the updated test data payload
*/
@@ -3019,7 +3019,6 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Processes any test cases if they exist in the components.x-test-examples vendor extensions
* If they exist then cast them to java class instances and return them back in a map
*
* @param refToTestCases the component schema name that the test cases are for
*/
private HashMap<String, SchemaTestCase> extractSchemaTestCases(String refToTestCases) {
@@ -3056,7 +3055,7 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Sets the booleans that define the model's type
*
* @param model the model to update
* @param model the model to update
* @param schema the model's schema
*/
protected void updateModelForString(CodegenModel model, Schema schema) {
@@ -3314,6 +3313,7 @@ public class DefaultCodegen implements CodegenConfig {
* @param sc The Schema that may contain the discriminator
* @param discPropName The String that is the discriminator propertyName in the schema
* @param visitedSchemas A set of visited schema names
*
*/
private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc, String discPropName, Set<String> visitedSchemas) {
if (visitedSchemas.contains(composedSchemaName)) { // recursive schema definition found
@@ -3400,7 +3400,7 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Recursively look in Schema sc for the discriminator and return it
*
* @param sc The Schema that may contain the discriminator
* @param sc The Schema that may contain the discriminator
* @param visitedSchemas An array list of visited schemas
*/
private Discriminator recursiveGetDiscriminator(Schema sc, ArrayList<Schema> visitedSchemas) {
@@ -3620,9 +3620,9 @@ public class DefaultCodegen implements CodegenConfig {
Map<String, Object> vendorExtensions = cs.getExtensions();
String mappingName =
Optional.ofNullable(vendorExtensions)
.map(ve -> ve.get("x-discriminator-value"))
.map(discriminatorValue -> (String) discriminatorValue)
.orElse(currentSchemaName);
.map(ve -> ve.get("x-discriminator-value"))
.map(discriminatorValue -> (String) discriminatorValue)
.orElse(currentSchemaName);
MappedModel mm = new MappedModel(mappingName, toModelName(currentSchemaName), !mappingName.equals(currentSchemaName));
descendentSchemas.add(mm);
}
@@ -3649,11 +3649,11 @@ public class DefaultCodegen implements CodegenConfig {
// the future..
String propertyType =
Optional.ofNullable(schema.getProperties())
.map(p -> (Schema<?>) p.get(discriminatorPropertyName))
.map(Schema::get$ref)
.map(ModelUtils::getSimpleRef)
.map(this::toModelName)
.orElseGet(() -> typeMapping.get("string"));
.map(p -> (Schema<?>) p.get(discriminatorPropertyName))
.map(Schema::get$ref)
.map(ModelUtils::getSimpleRef)
.map(this::toModelName)
.orElseGet(() -> typeMapping.get("string"));
discriminator.setPropertyType(propertyType);
// check to see if the discriminator property is an enum string
@@ -3944,8 +3944,8 @@ public class DefaultCodegen implements CodegenConfig {
* This method was kept when required was added to the fromProperty signature
* to ensure that the change was non-breaking
*
* @param name name of the property
* @param p OAS property schema
* @param name name of the property
* @param p OAS property schema
* @return Codegen Property object
*/
public CodegenProperty fromProperty(String name, Schema p) {
@@ -3961,9 +3961,9 @@ public class DefaultCodegen implements CodegenConfig {
* Any subsequent processing of the CodegenModel return value must be idempotent
* for a given (String name, Schema schema).
*
* @param name name of the property
* @param p OAS property schema
* @param required true if the property is required in the next higher object schema, false otherwise
* @param name name of the property
* @param p OAS property schema
* @param required true if the property is required in the next higher object schema, false otherwise
* @param schemaIsFromAdditionalProperties true if the property is a required property defined by additional properties schema
* If this is the actual additionalProperties schema not defining a required property, then
* the value should be false
@@ -4742,8 +4742,8 @@ public class DefaultCodegen implements CodegenConfig {
if (contentType != null) {
contentType = contentType.toLowerCase(Locale.ROOT);
}
if (contentType != null &&
((!(this instanceof RustAxumServerCodegen) && contentType.startsWith("application/x-www-form-urlencoded")) ||
if (!(this instanceof RustAxumServerCodegen) && contentType != null &&
(contentType.startsWith("application/x-www-form-urlencoded") ||
contentType.startsWith("multipart"))) {
// process form parameters
formParams = fromRequestBodyToFormParameters(requestBody, imports);
@@ -5909,10 +5909,10 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Add the model name of the child schema in a composed schema to the set of imports
*
* @param composed composed schema
* @param composed composed schema
* @param childSchema composed schema
* @param model codegen model
* @param modelName model name
* @param model codegen model
* @param modelName model name
*/
protected void addImport(Schema composed, Schema childSchema, CodegenModel model, String modelName) {
if (composed == null || childSchema == null) {
@@ -6795,12 +6795,12 @@ public class DefaultCodegen implements CodegenConfig {
String enumValue = isDataTypeString(dataType)
? enumUnknownDefaultCaseName
: // This is a dummy value that attempts to avoid collisions with previously specified cases.
// Int.max / 192
// The number 192 that is used to calculate this random value, is the Swift Evolution proposal for frozen/non-frozen enums.
// [SE-0192](https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md)
// Since this functionality was born in the Swift 5 generator and latter on broth to all generators
// https://github.com/OpenAPITools/openapi-generator/pull/11013
String.valueOf(11184809);
// Int.max / 192
// The number 192 that is used to calculate this random value, is the Swift Evolution proposal for frozen/non-frozen enums.
// [SE-0192](https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md)
// Since this functionality was born in the Swift 5 generator and latter on broth to all generators
// https://github.com/OpenAPITools/openapi-generator/pull/11013
String.valueOf(11184809);
enumVar.put("name", toEnumVarName(enumName, dataType));
enumVar.put("value", toEnumValue(enumValue, dataType));
@@ -7984,7 +7984,6 @@ public class DefaultCodegen implements CodegenConfig {
protected String getAdditionalPropertiesName() {
return "additional_properties";
}
private void addJsonSchemaForBodyRequestInCaseItsNotPresent(CodegenParameter codegenParameter, RequestBody body) {
if (codegenParameter.jsonSchema == null)
codegenParameter.jsonSchema = Json.pretty(body);
@@ -8251,8 +8250,8 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Add a given ComposedSchema as an interface model to be generated, assuming it has `oneOf` defined
*
* @param cs ComposedSchema object to create as interface model
* @param type name to use for the generated interface model
* @param cs ComposedSchema object to create as interface model
* @param type name to use for the generated interface model
*/
public void addOneOfInterfaceModel(Schema cs, String type) {
if (cs.getOneOf() == null) {
@@ -8442,7 +8441,7 @@ public class DefaultCodegen implements CodegenConfig {
// in other sub-schemas of allOf/anyOf/oneOf
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type", true);
} else {
if (isTypeErasedGenerics()) {
if(isTypeErasedGenerics()) {
dataTypeSet.add(cp.baseType);
} else {
dataTypeSet.add(cp.dataType);
@@ -8473,17 +8472,13 @@ public class DefaultCodegen implements CodegenConfig {
}
@Override
public boolean getUseInlineModelResolver() {
return true;
}
public boolean getUseInlineModelResolver() { return true; }
@Override
public boolean getUseOpenapiNormalizer() {
return true;
}
public boolean getUseOpenAPINormalizer() { return true; }
@Override
public Set<String> getOpenapiGeneratorIgnoreList() {
public Set<String> getOpenAPIGeneratorIgnoreList() {
return openapiGeneratorIgnoreList;
}
@@ -8497,9 +8492,7 @@ public class DefaultCodegen implements CodegenConfig {
And convert special characters like newline, tab, carriage return
Into strings that can be rendered in the language that the generator will output to
*/
protected String handleSpecialCharacters(String name) {
return name;
}
protected String handleSpecialCharacters(String name) { return name; }
/**
* Used to ensure that null or Schema is returned given an input Boolean/Schema/null
@@ -265,7 +265,7 @@ public class DefaultGenerator implements Generator {
// normalize the spec
try {
if (config.getUseOpenapiNormalizer()) {
if (config.getUseOpenAPINormalizer()) {
SemVer version = new SemVer(openAPI.getOpenapi());
if (version.atLeast("3.1.0")) {
config.openapiNormalizer().put("NORMALIZE_31SPEC", "true");
@@ -292,11 +292,13 @@ public class DefaultGenerator implements Generator {
// set OpenAPI to make these available to all methods
config.setOpenAPI(openAPI);
config.additionalProperties().putIfAbsent("generatorVersion", ImplementationVersion.read());
config.additionalProperties().putIfAbsent("generatedDate", ZonedDateTime.now().toString());
config.additionalProperties().putIfAbsent("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
config.additionalProperties().putIfAbsent("generatorClass", config.getClass().getName());
config.additionalProperties().putIfAbsent("inputSpec", config.getInputSpec());
if (!config.additionalProperties().containsKey("generatorVersion")) {
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
}
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
config.additionalProperties().put("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
config.additionalProperties().put("generatorClass", config.getClass().getName());
config.additionalProperties().put("inputSpec", config.getInputSpec());
if (openAPI.getExtensions() != null) {
config.vendorExtensions().putAll(openAPI.getExtensions());
@@ -320,59 +322,59 @@ public class DefaultGenerator implements Generator {
return;
}
if (info.getTitle() != null) {
config.additionalProperties().putIfAbsent("appName", config.escapeText(info.getTitle()));
config.additionalProperties().put("appName", config.escapeText(info.getTitle()));
}
if (info.getVersion() != null) {
config.additionalProperties().putIfAbsent("appVersion", config.escapeText(info.getVersion()));
config.additionalProperties().put("appVersion", config.escapeText(info.getVersion()));
} else {
LOGGER.error("Missing required field info version. Default appVersion set to 1.0.0");
config.additionalProperties().putIfAbsent("appVersion", "1.0.0");
config.additionalProperties().put("appVersion", "1.0.0");
}
if (StringUtils.isEmpty(info.getDescription())) {
// set a default description if none if provided
config.additionalProperties().putIfAbsent("appDescription",
config.additionalProperties().put("appDescription",
"No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
config.additionalProperties().putIfAbsent("appDescriptionWithNewLines", config.additionalProperties().get("appDescription"));
config.additionalProperties().putIfAbsent("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
config.additionalProperties().put("appDescriptionWithNewLines", config.additionalProperties().get("appDescription"));
config.additionalProperties().put("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
} else {
config.additionalProperties().putIfAbsent("appDescription", config.escapeText(info.getDescription()));
config.additionalProperties().putIfAbsent("appDescriptionWithNewLines", config.escapeTextWhileAllowingNewLines(info.getDescription()));
config.additionalProperties().putIfAbsent("unescapedAppDescription", info.getDescription());
config.additionalProperties().put("appDescription", config.escapeText(info.getDescription()));
config.additionalProperties().put("appDescriptionWithNewLines", config.escapeTextWhileAllowingNewLines(info.getDescription()));
config.additionalProperties().put("unescapedAppDescription", info.getDescription());
}
if (info.getContact() != null) {
Contact contact = info.getContact();
if (contact.getEmail() != null) {
config.additionalProperties().putIfAbsent("infoEmail", config.escapeText(contact.getEmail()));
config.additionalProperties().put("infoEmail", config.escapeText(contact.getEmail()));
}
if (contact.getName() != null) {
config.additionalProperties().putIfAbsent("infoName", config.escapeText(contact.getName()));
config.additionalProperties().put("infoName", config.escapeText(contact.getName()));
}
if (contact.getUrl() != null) {
config.additionalProperties().putIfAbsent("infoUrl", config.escapeText(contact.getUrl()));
config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl()));
}
}
if (info.getLicense() != null) {
License license = info.getLicense();
if (license.getName() != null) {
config.additionalProperties().putIfAbsent("licenseInfo", config.escapeText(license.getName()));
config.additionalProperties().put("licenseInfo", config.escapeText(license.getName()));
}
if (license.getUrl() != null) {
config.additionalProperties().putIfAbsent("licenseUrl", config.escapeText(license.getUrl()));
config.additionalProperties().put("licenseUrl", config.escapeText(license.getUrl()));
}
}
if (info.getVersion() != null) {
config.additionalProperties().putIfAbsent("version", config.escapeText(info.getVersion()));
config.additionalProperties().put("version", config.escapeText(info.getVersion()));
} else {
LOGGER.error("Missing required field info version. Default version set to 1.0.0");
config.additionalProperties().putIfAbsent("version", "1.0.0");
config.additionalProperties().put("version", "1.0.0");
}
if (info.getTermsOfService() != null) {
config.additionalProperties().putIfAbsent("termsOfService", config.escapeText(info.getTermsOfService()));
config.additionalProperties().put("termsOfService", config.escapeText(info.getTermsOfService()));
}
}
@@ -927,8 +929,8 @@ public class DefaultGenerator implements Generator {
/*
* Generate .openapi-generator-ignore if the option openapiGeneratorIgnoreFile is enabled.
*/
private void generateOpenapiGeneratorIgnoreFile() {
if (config.getOpenapiGeneratorIgnoreList() == null || config.getOpenapiGeneratorIgnoreList().isEmpty()) {
private void generateOpenAPIGeneratorIgnoreFile() {
if (config.getOpenAPIGeneratorIgnoreList() == null || config.getOpenAPIGeneratorIgnoreList().isEmpty()) {
return;
}
@@ -980,7 +982,7 @@ public class DefaultGenerator implements Generator {
Writer fileWriter = Files.newBufferedWriter(ignoreFile.toPath(), StandardCharsets.UTF_8);
fileWriter.write(header);
// add entries provided by the users
for (String entry : config.getOpenapiGeneratorIgnoreList()) {
for (String entry : config.getOpenAPIGeneratorIgnoreList()) {
fileWriter.write(entry);
fileWriter.write("\n");
}
@@ -1217,7 +1219,7 @@ public class DefaultGenerator implements Generator {
processUserDefinedTemplates();
// generate .openapi-generator-ignore if the option openapiGeneratorIgnoreFile is enabled
generateOpenapiGeneratorIgnoreFile();
generateOpenAPIGeneratorIgnoreFile();
List<File> files = new ArrayList<>();
// models
@@ -770,8 +770,9 @@ public class InlineModelResolver {
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
String key = propertiesEntry.getKey();
Schema property = propertiesEntry.getValue();
if (ModelUtils.isObjectSchema(property)) {
Schema op = property;
if (property instanceof ObjectSchema && ((ObjectSchema) property).getProperties() != null
&& ((ObjectSchema) property).getProperties().size() > 0) {
ObjectSchema op = (ObjectSchema) property;
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
Schema model = modelFromProperty(openAPI, op, modelName);
String existing = matchGenerated(model);
@@ -788,8 +789,8 @@ public class InlineModelResolver {
}
} else if (ModelUtils.isArraySchema(property)) {
Schema inner = ModelUtils.getSchemaItems(property);
if (ModelUtils.isObjectSchema(inner)) {
Schema op = inner;
if (inner instanceof ObjectSchema) {
ObjectSchema op = (ObjectSchema) inner;
if (op.getProperties() != null && op.getProperties().size() > 0) {
flattenProperties(openAPI, op.getProperties(), path);
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
@@ -818,8 +819,8 @@ public class InlineModelResolver {
}
} else if (ModelUtils.isMapSchema(property)) {
Schema inner = ModelUtils.getAdditionalProperties(property);
if (ModelUtils.isObjectSchema(inner)) {
Schema op = inner;
if (inner instanceof ObjectSchema) {
ObjectSchema op = (ObjectSchema) inner;
if (op.getProperties() != null && op.getProperties().size() > 0) {
flattenProperties(openAPI, op.getProperties(), path);
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
@@ -890,7 +890,7 @@ public class OpenAPINormalizer {
if (schema.getTypes() != null && !schema.getTypes().isEmpty()) {
// 3.1 spec
if (schema.getTypes().size() == 1) { // 1 type only
if (schema.getTypes().size() ==1) { // 1 type only
String type = (String) schema.getTypes().iterator().next();
return type == null || "null".equals(type);
} else { // more than 1 type so must not be just null
@@ -902,11 +902,6 @@ public class OpenAPINormalizer {
if (Boolean.TRUE.equals(schema.getNullable())) {
return true;
}
// for `type: null`
if (schema.getTypes() == null && schema.get$ref() == null) {
return true;
}
} else { // 3.0.x or 2.x spec
if ((schema.getType() == null || schema.getType().equals("null")) && schema.get$ref() == null) {
return true;
@@ -943,7 +938,7 @@ public class OpenAPINormalizer {
if (oneOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: oneOfSchemas) {
ts.add(ModelUtils.getType(s));
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
@@ -1068,7 +1063,7 @@ public class OpenAPINormalizer {
if (anyOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: anyOfSchemas) {
ts.add(ModelUtils.getType(s));
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
@@ -145,14 +145,14 @@ public class CodegenConfigurator {
if(generatorSettings.getOperationIdNameMappings() != null) {
configurator.operationIdNameMappings.putAll(generatorSettings.getOperationIdNameMappings());
}
if(generatorSettings.getOpenapiNormalizer() != null) {
configurator.openapiNormalizer.putAll(generatorSettings.getOpenapiNormalizer());
if(generatorSettings.getOpenAPINormalizer() != null) {
configurator.openapiNormalizer.putAll(generatorSettings.getOpenAPINormalizer());
}
if(generatorSettings.getLanguageSpecificPrimitives() != null) {
configurator.languageSpecificPrimitives.addAll(generatorSettings.getLanguageSpecificPrimitives());
}
if(generatorSettings.getOpenapiGeneratorIgnoreList() != null) {
configurator.openapiGeneratorIgnoreList.addAll(generatorSettings.getOpenapiGeneratorIgnoreList());
if(generatorSettings.getOpenAPIGeneratorIgnoreList() != null) {
configurator.openapiGeneratorIgnoreList.addAll(generatorSettings.getOpenAPIGeneratorIgnoreList());
}
if(generatorSettings.getReservedWordsMappings() != null) {
configurator.reservedWordsMappings.putAll(generatorSettings.getReservedWordsMappings());
@@ -268,9 +268,9 @@ public class CodegenConfigurator {
return this;
}
public CodegenConfigurator addOpenapiNormalizer(String key, String value) {
public CodegenConfigurator addOpenAPINormalizer(String key, String value) {
this.openapiNormalizer.put(key, value);
generatorSettingsBuilder.withOpenapiNormalizer(key, value);
generatorSettingsBuilder.withOpenAPINormalizer(key, value);
return this;
}
@@ -286,9 +286,9 @@ public class CodegenConfigurator {
return this;
}
public CodegenConfigurator addOpenapiGeneratorIgnoreList(String value) {
public CodegenConfigurator addOpenAPIGeneratorIgnoreList(String value) {
this.openapiGeneratorIgnoreList.add(value);
generatorSettingsBuilder.withOpenapiGeneratorIgnoreList(value);
generatorSettingsBuilder.withOpenAPIGeneratorIgnoreList(value);
return this;
}
@@ -482,9 +482,9 @@ public class CodegenConfigurator {
return this;
}
public CodegenConfigurator setOpenapiNormalizer(Map<String, String> openapiNormalizer) {
public CodegenConfigurator setOpenAPINormalizer(Map<String, String> openapiNormalizer) {
this.openapiNormalizer = openapiNormalizer;
generatorSettingsBuilder.withOpenapiNormalizer(openapiNormalizer);
generatorSettingsBuilder.withOpenAPINormalizer(openapiNormalizer);
return this;
}
@@ -515,10 +515,10 @@ public class CodegenConfigurator {
return this;
}
public CodegenConfigurator setOpenapiGeneratorIgnoreList(
public CodegenConfigurator setOpenAPIGeneratorIgnoreList(
Set<String> openapiGeneratorIgnoreList) {
this.openapiGeneratorIgnoreList = openapiGeneratorIgnoreList;
generatorSettingsBuilder.withOpenapiGeneratorIgnoreList(openapiGeneratorIgnoreList);
generatorSettingsBuilder.withOpenAPIGeneratorIgnoreList(openapiGeneratorIgnoreList);
return this;
}
@@ -779,9 +779,9 @@ public class CodegenConfigurator {
config.modelNameMapping().putAll(generatorSettings.getModelNameMappings());
config.enumNameMapping().putAll(generatorSettings.getEnumNameMappings());
config.operationIdNameMapping().putAll(generatorSettings.getOperationIdNameMappings());
config.openapiNormalizer().putAll(generatorSettings.getOpenapiNormalizer());
config.openapiNormalizer().putAll(generatorSettings.getOpenAPINormalizer());
config.languageSpecificPrimitives().addAll(generatorSettings.getLanguageSpecificPrimitives());
config.openapiGeneratorIgnoreList().addAll(generatorSettings.getOpenapiGeneratorIgnoreList());
config.openapiGeneratorIgnoreList().addAll(generatorSettings.getOpenAPIGeneratorIgnoreList());
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordsMappings());
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
@@ -185,16 +185,16 @@ public final class CodegenConfiguratorUtils {
}
}
public static void applyOpenapiNormalizerKvpList(List<String> openapiNormalizer, CodegenConfigurator configurator) {
public static void applyOpenAPINormalizerKvpList(List<String> openapiNormalizer, CodegenConfigurator configurator) {
for (String propString : openapiNormalizer) {
applyOpenapiNormalizerKvp(propString, configurator);
applyOpenAPINormalizerKvp(propString, configurator);
}
}
public static void applyOpenapiNormalizerKvp(String openapiNormalizer, CodegenConfigurator configurator) {
public static void applyOpenAPINormalizerKvp(String openapiNormalizer, CodegenConfigurator configurator) {
final Map<String, String> map = createMapFromKeyValuePairs(openapiNormalizer);
for (Map.Entry<String, String> entry : map.entrySet()) {
configurator.addOpenapiNormalizer(entry.getKey().trim(), entry.getValue().trim());
configurator.addOpenAPINormalizer(entry.getKey().trim(), entry.getValue().trim());
}
}
@@ -250,16 +250,16 @@ public final class CodegenConfiguratorUtils {
}
}
public static void applyOpenapiGeneratorIgnoreListCsvList(List<String> openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
public static void applyOpenAPIGeneratorIgnoreListCsvList(List<String> openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
for (String propString : openapiGeneratorIgnoreList) {
applyOpenapiGeneratorIgnoreListCsv(propString, configurator);
applyOpenAPIGeneratorIgnoreListCsv(propString, configurator);
}
}
public static void applyOpenapiGeneratorIgnoreListCsv(String openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
public static void applyOpenAPIGeneratorIgnoreListCsv(String openapiGeneratorIgnoreList, CodegenConfigurator configurator) {
final Set<String> set = createSetFromCsvList(openapiGeneratorIgnoreList);
for (String item : set) {
configurator.addOpenapiGeneratorIgnoreList(item);
configurator.addOpenAPIGeneratorIgnoreList(item);
}
}
@@ -585,7 +585,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
List<CodegenProperty> allOf = composedSchemas.getAllOf();
if (allOf != null) {
for (CodegenProperty property : allOf) {
property.name = patchPropertyName(model, camelize(property.baseType));
property.name = patchPropertyName(model, property.baseType);
patchPropertyVendorExtensions(property);
}
}
@@ -594,7 +594,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (anyOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, anyOf);
for (CodegenProperty property : anyOf) {
property.name = patchPropertyName(model, camelize(property.baseType));
property.name = patchPropertyName(model, property.baseType);
property.isNullable = true;
patchPropertyVendorExtensions(property);
}
@@ -604,7 +604,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (oneOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, oneOf);
for (CodegenProperty property : oneOf) {
property.name = patchPropertyName(model, camelize(property.baseType));
property.name = patchPropertyName(model, property.baseType);
property.isNullable = true;
patchPropertyVendorExtensions(property);
}
@@ -48,8 +48,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
protected boolean generateInterfaces = false;
protected boolean withGoMod = false;
protected boolean generateMarshalJSON = true;
protected boolean generateUnmarshalJSON = true;
protected String packageName = "openapi";
protected Set<String> numberTypes;
@@ -777,11 +775,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
}
if (generateMarshalJSON) {
model.vendorExtensions.putIfAbsent("x-go-generate-marshal-json", true);
}
if (generateUnmarshalJSON) {
model.vendorExtensions.putIfAbsent("x-go-generate-unmarshal-json", true);
model.vendorExtensions.put("x-go-generate-marshal-json", true);
}
}
@@ -938,10 +932,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
this.generateMarshalJSON = generateMarshalJSON;
}
public void setGenerateUnmarshalJSON(boolean generateUnmarshalJSON) {
this.generateUnmarshalJSON = generateUnmarshalJSON;
}
@Override
public String toDefaultValue(Schema schema) {
schema = unaliasSchema(schema);
@@ -192,7 +192,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
"ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil",
// language reserved words
"_", "abstract", "continue", "for", "new", "switch", "assert",
"abstract", "continue", "for", "new", "switch", "assert",
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
@@ -999,10 +999,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return getNumberBeanValidation(items);
}
if (ModelUtils.isLongSchema(items)) {
return getLongBeanValidation(items);
}
if (ModelUtils.isIntegerSchema(items)) {
return getIntegerBeanValidation(items);
}
@@ -1025,21 +1021,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return "";
}
private String getLongBeanValidation(Schema<?> items) {
if (items.getMinimum() != null && items.getMaximum() != null) {
return String.format(Locale.ROOT, "@Min(%sL) @Max(%sL)", items.getMinimum(), items.getMaximum());
}
if (items.getMinimum() != null) {
return String.format(Locale.ROOT, "@Min(%sL)", items.getMinimum());
}
if (items.getMaximum() != null) {
return String.format(Locale.ROOT, "@Max(%sL)", items.getMaximum());
}
return "";
}
private String getNumberBeanValidation(Schema<?> items) {
if (items.getMinimum() != null && items.getMaximum() != null) {
return String.format(Locale.ROOT, "@DecimalMin(value = \"%s\", inclusive = %s) @DecimalMax(value = \"%s\", inclusive = %s)",
@@ -1927,9 +1908,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// string
String var = value.replaceAll("\\W+", "_").toUpperCase(Locale.ROOT);
if (var.matches("\\d.*")) {
var = "_" + var;
return "_" + var;
} else {
return var;
}
return this.toVarName(var);
}
@Override
@@ -683,11 +683,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
*/
@Override
public String toModelName(final String name) {
// obtain the name from modelNameMapping directly if provided
if (modelNameMapping.containsKey(name)) {
return modelNameMapping.get(name);
}
// memoization
if (schemaKeyToModelNameCache.containsKey(name)) {
return schemaKeyToModelNameCache.get(name);
@@ -906,7 +901,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
} else if ("kotlin.Float".equals(datatype)) {
return value + "f";
} else {
return "\"" + value + "\"";
return "\"" + escapeText(value) + "\"";
}
}
@@ -1000,11 +1000,6 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
// set the extensions if the key is absent
model.getVendorExtensions().putIfAbsent("x-py-readonly", readOnlyFields);
// remove the items of postponedModelImports in modelImports to avoid circular imports error
if (!modelImports.isEmpty() && !postponedModelImports.isEmpty()){
modelImports.removeAll(postponedModelImports);
}
// import models one by one
if (!modelImports.isEmpty()) {
Set<String> modelsToImport = new TreeSet<>();
@@ -1002,11 +1002,6 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
model.getVendorExtensions().putIfAbsent("x-py-datetime-imports", datetimeImports);
model.getVendorExtensions().putIfAbsent("x-py-readonly", readOnlyFields);
// remove the items of postponedModelImports in modelImports to avoid circular imports error
if (!modelImports.isEmpty() && !postponedModelImports.isEmpty()){
modelImports.removeAll(postponedModelImports);
}
// import models one by one
if (!modelImports.isEmpty()) {
Set<String> modelsToImport = new TreeSet<>();
@@ -111,8 +111,6 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
.excludeParameterFeatures(
ParameterFeature.Cookie
)
.includeDataTypeFeatures(
DataTypeFeature.AnyType)
);
apiPackage = "org.openapitools.client.api";
@@ -176,7 +174,6 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
importMapping.put("std::string", "#include <string>");
importMapping.put("HttpContent", "#include \"HttpContent.h\"");
importMapping.put("Object", "#include \"Object.h\"");
importMapping.put("AnyType", "#include \"AnyType.h\"");
importMapping.put("utility::string_t", "#include <cpprest/details/basic_types.h>");
importMapping.put("utility::datetime", "#include <cpprest/details/basic_types.h>");
}
@@ -217,14 +214,11 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
importMapping.put("HttpContent", "#include \"" + packageName + "/" + "HttpContent.h\"");
importMapping.put("Object", "#include \"" + packageName + "/" + "Object.h\"");
importMapping.put("AnyType", "#include \"" + packageName + "/" + "AnyType.h\"");
supportingFiles.add(new SupportingFile("modelbase-header.mustache", getHeaderFolder(), "ModelBase.h"));
supportingFiles.add(new SupportingFile("modelbase-source.mustache", getSourceFolder(), "ModelBase.cpp"));
supportingFiles.add(new SupportingFile("object-header.mustache", getHeaderFolder(), "Object.h"));
supportingFiles.add(new SupportingFile("object-source.mustache", getSourceFolder(), "Object.cpp"));
supportingFiles.add(new SupportingFile("anytype-header.mustache", getHeaderFolder(), "AnyType.h"));
supportingFiles.add(new SupportingFile("anytype-source.mustache", getSourceFolder(), "AnyType.cpp"));
supportingFiles.add(new SupportingFile("apiclient-header.mustache", getHeaderFolder(), "ApiClient.h"));
supportingFiles.add(new SupportingFile("apiclient-source.mustache", getSourceFolder(), "ApiClient.cpp"));
supportingFiles.add(new SupportingFile("apiconfiguration-header.mustache", getHeaderFolder(), "ApiConfiguration.h"));
@@ -150,7 +150,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
this.setDisallowAdditionalPropertiesIfNotPresent(true);
cliOptions.add(CliOption.newBoolean(WITH_GO_MOD, "Generate go.mod and go.sum", true));
cliOptions.add(CliOption.newBoolean(CodegenConstants.GENERATE_MARSHAL_JSON, CodegenConstants.GENERATE_MARSHAL_JSON_DESC, true));
cliOptions.add(CliOption.newBoolean(CodegenConstants.GENERATE_UNMARSHAL_JSON, CodegenConstants.GENERATE_UNMARSHAL_JSON_DESC, true));
this.setWithGoMod(true);
}
@@ -288,11 +287,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
setGenerateMarshalJSON(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.GENERATE_MARSHAL_JSON).toString()));
}
if (additionalProperties.containsKey(CodegenConstants.GENERATE_UNMARSHAL_JSON)) {
setGenerateUnmarshalJSON(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.GENERATE_UNMARSHAL_JSON).toString()));
}
// add lambda for mustache templates to handle oneOf/anyOf naming
// e.g. []string => ArrayOfString
additionalProperties.put("lambda.type-to-name", (Mustache.Lambda) (fragment, writer) -> writer.write(typeToName(fragment.execute())));
@@ -333,14 +333,13 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
/**
* Internal method to set the generateToSchema parameter.
* <p>
*
* Basically we're generating ToSchema instances (generically) for all schemas.
* However, if any of the contained datatypes doesn't have the ToSchema instance,
* we cannot generate it for its "ancestor" type.
* This is the case with the "Data.Aeson.Value" type: it doesn't (and cannot) have
* a Swagger-compatible ToSchema instance. So we have to detect its presence "downstream"
* the current schema, and if we find it we just don't generate any ToSchema instance.
*
* @param model
*/
private void setGenerateToSchema(CodegenModel model) {
@@ -357,7 +356,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
List<CodegenModel> children = model.getChildren();
if (children != null) {
for (CodegenModel child : children) {
for(CodegenModel child : children) {
setGenerateToSchema(child);
}
}
@@ -513,7 +512,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// Query parameters appended to routes
for (CodegenParameter param : op.queryParams) {
String paramType = param.dataType;
if ("application/json".equals(param.contentType)) {
if (param.contentType == "application/json") {
if (param.isArray) {
paramType = "[JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + "]";
} else {
@@ -555,7 +554,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
path.add("Header \"" + param.baseName + "\" " + param.dataType);
String paramType = param.dataType;
if ("application/json".equals(param.contentType)) {
if (param.contentType == "application/json") {
if (param.isArray) {
paramType = "(JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + ")";
} else {
@@ -722,7 +721,5 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
}
@Override
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.HASKELL;
}
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.HASKELL; }
}
@@ -182,10 +182,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
.includeDocumentationFeatures(DocumentationFeature.Readme)
.includeGlobalFeatures(GlobalFeature.ParameterizedServer)
.includeSecurityFeatures(SecurityFeature.OAuth2_AuthorizationCode,
SecurityFeature.OAuth2_ClientCredentials,
SecurityFeature.OAuth2_Password,
SecurityFeature.SignatureAuth,//jersey only
SecurityFeature.AWSV4Signature)//okhttp-gson only
SecurityFeature.OAuth2_ClientCredentials,
SecurityFeature.OAuth2_Password,
SecurityFeature.SignatureAuth,//jersey only
SecurityFeature.AWSV4Signature)//okhttp-gson only
);
outputFolder = "generated-code" + File.separator + "java";
@@ -222,7 +222,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming));
cliOptions.add(CliOption.newBoolean(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT, CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT_DESC + " (only available for okhttp-gson library)", this.withAWSV4Signature));
cliOptions.add(CliOption.newString(GRADLE_PROPERTIES, "Append additional Gradle properties to the gradle.properties file"));
cliOptions.add(CliOption.newString(ERROR_OBJECT_TYPE, "Error Object type. (This option is for okhttp-gson only)"));
cliOptions.add(CliOption.newString(ERROR_OBJECT_TYPE, "Error Object type. (This option is for okhttp-gson-next-gen only)"));
cliOptions.add(CliOption.newString(CONFIG_KEY, "Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option."));
cliOptions.add(CliOption.newBoolean(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC + " Only jersey2, jersey3, native, okhttp-gson support this option."));
cliOptions.add(CliOption.newString(MICROPROFILE_REST_CLIENT_VERSION, "Version of MicroProfile Rest Client API."));
@@ -472,13 +472,15 @@ public class JavaClientCodegen extends AbstractJavaCodegen
if (additionalProperties.containsKey(CodegenConstants.MAX_ATTEMPTS_FOR_RETRY)) {
this.setMaxAttemptsForRetry(Integer.parseInt(additionalProperties.get(CodegenConstants.MAX_ATTEMPTS_FOR_RETRY).toString()));
} else {
}
else {
additionalProperties.put(CodegenConstants.MAX_ATTEMPTS_FOR_RETRY, maxAttemptsForRetry);
}
if (additionalProperties.containsKey(CodegenConstants.WAIT_TIME_OF_THREAD)) {
this.setWaitTimeMillis(Long.parseLong((additionalProperties.get(CodegenConstants.WAIT_TIME_OF_THREAD).toString())));
} else {
}
else {
additionalProperties.put(CodegenConstants.WAIT_TIME_OF_THREAD, waitTimeMillis);
}
writePropertyBack(USE_ENUM_CASE_INSENSITIVE, useEnumCaseInsensitive);
@@ -1262,11 +1264,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
public void setMaxAttemptsForRetry(int maxAttemptsForRetry) {
this.maxAttemptsForRetry = maxAttemptsForRetry;
this.maxAttemptsForRetry= maxAttemptsForRetry;
}
public void setWaitTimeMillis(long waitTimeMillis) {
this.waitTimeMillis = waitTimeMillis;
this.waitTimeMillis= waitTimeMillis;
}
/**
@@ -38,7 +38,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
public static final String GENERATE_POM = "generatePom";
public static final String USE_SWAGGER_ANNOTATIONS = "useSwaggerAnnotations";
public static final String USE_MICROPROFILE_OPENAPI_ANNOTATIONS = "useMicroProfileOpenAPIAnnotations";
public static final String USE_MUTINY = "useMutiny";
public static final String OPEN_API_SPEC_FILE_LOCATION = "openApiSpecFileLocation";
public static final String GENERATE_BUILDERS = "generateBuilders";
@@ -54,7 +53,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
private boolean generateBuilders = false;
private boolean useSwaggerAnnotations = true;
private boolean useMicroProfileOpenAPIAnnotations = false;
private boolean useMutiny = false;
protected boolean useGzipFeature = false;
private boolean useJackson = false;
@@ -122,7 +120,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
cliOptions.add(CliOption.newBoolean(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, "Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.", useMicroProfileOpenAPIAnnotations));
cliOptions.add(CliOption.newString(OPEN_API_SPEC_FILE_LOCATION, "Location where the file containing the spec will be generated in the output folder. No file generated when set to null or empty string."));
cliOptions.add(CliOption.newBoolean(SUPPORT_ASYNC, "Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).", supportAsync));
cliOptions.add(CliOption.newBoolean(USE_MUTINY, "Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.", useMutiny));
}
@Override
@@ -170,12 +167,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
writePropertyBack(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, useMicroProfileOpenAPIAnnotations);
}
if (QUARKUS_LIBRARY.equals(library)) {
if (additionalProperties.containsKey(USE_MUTINY)) {
useMutiny = Boolean.parseBoolean(additionalProperties.get(USE_MUTINY).toString());
}
writePropertyBack(USE_MUTINY, useMutiny);
}
if (additionalProperties.containsKey(GENERATE_BUILDERS)) {
generateBuilders = Boolean.parseBoolean(additionalProperties.get(GENERATE_BUILDERS).toString());
@@ -17,13 +17,11 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
@@ -673,10 +671,10 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
public void setParameterExampleValue(CodegenParameter p) {
String example;
if (p.example == null) {
example = p.defaultValue;
} else {
if (p.defaultValue == null) {
example = p.example;
} else {
example = p.defaultValue;
}
String type = p.baseType;
@@ -742,24 +740,6 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
p.example = example;
}
@Override
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
Schema schema = parameter.getSchema();
if (parameter.getExample() != null) {
codegenParameter.example = parameter.getExample().toString();
} else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
Example example = parameter.getExamples().values().iterator().next();
if (example.getValue() != null) {
codegenParameter.example = example.getValue().toString();
}
} else if (schema != null && schema.getExample() != null) {
codegenParameter.example = schema.getExample().toString();
}
setParameterExampleValue(codegenParameter);
}
protected String setPropertyExampleValue(CodegenProperty p) {
String example;
@@ -18,13 +18,11 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
@@ -673,10 +671,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
public void setParameterExampleValue(CodegenParameter p) {
String example;
if (p.example == null) {
example = p.defaultValue;
} else {
if (p.defaultValue == null) {
example = p.example;
} else {
example = p.defaultValue;
}
String type = p.baseType;
@@ -742,24 +740,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
p.example = example;
}
@Override
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
Schema schema = parameter.getSchema();
if (parameter.getExample() != null) {
codegenParameter.example = parameter.getExample().toString();
} else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
Example example = parameter.getExamples().values().iterator().next();
if (example.getValue() != null) {
codegenParameter.example = example.getValue().toString();
}
} else if (schema != null && schema.getExample() != null) {
codegenParameter.example = schema.getExample().toString();
}
setParameterExampleValue(codegenParameter);
}
protected String setPropertyExampleValue(CodegenProperty p) {
String example;
@@ -578,14 +578,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
private void processKotlinxDate() {
additionalProperties.put(DateLibrary.KOTLINX_DATETIME.value, true);
typeMapping.put("date-time", "Instant");
typeMapping.put("date", "LocalDate");
typeMapping.put("date-time", "kotlinx.datetime.Instant");
typeMapping.put("DateTime", "Instant");
typeMapping.put("Date", "LocalDate");
importMapping.put("Instant", "kotlinx.datetime.Instant");
importMapping.put("LocalDate", "kotlinx.datetime.LocalDate");
}
private void processJVMRetrofit2Library(String infrastructureFolder) {
@@ -962,7 +957,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
if (param.isQueryParam && "form".equals(param.style) && param.isExplode && param.isModel) {
// query parameter (style: form, explode) referencing models need to import
// models defined in the properties of the models
operations.put("x-kotlin-import-models", true);
operations.put("x-koltin-import-models", true);
}
}
@@ -281,7 +281,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
private void collectEnumSchemas(String parentName, String sName, Schema schema) {
if (ModelUtils.isArraySchema(schema)) {
collectEnumSchemas(parentName, sName, ModelUtils.getSchemaItems(schema));
} else if (ModelUtils.isMapSchema(schema) && schema.getAdditionalProperties() instanceof Schema) {
} else if (schema instanceof MapSchema && schema.getAdditionalProperties() instanceof Schema) {
collectEnumSchemas(parentName, sName, (Schema) schema.getAdditionalProperties());
} else if (isEnumSchema(schema)) {
String h = hashEnum(schema);
@@ -1,326 +0,0 @@
/*
* Copyright 2018 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 static org.openapitools.codegen.utils.StringUtils.camelize;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.io.File;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
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.DataTypeFeature;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.meta.features.GlobalFeature;
import org.openapitools.codegen.meta.features.ParameterFeature;
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.meta.features.WireFormatFeature;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PhpFlightServerCodegen extends AbstractPhpCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(PhpFlightServerCodegen.class);
// Type-hintable primitive types
// ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
protected HashSet<String> typeHintable = new HashSet<>(
Arrays.asList(
"array",
"bool",
"float",
"int",
"string"
)
);
public PhpFlightServerCodegen() {
super();
modifyFeatureSet(features -> features
.includeDocumentationFeatures(DocumentationFeature.Readme)
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON))
.securityFeatures(EnumSet.of(
SecurityFeature.BasicAuth,
SecurityFeature.BearerToken,
SecurityFeature.ApiKey,
SecurityFeature.OAuth2_Implicit))
.excludeDataTypeFeatures(
DataTypeFeature.MapOfCollectionOfEnum,
DataTypeFeature.MapOfEnum,
DataTypeFeature.MapOfCollectionOfModel,
DataTypeFeature.MapOfModel)
.excludeParameterFeatures(
ParameterFeature.FormMultipart,
ParameterFeature.FormUnencoded,
ParameterFeature.Cookie)
.excludeGlobalFeatures(
GlobalFeature.XMLStructureDefinitions,
GlobalFeature.Callbacks,
GlobalFeature.LinkObjects,
GlobalFeature.ParameterStyling
)
.excludeSchemaSupportFeatures(
SchemaSupportFeature.Polymorphism
)
);
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.EXPERIMENTAL)
.build();
embeddedTemplateDir = templateDir = "php-flight";
// clear import mapping (from default generator) as slim does not use it
// at the moment
importMapping.clear();
srcBasePath = "";
defaultIncludes = new HashSet<>(
Arrays.asList(
"\\DateTime"
)
);
variableNamingConvention = "camelCase";
artifactVersion = "1.0.0";
setInvokerPackage("OpenAPIServer");
testPackage = invokerPackage + "\\Test";
apiPackage = invokerPackage + "\\" + apiDirName;
modelPackage = invokerPackage + "\\" + modelDirName;
outputFolder = "generated-code" + File.separator + "php-flight";
// no doc files
modelDocTemplateFiles.clear();
apiDocTemplateFiles.clear();
apiTestTemplateFiles.clear();
embeddedTemplateDir = templateDir = "php-flight";
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
.defaultValue(Boolean.TRUE.toString()));
cliOptions.stream().filter(o -> Objects.equals(o.getOpt(), VARIABLE_NAMING_CONVENTION)).findFirst().ifPresent(o -> o.defaultValue("camelCase"));
}
@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}
@Override
public String getName() {
return "php-flight";
}
@Override
public String getHelp() {
return "Generates a PHP Flight Framework server library.";
}
@Override
public String apiFileFolder() {
if (apiPackage.startsWith(invokerPackage + "\\")) {
// need to strip out invokerPackage from path
return (outputFolder + File.separator + toSrcPath(StringUtils.removeStart(apiPackage, invokerPackage + "\\"), srcBasePath));
}
return (outputFolder + File.separator + toSrcPath(apiPackage, srcBasePath));
}
@Override
public String modelFileFolder() {
if (modelPackage.startsWith(invokerPackage + "\\")) {
// need to strip out invokerPackage from path
return (outputFolder + File.separator + toSrcPath(StringUtils.removeStart(modelPackage, invokerPackage + "\\"), srcBasePath));
}
return (outputFolder + File.separator + toSrcPath(modelPackage, srcBasePath));
}
@Override
public void processOpts() {
super.processOpts();
inlineSchemaOption.put("RESOLVE_INLINE_ENUMS", "true");
// add trailing slash for mustache templates
additionalProperties.put("relativeSrcBasePath", srcBasePath.isEmpty() ? "" : srcBasePath + "/");
additionalProperties.put("modelSrcPath", "." + "/" + toSrcPath(modelPackage, srcBasePath));
additionalProperties.put("apiSrcPath", "." + "/" + toSrcPath(apiPackage, srcBasePath));
additionalProperties.put("testSrcPath", "." + "/" + toSrcPath(testPackage, srcBasePath));
additionalProperties.put("escapedModelPackage", modelPackage.replace("\\", "\\\\"));
if (additionalProperties.containsKey("testPackage")) {
// Update model package to contain the specified model package name and the invoker package
testPackage = invokerPackage + "\\" + (String) additionalProperties.get("testPackage");
}
additionalProperties.put("testPackage", testPackage);
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
supportingFiles.add(new SupportingFile("phpunit.mustache", "", "phpunit.xml.dist"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("register_routes.mustache", toSrcPath(invokerPackage, srcBasePath), "RegisterRoutes.php"));
supportingFiles.add(new SupportingFile("register_routes_test.mustache", toSrcPath(testPackage, srcBasePath), "RegisterRoutesTest.php"));
}
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap operations = objs.getOperations();
List<CodegenOperation> operationList = operations.getOperation();
operationList.forEach(operation -> {
operation.vendorExtensions.put("x-path", mapToFlightPath(operation.path));
String returnType = operation.responses.stream().filter(r -> r.is2xx && r.dataType != null).map(r -> this.getTypeHint(r.dataType, false, false)).filter(t -> !t.isEmpty()).map(t -> t + "|null").findFirst().orElse("void");
operation.vendorExtensions.put("x-return-type", returnType);
operation.vendorExtensions.put("x-return-type-is-void", returnType.equals("void"));
operation.vendorExtensions.put("x-return-type-comment",
operation.responses.stream().filter(r -> r.is2xx && r.dataType != null).map(r -> this.getTypeHint(r.dataType, true, false)).filter(t -> !t.isEmpty()).map(t -> t + "|null").findFirst().orElse("void"));
operation.vendorExtensions.put("x-nonFormParams", operation.allParams.stream().filter(p -> !p.isFormParam).toArray());
operation.allParams.forEach(param -> {
param.vendorExtensions.put("x-parameter-type", param.required ? getTypeHint(param.dataType, false, false) : getTypeHintNullable(param.dataType, false));
String commentType = param.required ? getTypeHint(param.dataType, true, false) : getTypeHintNullable(param.dataType, false);
param.vendorExtensions.put("x-comment-type", commentType);
param.vendorExtensions.put("x-comment-type-escaped", commentType.replace("\\", "\\\\"));
});
});
escapeMediaType(operationList);
return objs;
}
private String mapToFlightPath(String path) {
return path.replaceAll("\\{([^}]+)}", "@$1");
}
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
objs = super.postProcessModels(objs);
ModelMap models = objs.getModels().get(0);
CodegenModel model = models.getModel();
// Simplify model var type
for (CodegenProperty var : model.vars) {
if (var.dataType != null) {
// Determine if the parameter type is supported as a type hint and make it available
// to the templating engine
var.vendorExtensions.put("x-parameter-type", var.required ? getTypeHint(var.dataType, false, true) : getTypeHintNullable(var.dataType, true));
var.vendorExtensions.put("x-comment-type", var.required ? getTypeHint(var.dataType, true, true) : getTypeHintNullableForComments(var.dataType, true));
}
}
return objs;
}
protected String getTypeHintNullable(String type, boolean modelContext) {
String typeHint = getTypeHint(type, false, modelContext);
if (!typeHint.equals("")) {
return "?" + typeHint;
}
return typeHint;
}
protected String getTypeHintNullableForComments(String type, boolean modelContext) {
String typeHint = getTypeHint(type, true, modelContext);
if (!typeHint.equals("")) {
return typeHint + "|null";
}
return typeHint;
}
protected String getTypeHint(String type, boolean forComments, boolean modelContext) {
// Type hint array types
if (type.endsWith("[]")) {
if (forComments) {
//Make type hints for array in comments. Call getTypeHint recursive for extractSimpleName for models
String typeWithoutArray = type.substring(0, type.length() - 2);
return this.getTypeHint(typeWithoutArray, true, modelContext) + "[]";
} else {
return "array";
}
}
// Check if the type is a native type that is type hintable in PHP
if (typeHintable.contains(type)) {
return type;
}
// Default includes are referenced by their fully-qualified class name (including namespace)
if (defaultIncludes.contains(type)) {
return type;
}
// Model classes are assumed to be imported and we reference them by their class name
if (isModelClass(type)) {
// This parameter is an instance of a model
return modelContext ? extractSimpleName(type) : type;
}
// PHP does not support type hinting for this parameter data type
return "";
}
protected Boolean isModelClass(String type) {
return Boolean.valueOf(type.contains(modelPackage()));
}
@Override
public String toApiName(String name) {
if (name.length() == 0) {
return toAbstractName("DefaultApi");
}
return toAbstractName(camelize(name) + "Api");
}
@Override
public String toApiTestFilename(String name) {
if (name.length() == 0) {
return "DefaultApiTest";
}
return camelize(name) + "ApiTest";
}
@Override
public CodegenOperation fromOperation(String path,
String httpMethod,
Operation operation,
List<Server> servers) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
op.path = encodePath(path);
return op;
}
}
@@ -753,9 +753,6 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
} else if (value instanceof Integer) {
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " +
value;
} else if (value instanceof Boolean) {
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " +
value;
} else if (value instanceof LinkedHashMap) {
String in = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": ";
ret = traverseMap(((LinkedHashMap<String, Object>) value), in);
@@ -270,10 +270,10 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
// Remove the discriminator field from the model, serde will take care of this
for (ModelMap model : objs.getModels()) {
CodegenModel cm = model.getModel();
// Remove the discriminator field from the model, serde will take care of this
if (cm.discriminator != null) {
String reserved_var_name = cm.discriminator.getPropertyBaseName();
@@ -284,14 +284,6 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
}
}
}
// Flag structs with byteArrays in them so that we can annotate them with the serde_as macro
for (CodegenProperty cp : cm.vars) {
if (cp.isByteArray) {
cm.vendorExtensions.put("x-rust-has-byte-array", true);
break;
}
}
}
// process enum in models
return postProcessModelsEnum(objs);
@@ -545,11 +537,6 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
if (property.isNullable && !property.required) {
additionalProperties.put("serdeWith", true);
}
// If a property is a base64-encoded byte array, use `serde_with` for deserialization.
if (property.isByteArray) {
additionalProperties.put("serdeWith", true);
}
}
@Override
@@ -1,857 +0,0 @@
/*
* Copyright 2018 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 io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FileUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.serializer.SerializerUtils;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements CodegenConfig {
public static final String PROJECT_NAME = "projectName";
private final Logger LOGGER = LoggerFactory.getLogger(ScalaCaskServerCodegen.class);
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "scala-cask";
}
public String getHelp() {
return "Generates a scala-cask server.";
}
protected String artifactVersion = "0.0.1";
static String ApiServiceTemplate = "apiService.mustache";
public ScalaCaskServerCodegen() {
super();
outputFolder = "generated-code/scala-cask";
embeddedTemplateDir = templateDir = "scala-cask";
apiPackage = "Apis";
modelPackage = "Models";
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
outputFolder = "generated-code/cask";
modelTestTemplateFiles.put("modelTest.mustache", ".scala");
modelTemplateFiles.put("model.mustache", ".scala");
modelTemplateFiles.put("modelData.mustache", "Data.scala");
apiTemplateFiles.put("api.mustache", ".scala");
apiTemplateFiles.put("apiRoutes.mustache", ".scala");
apiTemplateFiles.put(ApiServiceTemplate, "Service.scala");
embeddedTemplateDir = templateDir = "scala-cask";
setReservedWordsLowerCase(
Arrays.asList(
"abstract", "continue", "for", "new", "switch", "assert",
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while", "type")
);
defaultIncludes = new HashSet<String>(
Arrays.asList("double",
"Int",
"Long",
"Float",
"Double",
"char",
"float",
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"List",
"Set",
"Map")
);
typeMapping.put("integer", "Int");
typeMapping.put("long", "Long");
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "String");
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, CodegenConstants.PACKAGE_DESCRIPTION));
}
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isMapSchema(p)) {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "Map[String, " + inner + "]() ";
}
return super.toDefaultValue(p);
}
@Override
public String testPackage() {
return "jvm/src/test/scala";
}
public String toModelTestFilename(String name) {
String n = super.toModelTestFilename(name);
return (modelPackage + "." + n).replace('.', '/');
}
private String ensureProp(String key, String defaultValue) {
if (additionalProperties.containsKey(key) && !additionalProperties.get(key).toString().trim().isEmpty()) {
return (String) additionalProperties.get(key);
} else {
additionalProperties.put(key, defaultValue);
return defaultValue;
}
}
@Override
public void processOpts() {
super.processOpts();
final String groupId = ensureProp(CodegenConstants.GROUP_ID, "org.openapitools");
ensureProp(CodegenConstants.ARTIFACT_ID, "caskgen");
artifactVersion = ensureProp(CodegenConstants.ARTIFACT_VERSION, "0.0.1");
gitRepoId = ensureProp(CodegenConstants.GIT_REPO_ID, "<your git repo -- set 'gitRepoId'>");
gitUserId = ensureProp(CodegenConstants.GIT_USER_ID, "<your git user -- set 'gitUserId'>");
String basePackage = ensureProp(CodegenConstants.PACKAGE_NAME, groupId + ".server");
apiPackage = ensureProp(CodegenConstants.API_PACKAGE, basePackage + ".api");
modelPackage = ensureProp(CodegenConstants.MODEL_PACKAGE, basePackage + ".model");
final String apiPath = "jvm/src/main/scala/" + apiPackage.replace('.', '/');
final String modelPath = "shared/src/main/scala/" + modelPackage.replace('.', '/');
final List<String> appFullPath = Arrays.stream(apiPath.split("/")).collect(Collectors.toList());
final String appFolder = String.join("/", appFullPath.subList(0, appFullPath.size() - 1));
additionalProperties.put("appName", "Cask App");
additionalProperties.put("appDescription", "A cask service");
additionalProperties.put("infoUrl", "https://openapi-generator.tech");
additionalProperties.put("infoEmail", infoEmail);
additionalProperties.put("licenseInfo", "All rights reserved");
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
additionalProperties.put("openbrackets", "{{");
additionalProperties.put("closebrackets", "}}");
supportingFiles.add(new SupportingFile("example.mustache", "example", "Server.scala"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "example", "Dockerfile"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
supportingFiles.add(new SupportingFile("buildAndPublish.yml.mustache", "", ".github/workflows/buildAndPublish.yml"));
supportingFiles.add(new SupportingFile("build.sc.mustache", "", "build.sc"));
supportingFiles.add(new SupportingFile(".scalafmt.conf.mustache", "", ".scalafmt.conf"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("appPackage.mustache", appFolder, "package.scala"));
supportingFiles.add(new SupportingFile("apiPackage.mustache", apiPath, "package.scala"));
supportingFiles.add(new SupportingFile("modelPackage.mustache", modelPath, "package.scala"));
supportingFiles.add(new SupportingFile("exampleApp.mustache", appFolder, "ExampleApp.scala"));
supportingFiles.add(new SupportingFile("baseApp.mustache", appFolder, "BaseApp.scala"));
supportingFiles.add(new SupportingFile("openapiRoute.mustache", apiPath, "OpenApiRoutes.scala"));
supportingFiles.add(new SupportingFile("appRoutes.mustache", appFolder, "AppRoutes.scala"));
supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties"));
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
instantiationTypes.put("array", "Seq");
instantiationTypes.put("map", "Map");
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "scala.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.time.LocalDate as Date");
importMapping.put("Timestamp", "java.sql.Timestamp");
importMapping.put("Map", "Map");
importMapping.put("HashMap", "Map");
importMapping.put("Array", "Seq");
importMapping.put("ArrayList", "Seq");
importMapping.put("List", "Seq");
importMapping.put("DateTime", "java.time.LocalDateTime");
importMapping.put("LocalDateTime", "java.time.LocalDateTime");
importMapping.put("LocalDate", "java.time.LocalDate");
importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
importMapping.put("LocalTime", "java.time.LocalTime");
}
static boolean consumesMimetype(CodegenOperation op, String mimetype) {
// people don't always/often specify the 'consumes' property, so we assume true when
// the optional 'consumes' is null or empty
boolean defaultRetValue = true;
final List<Map<String, String>> consumes = op.consumes;
if (consumes != null) {
for (Map<String, String> c : consumes) {
final String mt = c.get("mediaType");
if (mt.equalsIgnoreCase(mimetype)) {
return true;
}
}
return false;
} else {
return defaultRetValue;
}
}
static String formatMap(Map<?, ?> map) {
StringBuilder mapAsString = new StringBuilder("{");
for (Object key : map.keySet().stream().sorted().collect(Collectors.toList())) {
mapAsString.append(key + " -- " + map.get(key) + ",\n");
}
if (mapAsString.length() > 1) {
mapAsString.delete(mapAsString.length() - 2, mapAsString.length());
}
mapAsString.append("}");
return mapAsString.toString();
}
@Override
public String toApiName(String name) {
if (name.isEmpty()) {
return "DefaultApi";
}
name = sanitizeName(name);
return camelize(name);
}
@Override
public String apiFilename(String templateName, String tag) {
String suffix = apiTemplateFiles().get(templateName);
String fn = toApiFilename(tag);
if (templateName.equals(ApiServiceTemplate)) {
return apiFileFolder() + '/' + fn + suffix;
} else {
return apiFileFolder() + '/' + fn + "Routes" + suffix;
}
}
@Override
public String apiFileFolder() {
return outputFolder + "/jvm/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
@Override
public String modelFileFolder() {
return outputFolder + "/shared/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
static String capitalise(String p) {
if (p.length() < 2) {
return p.toUpperCase(Locale.ROOT);
} else {
String first = "" + p.charAt(0);
return first.toUpperCase(Locale.ROOT) + p.substring(1);
}
}
// thanks FlaskConnectionCodeGen
private static List<Map<String, Object>> getOperations(Map<String, Object> objs) {
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
List<Map<String, Object>> apis = (List<Map<String, Object>>) apiInfo.get("apis");
for (Map<String, Object> api : apis) {
Map<String, Object> operations = (Map<String, Object>) api.get("operations");
result.add(operations);
}
return result;
}
@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
List<Map<String, Object>> operations = getOperations(objs);
for (int i = 0; i < operations.size(); i++) {
operations.get(i).put("hasMore", i < operations.size() - 1);
}
objs.put("operations", operations);
return super.postProcessSupportingFileData(objs);
}
protected String getResourceFolder() {
String src = getSourceFolder();
List<String> parts = Arrays.stream(src.split("/", -1)).collect(Collectors.toList());
if (parts.isEmpty()) {
return "resources";
} else {
String srcMain = String.join("/", parts.subList(0, parts.size() - 1));
return srcMain + "/resources";
}
}
@Override
public void processOpenAPI(OpenAPI openAPI) {
String jsonOpenAPI = SerializerUtils.toJsonString(openAPI);
try {
String outputFile = getOutputDir() + "/jvm/" + getResourceFolder() + "/openapi.json";
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI, StandardCharsets.UTF_8);
LOGGER.info("wrote file to {}", outputFile);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
public static class ParamPart {
final CodegenParameter param;
final String name;
final boolean isParam;
// flag for if there are more path parts
boolean hasMore;
// flag for if there are more path parts which are parameters
boolean hasMoreParams;
final String conversion;
public ParamPart(String name, CodegenParameter param) {
this.name = name;
this.param = param;
this.isParam = param != null;
this.hasMore = true;
this.conversion = !isParam || param.isString ? "" : ".to" + param.dataType;
}
}
/**
* Cask will compile but 'initialize' can throw a route overlap exception:
* <p>
* {{{
* Routes overlap with wildcards: get /user/logout, get /user/:username, get /user/login
* }}}
* <p>
* Note: The same error persists even if the suffixes are unique:
* {{{
* Routes overlap with wildcards: get /user/logout/3, get /user/:username/1, get /user/login/2
* }}}
* <p>
* To fix this, we need to identify and resolve conflicts in our generated code.
* <p>
* # How do we identify conflicts?
* </p>
* <p>
* 1. group routes by their non-param prefixes.
* <p>
* 2. add an "x-annotation" vendor extension for operations
* <p>
* 3. add a list of "RouteGroups" which can manually delegate as per below
* <p>
* <p>
* # How do we resolve conflicts?
* <p>
* We leave out the cask route annotation on the conflicting operations, e.g. :
* {{{
* //conflict: @cask.get("/user/:username")
* def getUserByName(username: String, request: cask.Request) = ...
* }}}
* <p>
* and we introduce a new discriminator function to "manually" call those conflicts:
* {{{
*
* @cask.get("/user", subpath = true)
* def userRouteDescriminator(request: cask.Request) = {
* request.remainingPathSegments match {
* case Seq("logout") => logoutUser(request)
* case Seq("login") => loginUser(request)
* case Seq(param) => getUserByName(param, request)
* }
* }
* }}}
*/
public static class OperationGroup {
List<CodegenOperation> operations = new ArrayList<>();
final String pathPrefix;
final String httpMethod;
final String caskAnnotation;
final String methodName;
// TODO - multiple operations may have the same query params, so we'll need to somehow merge them (and take the right type)
public boolean hasGroupQueryParams() {
return operations.stream().flatMap(op -> op.queryParams.stream()).count() > 0;
}
/**
* This is invoked from `scala-cask/apiRoutesQueryParamsTyped.mustache`
*
* @return the CodegenParameters
*/
public List<CodegenParameter> getGroupQueryParams() {
List<CodegenParameter> list = operations.stream().flatMap(op -> op.queryParams.stream()).map(p -> {
final CodegenParameter copy = p.copy();
copy.vendorExtensions.put("x-default-value", defaultValue(p));
copy.required = false; // all our query params are optional for our work-around as it's a super-set of a few different routes
copy.dataType = asScalaDataType(copy, false, true, true);
copy.defaultValue = defaultValue(copy);
return copy;
}
).collect(Collectors.toList());
return list;
}
@Override
public String toString() {
List<String> ops = operations.stream().map(o -> o.path + "\n").collect(Collectors.toList());
return httpMethod + " " + pathPrefix + " w/ " + operations.size() + " operations:\n" + String.join("", ops);
}
public OperationGroup(String httpMethod, String pathPrefix) {
this.httpMethod = httpMethod;
this.pathPrefix = pathPrefix;
caskAnnotation = "@cask." + httpMethod.toLowerCase(Locale.ROOT);
List<String> stripped = Arrays.stream(pathPrefix.split("/", -1))
.map(ScalaCaskServerCodegen::capitalise).collect(Collectors.toList());
methodName = "routeWorkAroundFor" + capitalise(httpMethod) + String.join("", stripped);
}
public void add(CodegenOperation op) {
if (!op.path.startsWith(pathPrefix)) {
throw new IllegalArgumentException("inconsistent path: " + pathPrefix);
}
if (!op.httpMethod.equals(httpMethod)) {
throw new IllegalArgumentException("inconsistent method: " + httpMethod);
}
final List<ScalaCaskServerCodegen.ParamPart> pathParts = new ArrayList<>();
final List<String> parts = Arrays.stream(op.path.substring(pathPrefix.length()).split("/", -1)).filter(p -> !p.isEmpty()).collect(Collectors.toList());
for (int i = 0; i < parts.size(); i++) {
String p = parts.get(i);
ScalaCaskServerCodegen.ParamPart pp = hasBrackets(p) ? new ScalaCaskServerCodegen.ParamPart(chompBrackets(p), pathParamForName(op, chompBrackets(p))) : new ScalaCaskServerCodegen.ParamPart(p, null);
pathParts.add(pp);
}
List<ScalaCaskServerCodegen.ParamPart> paramPathParts = pathParts.stream().filter(p -> p.isParam).collect(Collectors.toList());
if (!paramPathParts.isEmpty()) {
final String lastParamName = paramPathParts.get(paramPathParts.size() - 1).name;
paramPathParts.forEach(p -> p.hasMoreParams = !p.name.equals(lastParamName));
}
if (!pathParts.isEmpty()) {
pathParts.get(pathParts.size() - 1).hasMore = false;
}
op.vendorExtensions.put("x-path-remaining", pathParts);
op.vendorExtensions.put("x-has-path-remaining", !paramPathParts.isEmpty());
operations.add(op);
}
public boolean contains(CodegenOperation op) {
return operations.contains(op);
}
public void updateAnnotations() {
operations.forEach(op -> {
String annotation = op.vendorExtensions.get("x-annotation").toString();
String conflicts = String.join(", ", operations.stream().map(o -> o.path).collect(Collectors.toList()));
op.vendorExtensions.put("x-annotation", "// conflicts with [" + conflicts + "] after" + pathPrefix + ", ignoring " + annotation);
});
operations = operations.stream().sorted((a, b) -> a.pathParams.size() - b.pathParams.size()).collect(Collectors.toList());
}
}
static List<ScalaCaskServerCodegen.OperationGroup> group(List<CodegenOperation> operationList) {
Map<String, ScalaCaskServerCodegen.OperationGroup> groupedByPrefix = new HashMap<>();
operationList.forEach(op -> {
String prefix = nonParamPathPrefix(op);
String key = op.httpMethod + " " + prefix;
if (!op.pathParams.isEmpty()) {
final ScalaCaskServerCodegen.OperationGroup group = groupedByPrefix.getOrDefault(key, new ScalaCaskServerCodegen.OperationGroup(op.httpMethod, prefix));
group.add(op);
groupedByPrefix.put(key, group);
}
});
return groupedByPrefix.values().stream().collect(Collectors.toList());
}
static String nonParamPathPrefix(CodegenOperation op) {
if (op.pathParams.isEmpty()) {
return op.path;
}
final String firstParam = op.pathParams.stream().findFirst().get().paramName;
final int i = op.path.indexOf(firstParam);
final String path = chompSuffix(op.path.substring(0, i - 1), "/");
return path;
}
static List<ScalaCaskServerCodegen.OperationGroup> createRouteGroups(List<CodegenOperation> operationList) {
List<ScalaCaskServerCodegen.OperationGroup> groups = group(operationList);
operationList.forEach((op) -> {
// for the usage/call site
final String scalaPath = pathWithBracketPlaceholdersRemovedAndXPathIndexAdded(op);
op.vendorExtensions.put("x-cask-path", scalaPath);
final String annotation = "@cask." + op.httpMethod.toLowerCase(Locale.ROOT);
op.vendorExtensions.put("x-annotation", annotation);
for (final ScalaCaskServerCodegen.OperationGroup group : groups) {
if (!group.contains(op)) {
if (op.path.startsWith(group.pathPrefix) && op.httpMethod.equalsIgnoreCase(group.httpMethod)) {
group.add(op);
}
}
}
});
List<ScalaCaskServerCodegen.OperationGroup> trimmed = groups.stream().filter(g -> g.operations.size() > 1).map(g -> {
g.updateAnnotations();
return g;
}).collect(Collectors.toList());
return trimmed;
}
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
final Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
final List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
objs.put("route-groups", createRouteGroups(operationList));
operationList.forEach(ScalaCaskServerCodegen::postProcessOperation);
return objs;
}
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
objs.getModels().stream().map(ModelMap::getModel).forEach(this::postProcessModel);
return objs;
}
private void setDefaultValueForCodegenProperty(CodegenProperty p) {
if (p.defaultValue == null || p.defaultValue.trim().isEmpty()) {
if (p.getIsEnumOrRef()) {
p.defaultValue = "null";
} else {
p.defaultValue = defaultValueNonOption(p);
}
} else if (p.defaultValue.contains("Seq.empty")) {
p.defaultValue = "Nil";
}
}
private void postProcessModel(CodegenModel model) {
model.getAllVars().forEach(this::setDefaultValueForCodegenProperty);
model.getVars().forEach(this::setDefaultValueForCodegenProperty);
model.getVars().forEach(ScalaCaskServerCodegen::postProcessProperty);
model.getAllVars().forEach(ScalaCaskServerCodegen::postProcessProperty);
}
private static void postProcessOperation(CodegenOperation op) {
// force http method to lower case
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
/* Put in 'x-consumes-json' and 'x-consumes-xml' */
op.vendorExtensions.put("x-consumes-json", consumesMimetype(op, "application/json"));
op.vendorExtensions.put("x-consumes-xml", consumesMimetype(op, "application/xml"));
op.bodyParams.stream().filter((b) -> b.isBodyParam).forEach((p) -> {
p.vendorExtensions.put("x-consumes-json", consumesMimetype(op, "application/json"));
p.vendorExtensions.put("x-consumes-xml", consumesMimetype(op, "application/xml"));
});
/* put in 'x-container-type' to help with unmarshalling from json */
op.allParams.forEach((p) -> p.vendorExtensions.put("x-container-type", containerType(p.dataType)));
op.bodyParams.forEach((p) -> p.vendorExtensions.put("x-container-type", containerType(p.dataType)));
final String paramList = op.allParams.stream().map((p) -> p.paramName).collect(Collectors.joining(", "));
op.vendorExtensions.put("x-param-list", paramList);
final Stream<String> typed = op.allParams.stream().map((p) -> p.paramName + " : " + asScalaDataType(p, p.required, false));
op.vendorExtensions.put("x-param-list-typed", String.join(", ", typed.collect(Collectors.toList())));
final Stream<String> typedJson = op.allParams.stream().map((p) -> p.paramName + " : " + asScalaDataType(p, p.required, true));
op.vendorExtensions.put("x-param-list-typed-json", String.join(", ", typedJson.collect(Collectors.toList())));
// for the declaration site
op.vendorExtensions.put("x-cask-path-typed", routeArgs(op));
op.vendorExtensions.put("x-query-args", queryArgs(op));
List<String> responses = op.responses.stream().map(r -> r.dataType).filter(Objects::nonNull).collect(Collectors.toList());
op.vendorExtensions.put("x-response-type", responses.isEmpty() ? "Unit" : String.join(" | ", responses));
}
private static void postProcessProperty(CodegenProperty p) {
p.vendorExtensions.put("x-datatype-model", asScalaDataType(p, p.required, false));
p.vendorExtensions.put("x-defaultValue-model", defaultValue(p, p.required, p.defaultValue));
String dataTypeData = asScalaDataType(p, p.required, true);
p.vendorExtensions.put("x-datatype-data", dataTypeData);
p.vendorExtensions.put("x-containertype-data", containerType(dataTypeData));
p.vendorExtensions.put("x-defaultValue-data", defaultValueNonOption(p, p.defaultValue));
// the 'asModel' logic for modelData.mustache
//
// if it's optional (not required), then wrap the value in Option()
// ... unless it's a map or array, in which case it can just be empty
//
p.vendorExtensions.put("x-wrap-in-optional", !p.required && !p.isArray && !p.isMap);
// if it's an array or optional, we need to map it as a model -- unless it's a map,
// in which case we have to map the values
boolean hasItemModel = p.items != null && p.items.isModel;
boolean isObjectArray = p.isArray && hasItemModel;
boolean isOptionalObj = !p.required && p.isModel;
p.vendorExtensions.put("x-map-asModel", (isOptionalObj || isObjectArray) && !p.isMap);
// when deserialising map objects, the logic is tricky.
p.vendorExtensions.put("x-deserialize-asModelMap", p.isMap && hasItemModel);
// for some reason, an openapi spec with pattern field like this:
// pattern: '^[A-Za-z]+$'
// will result in the pattern property text of
// pattern: '/^[A-Za-z]+$/'
if (p.pattern != null && p.pattern.startsWith("/") && p.pattern.endsWith("/")) {
p.pattern = p.pattern.substring(1, p.pattern.length() - 1);
}
}
/**
* Cask path params use the :pathParam syntax rather than the {pathParam} syntax
*
* @param op
* @return
*/
private static String pathWithBracketPlaceholdersRemovedAndXPathIndexAdded(CodegenOperation op) {
String[] items = op.path.split("/", -1);
String scalaPath = "";
for (int i = 0; i < items.length; ++i) {
final String nextPart = hasBrackets(items[i]) ? ":" + chompBrackets(items[i]) : items[i];
if (i != items.length - 1) {
scalaPath = scalaPath + nextPart + "/";
} else {
scalaPath = scalaPath + nextPart;
}
}
return scalaPath;
}
private static CodegenParameter pathParamForName(CodegenOperation op, String pathParam) {
final CodegenParameter param = op.pathParams.stream().filter(p -> p.paramName.equals(pathParam)).findFirst().get();
if (param == null) {
throw new RuntimeException("Bug: path param " + pathParam + " not found");
}
return param;
}
/**
* The path placeholders as well as query parameters
*
* @param op the codegen operations
* @return a list of both the path and query parameters as typed arguments (e.g. "aPathArg : Int, request: cask.Request, aQueryArg : Option[Long]")
*/
private static String routeArgs(CodegenOperation op) {
final Stream<String> pathParamNames = Arrays.stream(op.path.split("/", -1)).filter(ScalaCaskServerCodegen::hasBrackets).map(p -> {
final CodegenParameter param = pathParamForName(op, chompBrackets(p));
return param.paramName + " : " + asScalaDataType(param, param.required, true);
});
final List<String> pathList = pathParamNames.collect(Collectors.toList());
// we always include the cask request
pathList.add("request: cask.Request");
final Stream<String> queryParams = op.queryParams.stream().map(p -> {
p.vendorExtensions.put("x-default-value", defaultValue(p));
return p.paramName + " : " + asScalaDataType(p, p.required, true, true);
});
pathList.addAll(queryParams.collect(Collectors.toList()));
return pathList.isEmpty() ? "" : (String.join(", ", pathList));
}
private static String defaultValue(CodegenParameter p) {
return defaultValue(p, p.required, p.defaultValue);
}
private static String defaultValue(IJsonSchemaValidationProperties p, boolean required, String fallbackDefaultValue) {
if (!required && !(p.getIsArray() || p.getIsMap())) {
return "None";
}
return defaultValueNonOption(p, fallbackDefaultValue);
}
private static String defaultValueNonOption(IJsonSchemaValidationProperties p, String fallbackDefaultValue) {
if (p.getIsArray()) {
if (p.getUniqueItems()) {
return "Set.empty";
}
return "Nil";
}
if (p.getIsMap()) {
return "Map.empty";
}
if (p.getIsNumber()) {
return "0";
}
if (p.getIsEnum()) {
return fallbackDefaultValue;
}
if (p.getIsBoolean()) {
return "false";
}
if (p.getIsUuid()) {
return "java.util.UUID.randomUUID()";
}
if (p.getIsString()) {
return "\"\"";
}
return fallbackDefaultValue;
}
private static String defaultValueNonOption(CodegenProperty p) {
if (p.getIsArray()) {
return "Nil";
}
if (p.getIsMap()) {
return "Map.empty";
}
if (p.isNumber || p.isNumeric) {
return "0";
}
if (p.isBoolean) {
return "false";
}
if (p.isUuid) {
return "java.util.UUID.randomUUID()";
}
if (p.isModel) {
return "null";
}
if (p.isDate || p.isDateTime) {
return "null";
}
if (p.isString) {
return "\"\"";
}
return p.defaultValue;
}
private static String queryArgs(final CodegenOperation op) {
final List<String> list = op.queryParams.stream().map(p -> p.paramName).collect(Collectors.toList());
final String prefix = list.isEmpty() ? "" : ", ";
return prefix + String.join(", ", list);
}
/**
* For our model classes, we have two variants:
* <p>
* 1) a {model}.scala one which is a validated, model class
* 2) a {model}Data.scala one which is just our data-transfer-object (DTO) which is written primarily for e.g. json serialisation
* <p>
* The data variant can have nulls and other non-scala things, but they know how to create validated model objects.
* <p>
* This 'asScalaDataType' is used to ensure the type hierarchy is correct for both the model and data varients.
* <p>
* e.g. consider this example:
* ```
* case class Foo(bar : Bar, bazz :List[Bazz])
* case class Bar(x : Option[String] = None)
* case class Bazz(y : Int)
* <p>
* // vs
* <p>
* case class FooData(bar : BarData, bazz :List[BazzData])
* case class BarData(x : String = "")
* case class BazzData(y : Int)
* ```
*/
private static String asScalaDataType(final IJsonSchemaValidationProperties param, boolean required, boolean useJason) {
return asScalaDataType(param, required, useJason, !useJason);
}
private static String asScalaDataType(final IJsonSchemaValidationProperties param, boolean required, boolean useJason, boolean allowOptional) {
String dataType = (param.getIsModel() && useJason) ? param.getDataType() + "Data" : param.getDataType();
final String dataSuffix = useJason && param.getItems() != null && param.getItems().getIsModel() ? "Data" : "";
if (dataType.startsWith("List[")) {
dataType = dataType.replace("List[", "Seq[");
dataType = dataType.replace("]", dataSuffix + "]");
} else if (dataType.startsWith("Set[")) {
dataType = dataType.replace("]", dataSuffix + "]");
} else if (!required && allowOptional) {
dataType = "Option[" + dataType + "]";
}
return dataType;
}
private static String chompBrackets(String str) {
return str.replace("{", "").replace("}", "");
}
private static String chompSuffix(String str, String suffix) {
return str.endsWith(suffix) ? chompSuffix(str.substring(0, str.length() - suffix.length()), suffix) : str;
}
private static boolean hasBrackets(String str) {
return str.matches("^\\{(.*)\\}$");
}
static String containerType(String dataType) {
String fixedForList = dataType.replaceAll(".*\\[(.*)\\]", "$1");
// if it is a map, we want the value type
final String[] parts = fixedForList.split(",");
return parts[parts.length - 1];
}
}
@@ -340,12 +340,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.processCodeGenModel(cm);
}
// Add supporting file only if we plan to generate files in /models
if (!objs.isEmpty() && !addedModelIndex) {
addedModelIndex = true;
supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts"));
}
return objs;
}

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