Merge remote-tracking branch 'origin/master' into 6.3.x

This commit is contained in:
William Cheng 2022-11-01 17:42:59 +08:00
commit 2947d147b4
1972 changed files with 36976 additions and 6630 deletions

View File

@ -0,0 +1,43 @@
name: Gradle plugin tests
on:
push:
paths:
- modules/openapi-generator-gradle-plugin/**
pull_request:
paths:
- modules/openapi-generator-gradle-plugin/**
jobs:
test:
name: Gradle plugin tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/modules-2/modules-2.lock
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-test-gradle-plugin-${{ env.cache-name }}-
${{ runner.os }}-test-gradle-plugin-
- name: Run tests
run: |
mvn --no-snapshot-updates --batch-mode --quiet install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=error
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk) # using gradle-6.8.3 via wrapper
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildDotnetSdk)
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && gradle buildJavaResttemplateSdk) # not using gradle wrapper

View File

@ -2,17 +2,12 @@ name: Gradle tests (Java samples)
on:
push:
branches:
- master
- '[5-9]+.[0-9]+.x'
- "java*"
paths:
- 'samples/client/petstore/java/**'
- 'samples/openapi3/client/petstore/java/**'
pull_request:
branches:
- master
- '[5-9]+.[0-9]+.x'
paths:
- 'samples/client/petstore/java/**'
- 'samples/openapi3/client/petstore/java/**'
env:
GRADLE_VERSION: 7.2
@ -26,11 +21,11 @@ jobs:
fail-fast: true
matrix:
sample:
- samples/client/petstore/java/jersey2-java8-localdatetime
- samples/client/petstore/java/jersey2-java8
- samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters
- samples/openapi3/client/petstore/java/jersey2-java8
- samples/client/petstore/java/jersey2-java8-localdatetime
- samples/client/petstore/java/jersey2-java8
- samples/client/petstore/java/okhttp-gson
- samples/client/petstore/java/okhttp-gson-group-parameter
steps:

View File

@ -0,0 +1,46 @@
name: Java Helidon Functional tests
on:
push:
paths:
- modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/**
pull_request:
paths:
- modules/openapi-generator/src/test/java/org/openapitools/codegen/java/helidon/**
jobs:
build:
name: Java Helidon Functional tests
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [11, 17]
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
- name: Run unit tests
run: cd modules/openapi-generator && mvn --no-snapshot-updates --batch-mode -Dtest="**/functional/*Test" test -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- name: Publish unit test reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'

View File

@ -0,0 +1,42 @@
name: Maven plugin tests
on:
push:
paths:
- modules/openapi-generator-maven-plugin/**
pull_request:
paths:
- modules/openapi-generator-maven-plugin/**
jobs:
test:
name: Maven plugin tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-test-maven-plugin-${{ env.cache-name }}-
${{ runner.os }}-test-maven-plugin-
- name: Run tests
run: |
mvn clean install -DskipTests -Dmaven.javadoc.skip=true
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error

View File

@ -80,44 +80,6 @@ jobs:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
functional-test:
name: Functional tests
runs-on: ubuntu-latest
needs:
- build
strategy:
matrix:
java-version: [11, 17]
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
- name: Run unit tests
run: cd modules/openapi-generator && mvn --no-snapshot-updates --batch-mode -Dtest="**/functional/*Test" test -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- name: Publish unit test reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
documentation:
name: Docs up-to-date
runs-on: ubuntu-latest
@ -191,71 +153,3 @@ jobs:
echo "Please run 'bin/generate-samples.sh' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
exit 1
fi
test-maven-plugin:
name: Maven plugin tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-test-maven-plugin-${{ env.cache-name }}-
${{ runner.os }}-test-maven-plugin-
- name: Run tests
run: |
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
test-gradle-plugin:
name: Gradle plugin tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/modules-2/modules-2.lock
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-test-gradle-plugin-${{ env.cache-name }}-
${{ runner.os }}-test-gradle-plugin-
- name: Run tests
run: |
mvn --no-snapshot-updates --batch-mode --quiet install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=error
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk) # using gradle-6.8.3 via wrapper
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildDotnetSdk)
(cd modules/openapi-generator-gradle-plugin/samples/local-spec && gradle buildJavaResttemplateSdk) # not using gradle wrapper

View File

@ -27,7 +27,7 @@ jobs:
- samples/server/petstore/aspnetcore-6.0-project4Models
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3.0.2
- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '6.0.x'
- name: Build

36
.github/workflows/samples-go.yaml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Samples Go
on:
push:
paths:
- 'samples/server/petstore/go-echo-server/**'
- 'samples/server/petstore/go-api-server/**'
pull_request:
paths:
- 'samples/server/petstore/go-echo-server/**'
- 'samples/server/petstore/go-api-server/**'
jobs:
build:
name: Build Go
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
- samples/server/petstore/go-echo-server/
- samples/server/petstore/go-api-server/
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '>=1.17.0'
- run: go version
- name: Install
working-directory: ${{ matrix.sample }}
run: |
go get github.com/labstack/echo/v4/middleware@v4.9.0
go get github.com/labstack/echo/v4@v4.9.0
- name: Build
working-directory: ${{ matrix.sample }}
run: go test -v

View File

@ -51,6 +51,11 @@ jobs:
- samples/client/petstore/kotlin-bigdecimal-default-okhttp4
- samples/client/petstore/kotlin-jvm-ktor-jackson
- samples/client/petstore/kotlin-jvm-ktor-gson
- samples/client/petstore/kotlin-jvm-ktor-gson
- samples/client/petstore/kotlin-jvm-vertx-gson
- samples/client/petstore/kotlin-jvm-vertx-jackson
- samples/client/petstore/kotlin-jvm-vertx-jackson-coroutines
- samples/client/petstore/kotlin-jvm-vertx-moshi
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3

View File

@ -1,23 +1,26 @@
name: Samples Scala
name: Samples Scala/sbt
on:
push:
paths:
- 'samples/client/petstore/scala**'
- 'samples/server/petstore/scala**'
- 'samples/client/petstore/java/okhttp-gson/**'
pull_request:
paths:
- 'samples/client/petstore/scala**'
- 'samples/server/petstore/scala**'
- 'samples/client/petstore/java/okhttp-gson/**'
jobs:
build:
name: Build Scala client, servers
name: Build sbt/Scala client, servers
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
# clients
- 'samples/client/petstore/java/okhttp-gson'
- samples/client/petstore/scalaz
#- samples/client/petstore/scala-sttp # won't pass while the same tests in circleci pass
# servers

3
.gitignore vendored
View File

@ -32,6 +32,9 @@ packages/
**/.vs
.factorypath
.metals/*
nbproject/
nbactions.xml
nb-configuration.xml
.settings

View File

@ -57,6 +57,8 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
[<img src="https://openapi-generator.tech/img/companies/onesignal.png" width="128" height="128">](https://www.onesignal.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/virtualansoftware.png" width="128" height="128">](https://www.virtualansoftware.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/mergedev.jpeg" width="128" height="128">](https://www.merge.dev/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/burkert.jpg" width="128" height="128">](https://www.burkert.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/finbourne.png" width="128" height="128">](https://www.finbourne.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS and Checkly for sponsoring the API monitoring
@ -70,8 +72,8 @@ 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, Jersey1.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), **k6**, **Kotlin**, **Lua**, **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), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
| **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/)), **Kotlin** (Spring Boot, Ktor, Vertx), **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 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, Jersey1.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), **k6**, **Kotlin**, **Lua**, **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), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
| **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/)), **Kotlin** (Spring Boot, Ktor, Vertx), **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**, **Protocol Buffer**, **WSDL** |
@ -682,6 +684,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [TribalScale](https://www.tribalscale.com)
- [Trifork](https://trifork.com)
- [TUI InfoTec GmbH](http://www.tui-infotec.com/)
- [Twilio](https://www.twilio.com/)
- [Twitter](https://twitter.com)
- [unblu inc.](https://www.unblu.com/)
- [Veamly](https://www.veamly.com/)
@ -872,6 +875,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2022-08-01 - [Tutorial: Etsy Open API v3 (ruby)](https://blog.tjoyal.dev/etsy-open-api-v3/) by [Thierry Joyal](https://github.com/tjoyal)
- 2022-09-03 - [OpenAPI Generator For Go Web Development](https://blog.kevinhu.me/2022/09/03/03-openapi-generator/) by [Kevin Hu](https://twitter.com/Oldgunix)
- 2022-10-01 - [OpenAPI Generatorをカスタマイズしたコードを生成するSwagger Codegenとほぼ同じ](https://nainaistar.hatenablog.com/entry/2022/10/03/120000) by [きり丸](https://twitter.com/nainaistar)
- 2022-10-21 - [KotlinSpring Bootの API を OpenAPI Generator で自動生成](https://zenn.dev/msksgm/articles/20221021-kotlin-spring-openapi-generator) by [msksgm](https://zenn.dev/msksgm)
- 2022-10-26 - [Quarkus Insights #106: Quarkiverse Extension Spotlight: OpenApi Generator](https://www.youtube.com/watch?v=_s_if69t2iQ) by [Quarkusio](https://www.youtube.com/c/Quarkusio)
## [6 - About Us](#table-of-contents)
@ -942,6 +947,7 @@ Here is a list of template creators:
* Java (Rest-assured): @viclovsky
* Java (Java 11 Native HTTP client): @bbdouglas
* Java (Apache HttpClient): @harrywhite4
* Java (Helidon): @spericas @tjquinno @tvallin
* Javascript/NodeJS: @jfiala
* JavaScript (Apollo DataSource): @erithmetic
* JavaScript (Closure-annotated Angular) @achew22
@ -1009,6 +1015,7 @@ Here is a list of template creators:
* Java PKMST: @anshu2185 @sanshuman @rkumar-pk @ninodpillai
* Java Vert.x: @lwlee2608
* Java Micronaut: @andriy-dmytruk
* Java Helidon: @spericas @tjquinno @tvallin
* JAX-RS RestEasy: @chameleon82
* JAX-RS CXF: @hiveship
* JAX-RS CXF (CDI): @nickcmaynard

View File

@ -0,0 +1,8 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-gson
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "gson"

View File

@ -0,0 +1,9 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-jackson-coroutines
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "jackson"
useCoroutines: "true"

View File

@ -0,0 +1,8 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-jackson
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "jackson"

View File

@ -0,0 +1,8 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-moshi
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "moshi"

View File

@ -8,3 +8,4 @@ additionalProperties:
artifactId: springboot
snapshotVersion: "true"
hideGenerationTimestamp: "true"
requestMappingMode: api_interface

View File

@ -7,3 +7,4 @@ additionalProperties:
artifactId: springboot
snapshotVersion: "true"
hideGenerationTimestamp: "true"
camelCaseDollarSign: "true"

View File

@ -0,0 +1,4 @@
generatorName: typescript-rxjs
outputDir: samples/client/others/typescript-rxjs/allOf-composition
inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf_composition.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript-rxjs

View File

@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -32,6 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|camelDataformatProperties|list of dataformat properties separated by comma (propertyName1=propertyValue2,...| ||
|camelRestBindingMode|binding mode to be used by the REST consumer| |auto|
|camelRestClientRequestValidation|enable validation of the client request to check whether the Content-Type and Accept headers from the client is supported by the Rest-DSL configuration| |false|
@ -73,6 +74,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|performBeanValidation|Use Bean Validation Impl. to perform BeanValidation| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
|requestMappingMode|Where to generate the class level @RequestMapping annotation.|<dl><dt>**api_interface**</dt><dd>Generate the @RequestMapping annotation on the generated Api Interface.</dd><dt>**controller**</dt><dd>Generate the @RequestMapping annotation on the generated Api Controller Implementation.</dd><dt>**none**</dt><dd>Do not add a class level @RequestMapping annotation.</dd></dl>|controller|
|responseWrapper|wrap the responses in given type (Future, Callable, CompletableFuture,ListenableFuture, DeferredResult, RxObservable, RxSingle or fully qualified type)| |null|
|returnSuccessCode|Generated server returns 2xx code| |false|
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configKey|Config key in @RegisterRestClient. Default to none.| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</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|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</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|
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|build|Specify for which build tool to generate files|<dl><dt>**gradle**</dt><dd>Gradle configuration is generated for the project</dd><dt>**all**</dt><dd>Both Gradle and Maven configurations are generated</dd><dt>**maven**</dt><dd>Maven configuration is generated for the project</dd></dl>|all|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configureAuth|Configure all the authorization methods as specified in the file| |false|
|dateFormat|Specify the format pattern of date as a string| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|

View File

@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|build|Specify for which build tool to generate files|<dl><dt>**gradle**</dt><dd>Gradle configuration is generated for the project</dd><dt>**all**</dt><dd>Both Gradle and Maven configurations are generated</dd><dt>**maven**</dt><dd>Maven configuration is generated for the project</dd></dl>|all|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|controllerPackage|The package in which controllers will be generated| |org.openapitools.api|
|dateFormat|Specify the format pattern of date as a string| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package for java source code| |null|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package for generated code| |org.openapitools|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
|controllerOnly|Whether to generate only API interface stubs without the server files.| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0-SNAPSHOT|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0-SNAPSHOT|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|asyncNative|If true, async handlers will be used, instead of the sync version| |false|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|configKey|Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option.| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|artifactVersion|Generated artifact's package version.| |1.0.0|

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|annotationLibrary|Select the complementary documentation annotation library.|<dl><dt>**none**</dt><dd>Do not annotate Model and Api with complementary annotations.</dd><dt>**swagger1**</dt><dd>Annotate Model and Api using the Swagger Annotations 1.x library.</dd><dt>**swagger2**</dt><dd>Annotate Model and Api using the Swagger Annotations 2.x library.</dd></dl>|swagger2|
|apiPackage|api package for generated code| |org.openapitools.api|
|apiSuffix|suffix for api classes| |Api|

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |null|
|artifactVersion|Generated artifact's package version.| |1.0.0|

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
|artifactVersion|Generated artifact's package version.| |1.0.0|
@ -27,7 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false|
|library|Library template (sub-template) to use|<dl><dt>**jvm-ktor**</dt><dd>Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).</dd><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd></dl>|jvm-okhttp4|
|library|Library template (sub-template) to use|<dl><dt>**jvm-ktor**</dt><dd>Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).</dd><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd><dt>**jvm-vertx**</dt><dd>Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.</dd></dl>|jvm-okhttp4|
|modelMutable|Create mutable models| |false|
|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|omitGradlePluginVersions|Whether to declare Gradle plugin versions in build files.| |false|

View File

@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|addSurrogateKey|Adds the surrogate key for all models that don't already have a primary key (named by the above convention)| |false|
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|artifactId|Generated artifact id (name of jar).| |ktorm|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|defaultDatabaseName|Default database name for all queries| |sqlite.db|

View File

@ -33,7 +33,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|gemVersion|gem version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|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|
|library|HTTP library template (sub-template) to use|<dl><dt>**faraday**</dt><dd>Faraday (https://github.com/lostisland/faraday) (Beta support)</dd><dt>**typhoeus**</dt><dd>Typhoeus &gt;= 1.0.1 (https://github.com/typhoeus/typhoeus)</dd></dl>|typhoeus|
|library|HTTP library template (sub-template) to use|<dl><dt>**faraday**</dt><dd>Faraday &gt;= 1.0.1 (https://github.com/lostisland/faraday)</dd><dt>**typhoeus**</dt><dd>Typhoeus &gt;= 1.0.1 (https://github.com/typhoeus/typhoeus)</dd></dl>|typhoeus|
|moduleName|top module name (convention: CamelCase, usually corresponding to gem name).| |OpenAPIClient|
|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|

View File

@ -32,6 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
@ -66,6 +67,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|performBeanValidation|Use Bean Validation Impl. to perform BeanValidation| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
|requestMappingMode|Where to generate the class level @RequestMapping annotation.|<dl><dt>**api_interface**</dt><dd>Generate the @RequestMapping annotation on the generated Api Interface.</dd><dt>**controller**</dt><dd>Generate the @RequestMapping annotation on the generated Api Controller Implementation.</dd><dt>**none**</dt><dd>Do not add a class level @RequestMapping annotation.</dd></dl>|controller|
|responseWrapper|wrap the responses in given type (Future, Callable, CompletableFuture,ListenableFuture, DeferredResult, RxObservable, RxSingle or fully qualified type)| |null|
|returnSuccessCode|Generated server returns 2xx code| |false|
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|

View File

@ -87,6 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>char</li>
<li>class</li>
<li>const</li>
<li>constructor</li>
<li>continue</li>
<li>debugger</li>
<li>default</li>

View File

@ -21,6 +21,7 @@ import org.gradle.api.GradleException
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
@ -98,7 +99,8 @@ open class GenerateTask : DefaultTask() {
* The template directory holding a custom template.
*/
@Optional
@Input
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
val templateDir = project.objects.property<String?>()
/**
@ -122,7 +124,8 @@ open class GenerateTask : DefaultTask() {
* Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options.
*/
@Optional
@Input
@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
val configFile = project.objects.property<String>()
/**
@ -320,7 +323,8 @@ open class GenerateTask : DefaultTask() {
* Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
*/
@Optional
@Input
@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
val ignoreFileOverride = project.objects.property<String?>()
/**

View File

@ -0,0 +1,200 @@
package org.openapitools.generator.gradle.plugin
import org.gradle.testkit.runner.TaskOutcome
import org.testng.annotations.BeforeMethod
import org.testng.annotations.DataProvider
import org.testng.annotations.Test
import java.io.File
import kotlin.test.assertEquals
class GenerateTaskFromCacheTest : TestBase() {
private lateinit var buildCacheDir: File
private lateinit var projectDir1: File
private lateinit var projectDir2: File
@BeforeMethod
override fun before() {
initialize()
buildCacheDir = temp.resolve("buildCacheDir").apply { mkdir() }
projectDir1 = temp.resolve("projectDir1").apply { mkdir() }
projectDir2 = temp.resolve("projectDir2").apply { mkdir() }
}
@DataProvider(name = "gradle_version_provider")
private fun gradleVersionProvider(): Array<Array<String>> = arrayOf(arrayOf("6.9.2"), arrayOf("7.5.1"))
// inputSpec tests
private val inputSpecExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
""".trimIndent()
@Test(dataProvider = "gradle_version_provider")
fun `inputSpec - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
runCacheabilityTestUsingSameDirectory(gradleVersion, inputSpecExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `inputSpec - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
runCacheabilityTestUsingDifferentDirectories(gradleVersion, inputSpecExtensionContents)
}
// templateDir tests
private val templateDirExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
templateDir = file("templateDir").absolutePath
""".trimIndent()
private fun initializeTemplateDirTest() {
projectDir1.resolve("templateDir").mkdir()
}
@Test(dataProvider = "gradle_version_provider")
fun `templateDir - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
initializeTemplateDirTest()
runCacheabilityTestUsingSameDirectory(gradleVersion, templateDirExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `templateDir - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
initializeTemplateDirTest()
runCacheabilityTestUsingDifferentDirectories(gradleVersion, templateDirExtensionContents)
}
// configFile tests
private val configFileExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
configFile = file("configFile").absolutePath
""".trimIndent()
private fun initializeConfigFileTest() {
val configFile = projectDir1.resolve("configFile")
configFile.createNewFile()
configFile.writeText("""{"foo":"bar"}""")
}
@Test(dataProvider = "gradle_version_provider")
fun `configFile - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
initializeConfigFileTest()
runCacheabilityTestUsingSameDirectory(gradleVersion, configFileExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `configFile - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
initializeConfigFileTest()
runCacheabilityTestUsingDifferentDirectories(gradleVersion, configFileExtensionContents)
}
// ignoreFileOverride tests
private val ignoreFileOverrideExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
ignoreFileOverride = file(".openapi-generator-ignore").absolutePath
""".trimIndent()
private fun initializeIgnoreFileTest() {
projectDir1.resolve(".openapi-generator-ignore").createNewFile()
}
@Test(dataProvider = "gradle_version_provider")
fun `ignoreFileOverride - same directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
initializeIgnoreFileTest()
runCacheabilityTestUsingSameDirectory(gradleVersion, ignoreFileOverrideExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `ignoreFileOverride - different directory - openApiGenerate task output should come from cache`(gradleVersion: String) {
initializeIgnoreFileTest()
runCacheabilityTestUsingDifferentDirectories(gradleVersion, ignoreFileOverrideExtensionContents)
}
// Helper methods & test fixtures
private fun runCacheabilityTestUsingSameDirectory(gradleVersion: String, extensionContents: String) {
// Arrange
withProject(extensionContents)
// Act
val result1 = build {
withProjectDir(projectDir1)
withArguments("--build-cache", "clean", "openApiGenerate")
withGradleVersion(gradleVersion)
}
val expectedRelativeFilePathSet = projectDir1.toRelativeFilePathSet()
val result2 = build {
withProjectDir(projectDir1)
withArguments("--build-cache", "clean", "openApiGenerate")
withGradleVersion(gradleVersion)
}
// Assert
assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
assertEquals(TaskOutcome.FROM_CACHE, result2.task(":openApiGenerate")?.outcome)
assertEquals(expectedRelativeFilePathSet, projectDir1.toRelativeFilePathSet())
}
private fun runCacheabilityTestUsingDifferentDirectories(gradleVersion: String, extensionContents: String) {
// Arrange
withProject(extensionContents)
projectDir1.copyRecursively(projectDir2)
// Act
val result1 = build {
withProjectDir(projectDir1)
withArguments("--build-cache", "clean", "openApiGenerate")
withGradleVersion(gradleVersion)
}
val result2 = build {
withProjectDir(projectDir2)
withArguments("--build-cache", "clean", "openApiGenerate")
withGradleVersion(gradleVersion)
}
// Assert
assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
assertEquals(TaskOutcome.FROM_CACHE, result2.task(":openApiGenerate")?.outcome)
assertEquals(projectDir1.toRelativeFilePathSet(), projectDir2.toRelativeFilePathSet())
}
private fun File.toRelativeFilePathSet() =
resolve("build").walk().map { it.toRelativeString(resolve("build")) }.toSet()
private fun withProject(extensionContents: String) {
val settingsContents = """
buildCache {
local {
directory = file("${buildCacheDir.toURI()}")
}
}
rootProject.name = "openapi-generator"
""".trimIndent()
val buildContents = """
plugins {
id 'base'
id 'org.openapi.generator'
}
openApiGenerate {
$extensionContents
}
""".trimIndent()
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")!!
)
withProject(
projectDir = projectDir1,
settingsContents = settingsContents,
buildContents = buildContents,
projectFiles = projectFiles
)
}
}

View File

@ -0,0 +1,173 @@
package org.openapitools.generator.gradle.plugin
import org.gradle.testkit.runner.TaskOutcome
import org.testng.annotations.DataProvider
import org.testng.annotations.Test
import java.io.File
import kotlin.test.assertEquals
class GenerateTaskUpToDateTest : TestBase() {
@DataProvider(name = "gradle_version_provider")
private fun gradleVersionProvider(): Array<Array<String>> = arrayOf(arrayOf("6.9.2"), arrayOf("7.5.1"))
// inputSpec tests
private val inputSpecExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
""".trimIndent()
@Test(dataProvider = "gradle_version_provider")
fun `inputSpec - no file changes - should be up-to-date`(gradleVersion: String) {
runShouldBeUpToDateTest(gradleVersion, inputSpecExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `inputSpec - has file changes - should execute`(gradleVersion: String) {
runShouldExecuteTest(gradleVersion, inputSpecExtensionContents) {
val inputSpec = File(temp, "spec.yaml")
val newContents = inputSpec.readText().replace("version: 1.0.0", "version: 1.0.1")
inputSpec.writeText(newContents)
}
}
// templateDir tests
private val templateDirExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
templateDir = file("templateDir").absolutePath
""".trimIndent()
private fun initializeTemplateDirTest(): File {
val templateDir = temp.resolve("templateDir")
templateDir.mkdir()
return templateDir.resolve("templateFile").apply { writeText("contents") }
}
@Test(dataProvider = "gradle_version_provider")
fun `templateDir - no file changes - should be up-to-date`(gradleVersion: String) {
initializeTemplateDirTest()
runShouldBeUpToDateTest(gradleVersion, templateDirExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `templateDir - has file changes - should execute`(gradleVersion: String) {
val templateFile = initializeTemplateDirTest()
runShouldExecuteTest(gradleVersion, templateDirExtensionContents) {
templateFile.writeText("new contents")
}
}
// configFile tests
private val configFileExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
configFile = file("configFile").absolutePath
""".trimIndent()
private fun initializeConfigFileTest(): File {
return temp.resolve("configFile").apply { writeText("""{"foo":"bar"}""") }
}
@Test(dataProvider = "gradle_version_provider")
fun `configFile - no file changes - should be up-to-date`(gradleVersion: String) {
initializeConfigFileTest()
runShouldBeUpToDateTest(gradleVersion, configFileExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `configFile - has file changes - should execute`(gradleVersion: String) {
val configFile = initializeConfigFileTest()
runShouldExecuteTest(gradleVersion, configFileExtensionContents) {
configFile.writeText("""{"foo":"baz"}""")
}
}
// ignoreFileOverride tests
private val ignoreFileOverrideExtensionContents = """
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
ignoreFileOverride = file(".openapi-generator-ignore").absolutePath
""".trimIndent()
private fun initializeIgnoreFileTest(): File {
return temp.resolve(".openapi-generator-ignore").apply { writeText(".some_file_to_ignore") }
}
@Test(dataProvider = "gradle_version_provider")
fun `ignoreFileOverride - no file changes - should be up-to-date`(gradleVersion: String) {
initializeIgnoreFileTest()
runShouldBeUpToDateTest(gradleVersion, ignoreFileOverrideExtensionContents)
}
@Test(dataProvider = "gradle_version_provider")
fun `ignoreFileOverride - has file changes - should execute`(gradleVersion: String) {
val ignoreFileOverride = initializeIgnoreFileTest()
runShouldExecuteTest(gradleVersion, ignoreFileOverrideExtensionContents) {
ignoreFileOverride.writeText(".new_file_to_ignore")
}
}
// Helper methods & test fixtures
private fun runShouldBeUpToDateTest(gradleVersion: String, extensionContents: String) {
// Arrange
withProject(extensionContents)
// Act
val result1 = build {
withArguments("clean", "openApiGenerate")
withGradleVersion(gradleVersion)
}
val result2 = build {
withArguments("openApiGenerate")
withGradleVersion(gradleVersion)
}
// Assert
assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
assertEquals(TaskOutcome.UP_TO_DATE, result2.task(":openApiGenerate")?.outcome)
}
private fun runShouldExecuteTest(gradleVersion: String, extensionContents: String, action: () -> Unit) {
// Arrange
withProject(extensionContents)
// Act
val result1 = build {
withArguments("clean", "openApiGenerate")
withGradleVersion(gradleVersion)
}
action()
val result2 = build {
withArguments("openApiGenerate")
withGradleVersion(gradleVersion)
}
// Assert
assertEquals(TaskOutcome.SUCCESS, result1.task(":openApiGenerate")?.outcome)
assertEquals(TaskOutcome.SUCCESS, result2.task(":openApiGenerate")?.outcome)
}
private fun withProject(extensionContents: String) {
val buildContents = """
plugins {
id 'base'
id 'org.openapi.generator'
}
openApiGenerate {
$extensionContents
}
""".trimIndent()
File(temp, "build.gradle").writeText(buildContents)
File(javaClass.classLoader.getResource("specs/petstore-v3.0.yaml")!!.toURI())
.copyTo(File(temp, "spec.yaml"))
}
}

View File

@ -1,5 +1,6 @@
package org.openapitools.generator.gradle.plugin
import org.gradle.testkit.runner.GradleRunner
import org.testng.annotations.AfterMethod
import org.testng.annotations.BeforeMethod
import java.io.File
@ -10,7 +11,11 @@ abstract class TestBase {
protected open lateinit var temp: File
@BeforeMethod
protected fun before() {
protected open fun before() {
initialize()
}
protected fun initialize() {
temp = createTempDirectory(javaClass.simpleName).toFile()
temp.deleteOnExit()
}
@ -20,12 +25,28 @@ abstract class TestBase {
temp.deleteRecursively()
}
protected fun withProject(buildContents: String, projectFiles: Map<String, InputStream> = mapOf()) {
File(temp, "build.gradle").writeText(buildContents)
protected fun withProject(
buildContents: String,
projectFiles: Map<String, InputStream> = mapOf(),
projectDir: File? = temp,
settingsContents: String? = null
) {
File(projectDir, "build.gradle").writeText(buildContents)
if (!settingsContents.isNullOrEmpty()) {
File(projectDir, "settings.gradle").writeText(settingsContents)
}
projectFiles.forEach { entry ->
val target = File(temp, entry.key)
val target = File(projectDir, entry.key)
entry.value.copyTo(target.outputStream())
}
}
protected fun build(configure: GradleRunner.() -> Unit = {}) =
GradleRunner.create()
.withProjectDir(temp)
.withPluginClasspath()
.forwardOutput()
.apply(configure)
.build()!!
}

View File

@ -147,7 +147,7 @@
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-apis</artifactId>
<version>6.9.0</version>
<version>8.3.1</version>
</dependency>
<dependency>
<groupId>org.tomitribe</groupId>

View File

@ -377,7 +377,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<version>${jackson-databind.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>

View File

@ -90,7 +90,7 @@ public class DefaultCodegen implements CodegenConfig {
// A cache of sanitized words. The sanitizeName() method is invoked many times with the same
// arguments, this cache is used to optimized performance.
private static Cache<SanitizeNameOptions, String> sanitizedNameCache;
private static final Cache<SanitizeNameOptions, String> sanitizedNameCache;
private static final String xSchemaTestExamplesKey = "x-schema-test-examples";
private static final String xSchemaTestExamplesRefPrefix = "#/components/x-schema-test-examples/";
protected static Schema falseSchema;
@ -161,9 +161,9 @@ public class DefaultCodegen implements CodegenConfig {
protected Set<String> reservedWords;
protected Set<String> languageSpecificPrimitives = new HashSet<>();
protected Map<String, String> importMapping = new HashMap<>();
// a map to store the mappping between a schema and the new one
// a map to store the mapping between a schema and the new one
protected Map<String, String> schemaMapping = new HashMap<>();
// a map to store the mappping between inline schema and the name provided by the user
// a map to store the mapping between inline schema and the name provided by the user
protected Map<String, String> inlineSchemaNameMapping = new HashMap<>();
// a map to store the inline schema naming conventions
protected Map<String, String> inlineSchemaNameDefault = new HashMap<>();
@ -3715,7 +3715,7 @@ public class DefaultCodegen implements CodegenConfig {
} else {
property.openApiType = p.getType();
}
property.nameInCamelCase = camelize(property.name, false);
property.nameInCamelCase = camelize(property.name);
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
property.description = escapeText(p.getDescription());
property.unescapedDescription = p.getDescription();

View File

@ -903,7 +903,7 @@ public class InlineModelResolver {
addGenerated(name, schema);
openAPI.getComponents().addSchemas(name, schema);
if (!name.equals(schema.getTitle()) && !inlineSchemaNameMappingValues.contains(name)) {
LOGGER.info("Inline schema created as {}. To have complete control of the model name, set the `title` field or use the inlineSchemaNameMapping option (--inline-schema-name-mapping in CLI).", name);
LOGGER.info("Inline schema created as {}. To have complete control of the model name, set the `title` field or use the inlineSchemaNameMapping option (--inline-schema-name-mappings in CLI).", name);
}
uniqueNames.add(name);

View File

@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
abstract public class AbstractAdaCodegen extends DefaultCodegen implements CodegenConfig {
@ -826,7 +827,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
// method with only the scope that it requires. We have to create a new auth method
// instance because the original object must not be modified.
List<String> opScopes = (scopes == null) ? null : scopes.get(authMethod.name);
authMethod.name = camelize(sanitizeName(authMethod.name), true);
authMethod.name = camelize(sanitizeName(authMethod.name), LOWERCASE_FIRST_LETTER);
if (opScopes != null) {
CodegenSecurity opSecurity = new CodegenSecurity();
opSecurity.name = authMethod.name;

View File

@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {
@ -111,7 +112,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
@ -422,11 +423,11 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}

View File

@ -41,6 +41,7 @@ import java.io.IOException;
import java.io.Writer;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig {
@ -521,6 +522,16 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
property.isMap = composedProperty.isMap;
property.isContainer = composedProperty.isContainer;
}
// fix incorrect data types for maps of maps
if (property.datatypeWithEnum.contains("List>") && property.items != null) {
property.datatypeWithEnum = property.datatypeWithEnum.replace("List>", property.items.datatypeWithEnum + ">");
property.dataType = property.datatypeWithEnum;
}
if (property.datatypeWithEnum.contains("Dictionary>") && property.items != null) {
property.datatypeWithEnum = property.datatypeWithEnum.replace("Dictionary>", property.items.datatypeWithEnum + ">");
property.dataType = property.datatypeWithEnum;
}
}
@Override
@ -964,7 +975,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// camelize(lower) the variable name
// pet_id => petId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {

View File

@ -28,6 +28,7 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractDartCodegen extends DefaultCodegen {
@ -373,7 +374,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
if (name.matches("^\\d.*")) {
name = "n" + name;
@ -721,18 +722,18 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
public String toOperationId(String operationId) {
operationId = super.toOperationId(operationId);
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
operationId = newOperationId;
}

View File

@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -343,7 +344,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
String sanitizedOperationId = camelize(sanitizeName(operationId), true);
String sanitizedOperationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
@ -354,7 +355,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
sanitizedOperationId = camelize("call_" + sanitizedOperationId, true);
sanitizedOperationId = camelize("call_" + sanitizedOperationId, LOWERCASE_FIRST_LETTER);
}
// method name from updateSomething to update_Something.

View File

@ -38,6 +38,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -661,7 +662,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@ -707,7 +708,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
// camelize(lower) the variable name
// pet_id => petId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {

View File

@ -34,6 +34,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -232,7 +233,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
// params should be lowerCamelCase. E.g. "person Person", instead of
// "Person Person".
//
name = camelize(toVarName(name), true);
name = camelize(toVarName(name), LOWERCASE_FIRST_LETTER);
// REVISIT: Actually, for idiomatic go, the param name should
// really should just be a letter, e.g. "p Person"), but we'll get
@ -626,11 +627,39 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
iterator.remove();
}
boolean addedTimeImport = false;
boolean addedOSImport = false;
for (ModelMap m : objs.getModels()) {
boolean addedTimeImport = false;
boolean addedOSImport = false;
CodegenModel model = m.getModel();
for (CodegenProperty cp : model.vars) {
List<CodegenProperty> inheritedProperties = new ArrayList<>();
if (model.getComposedSchemas() != null) {
if (model.getComposedSchemas().getAllOf() != null) {
inheritedProperties.addAll(model.getComposedSchemas().getAllOf());
}
if (model.getComposedSchemas().getAnyOf() != null) {
inheritedProperties.addAll(model.getComposedSchemas().getAnyOf());
}
if (model.getComposedSchemas().getOneOf() != null) {
inheritedProperties.addAll(model.getComposedSchemas().getOneOf());
}
}
List<CodegenProperty> codegenProperties = new ArrayList<>();
if(model.getIsModel() || model.getComposedSchemas() == null) {
// If the model is a model, use model.vars as it only
// contains properties the generated struct will own itself.
// If model is no model and it has no composed schemas use
// model.vars.
codegenProperties.addAll(model.vars);
} else {
// If the model is no model, but is a
// allOf, anyOf or oneOf, add all first level options
// from allOf, anyOf or oneOf.
codegenProperties.addAll(inheritedProperties);
}
for (CodegenProperty cp : codegenProperties) {
if (!addedTimeImport && ("time.Time".equals(cp.dataType) ||
(cp.items != null && "time.Time".equals(cp.items.dataType)))) {
imports.add(createMapping("import", "time"));
@ -647,6 +676,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
imports.add(createMapping("import", "fmt"));
}
// if oneOf contains "time.Time" type
if (!addedTimeImport && model.oneOf != null && model.oneOf.contains("time.Time")) {
imports.add(createMapping("import", "time"));
}
// if oneOf contains "null" type
if (model.oneOf != null && !model.oneOf.isEmpty() && model.oneOf.contains("nil")) {
model.isNullable = true;

View File

@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -160,7 +161,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
if (name.matches("^[A-Z_]*$"))
return name;
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name))
@ -326,7 +327,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
sanitizedOperationId = "call_" + sanitizedOperationId;
}
return camelize(sanitizedOperationId, false);
return camelize(sanitizedOperationId);
}
@Override

View File

@ -40,6 +40,7 @@ import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -55,6 +56,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import static org.openapitools.codegen.utils.CamelizeOption.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig,
@ -81,6 +83,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public static final String IMPLICIT_HEADERS = "implicitHeaders";
public static final String IMPLICIT_HEADERS_REGEX = "implicitHeadersRegex";
public static final String CAMEL_CASE_DOLLAR_SIGN = "camelCaseDollarSign";
public static final String DEFAULT_TEST_FOLDER = "${project.build.directory}/generated-test-sources/openapi";
protected String dateLibrary = "java8";
@ -130,6 +134,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected boolean implicitHeaders = false;
protected String implicitHeadersRegex = null;
protected boolean camelCaseDollarSign = false;
private Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
public AbstractJavaCodegen() {
@ -262,6 +268,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
cliOptions.add(CliOption.newBoolean(OPENAPI_NULLABLE, "Enable OpenAPI Jackson Nullable library", this.openApiNullable));
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Skip header parameters in the generated API methods using @ApiImplicitParams annotation.", implicitHeaders));
cliOptions.add(CliOption.newString(IMPLICIT_HEADERS_REGEX, "Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true"));
cliOptions.add(CliOption.newBoolean(CAMEL_CASE_DOLLAR_SIGN, "Fix camelCase when starting with $ sign. when true : $Value when false : $value"));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_GROUP_ID, CodegenConstants.PARENT_GROUP_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_ARTIFACT_ID, CodegenConstants.PARENT_ARTIFACT_ID_DESC));
@ -549,6 +556,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.setImplicitHeadersRegex(additionalProperties.get(IMPLICIT_HEADERS_REGEX).toString());
}
if (additionalProperties.containsKey(CAMEL_CASE_DOLLAR_SIGN)) {
this.setCamelCaseDollarSign(Boolean.parseBoolean(additionalProperties.get(CAMEL_CASE_DOLLAR_SIGN).toString()));
}
if (!StringUtils.isEmpty(parentGroupId) && !StringUtils.isEmpty(parentArtifactId) && !StringUtils.isEmpty(parentVersion)) {
additionalProperties.put("parentOverridden", true);
}
@ -795,7 +806,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
if (camelCaseDollarSign) {
name = camelize(name, LOWERCASE_FIRST_CHAR);
} else {
name = camelize(name, LOWERCASE_FIRST_LETTER);
}
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
@ -1261,11 +1276,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@ -1273,7 +1288,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + operationId), true);
operationId = camelize("call_" + operationId, true);
operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@ -1902,6 +1917,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.implicitHeadersRegex = implicitHeadersRegex;
}
public void setCamelCaseDollarSign(boolean camelCaseDollarSign) {
this.camelCaseDollarSign = camelCaseDollarSign;
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
@ -1984,7 +2003,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
*/
@Override
public String getterAndSetterCapitalize(String name) {
boolean lowercaseFirstLetter = false;
CamelizeOption camelizeOption = UPPERCASE_FIRST_CHAR;
if (name == null || name.length() == 0) {
return name;
}
@ -1996,9 +2015,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// http://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf)
//
if (name.length() > 1 && Character.isLowerCase(name.charAt(0)) && Character.isUpperCase(name.charAt(1))) {
lowercaseFirstLetter = true;
camelizeOption = LOWERCASE_FIRST_LETTER;
}
return camelize(name, lowercaseFirstLetter);
return camelize(name, camelizeOption);
}
@Override

View File

@ -39,6 +39,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
@ -49,6 +50,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
public static final String MODEL_MUTABLE = "modelMutable";
public static final String MODEL_MUTABLE_DESC = "Create mutable models";
public static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS = "additionalModelTypeAnnotations";
private final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
@ -60,12 +62,12 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
protected String sourceFolder = "src/main/kotlin";
protected String testFolder = "src/test/kotlin";
protected String resourcesFolder = "src/main/resources";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected boolean parcelizeModels = false;
protected boolean serializableModel = false;
protected boolean needsDataClassBody = false;
protected boolean nonPublicApi = false;
@ -76,7 +78,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// ref: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-hash-map/
protected Set<String> propertyAdditionalKeywords = new HashSet<>(Arrays.asList("entries", "keys", "size", "values"));
private Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
protected List<String> additionalModelTypeAnnotations = new LinkedList<>();
public AbstractKotlinCodegen() {
super();
@ -262,6 +265,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
cliOptions.add(new CliOption(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG_DESC));
cliOptions.add(CliOption.newBoolean(MODEL_MUTABLE, MODEL_MUTABLE_DESC, false));
cliOptions.add(CliOption.newString(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)"));
}
@Override
@ -398,6 +402,21 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
}
@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
objs = super.postProcessAllModels(objs);
objs = super.updateAllModels(objs);
if (!additionalModelTypeAnnotations.isEmpty()) {
for (String modelName : objs.keySet()) {
Map<String, Object> models = (Map<String, Object>) objs.get(modelName);
models.put(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, additionalModelTypeAnnotations);
}
}
return objs;
}
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
objs = super.postProcessModelsEnum(objs);
@ -506,6 +525,11 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi);
}
if (additionalProperties.containsKey(ADDITIONAL_MODEL_TYPE_ANNOTATIONS)) {
String additionalAnnotationsList = additionalProperties.get(ADDITIONAL_MODEL_TYPE_ANNOTATIONS).toString();
this.setAdditionalModelTypeAnnotations(Arrays.asList(additionalAnnotationsList.trim().split("\\s*(;|\\r?\\n)\\s*")));
}
additionalProperties.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, getSortParamsByRequiredFlag());
additionalProperties.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, getSortModelPropertiesByRequiredFlag());
@ -578,14 +602,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
this.nonPublicApi = nonPublicApi;
}
public boolean isNeedsDataClassBody() {
return needsDataClassBody;
}
public void setNeedsDataClassBody(boolean needsDataClassBody) {
this.needsDataClassBody = needsDataClassBody;
}
/**
* Return the sanitized variable name for enum
*
@ -610,7 +626,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
break;
case camelCase:
// NOTE: Removes hyphens and underscores
modified = camelize(modified, true);
modified = camelize(modified, LOWERCASE_FIRST_LETTER);
break;
case PascalCase:
// NOTE: Removes hyphens and underscores
@ -673,9 +689,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toModelName(final String name) {
// memoization
String origName = name;
if (schemaKeyToModelNameCache.containsKey(origName)) {
return schemaKeyToModelNameCache.get(origName);
if (schemaKeyToModelNameCache.containsKey(name)) {
return schemaKeyToModelNameCache.get(name);
}
// Allow for explicitly configured kotlin.* and java.* types
@ -695,9 +710,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
String modifiedName = name.replaceAll("\\.", "");
String sanitizedName = sanitizeKotlinSpecificNames(modifiedName);
String nameWithPrefixSuffix = sanitizedName;
String nameWithPrefixSuffix = sanitizeKotlinSpecificNames(modifiedName);
if (!StringUtils.isEmpty(modelNamePrefix)) {
// add '_' so that model name can be camelized correctly
nameWithPrefixSuffix = modelNamePrefix + "_" + nameWithPrefixSuffix;
@ -726,8 +740,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return modelName;
}
schemaKeyToModelNameCache.put(origName, titleCase(modifiedName));
return schemaKeyToModelNameCache.get(origName);
schemaKeyToModelNameCache.put(name, titleCase(modifiedName));
return schemaKeyToModelNameCache.get(name);
}
/**
@ -742,19 +756,19 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
if (StringUtils.isEmpty(operationId))
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
operationId = camelize("call_" + operationId, true);
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), LOWERCASE_FIRST_LETTER);
operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@ -843,10 +857,9 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
protected boolean needToImport(String type) {
// provides extra protection against improperly trying to import language primitives and java types
boolean imports = !type.startsWith("kotlin.") && !type.startsWith("java.") &&
return !type.startsWith("kotlin.") && !type.startsWith("java.") &&
!defaultIncludes.contains(type) && !languageSpecificPrimitives.contains(type) &&
!type.contains(".");
return imports;
}
@Override
@ -909,7 +922,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
public String toVarName(String name) {
name = toVariableName(name);
if (propertyAdditionalKeywords.contains(name)) {
return camelize("property_" + name, true);
return camelize("property_" + name, LOWERCASE_FIRST_LETTER);
} else {
return name;
}
@ -938,7 +951,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
// If name contains special chars -> replace them.
if ((name.chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character))))) {
if ((name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character))))) {
List<String> allowedCharacters = new ArrayList<>();
allowedCharacters.add("_");
allowedCharacters.add("$");
@ -947,7 +960,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number or containing dollar symbol, escape it
if (isReservedWord(name) || name.matches("(^\\d.*)|(.*[$].*)")) {
@ -1017,15 +1030,17 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toDefaultValue(Schema schema) {
Schema p = ModelUtils.getReferencedSchema(this.openAPI, schema);
Schema<?> p = ModelUtils.getReferencedSchema(this.openAPI, schema);
if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
} else if (ModelUtils.isDateSchema(p)) {
// TODO
return null;
} else if (ModelUtils.isDateTimeSchema(p)) {
// TODO
return null;
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {
return fixNumberValue(p.getDefault().toString(), p);
@ -1071,7 +1086,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
return null;
}
return null;
}
@ -1082,7 +1096,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
protected void updateModelForObject(CodegenModel m, Schema schema) {
/**
/*
* we have a custom version of this function so we only set isMap to true if
* ModelUtils.isMapSchema
* In other generators, isMap is true for all type object schemas
@ -1105,4 +1119,12 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// process 'additionalProperties'
setAddProps(schema, m);
}
public List<String> getAdditionalModelTypeAnnotations() {
return additionalModelTypeAnnotations;
}
public void setAdditionalModelTypeAnnotations(final List<String> additionalModelTypeAnnotations) {
this.additionalModelTypeAnnotations = additionalModelTypeAnnotations;
}
}

View File

@ -35,6 +35,9 @@ import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -413,9 +416,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
if ("camelCase".equals(variableNamingConvention)) {
// return the name in camelCase style
// phone_number => phoneNumber
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
} else if ("PascalCase".equals(variableNamingConvention)) {
name = camelize(name, false);
name = camelize(name, UPPERCASE_FIRST_CHAR);
} else { // default to snake case
// return the name in underscore style
// PhoneNumber => phone_number
@ -542,17 +545,17 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER));
operationId = "call_" + operationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER));
operationId = "call_" + operationId;
}
return camelize(sanitizeName(operationId), true);
return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
/**

View File

@ -313,7 +313,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
if (name == null || name.length() == 0) {
return "DefaultController";
}
return camelize(name, false) + "Controller";
return camelize(name) + "Controller";
}

View File

@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Escapers;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
@ -27,15 +28,20 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.*;
import static org.openapitools.codegen.languages.AbstractJavaCodegen.DATE_LIBRARY;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -293,7 +299,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@ -527,7 +533,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
if (specialCharReplacements.containsKey(name)) {
name = specialCharReplacements.get(name);
}
String identifier = camelize(sanitizeName(name), true);
String identifier = camelize(sanitizeName(name), LOWERCASE_FIRST_LETTER);
if (capitalized) {
identifier = StringUtils.capitalize(identifier);
}
@ -588,11 +594,11 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@ -600,7 +606,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
operationId = camelize("call_" + operationId, true);
operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@ -614,4 +620,32 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.SCALA;
}
protected static abstract class CustomLambda implements Mustache.Lambda {
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
final StringWriter tempWriter = new StringWriter();
frag.execute(tempWriter);
out.write(formatFragment(tempWriter.toString()));
}
public abstract String formatFragment(String fragment);
}
protected static class CamelizeLambda extends CustomLambda {
private final CamelizeOption option;
public CamelizeLambda(boolean capitalizeFirst) {
if (capitalizeFirst) {
option = UPPERCASE_FIRST_CHAR;
} else {
option = LOWERCASE_FIRST_LETTER;
}
}
@Override
public String formatFragment(String fragment) {
return camelize(fragment, option);
}
}
}

View File

@ -47,6 +47,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.ParameterExpander.ParamStyle.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -757,7 +758,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
throw new RuntimeException("Empty method name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
operationId = toSafeIdentifier(operationId);
return operationId;
@ -802,7 +803,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@ -820,7 +821,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@ -911,7 +912,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
case original:
return name;
case camelCase:
return camelize(underscore(name), true);
return camelize(underscore(name), LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(underscore(name));
case snake_case:

View File

@ -30,6 +30,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -267,7 +268,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
@ -394,11 +395,11 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
throw new RuntimeException("Empty method name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}

View File

@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -807,7 +808,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
public String toOperationId(String operationId) {
// rename to empty_method_name_1 (e.g.) if method name is empty
if (StringUtils.isEmpty(operationId)) {
operationId = camelize("empty_method_name_" + emptyMethodNameCounter++, true);
operationId = camelize("empty_method_name_" + emptyMethodNameCounter++, LOWERCASE_FIRST_LETTER);
LOGGER.warn("Empty method name (operationId) found. Renamed to {}", operationId);
return operationId;
}
@ -825,7 +826,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
operationId = "call_" + operationId;
}
return camelize(sanitizeName(operationId), true);
return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
@Override

View File

@ -32,6 +32,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -733,19 +734,19 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize(sanitizeName("call_" + operationId), true);
String newOperationId = camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
String newOperationId = camelize(sanitizeName("call_" + operationId), true);
String newOperationId = camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
return camelize(sanitizeName(operationId), true);
return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
@Override

View File

@ -31,6 +31,7 @@ import java.io.File;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -835,7 +836,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:

View File

@ -42,6 +42,7 @@ import java.util.Comparator;
import java.util.List;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -84,10 +85,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
private static FrameworkStrategy defaultFramework = FrameworkStrategy.NETSTANDARD_2_0;
protected final Map<String, String> frameworks;
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
protected String clientPackage = "Org.OpenAPITools.Client";
protected String clientPackage = "Client";
protected String authFolder = "Auth";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected String apiDocPath = "docs" + File.separator;
protected String modelDocPath = "docs" + File.separator;
// Defines TargetFrameworkVersion in csproj files
protected String targetFramework = defaultFramework.name;
@ -490,7 +491,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@ -547,6 +548,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
postProcessPattern(property.pattern, property.vendorExtensions);
postProcessEmitDefaultValue(property.vendorExtensions);
// remove once https://github.com/OpenAPITools/openapi-generator/pull/13681 is merged
if (GENERICHOST.equals(getLibrary())) {
// all c# libraries should want this, but avoid breaking changes for now
// a class cannot contain a property with the same name
@ -664,8 +666,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
setModelPackage("Model");
}
clientPackage = "Client";
if (GENERICHOST.equals(getLibrary())) {
setLibrary(GENERICHOST);
additionalProperties.put("useGenericHost", true);
@ -679,7 +679,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
additionalProperties.put("useHttpClient", true);
needsUriBuilder = true;
} else {
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only restsharp, httpclient are supported.");
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only restsharp, httpclient, and generichost are supported.");
}
String inputFramework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
@ -742,7 +742,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
final AtomicReference<Boolean> excludeTests = new AtomicReference<>();
syncBooleanProperty(additionalProperties, CodegenConstants.EXCLUDE_TESTS, excludeTests::set, false);
syncStringProperty(additionalProperties, "clientPackage", (s) -> { }, clientPackage);
syncStringProperty(additionalProperties, "clientPackage", this::setClientPackage, clientPackage);
syncStringProperty(additionalProperties, CodegenConstants.API_PACKAGE, this::setApiPackage, apiPackage);
syncStringProperty(additionalProperties, CodegenConstants.MODEL_PACKAGE, this::setModelPackage, modelPackage);
@ -809,6 +809,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
addTestInstructions();
}
public void setClientPackage(String clientPackage) {
this.clientPackage = clientPackage;
}
@Override
public CodegenOperation fromOperation(String path,
String httpMethod,

View File

@ -37,6 +37,7 @@ import java.util.function.Consumer;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -415,7 +416,7 @@ public class CSharpNetCoreReducedClientCodegen extends AbstractCSharpCodegen {
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:

View File

@ -32,6 +32,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class CppTizenClientCodegen extends AbstractCppCodegen implements CodegenConfig {
@ -311,7 +312,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
}
// add_pet_by_id => addPetById
return camelize(operationId, true);
return camelize(operationId, LOWERCASE_FIRST_LETTER);
}
/**
* Output the Getter name for boolean property, e.g. getActive

View File

@ -485,7 +485,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
languageSpecificPrimitives.contains(type)) {
return type;
} else {
return modelNamePrefix + camelize(sanitizeName(type), false);
return modelNamePrefix + camelize(sanitizeName(type));
}
}
@ -500,7 +500,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
}
//Unreal variable names are CamelCase
String camelCaseName = camelize(name, false);
String camelCaseName = camelize(name);
//Avoid empty variable name at all costs
if(!camelCaseName.isEmpty()) {
@ -527,7 +527,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
@Override
public String toApiName(String type) {
return modelNamePrefix + camelize(type, false) + "Api";
return modelNamePrefix + camelize(type) + "Api";
}
@Override

View File

@ -84,27 +84,21 @@ public class CrystalClientCodegen extends DefaultCodegen {
SecurityFeature.BasicAuth,
SecurityFeature.BearerToken,
SecurityFeature.ApiKey,
SecurityFeature.OAuth2_Implicit
))
SecurityFeature.OAuth2_Implicit))
.excludeGlobalFeatures(
GlobalFeature.XMLStructureDefinitions,
GlobalFeature.Callbacks,
GlobalFeature.LinkObjects,
GlobalFeature.ParameterStyling,
GlobalFeature.ParameterizedServer,
GlobalFeature.MultiServer
)
GlobalFeature.MultiServer)
.includeSchemaSupportFeatures(
SchemaSupportFeature.Polymorphism
)
SchemaSupportFeature.Polymorphism)
.excludeParameterFeatures(
ParameterFeature.Cookie
)
ParameterFeature.Cookie)
.includeClientModificationFeatures(
ClientModificationFeature.BasePath,
ClientModificationFeature.UserAgent
)
);
ClientModificationFeature.UserAgent));
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
@ -128,13 +122,14 @@ public class CrystalClientCodegen extends DefaultCodegen {
apiTestTemplateFiles.put("api_test.mustache", ".cr");
// TODO support auto-generated doc
//modelDocTemplateFiles.put("model_doc.mustache", ".md");
//apiDocTemplateFiles.put("api_doc.mustache", ".md");
// modelDocTemplateFiles.put("model_doc.mustache", ".md");
// apiDocTemplateFiles.put("api_doc.mustache", ".md");
// default HIDE_GENERATION_TIMESTAMP to true
hideGenerationTimestamp = Boolean.TRUE;
// reserved word. Ref: https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#available-keywords
// reserved word. Ref:
// https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#available-keywords
reservedWords = new HashSet<>(
Arrays.asList(
"abstract", "annotation", "do", "if", "nil?", "select", "union",
@ -146,8 +141,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
"break", "extend", "macro", "require", "true", "with",
"case", "false", "module", "rescue", "type", "yield",
"class", "for", "next", "responds_to?", "typeof",
"def", "fun", "nil", "return", "uninitialized")
);
"def", "fun", "nil", "return", "uninitialized"));
languageSpecificPrimitives.clear();
languageSpecificPrimitives.add("String");
@ -180,6 +174,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
typeMapping.put("set", "Set");
typeMapping.put("map", "Hash");
typeMapping.put("object", "Object");
typeMapping.put("AnyType", "Object");
typeMapping.put("file", "::File");
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
@ -194,29 +189,25 @@ public class CrystalClientCodegen extends DefaultCodegen {
cliOptions.removeIf(opt -> CodegenConstants.MODEL_PACKAGE.equals(opt.getOpt()) ||
CodegenConstants.API_PACKAGE.equals(opt.getOpt()));
cliOptions.add(new CliOption(SHARD_NAME, "shard name (e.g. twitter_client").
defaultValue("openapi_client"));
cliOptions.add(new CliOption(SHARD_NAME, "shard name (e.g. twitter_client").defaultValue("openapi_client"));
cliOptions.add(new CliOption(MODULE_NAME, "module name (e.g. TwitterClient").
defaultValue("OpenAPIClient"));
cliOptions.add(new CliOption(MODULE_NAME, "module name (e.g. TwitterClient").defaultValue("OpenAPIClient"));
cliOptions.add(new CliOption(SHARD_VERSION, "shard version.").defaultValue("1.0.0"));
cliOptions.add(new CliOption(SHARD_LICENSE, "shard license.").
defaultValue("unlicense"));
cliOptions.add(new CliOption(SHARD_LICENSE, "shard license.").defaultValue("unlicense"));
cliOptions.add(new CliOption(SHARD_HOMEPAGE, "shard homepage.").
defaultValue("http://org.openapitools"));
cliOptions.add(new CliOption(SHARD_HOMEPAGE, "shard homepage.").defaultValue("http://org.openapitools"));
cliOptions.add(new CliOption(SHARD_DESCRIPTION, "shard description.").
defaultValue("This shard maps to a REST API"));
cliOptions.add(
new CliOption(SHARD_DESCRIPTION, "shard description.").defaultValue("This shard maps to a REST API"));
cliOptions.add(new CliOption(SHARD_AUTHOR, "shard author (only one is supported)."));
cliOptions.add(new CliOption(SHARD_AUTHOR_EMAIL, "shard author email (only one is supported)."));
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).
defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).defaultValue(Boolean.TRUE.toString()));
}
@Override
@ -224,7 +215,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
super.processOpts();
if (StringUtils.isEmpty(System.getenv("CRYSTAL_POST_PROCESS_FILE"))) {
LOGGER.info("Hint: Environment variable 'CRYSTAL_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export CRYSTAL_POST_PROCESS_FILE=\"/usr/local/bin/crystal tool format\"' (Linux/Mac)");
LOGGER.info(
"Hint: Environment variable 'CRYSTAL_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export CRYSTAL_POST_PROCESS_FILE=\"/usr/local/bin/crystal tool format\"' (Linux/Mac)");
}
if (additionalProperties.containsKey(SHARD_NAME)) {
@ -313,12 +305,14 @@ public class CrystalClientCodegen extends DefaultCodegen {
@Override
public String apiFileFolder() {
return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator + apiPackage.replace("/", File.separator);
return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator
+ apiPackage.replace("/", File.separator);
}
@Override
public String modelFileFolder() {
return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator + modelPackage.replace("/", File.separator);
return outputFolder + File.separator + srcFolder + File.separator + shardName + File.separator
+ modelPackage.replace("/", File.separator);
}
@Override
@ -364,7 +358,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
@Override
public String toModelName(final String name) {
String modelName;
modelName = sanitizeName(name);
modelName = sanitizeModelName(name);
if (!StringUtils.isEmpty(modelNamePrefix)) {
modelName = modelNamePrefix + "_" + modelName;
@ -393,6 +387,15 @@ public class CrystalClientCodegen extends DefaultCodegen {
return camelize(modelName);
}
public String sanitizeModelName(String modelName) {
String[] parts = modelName.split("::");
ArrayList<String> new_parts = new ArrayList<String>();
for (String part : parts) {
new_parts.add(sanitizeName(part));
}
return String.join("::", new_parts);
}
@Override
public String toModelFilename(String name) {
return underscore(toModelName(name));
@ -510,7 +513,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId,
underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@ -609,7 +613,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
return objs;
}
private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps,
HashMap<String, Integer> processedModelMap) {
if (codegenParameter.isArray) { // array
if (codegenParameter.items == null) {
return "[]";
@ -669,13 +674,15 @@ public class CrystalClientCodegen extends DefaultCodegen {
if (modelMaps.containsKey(codegenParameter.dataType)) {
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
} else {
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
// LOGGER.error("Error in constructing examples. Failed to look up the model " +
// codegenParameter.dataType);
return "TODO";
}
}
}
private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps,
HashMap<String, Integer> processedModelMap) {
if (codegenProperty.isArray) { // array
return "[" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "]";
} else if (codegenProperty.isMap) {
@ -735,14 +742,17 @@ public class CrystalClientCodegen extends DefaultCodegen {
if (modelMaps.containsKey(codegenProperty.dataType)) {
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
} else {
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
// LOGGER.error("Error in constructing examples. Failed to look up the model " +
// codegenParameter.dataType);
return "TODO";
}
}
}
private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
// break infinite recursion. Return, in case a model is already processed in the current context.
private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps,
HashMap<String, Integer> processedModelMap) {
// break infinite recursion. Return, in case a model is already processed in the
// current context.
String model = codegenModel.name;
if (processedModelMap.containsKey(model)) {
int count = processedModelMap.get(model);
@ -754,7 +764,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
throw new RuntimeException("Invalid count when constructing example: " + count);
}
} else if (codegenModel.isEnum) {
List<Map<String, String>> enumVars = (List<Map<String, String>>) codegenModel.allowableValues.get("enumVars");
List<Map<String, String>> enumVars = (List<Map<String, String>>) codegenModel.allowableValues
.get("enumVars");
return moduleName + "::" + codegenModel.classname + "::" + enumVars.get(0).get("name");
} else if (codegenModel.oneOf != null && !codegenModel.oneOf.isEmpty()) {
String subModel = (String) codegenModel.oneOf.toArray()[0];
@ -766,7 +777,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
List<String> propertyExamples = new ArrayList<>();
for (CodegenProperty codegenProperty : codegenModel.requiredVars) {
propertyExamples.add(codegenProperty.name + ": " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));
propertyExamples.add(
codegenProperty.name + ": " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));
}
String example = moduleName + "::" + toModelName(model) + ".new";
if (!propertyExamples.isEmpty()) {
@ -826,7 +838,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return "Date.parse(\"" + String.format(Locale.ROOT, localDate.toString(), "") + "\")";
} else if (p.getDefault() instanceof java.time.OffsetDateTime) {
return "Time.parse(\"" + String.format(Locale.ROOT, ((java.time.OffsetDateTime) p.getDefault()).atZoneSameInstant(ZoneId.systemDefault()).toString(), "") + "\")";
return "Time.parse(\"" + String.format(Locale.ROOT, ((java.time.OffsetDateTime) p.getDefault())
.atZoneSameInstant(ZoneId.systemDefault()).toString(), "") + "\")";
} else {
return "\"" + escapeText((String.valueOf(p.getDefault()))) + "\"";
}
@ -901,14 +914,16 @@ public class CrystalClientCodegen extends DefaultCodegen {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
try (InputStreamReader inputStreamReader = new InputStreamReader(p.getErrorStream(), StandardCharsets.UTF_8);
BufferedReader br = new BufferedReader(inputStreamReader)) {
try (InputStreamReader inputStreamReader = new InputStreamReader(p.getErrorStream(),
StandardCharsets.UTF_8);
BufferedReader br = new BufferedReader(inputStreamReader)) {
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb);
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command,
exitValue, sb);
}
} else {
LOGGER.info("Successfully executed: {}", command);
@ -922,5 +937,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
}
@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.CRYSTAL; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.CRYSTAL;
}
}

View File

@ -43,6 +43,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -187,11 +188,11 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@ -199,7 +200,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
operationId = camelize("call_" + operationId, true);
operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;
@ -226,7 +227,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toVarName(String name) {
final String varName = camelize(name.replaceAll("[^a-zA-Z0-9_]", ""), true);
final String varName = camelize(name.replaceAll("[^a-zA-Z0-9_]", ""), LOWERCASE_FIRST_LETTER);
return isReservedWord(varName) ? escapeReservedWord(name) : varName;
}

View File

@ -33,6 +33,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -297,7 +298,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
// underscore the variable name
// petId => pet_id
name = camelize(dropDots(name), true);
name = camelize(dropDots(name), LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {

View File

@ -41,6 +41,7 @@ import java.io.IOException;
import java.io.Writer;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class GoClientCodegen extends AbstractGoCodegen {
@ -392,7 +393,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
@Override
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
CodegenProperty prop = super.fromProperty(name, p, required);
String cc = camelize(prop.name, true);
String cc = camelize(prop.name, LOWERCASE_FIRST_LETTER);
if (isReservedWord(cc)) {
cc = escapeReservedWord(cc);
}

View File

@ -43,6 +43,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -1171,9 +1173,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
}
public String toVarName(String prefix, String name) {
Boolean hasPrefix = !StringUtils.isBlank(prefix);
boolean hasPrefix = !StringUtils.isBlank(prefix);
name = underscore(sanitizeName(name.replaceAll("-", "_")));
name = camelize(name, !hasPrefix);
name = camelize(name, hasPrefix ? UPPERCASE_FIRST_CHAR : LOWERCASE_FIRST_LETTER);
if (hasPrefix) {
return prefix + name;
} else {
@ -1227,7 +1230,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = escapeIdentifier("op", camelize(sanitizeName(operationId), true));
operationId = escapeIdentifier("op", camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER));
return operationId;
}

View File

@ -35,6 +35,7 @@ import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class HaskellServantCodegen extends DefaultCodegen implements CodegenConfig {
@ -592,7 +593,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
op.vendorExtensions.put("x-client-type", joinStrings(" -> ", type));
op.vendorExtensions.put("x-form-name", "Form" + camelize(op.operationId));
for (CodegenParameter param : op.formParams) {
param.vendorExtensions.put("x-form-prefix", camelize(op.operationId, true));
param.vendorExtensions.put("x-form-prefix", camelize(op.operationId, LOWERCASE_FIRST_LETTER));
}
return op;
}
@ -658,7 +659,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
}
// From the model name, compute the prefix for the fields.
String prefix = camelize(model.classname, true);
String prefix = camelize(model.classname, LOWERCASE_FIRST_LETTER);
for (CodegenProperty prop : model.vars) {
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
}

View File

@ -37,6 +37,7 @@ import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.dashize;
@ -571,7 +572,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
}
// From the model name, compute the prefix for the fields.
String prefix = camelize(model.classname, true);
String prefix = camelize(model.classname, LOWERCASE_FIRST_LETTER);
for (CodegenProperty prop : model.vars) {
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
}

View File

@ -44,6 +44,7 @@ import java.util.regex.Pattern;
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
import static java.util.Collections.sort;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavaClientCodegen extends AbstractJavaCodegen
@ -762,7 +763,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
for (int i = 0; i < items.length; ++i) {
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
// camelize path variable
items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), LOWERCASE_FIRST_LETTER) + "}";
}
}
op.path = StringUtils.join(items, "/");

View File

@ -33,6 +33,7 @@ import java.io.File;
import java.net.URL;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
/**
@ -512,7 +513,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
title = title.substring(0, title.length() - 3);
}
this.title = camelize(sanitizeName(title), true);
this.title = camelize(sanitizeName(title), LOWERCASE_FIRST_LETTER);
}
additionalProperties.put(TITLE, this.title);
}

View File

@ -34,6 +34,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
@ -330,7 +331,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
Matcher match = pathVariableMatcher.matcher(operation.path);
while (match.find()) {
String completeMatch = match.group();
String replacement = ":" + camelize(match.group(1), true);
String replacement = ":" + camelize(match.group(1), LOWERCASE_FIRST_LETTER);
operation.path = operation.path.replace(completeMatch, replacement);
}

View File

@ -40,6 +40,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class JavascriptApolloClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -507,7 +508,7 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@ -840,18 +841,18 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}

View File

@ -39,6 +39,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -492,7 +493,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
@ -825,18 +826,18 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}

View File

@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -179,7 +180,7 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
// camelize the variable name
// pet_id => PetId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*"))
@ -287,11 +288,11 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}

View File

@ -16,6 +16,7 @@
package org.openapitools.codegen.languages;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.dashize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -708,7 +709,7 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
case original:
return name;
case camelCase:
return camelize(name, true);
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:

View File

@ -63,6 +63,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
protected static final String JVM_RETROFIT2 = "jvm-retrofit2";
protected static final String MULTIPLATFORM = "multiplatform";
protected static final String JVM_VOLLEY = "jvm-volley";
protected static final String JVM_VERTX = "jvm-vertx";
public static final String USE_RX_JAVA = "useRxJava";
public static final String USE_RX_JAVA2 = "useRxJava2";
@ -215,6 +216,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportedLibraries.put(JVM_RETROFIT2, "Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.");
supportedLibraries.put(MULTIPLATFORM, "Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.");
supportedLibraries.put(JVM_VOLLEY, "Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9");
supportedLibraries.put(JVM_VERTX, "Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
@ -441,6 +443,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
case MULTIPLATFORM:
processMultiplatformLibrary(infrastructureFolder);
break;
case JVM_VERTX:
processJVMVertXLibrary(infrastructureFolder);
break;
default:
break;
}
@ -666,6 +671,22 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("auth/OAuth.kt.mustache", authFolder, "OAuth.kt"));
}
/**
* Process Vert.x client options
*
* @param infrastructureFolder infrastructure destination folder
*/
private void processJVMVertXLibrary(final String infrastructureFolder) {
supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiResponse.kt.mustache", infrastructureFolder, "ApiResponse.kt"));
addSupportingSerializerAdapters(infrastructureFolder);
additionalProperties.put(JVM, true);
additionalProperties.put(JVM_VERTX, true);
}
private void processJVMOkHttpLibrary(final String infrastructureFolder) {
commonJvmMultiplatformSupportingFiles(infrastructureFolder);
addSupportingSerializerAdapters(infrastructureFolder);

View File

@ -131,7 +131,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files. This option is currently supported only when using jaxrs-spec library.").defaultValue(String.valueOf(interfaceOnly)));
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations. This option is currently supported only when using jaxrs-spec library.", useBeanValidation));
cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines. This option is currently supported only when using jaxrs-spec library."));
cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines. This option is currently supported only when using jaxrs-spec library.", useCoroutines));
cliOptions.add(CliOption.newBoolean(RETURN_RESPONSE, "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true. This option is currently supported only when using jaxrs-spec library.").defaultValue(String.valueOf(returnResponse)));
}
@ -293,7 +293,6 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
boolean generateApis = additionalProperties.containsKey(CodegenConstants.GENERATE_APIS) && (Boolean) additionalProperties.get(CodegenConstants.GENERATE_APIS);
String packageFolder = (sourceFolder + File.separator + packageName).replace(".", File.separator);
String resourcesFolder = "src/main/resources"; // not sure this can be user configurable.
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));

View File

@ -214,7 +214,6 @@ public class KotlinServerDeprecatedCodegen extends AbstractKotlinCodegen {
boolean generateApis = additionalProperties.containsKey(CodegenConstants.GENERATE_APIS) && (Boolean) additionalProperties.get(CodegenConstants.GENERATE_APIS);
String packageFolder = (sourceFolder + File.separator + packageName).replace(".", File.separator);
String resourcesFolder = "src/main/resources"; // not sure this can be user configurable.
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));

View File

@ -42,6 +42,7 @@ import java.net.URL;
import java.util.*;
import java.util.regex.Matcher;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
@ -75,7 +76,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
private String invokerPackage;
private String serverPort = "8080";
private String title = "OpenAPI Kotlin Spring";
private String resourceFolder = "src/main/resources";
private boolean useBeanValidation = true;
private boolean exceptionHandler = true;
private boolean gradleBuildFile = true;
@ -234,14 +234,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
getDocumentationProvider().equals(DocumentationProvider.SOURCE);
}
public String getResourceFolder() {
return this.resourceFolder;
}
public void setResourceFolder(String resourceFolder) {
this.resourceFolder = resourceFolder;
}
public String getBasePackage() {
return this.basePackage;
}
@ -336,10 +328,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
this.reactive = reactive;
}
public boolean isBeanQualifiers() {
return beanQualifiers;
}
public void setBeanQualifiers(boolean beanQualifiers) {
this.beanQualifiers = beanQualifiers;
}
@ -569,16 +557,16 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),
"HomeController.kt"));
supportingFiles.add(new SupportingFile("openapi.mustache",
("src/main/resources").replace("/", java.io.File.separator), "openapi.yaml"));
resourcesFolder.replace("/", java.io.File.separator), "openapi.yaml"));
}
supportingFiles.add(new SupportingFile("application.mustache", resourceFolder, "application.yaml"));
supportingFiles.add(new SupportingFile("application.mustache", resourcesFolder, "application.yaml"));
supportingFiles.add(new SupportingFile("springBootApplication.mustache",
sanitizeDirectory(sourceFolder + File.separator + basePackage), "Application.kt"));
if (useSwaggerUI && selectedDocumentationProviderRequiresSwaggerUiBootstrap()) {
supportingFiles.add(new SupportingFile("swagger-ui.mustache",
"src/main/resources/static", "swagger-ui.html"));
resourcesFolder + "/static", "swagger-ui.html"));
}
}
}
@ -656,7 +644,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
if (title.toUpperCase(Locale.ROOT).endsWith("API"))
title = title.substring(0, title.length() - 3);
this.title = camelize(sanitizeName(title), true);
this.title = camelize(sanitizeName(title), LOWERCASE_FIRST_LETTER);
}
additionalProperties.put(TITLE, this.title);
}

View File

@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -253,10 +254,10 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
String sanitizedOperationId = sanitizeName(operationId);
if (isReservedWord(sanitizedOperationId)) {
sanitizedOperationId = "call" + StringUtils.camelize(sanitizedOperationId, false);
sanitizedOperationId = "call" + StringUtils.camelize(sanitizedOperationId);
}
return StringUtils.camelize(sanitizedOperationId, true);
return StringUtils.camelize(sanitizedOperationId, LOWERCASE_FIRST_LETTER);
}
@Override
@ -320,7 +321,7 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, append _
if (isReservedWord(name)) {
@ -350,7 +351,7 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toEnumName(CodegenProperty property) {
String name = StringUtils.camelize(property.name, false);
String name = StringUtils.camelize(property.name);
if (name.matches("\\d.*")) { // starts with number
return "`" + name + "`";
@ -362,7 +363,7 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toEnumVarName(String name, String datatype) {
name = name.replace(" ", "_");
name = StringUtils.camelize(name, false);
name = StringUtils.camelize(name);
if (name.matches("\\d.*")) { // starts with number
return "`" + name + "`";

View File

@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -573,7 +574,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
// camelize (lower first character) the variable name
// e.g. `pet_id` to `petId`
name = camelize(name, true);
name = camelize(name, LOWERCASE_FIRST_LETTER);
// for reserved word or word starting with number, prepend `_`
if (isReservedWord(name) || name.matches("^\\d.*")) {
@ -618,11 +619,12 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
operationId = "call_" + operationId;
final String newName = "call_" + operationId;
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newName);
operationId = newName;
}
return camelize(sanitizeName(operationId), true);
return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
public void setClassPrefix(String classPrefix) {
@ -677,6 +679,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
/**
* Return the default value of the schema
*
* @param p OpenAPI schema object
* @return string presentation of the default value of the schema
*/
@ -795,5 +798,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
}
@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.OBJECTIVE_C; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.OBJECTIVE_C;
}
}

View File

@ -276,7 +276,7 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
return "DefaultController";
}
return camelize(name, false) + "Controller";
return camelize(name) + "Controller";
}
protected String controllerFileFolder() {
@ -298,7 +298,7 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
return "DefaultController";
}
return camelize(name, false) + "Controller";
return camelize(name) + "Controller";
}
@Override

View File

@ -32,6 +32,7 @@ import org.openapitools.codegen.meta.Stability;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -273,7 +274,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
for (int i = 0; i < items.length; ++i) {
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
// camelize path variable
items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), LOWERCASE_FIRST_LETTER) + "}";
}
}

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