mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-14 08:23:45 +00:00
Merge remote-tracking branch 'origin/master' into 6.0.x
This commit is contained in:
commit
0357b80f19
10
.github/.test/js-yaml.js
vendored
10
.github/.test/js-yaml.js
vendored
@ -1811,7 +1811,7 @@ function readBlockScalar(state, nodeIndent) {
|
||||
}
|
||||
}
|
||||
|
||||
// Break this `while` cycle and go to the funciton's epilogue.
|
||||
// Break this `while` cycle and go to the function's epilogue.
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2862,7 +2862,7 @@ module.exports = new Schema({
|
||||
//
|
||||
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
||||
// So, this schema is not such strict as defined in the YAML specification.
|
||||
// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
|
||||
// It allows numbers in binary notation, use `Null` and `NULL` as `null`, etc.
|
||||
|
||||
|
||||
'use strict';
|
||||
@ -3222,7 +3222,7 @@ function representYamlFloat(object, style) {
|
||||
res = object.toString(10);
|
||||
|
||||
// JS stringifier can build scientific format without dots: 5e-100,
|
||||
// while YAML requres dot: 5.e-100. Fix it with simple hack
|
||||
// while YAML requires dot: 5.e-100. Fix it with simple hack
|
||||
|
||||
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
|
||||
}
|
||||
@ -3424,7 +3424,7 @@ var esprima;
|
||||
// Browserified version does not have esprima
|
||||
//
|
||||
// 1. For node.js just require module as deps
|
||||
// 2. For browser try to require mudule via external AMD system.
|
||||
// 2. For browser try to require module via external AMD system.
|
||||
// If not found - try to fallback to window.esprima. If not
|
||||
// found too - then fail to parse.
|
||||
//
|
||||
@ -3881,7 +3881,7 @@ function constructYamlTimestamp(data) {
|
||||
if (match[9]) {
|
||||
tz_hour = +(match[10]);
|
||||
tz_minute = +(match[11] || 0);
|
||||
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
||||
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in milliseconds
|
||||
if (match[9] === '-') delta = -delta;
|
||||
}
|
||||
|
||||
|
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@ -18,7 +18,7 @@ scripts/**/* @jimschubert
|
||||
website/**/* @jimschubert
|
||||
bin/ci/**/* @jimschubert
|
||||
|
||||
## Bulid related
|
||||
## Build related
|
||||
CI/**/* @OpenAPITools/build
|
||||
.mvn/**/* @OpenAPITools/build
|
||||
bin/utils/**/* @OpenAPITools/build
|
||||
|
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -16,5 +16,5 @@
|
||||
These must match the expectations made by your contribution.
|
||||
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`.
|
||||
For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `5.3.x`, `6.0.x`
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (5.3.0), `6.0.x`
|
||||
- [ ] If your PR is targeting a particular programming language, @mention the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members, so they are more likely to review the pull request.
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -215,7 +215,9 @@ cabal.project.local
|
||||
samples/client/petstore/haskell-http-client/docs/haddock-bundle.min.js
|
||||
samples/client/petstore/haskell-http-client/docs/meta.json
|
||||
samples/client/petstore/haskell-http-client/docs/quick-jump.css
|
||||
samples/client/petstore/haskell-http-client/stack.yaml.lock
|
||||
samples/server/petstore/haskell-servant/stack.yaml.lock
|
||||
samples/server/petstore/haskell-yesod/stack.yaml.lock
|
||||
|
||||
# R
|
||||
.Rproj.user
|
||||
|
@ -126,7 +126,7 @@ before_install:
|
||||
# -- skip perl test to shorten build time
|
||||
# perl dep
|
||||
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
||||
#- cpanm --quiet --no-interactive Test::Exception Test::More Log::Any LWP::UserAgent URI::Query Module::Runtime DateTime Module::Find Moose::Role JSON || echo "Igorned failure from cpanm"
|
||||
#- cpanm --quiet --no-interactive Test::Exception Test::More Log::Any LWP::UserAgent URI::Query Module::Runtime DateTime Module::Find Moose::Role JSON || echo "Ignored failure from cpanm"
|
||||
# -- skip perl test end
|
||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||
- cat /etc/hosts
|
||||
|
11
README.md
11
README.md
@ -54,6 +54,7 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
|
||||
[<img src="https://openapi-generator.tech/img/companies/datadog.png" width="128" height="128">](https://datadoghq.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/thales.jpg" width="128" height="128">](https://cpl.thalesgroup.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/apideck.jpg" width="128" height="128">](https://www.apideck.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/pexa.png" width="128" height="128">](https://www.pexa.com.au/?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
|
||||
|
||||
@ -67,8 +68,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.0, .NET Core 2.0, .NET 5.0. Libraries: RestSharp, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (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 - 11.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
|
||||
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant), **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/)), **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), **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.0, .NET Core 2.0, .NET 5.0. Libraries: RestSharp, 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 - 11.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
|
||||
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **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/)), **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), **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** |
|
||||
@ -821,6 +822,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2021-05-31 - [FlutterでOpen Api Generator(Swagger)を使う](https://aakira.app/blog/2021/05/flutter-open-api/) by [AAkira](https://twitter.com/_a_akira)
|
||||
- 2021-06-22 - [Rest API Documentation and Client Generation With OpenAPI](https://dzone.com/articles/rest-api-documentation-and-client-generation-with) by [Prasanth Gullapalli](https://dzone.com/users/1011797/prasanthnath.g@gmail.com.html)
|
||||
- 2021-07-16 - [銀行事業のサーバーサイド開発について / LINE 京都開発室 エンジニア採用説明会](https://www.youtube.com/watch?v=YrrKQHxLPpQ) by 野田誠人, Robert Mitchell
|
||||
- 2021-07-29 - [How To Rewrite a Huge Codebase](https://dzone.com/articles/how-to-rewrite-a-huge-code-base) by [Curtis Poe](https://dzone.com/users/4565446/publiusovidius.html)
|
||||
- 2021-08-21 - [Generating Client APIs using Swagger Part 1](https://medium.com/@flowsquad/generating-client-apis-using-swagger-part-1-2d46f13f5e92) by [FlowSquad.io](https://medium.com/@flowsquad)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@ -884,6 +887,7 @@ Here is a list of template creators:
|
||||
* Java (Google APIs Client Library): @charlescapps
|
||||
* Java (Rest-assured): @viclovsky
|
||||
* Java (Java 11 Native HTTP client): @bbdouglas
|
||||
* Java (Apache HttpClient): @harrywhite4
|
||||
* Javascript/NodeJS: @jfiala
|
||||
* Javascript (Apollo DataSource): @erithmetic
|
||||
* Javascript (Closure-annotated Angular) @achew22
|
||||
@ -939,6 +943,7 @@ Here is a list of template creators:
|
||||
* Go (Gin) Server: @kemokemo
|
||||
* GraphQL Express Server: @renepardon
|
||||
* Haskell Servant: @algas
|
||||
* Haskell Yesod: @yotsuya
|
||||
* Java MSF4J: @sanjeewa-malalgoda
|
||||
* Java Spring Boot: @diyfr
|
||||
* Java Undertow: @stevehu
|
||||
@ -1025,7 +1030,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||
| C# | @mandrean (2017/08) @frankyjuang (2019/09) @shibayan (2020/02) @Blackclaws (2021/03) @lucamazzanti (2021/05) |
|
||||
| Clojure | |
|
||||
| Dart | @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) |
|
||||
| Dart | @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08) |
|
||||
| Eiffel | @jvelilla (2017/09) |
|
||||
| Elixir | @mrmstn (2018/12) |
|
||||
| Elm | @eriktim (2018/09) |
|
||||
|
@ -95,7 +95,7 @@ test_script:
|
||||
# generate all petstore clients (openapi3)
|
||||
# - .\bin\openapi3\windows\run-all-petstore.cmd
|
||||
|
||||
# test ps pestore
|
||||
# test ps petstore
|
||||
- ps: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
cd samples\client\petstore\powershell\
|
||||
|
6
bin/configs/haskell-yesod-petstore-new.yaml
Normal file
6
bin/configs/haskell-yesod-petstore-new.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
generatorName: haskell-yesod
|
||||
outputDir: samples/server/petstore/haskell-yesod
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/haskell-yesod
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
8
bin/configs/java-apache-httpclient.yaml
Normal file
8
bin/configs/java-apache-httpclient.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/apache-httpclient
|
||||
library: apache-httpclient
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: petstore-apache-httpclient
|
||||
hideGenerationTimestamp: true
|
@ -17,4 +17,4 @@ The last Dart version that was used to generate the keywords can be found in `da
|
||||
1. run the dart app
|
||||
- `./save-dart-keywords.exe`
|
||||
|
||||
1. the ouput is `dart-keywords.txt` and `dart-version.txt`
|
||||
1. the output is `dart-keywords.txt` and `dart-version.txt`
|
||||
|
@ -26,7 +26,7 @@ if [[ "--skip-docs" == "${1}" ]]; then
|
||||
export SKIP_EXPORT_DOCS=true
|
||||
fi
|
||||
|
||||
# Some special case generators may expect to be run as a stanalone process (e.g. modifying classpath)
|
||||
# Some special case generators may expect to be run as a standalone process (e.g. modifying classpath)
|
||||
# Docs should always be run, regardless of batch or operation.
|
||||
declare -a always_iterate=(
|
||||
"${root}/bin/meta-codegen.sh"
|
||||
|
@ -83,6 +83,8 @@ declare -a xml_files=(
|
||||
"${root}/modules/openapi-generator-maven-plugin/examples/java-client.xml"
|
||||
"${root}/modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
|
||||
"${root}/modules/openapi-generator-maven-plugin/examples/non-java.xml"
|
||||
"${root}/modules/openapi-generator-maven-plugin/examples/kotlin.xml"
|
||||
"${root}/modules/openapi-generator-maven-plugin/examples/spring.xml"
|
||||
"${root}/pom.xml"
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
#
|
||||
# release_chekcout.rb
|
||||
# release_checkout.rb
|
||||
#
|
||||
require 'rubygems'
|
||||
require 'open-uri'
|
||||
@ -37,7 +37,7 @@ def check_npmjs
|
||||
end
|
||||
|
||||
def check_homebrew
|
||||
print "Checking homebrew forumla ... "
|
||||
print "Checking homebrew formula ... "
|
||||
|
||||
url = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/openapi-generator.rb"
|
||||
new_maven_url = "https://search.maven.org/remotecontent?filepath=org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"
|
||||
|
@ -104,7 +104,7 @@ sidebar_label: "Release Notes: 3.0.0"
|
||||
* 39fa375e3 \[kotlin] Fix NPE for POST/PUT/PATCH with empty request models.
|
||||
* c599906f1 Kotlin: Correct data_class.mustache to use proper property for inner enum data type
|
||||
* c69925b53 \[Kotlin] Fix issues with threetenbp
|
||||
* a811a48c3 minor fix to kotlin client genrator due to merge conflict
|
||||
* a811a48c3 minor fix to kotlin client generator due to merge conflict
|
||||
* 914275fe7 \[kotlin] support selection of datelibrary
|
||||
* a61d23265 Fixed incorrect renaming of header and query param to camel cases for Kotlin Client template
|
||||
|
||||
@ -141,7 +141,7 @@ sidebar_label: "Release Notes: 3.0.0"
|
||||
* 82ee8656f \[java] Enum in array of array (#66)
|
||||
* bf7e4e7df Java gson: add @SerializedName value as constant (#22)
|
||||
* 30c1448d7 Fix build.gradle for Java RESTEasy client
|
||||
* 642c0566d \[Java] Use Rx2 Completalbe for Void Retrofit2 responses
|
||||
* 642c0566d \[Java] Use Rx2 Completable for Void Retrofit2 responses
|
||||
* 72221b1cf Adding @Deprecated to retrofit2 client interfaces.
|
||||
* 47111b324 \[Java] fix gson deserialize format byte
|
||||
* 9e06f7063 \[Java] Fix assignment of new object instance to variable
|
||||
@ -183,7 +183,7 @@ sidebar_label: "Release Notes: 3.0.0"
|
||||
* 61e58d649 Add R namespace file
|
||||
|
||||
* ### Ruby
|
||||
* a08164592 fix ruby parameters in documentation, fix reuqiredParams, optionalParams
|
||||
* a08164592 fix ruby parameters in documentation, fix requiredParams, optionalParams
|
||||
* 8e34f9a98 update to newer version of ruby
|
||||
* aa6b217bb \[Ruby] Add auto-generated rubocop config file
|
||||
|
||||
@ -238,15 +238,15 @@ sidebar_label: "Release Notes: 3.0.0"
|
||||
* 866817587 \[aspnetcore] Fix string enum generation
|
||||
|
||||
* ### Java
|
||||
* bd50d368e \[JAVA - jaxrs-reasteasy-eap] Add import to models (#179)
|
||||
* bd50d368e \[JAVA - jaxrs-resteasy-eap] Add import to models (#179)
|
||||
* 7efda597c Fix issue with useBeanValidation option in Java server generators (#160)
|
||||
* 71b5de3ed Do not set contextPath for spring-boot (#104)
|
||||
* b73ab0260 jaxrs-cxf-cdi: fix outer enum (#131)
|
||||
* 4d7fc046f \[JaxRS] Add "validation-api" dependency in jetty (#30)
|
||||
* ce930e7a6 \[Jaxrs-cxf] Add bean-level cascaded beanvalidation for pojos (@Valid)
|
||||
* 386b9f432 Modify "postProcessOperations" for "jaxrs-cxf-client"
|
||||
* 5d92717dc update jaxrs to listent at port 10080
|
||||
* 7c2031675 update artifict id for jaxrs datelib j8
|
||||
* 5d92717dc update jaxrs to listen at port 10080
|
||||
* 7c2031675 update artifact id for jaxrs datelib j8
|
||||
* 88c5112f2 Adds support for returning response in jaxrs-spec interfaces
|
||||
* 6bf84d5fa \[JAXRS-SPEC] Fix lowercase enums sent as uppercase
|
||||
* 3a1922bc9 Fix version for "spring-boot-maven-plugin" (#85)
|
||||
@ -329,7 +329,7 @@ sidebar_label: "Release Notes: 3.0.0"
|
||||
* 1492df6ce Override server port for Jetty configuration
|
||||
* 622a75b2c Fix data type shadowing
|
||||
* 861d11d01 use vendor extension in operation to set the body parameter name
|
||||
* 80c8b92cb add postProcessParamter for body, form parameter
|
||||
* 80c8b92cb add postProcessParameter for body, form parameter
|
||||
* 7fe555a51 Set collectionFormat default only for array
|
||||
* 16589de97 default collection format to csv according to the spec
|
||||
* edbe4902a Consider '$ref' for consumes and produces in CodegenOperation
|
||||
|
@ -360,7 +360,7 @@ import org.openapitools.codegen.languages.*;
|
||||
|
||||
public class MyObjcCodegen extends ObjcClientCodegen {
|
||||
static {
|
||||
PREFIX = "HELO";
|
||||
PREFIX = "HELLO";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -5,7 +5,7 @@ title: "FAQ: General"
|
||||
|
||||
## Do you have a chat room?
|
||||
|
||||
[](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM)
|
||||
[](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM)
|
||||
|
||||
## What is the governance structure of the OpenAPI Generator project?
|
||||
|
||||
|
@ -94,6 +94,7 @@ The following generators are available:
|
||||
* [go-server](generators/go-server.md)
|
||||
* [graphql-nodejs-express-server](generators/graphql-nodejs-express-server.md)
|
||||
* [haskell](generators/haskell.md)
|
||||
* [haskell-yesod (beta)](generators/haskell-yesod.md)
|
||||
* [java-inflector](generators/java-inflector.md)
|
||||
* [java-msf4j](generators/java-msf4j.md)
|
||||
* [java-pkmst](generators/java-pkmst.md)
|
||||
|
@ -19,7 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|groupId|groupId for use in the generated build.gradle and pom.xml| |null|
|
||||
|invokerPackage|root package for generated code| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|library|library template (sub-template) to use|<dl><dt>**volley**</dt><dd>HTTP client: Volley 1.0.19 (default)</dd><dt>**httpclient**</dt><dd>HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1. IMPORTANT: Android client using HttpClient is not actively maintained and will be depecreated in the next major release.</dd></dl>|null|
|
||||
|library|library template (sub-template) to use|<dl><dt>**volley**</dt><dd>HTTP client: Volley 1.0.19 (default)</dd><dt>**httpclient**</dt><dd>HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1. IMPORTANT: Android client using HttpClient is not actively maintained and will be deprecated in the next major release.</dd></dl>|null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |false|
|
||||
|
@ -43,6 +43,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>TArray<uint8></li>
|
||||
<li>TMap</li>
|
||||
<li>TSharedPtr<FJsonObject></li>
|
||||
<li>TSharedPtr<FJsonValue></li>
|
||||
<li>bool</li>
|
||||
<li>double</li>
|
||||
<li>float</li>
|
||||
|
@ -14,7 +14,8 @@ sidebar_label: go-experimental
|
||||
|packageVersion|Go package version.| |1.0.0|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|structPrefix|whether to prefix struct with the class name. e.g. DeletePetOpts => PetApiDeletePetOpts| |false|
|
||||
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and onlye one match in oneOf's schemas) will be skipped.| |false|
|
||||
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
|
||||
|skipReadonlyPropertiesInInt|Skip default values to the readOnly properties in the model init function./ /false/
|
||||
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
|
||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default in GitHub PRs and diffs| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-groovy|
|
||||
|
187
docs/generators/haskell-yesod.md
Normal file
187
docs/generators/haskell-yesod.md
Normal file
@ -0,0 +1,187 @@
|
||||
---
|
||||
title: Config Options for haskell-yesod
|
||||
sidebar_label: haskell-yesod
|
||||
---
|
||||
|
||||
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiModuleName|name of the API module (Default: generated from info.title or "API")| |null|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|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|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|projectName|name of the project (Default: generated from info.title or "openapi-haskell-yesod-server")| |null|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Bool</li>
|
||||
<li>Day</li>
|
||||
<li>Double</li>
|
||||
<li>Float</li>
|
||||
<li>Int</li>
|
||||
<li>Int64</li>
|
||||
<li>Text</li>
|
||||
<li>UTCTime</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>as</li>
|
||||
<li>case</li>
|
||||
<li>class</li>
|
||||
<li>data</li>
|
||||
<li>default</li>
|
||||
<li>deriving</li>
|
||||
<li>do</li>
|
||||
<li>else</li>
|
||||
<li>family</li>
|
||||
<li>forall</li>
|
||||
<li>foreign</li>
|
||||
<li>hiding</li>
|
||||
<li>if</li>
|
||||
<li>import</li>
|
||||
<li>in</li>
|
||||
<li>infix</li>
|
||||
<li>infixl</li>
|
||||
<li>infixr</li>
|
||||
<li>instance</li>
|
||||
<li>let</li>
|
||||
<li>mdo</li>
|
||||
<li>module</li>
|
||||
<li>newtype</li>
|
||||
<li>of</li>
|
||||
<li>proc</li>
|
||||
<li>qualified</li>
|
||||
<li>rec</li>
|
||||
<li>then</li>
|
||||
<li>type</li>
|
||||
<li>where</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
||||
|
||||
### Client Modification Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasePath|✗|ToolingExtension
|
||||
|Authorizations|✗|ToolingExtension
|
||||
|UserAgent|✗|ToolingExtension
|
||||
|MockServer|✗|ToolingExtension
|
||||
|
||||
### Data Type Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Custom|✗|OAS2,OAS3
|
||||
|Int32|✓|OAS2,OAS3
|
||||
|Int64|✓|OAS2,OAS3
|
||||
|Float|✓|OAS2,OAS3
|
||||
|Double|✓|OAS2,OAS3
|
||||
|Decimal|✓|ToolingExtension
|
||||
|String|✓|OAS2,OAS3
|
||||
|Byte|✓|OAS2,OAS3
|
||||
|Binary|✓|OAS2,OAS3
|
||||
|Boolean|✓|OAS2,OAS3
|
||||
|Date|✓|OAS2,OAS3
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|CollectionFormatMulti|✓|OAS2
|
||||
|Enum|✓|OAS2,OAS3
|
||||
|ArrayOfEnum|✓|ToolingExtension
|
||||
|ArrayOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
||||
|MapOfEnum|✓|ToolingExtension
|
||||
|MapOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|MapOfCollectionOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfEnum|✓|ToolingExtension
|
||||
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✓|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
### Global Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Host|✓|OAS2,OAS3
|
||||
|BasePath|✓|OAS2,OAS3
|
||||
|Info|✓|OAS2,OAS3
|
||||
|Schemes|✗|OAS2,OAS3
|
||||
|PartialSchemes|✓|OAS2,OAS3
|
||||
|Consumes|✓|OAS2
|
||||
|Produces|✓|OAS2
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✗|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✓|OAS2
|
||||
|Cookie|✓|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✗|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✗|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
||||
|
||||
### Wire Format Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✗|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✗|OAS2,OAS3
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.controllers|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |com.prokarma.pkmst.controller|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |controllers|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.vertxweb.server.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.server.api.verticle|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.client.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
@ -36,7 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|invokerPackage|root package for generated code| |org.openapitools.client|
|
||||
|java8|Use Java8 classes instead of third party equivalents. Starting in 5.x, JDK8 is the default and the support for JDK7, JDK6 has been dropped|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd></dl>|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|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x.</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: Jackson 2.9.x</dd></dl>|okhttp-gson|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x.</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: JSON-B</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 4.x</dd></dl>|okhttp-gson|
|
||||
|licenseName|The name of the license| |Unlicense|
|
||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
|
||||
@ -53,7 +53,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|scmDeveloperConnection|SCM developer connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|
||||
|scmUrl|SCM URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |false|
|
||||
|serializationLibrary|Serialization library, default depends from the library|<dl><dt>**jsonb**</dt><dd>Use JSON-B as serialization library</dd><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd><dt>**gson**</dt><dd>Use Gson as serialization library</dd></dl>|null|
|
||||
|serializationLibrary|Serialization library, default depends on value of the option library|<dl><dt>**jsonb**</dt><dd>Use JSON-B as serialization library</dd><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd><dt>**gson**</dt><dd>Use Gson as serialization library</dd></dl>|null|
|
||||
|snapshotVersion|Uses a SNAPSHOT version.|<dl><dt>**true**</dt><dd>Use a SnapShot Version</dd><dt>**false**</dt><dd>Use a Release Version</dd></dl>|null|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -9,7 +9,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|addConsumesProducesJson|Add @Consumes/@Produces Json to API interface| |false|
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -9,7 +9,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|addConsumesProducesJson|Add @Consumes/@Produces Json to API interface| |false|
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|
@ -19,7 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|
||||
|packageName|Generated artifact package name.| |org.openapitools.client|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|requestDateConverter|JVM-Option. Defines in how to handle date-time objects that are used for a request (as query or parameter)|<dl><dt>**toJson**</dt><dd>[DEFAULT] Date formater option using a json converter.</dd><dt>**toString**</dt><dd>Use the 'toString'-method of the date-time object to retrieve the related string representation.</dd></dl>|toJson|
|
||||
|requestDateConverter|JVM-Option. Defines in how to handle date-time objects that are used for a request (as query or parameter)|<dl><dt>**toJson**</dt><dd>[DEFAULT] Date formatter option using a json converter.</dd><dt>**toString**</dt><dd>Use the 'toString'-method of the date-time object to retrieve the related string representation.</dd></dl>|toJson|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |null|
|
||||
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson' or 'jackson'| |moshi|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |null|
|
||||
|
@ -30,6 +30,24 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>ByteArray</li>
|
||||
<li>DateTime</li>
|
||||
<li>URI</li>
|
||||
<li>UUID</li>
|
||||
<li>boolean</li>
|
||||
<li>char</li>
|
||||
<li>date</li>
|
||||
<li>decimal</li>
|
||||
<li>double</li>
|
||||
<li>file</li>
|
||||
<li>float</li>
|
||||
<li>int</li>
|
||||
<li>integer</li>
|
||||
<li>long</li>
|
||||
<li>number</li>
|
||||
<li>object</li>
|
||||
<li>short</li>
|
||||
<li>string</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
@ -83,6 +83,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>class</li>
|
||||
<li>clone</li>
|
||||
<li>def</li>
|
||||
<li>do</li>
|
||||
<li>else</li>
|
||||
|
@ -81,6 +81,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>class</li>
|
||||
<li>clone</li>
|
||||
<li>def</li>
|
||||
<li>do</li>
|
||||
<li>else</li>
|
||||
|
@ -76,6 +76,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>class</li>
|
||||
<li>clone</li>
|
||||
<li>def</li>
|
||||
<li>do</li>
|
||||
<li>else</li>
|
||||
|
@ -8,7 +8,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiFirst|Generate the API from the OAI spec at server compile time (API first approach)| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|
@ -166,7 +166,7 @@ You don't need to rename the file manually, OpenAPI Generator will do it when yo
|
||||
|
||||
## Metadata folder
|
||||
|
||||
The metatata folder (to store the `VERSION` file for example) is now called `.openapi-generator/` instead of `.swagger-codegen/`.
|
||||
The metadata folder (to store the `VERSION` file for example) is now called `.openapi-generator/` instead of `.swagger-codegen/`.
|
||||
|
||||
|
||||
|
||||
|
@ -563,7 +563,7 @@ For C-like languages which also require header files, you may create two files p
|
||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||
apiTemplateFiles.put("api-body.mustache", ".m");
|
||||
```
|
||||
Here, an Operation with tag `Pet` will generate two files: `SWGPetApi.h` and `SWGPetApi.m`. The `SWG` prefix and `Api` suffix are options specific to the Objective-C geneator.
|
||||
Here, an Operation with tag `Pet` will generate two files: `SWGPetApi.h` and `SWGPetApi.m`. The `SWG` prefix and `Api` suffix are options specific to the Objective-C generator.
|
||||
|
||||
### Models
|
||||
|
||||
|
@ -62,7 +62,7 @@ public interface TemplatingEngineAdapter {
|
||||
* @param bundle The map of values to pass to the template
|
||||
* @param templateFile The name of the template (e.g. model.mustache )
|
||||
* @return the processed template result
|
||||
* @throws IOException an error ocurred in the template processing
|
||||
* @throws IOException an error occurred in the template processing
|
||||
*/
|
||||
String compileTemplate(TemplatingExecutor executor, Map<String, Object> bundle,
|
||||
String templateFile) throws IOException;
|
||||
|
@ -54,7 +54,7 @@ public class ValidationRule {
|
||||
}
|
||||
|
||||
/**
|
||||
* Evalute an instance of an object against this rule.
|
||||
* Evaluate an instance of an object against this rule.
|
||||
*
|
||||
* @param input The instance to be evaluated.
|
||||
*
|
||||
|
@ -677,7 +677,7 @@ You can run `gradle tasks --debug` to see this registration.
|
||||
|
||||
=== Android Studio
|
||||
|
||||
Android Studio may experience a Windows-specific Guava dependency conflict with openapig-enerator-gradle-plugin versions greater than 3.0.0.
|
||||
Android Studio may experience a Windows-specific Guava dependency conflict with openapi-generator-gradle-plugin versions greater than 3.0.0.
|
||||
|
||||
As a workaround, you may force exclude conflicting Guava dependencies.
|
||||
|
||||
|
@ -80,7 +80,7 @@ test {
|
||||
failFast = true
|
||||
|
||||
onOutput { descriptor, event ->
|
||||
// SLF4J may complain about multiple bindings dependign on how this is run.
|
||||
// SLF4J may complain about multiple bindings depending on how this is run.
|
||||
// This is just a warning, but can make test output less readable. So we ignore it specifically.
|
||||
if (!event.message.contains("SLF4J:")) {
|
||||
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message)
|
||||
|
@ -7,11 +7,11 @@ First, publish the openapi-generator-gradle-plugin locally via `./gradlew assemb
|
||||
Then, run the following tasks in this example directory.
|
||||
|
||||
```bash
|
||||
gradle openApiGenerate # expected outcome: BUILD SCCESSFUL
|
||||
gradle openApiMeta # expected outcome: BUILD SCCESSFUL
|
||||
gradle openApiGenerate # expected outcome: BUILD SUCCESSFUL
|
||||
gradle openApiMeta # expected outcome: BUILD SUCCESSFUL
|
||||
gradle openApiValidate # expected outcome: BUILD FAILED
|
||||
gradle buildGoSdk # expected outcome: BUILD SCCESSFUL
|
||||
gradle buildDotnetSdk # expected outcome: BUILD SCCESSFUL
|
||||
gradle buildGoSdk # expected outcome: BUILD SUCCESSFUL
|
||||
gradle buildDotnetSdk # expected outcome: BUILD SUCCESSFUL
|
||||
gradle generateGoWithInvalidSpec # expected outcome: BUILD FAILED
|
||||
```
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=5.2.1-SNAPSHOT
|
||||
openApiGeneratorVersion=5.3.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
@ -63,14 +63,14 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||
|
||||
tasks.apply {
|
||||
create("openApiGenerators", GeneratorsTask::class.java) {
|
||||
register("openApiGenerators", GeneratorsTask::class.java).configure {
|
||||
group = pluginGroup
|
||||
description = "Lists generators available via Open API Generators."
|
||||
|
||||
include.set(generators.include)
|
||||
}
|
||||
|
||||
create("openApiMeta", MetaTask::class.java) {
|
||||
register("openApiMeta", MetaTask::class.java).configure {
|
||||
group = pluginGroup
|
||||
description = "Generates a new generator to be consumed via Open API Generator."
|
||||
|
||||
@ -79,7 +79,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
outputFolder.set(meta.outputFolder)
|
||||
}
|
||||
|
||||
create("openApiValidate", ValidateTask::class.java) {
|
||||
register("openApiValidate", ValidateTask::class.java).configure {
|
||||
group = pluginGroup
|
||||
description = "Validates an Open API 2.0 or 3.x specification document."
|
||||
|
||||
@ -87,7 +87,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
recommend.set(validate.recommend)
|
||||
}
|
||||
|
||||
create("openApiGenerate", GenerateTask::class.java) {
|
||||
register("openApiGenerate", GenerateTask::class.java).configure {
|
||||
group = pluginGroup
|
||||
description = "Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents."
|
||||
|
||||
|
@ -127,7 +127,7 @@
|
||||
<version>${swagger-annotations-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- You can find the dependencies for the library configuation you chose by looking in JavaClientCodegen.
|
||||
<!-- You can find the dependencies for the library configuration you chose by looking in JavaClientCodegen.
|
||||
Then find the corresponding dependency on Maven Central, and set the versions in the property section below -->
|
||||
|
||||
<!-- HTTP client: jersey-client -->
|
||||
|
@ -81,7 +81,7 @@
|
||||
<version>${swagger-annotations-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- You can find the dependencies for the library configuation you chose by looking in JavaClientCodegen.
|
||||
<!-- You can find the dependencies for the library configuration you chose by looking in JavaClientCodegen.
|
||||
Then find the corresponding dependency on Maven Central, and set the versions in the property section below -->
|
||||
|
||||
<!-- HTTP client: jersey-client -->
|
||||
|
@ -478,7 +478,7 @@ paths:
|
||||
X-Expires-After:
|
||||
type: "string"
|
||||
format: "date-time"
|
||||
description: "date in UTC when toekn expires"
|
||||
description: "date in UTC when token expires"
|
||||
400:
|
||||
description: "Invalid username/password supplied"
|
||||
/user/logout:
|
||||
|
@ -78,7 +78,7 @@
|
||||
<version>${swagger-annotations-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- You can find the dependencies for the library configuation you chose by looking in JavaClientCodegen.
|
||||
<!-- You can find the dependencies for the library configuration you chose by looking in JavaClientCodegen.
|
||||
Then find the corresponding dependency on Maven Central, and set the versions in the property section below -->
|
||||
|
||||
<dependency>
|
||||
|
@ -478,7 +478,7 @@ paths:
|
||||
X-Expires-After:
|
||||
type: "string"
|
||||
format: "date-time"
|
||||
description: "date in UTC when toekn expires"
|
||||
description: "date in UTC when token expires"
|
||||
400:
|
||||
description: "Invalid username/password supplied"
|
||||
/user/logout:
|
||||
|
@ -637,7 +637,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
GlobalSettings.setProperty(CodegenConstants.WITH_XML, withXml.toString());
|
||||
|
||||
if (configOptions != null) {
|
||||
// Retained for backwards-compataibility with configOptions -> instantiation-types
|
||||
// Retained for backwards-compatibility with configOptions -> instantiation-types
|
||||
if (instantiationTypes == null && configOptions.containsKey("instantiation-types")) {
|
||||
applyInstantiationTypesKvp(configOptions.get("instantiation-types").toString(),
|
||||
configurator);
|
||||
@ -649,18 +649,18 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compataibility with configOptions -> type-mappings
|
||||
// Retained for backwards-compatibility with configOptions -> type-mappings
|
||||
if (typeMappings == null && configOptions.containsKey("type-mappings")) {
|
||||
applyTypeMappingsKvp(configOptions.get("type-mappings").toString(), configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compataibility with configOptions -> language-specific-primitives
|
||||
// Retained for backwards-compatibility with configOptions -> language-specific-primitives
|
||||
if (languageSpecificPrimitives == null && configOptions.containsKey("language-specific-primitives")) {
|
||||
applyLanguageSpecificPrimitivesCsv(configOptions
|
||||
.get("language-specific-primitives").toString(), configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compataibility with configOptions -> additional-properties
|
||||
// Retained for backwards-compatibility with configOptions -> additional-properties
|
||||
if (additionalProperties == null && configOptions.containsKey("additional-properties")) {
|
||||
applyAdditionalPropertiesKvp(configOptions.get("additional-properties").toString(),
|
||||
configurator);
|
||||
@ -670,7 +670,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
applyServerVariablesKvp(configOptions.get("server-variables").toString(), configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compataibility with configOptions -> reserved-words-mappings
|
||||
// Retained for backwards-compatibility with configOptions -> reserved-words-mappings
|
||||
if (reservedWordsMappings == null && configOptions.containsKey("reserved-words-mappings")) {
|
||||
applyReservedWordsMappingsKvp(configOptions.get("reserved-words-mappings")
|
||||
.toString(), configurator);
|
||||
|
@ -465,7 +465,7 @@ paths:
|
||||
type: integer
|
||||
format: int32
|
||||
X-Expires-After:
|
||||
description: date in UTC when toekn expires
|
||||
description: date in UTC when token expires
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
|
@ -465,7 +465,7 @@ paths:
|
||||
type: integer
|
||||
format: int32
|
||||
X-Expires-After:
|
||||
description: date in UTC when toekn expires
|
||||
description: date in UTC when token expires
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!doctype html> <!-- Important: must specify -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 charecters -->
|
||||
<meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 characters -->
|
||||
<script src="rapidoc-min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -207,7 +207,7 @@
|
||||
<groupId>se.bjurr.violations</groupId>
|
||||
<artifactId>violations-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- Should be decreased continuousle as issues are fixed, and will eventually
|
||||
<!-- Should be decreased continuously as issues are fixed, and will eventually
|
||||
reach 0. -->
|
||||
<maxViolations>65</maxViolations>
|
||||
</configuration>
|
||||
|
@ -229,7 +229,7 @@ public interface CodegenConfig {
|
||||
/**
|
||||
* Library template (sub-template).
|
||||
*
|
||||
* @return libray template
|
||||
* @return library template
|
||||
*/
|
||||
String getLibrary();
|
||||
|
||||
|
@ -49,6 +49,11 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public Set<String> oneOf = new TreeSet<String>();
|
||||
public Set<String> allOf = new TreeSet<String>();
|
||||
|
||||
// anyOf, oneOf, allOf with full properties/tags (e.g. isString, etc)
|
||||
public List<CodegenProperty> anyOfProps = new ArrayList<>();
|
||||
public List<CodegenProperty> allOfProps = new ArrayList<>();
|
||||
public List<CodegenProperty> oneOfProps = new ArrayList<>();
|
||||
|
||||
// The schema name as written in the OpenAPI document.
|
||||
public String name;
|
||||
// The language-specific name of the class that implements this schema.
|
||||
@ -825,6 +830,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
Objects.equals(parentModel, that.parentModel) &&
|
||||
Objects.equals(interfaceModels, that.interfaceModels) &&
|
||||
Objects.equals(children, that.children) &&
|
||||
Objects.equals(anyOf, that.anyOfProps) &&
|
||||
Objects.equals(oneOf, that.oneOfProps) &&
|
||||
Objects.equals(allOf, that.allOfProps) &&
|
||||
Objects.equals(anyOf, that.anyOf) &&
|
||||
Objects.equals(oneOf, that.oneOf) &&
|
||||
Objects.equals(allOf, that.allOf) &&
|
||||
@ -887,7 +895,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(),
|
||||
getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(),
|
||||
getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(),
|
||||
getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping);
|
||||
getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping, anyOfProps, oneOfProps, allOfProps);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -903,6 +911,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
sb.append(", anyOf=").append(anyOf);
|
||||
sb.append(", oneOf=").append(oneOf);
|
||||
sb.append(", allOf=").append(allOf);
|
||||
sb.append(", anyOf=").append(anyOfProps);
|
||||
sb.append(", oneOf=").append(oneOfProps);
|
||||
sb.append(", allOf=").append(allOfProps);
|
||||
sb.append(", name='").append(name).append('\'');
|
||||
sb.append(", classname='").append(classname).append('\'');
|
||||
sb.append(", title='").append(title).append('\'');
|
||||
|
@ -928,7 +928,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// remove \t, \n, \r
|
||||
// replace \ with \\
|
||||
// replace " with \"
|
||||
// outter unescape to retain the original multi-byte characters
|
||||
// outer unescape to retain the original multi-byte characters
|
||||
// finally escalate characters avoiding code injection
|
||||
return escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
@ -954,7 +954,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// remove \t
|
||||
// replace \ with \\
|
||||
// replace " with \"
|
||||
// outter unescape to retain the original multi-byte characters
|
||||
// outer unescape to retain the original multi-byte characters
|
||||
// finally escalate characters avoiding code injection
|
||||
return escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
@ -1331,7 +1331,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Return the variable name in the Api
|
||||
*
|
||||
* @param name the varible name of the Api
|
||||
* @param name the variable name of the Api
|
||||
* @return the snake-cased variable name
|
||||
*/
|
||||
@Override
|
||||
@ -2317,7 +2317,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Converts the OpenAPI schema name to a model name suitable for the current code generator.
|
||||
* May be overriden for each programming language.
|
||||
* May be overridden for each programming language.
|
||||
* In case the name belongs to the TypeSystem it won't be renamed.
|
||||
*
|
||||
* @param name the name of the model
|
||||
@ -2453,7 +2453,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
final List<String> allParents = ModelUtils.getAllParentsName(composed, allDefinitions, false);
|
||||
final Schema parent = StringUtils.isBlank(parentName) || allDefinitions == null ? null : allDefinitions.get(parentName);
|
||||
|
||||
// TODO revise the logic below to set dicriminator, xml attributes
|
||||
// TODO revise the logic below to set discriminator, xml attributes
|
||||
if (supportsInheritance || supportsMixins) {
|
||||
m.allVars = new ArrayList<CodegenProperty>();
|
||||
if (composed.getAllOf() != null) {
|
||||
@ -2488,6 +2488,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// interfaces (schemas defined in allOf, anyOf, oneOf)
|
||||
List<Schema> interfaces = ModelUtils.getInterfaces(composed);
|
||||
List<CodegenProperty> anyOfProps = new ArrayList<>();
|
||||
List<CodegenProperty> allOfProps = new ArrayList<>();
|
||||
List<CodegenProperty> oneOfProps = new ArrayList<>();
|
||||
if (!interfaces.isEmpty()) {
|
||||
// m.interfaces is for backward compatibility
|
||||
if (m.interfaces == null)
|
||||
@ -2499,11 +2502,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (StringUtils.isBlank(interfaceSchema.get$ref())) {
|
||||
// primitive type
|
||||
String languageType = getTypeDeclaration(interfaceSchema);
|
||||
CodegenProperty interfaceProperty = fromProperty(languageType, interfaceSchema);
|
||||
if (ModelUtils.isArraySchema(interfaceSchema) || ModelUtils.isMapSchema(interfaceSchema)) {
|
||||
CodegenProperty cp = fromProperty("composedSchemaImports", interfaceSchema);
|
||||
while (cp != null) {
|
||||
addImport(m, cp.complexType);
|
||||
cp = cp.items;
|
||||
while (interfaceProperty != null) {
|
||||
addImport(m, interfaceProperty.complexType);
|
||||
interfaceProperty = interfaceProperty.items;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2512,12 +2515,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.warn("{} (anyOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType);
|
||||
} else {
|
||||
m.anyOf.add(languageType);
|
||||
anyOfProps.add(interfaceProperty);
|
||||
|
||||
}
|
||||
} else if (composed.getOneOf() != null) {
|
||||
if (m.oneOf.contains(languageType)) {
|
||||
LOGGER.warn("{} (oneOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType);
|
||||
} else {
|
||||
m.oneOf.add(languageType);
|
||||
oneOfProps.add(interfaceProperty);
|
||||
}
|
||||
} else if (composed.getAllOf() != null) {
|
||||
// no need to add primitive type to allOf, which should comprise of schemas (models) only
|
||||
@ -2534,6 +2540,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
refSchema = allDefinitions.get(ref);
|
||||
}
|
||||
final String modelName = toModelName(ref);
|
||||
CodegenProperty interfaceProperty = fromProperty(modelName, interfaceSchema);
|
||||
m.interfaces.add(modelName);
|
||||
addImport(m, modelName);
|
||||
if (allDefinitions != null && refSchema != null) {
|
||||
@ -2552,16 +2559,23 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (composed.getAnyOf() != null) {
|
||||
m.anyOf.add(modelName);
|
||||
anyOfProps.add(interfaceProperty);
|
||||
} else if (composed.getOneOf() != null) {
|
||||
m.oneOf.add(modelName);
|
||||
oneOfProps.add(interfaceProperty);
|
||||
} else if (composed.getAllOf() != null) {
|
||||
m.allOf.add(modelName);
|
||||
allOfProps.add(interfaceProperty);
|
||||
} else {
|
||||
LOGGER.error("Composed schema has incorrect anyOf, allOf, oneOf defined: {}", composed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m.oneOfProps = oneOfProps;
|
||||
m.allOfProps = allOfProps;
|
||||
m.anyOfProps = anyOfProps;
|
||||
|
||||
if (parent != null && composed.getAllOf() != null) { // set parent for allOf only
|
||||
m.parentSchema = parentName;
|
||||
m.parent = toModelName(parentName);
|
||||
@ -3837,13 +3851,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// remove prefix in operationId
|
||||
if (removeOperationIdPrefix) {
|
||||
// The prefix is everything before the removeOperationIdPrefixCount occurrence of removeOperationIdPrefixDelimiter
|
||||
String[] componenets = operationId.split("[" + removeOperationIdPrefixDelimiter + "]");
|
||||
if (componenets.length > 1) {
|
||||
String[] components = operationId.split("[" + removeOperationIdPrefixDelimiter + "]");
|
||||
if (components.length > 1) {
|
||||
// If removeOperationIdPrefixCount is -1 or bigger that the number of occurrences, uses the last one
|
||||
int componenet_number = removeOperationIdPrefixCount == -1 ? componenets.length - 1 : removeOperationIdPrefixCount;
|
||||
componenet_number = Math.min(componenet_number, componenets.length - 1);
|
||||
int component_number = removeOperationIdPrefixCount == -1 ? components.length - 1 : removeOperationIdPrefixCount;
|
||||
component_number = Math.min(component_number, components.length - 1);
|
||||
// Reconstruct the operationId from its split elements and the delimiter
|
||||
operationId = String.join(removeOperationIdPrefixDelimiter, Arrays.copyOfRange(componenets, componenet_number, componenets.length));
|
||||
operationId = String.join(removeOperationIdPrefixDelimiter, Arrays.copyOfRange(components, component_number, components.length));
|
||||
}
|
||||
}
|
||||
operationId = removeNonNameElementToCamelCase(operationId);
|
||||
@ -3892,9 +3906,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
op.responses.sort((a, b) -> {
|
||||
int aDefault = "0".equals(a.code) ? 1 : 0;
|
||||
int bDefault = "0".equals(b.code) ? 1 : 0;
|
||||
return aDefault - bDefault;
|
||||
int aScore = a.isWildcard() ? 2 : a.isRange() ? 1 : 0;
|
||||
int bScore = b.isWildcard() ? 2 : b.isRange() ? 1 : 0;
|
||||
return Integer.compare(aScore, bScore);
|
||||
});
|
||||
|
||||
if (methodResponse != null) {
|
||||
@ -4933,7 +4947,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop through propertiies and unalias the reference if $ref (reference) is defined
|
||||
* Loop through properties and unalias the reference if $ref (reference) is defined
|
||||
*
|
||||
* @param properties model properties (schemas)
|
||||
* @return model properties with direct reference to schemas
|
||||
@ -6008,7 +6022,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else {
|
||||
LOGGER.warn("Could not compute datatypeWithEnum from {}, {}", codegenParameter.baseType, codegenParameter.enumName);
|
||||
}
|
||||
//TODO fix collectformat for form parameters
|
||||
//TODO fix collectionFormat for form parameters
|
||||
//collectionFormat = getCollectionFormat(s);
|
||||
String collectionFormat = getCollectionFormat(codegenParameter);
|
||||
// default to csv:
|
||||
@ -6563,7 +6577,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Boolean value indicating the state of the option for post-processing file using envirionment variables.
|
||||
* Boolean value indicating the state of the option for post-processing file using environment variables.
|
||||
*
|
||||
* @return true if the option is enabled
|
||||
*/
|
||||
@ -6573,7 +6587,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the boolean value indicating the state of the option for post-processing file using envirionment variables.
|
||||
* Set the boolean value indicating the state of the option for post-processing file using environment variables.
|
||||
*
|
||||
* @param enablePostProcessFile true to enable post-processing file
|
||||
*/
|
||||
|
@ -458,7 +458,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
Schema schema = schemas.get(name);
|
||||
|
||||
if (ModelUtils.isFreeFormObject(this.openAPI, schema)) { // check to see if it'a a free-form object
|
||||
if (ModelUtils.isFreeFormObject(this.openAPI, schema)) { // check to see if it's a free-form object
|
||||
// there are 3 free form use cases
|
||||
// 1. free form with no validation that is not allOf included in any composed schemas
|
||||
// 2. free form with validation
|
||||
@ -1320,8 +1320,8 @@ public class DefaultGenerator implements Generator {
|
||||
if (securityScheme != null) {
|
||||
|
||||
if (securityScheme.getType().equals(SecurityScheme.Type.OAUTH2)) {
|
||||
OAuthFlows oautUpdatedFlows = new OAuthFlows();
|
||||
oautUpdatedFlows.extensions(securityScheme.getFlows().getExtensions());
|
||||
OAuthFlows oauthUpdatedFlows = new OAuthFlows();
|
||||
oauthUpdatedFlows.extensions(securityScheme.getFlows().getExtensions());
|
||||
|
||||
SecurityScheme oauthUpdatedScheme = new SecurityScheme()
|
||||
.type(securityScheme.getType())
|
||||
@ -1333,7 +1333,7 @@ public class DefaultGenerator implements Generator {
|
||||
.bearerFormat(securityScheme.getBearerFormat())
|
||||
.openIdConnectUrl(securityScheme.getOpenIdConnectUrl())
|
||||
.extensions(securityScheme.getExtensions())
|
||||
.flows(oautUpdatedFlows);
|
||||
.flows(oauthUpdatedFlows);
|
||||
|
||||
// Ensure inserted AuthMethod only contains scopes of actual operation, and not all of them defined in the Security Component
|
||||
// have to iterate through and create new SecurityScheme objects with the scopes 'fixed/updated'
|
||||
@ -1343,22 +1343,22 @@ public class DefaultGenerator implements Generator {
|
||||
if (securitySchemeFlows.getAuthorizationCode() != null) {
|
||||
OAuthFlow updatedFlow = cloneOAuthFlow(securitySchemeFlows.getAuthorizationCode(), entry.getValue());
|
||||
|
||||
oautUpdatedFlows.setAuthorizationCode(updatedFlow);
|
||||
oauthUpdatedFlows.setAuthorizationCode(updatedFlow);
|
||||
}
|
||||
if (securitySchemeFlows.getImplicit() != null) {
|
||||
OAuthFlow updatedFlow = cloneOAuthFlow(securitySchemeFlows.getImplicit(), entry.getValue());
|
||||
|
||||
oautUpdatedFlows.setImplicit(updatedFlow);
|
||||
oauthUpdatedFlows.setImplicit(updatedFlow);
|
||||
}
|
||||
if (securitySchemeFlows.getPassword() != null) {
|
||||
OAuthFlow updatedFlow = cloneOAuthFlow(securitySchemeFlows.getPassword(), entry.getValue());
|
||||
|
||||
oautUpdatedFlows.setPassword(updatedFlow);
|
||||
oauthUpdatedFlows.setPassword(updatedFlow);
|
||||
}
|
||||
if (securitySchemeFlows.getClientCredentials() != null) {
|
||||
OAuthFlow updatedFlow = cloneOAuthFlow(securitySchemeFlows.getClientCredentials(), entry.getValue());
|
||||
|
||||
oautUpdatedFlows.setClientCredentials(updatedFlow);
|
||||
oauthUpdatedFlows.setClientCredentials(updatedFlow);
|
||||
}
|
||||
|
||||
authMethods.put(key, oauthUpdatedScheme);
|
||||
|
@ -80,7 +80,7 @@ public class ExampleGenerator {
|
||||
|
||||
if (ModelUtils.isArraySchema(responseSchema)) { // array of schema
|
||||
ArraySchema as = (ArraySchema) responseSchema;
|
||||
if (as.getItems() != null && StringUtils.isEmpty(as.getItems().get$ref())) { // arary of primtive types
|
||||
if (as.getItems() != null && StringUtils.isEmpty(as.getItems().get$ref())) { // array of primitive types
|
||||
return generate((Map<String, Object>) responseSchema.getExample(),
|
||||
new ArrayList<String>(producesInfo), as.getItems());
|
||||
} else if (as.getItems() != null && !StringUtils.isEmpty(as.getItems().get$ref())) { // array of model
|
||||
@ -90,7 +90,7 @@ public class ExampleGenerator {
|
||||
// TODO log warning message as such case is not handled at the moment
|
||||
return null;
|
||||
}
|
||||
} else if (StringUtils.isEmpty(responseSchema.get$ref())) { // primtiive type (e.g. integer, string)
|
||||
} else if (StringUtils.isEmpty(responseSchema.get$ref())) { // primitive type (e.g. integer, string)
|
||||
return generate((Map<String, Object>) responseSchema.getExample(),
|
||||
new ArrayList<String>(producesInfo), responseSchema);
|
||||
} else { // model
|
||||
|
@ -96,7 +96,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
name = "_u";
|
||||
}
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
if (isReservedWord(name)) {
|
||||
name = escapeReservedWord(name);
|
||||
@ -600,15 +600,15 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// Iterate over all of the parent model properties
|
||||
boolean removedChildEnum = false;
|
||||
for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) {
|
||||
for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) {
|
||||
// Look for enums
|
||||
if (parentModelCodegenPropery.isEnum) {
|
||||
if (parentModelCodegenProperty.isEnum) {
|
||||
// Now that we have found an enum in the parent class,
|
||||
// and search the child class for the same enum.
|
||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CodegenProperty codegenProperty = iterator.next();
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) {
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenProperty)) {
|
||||
// We found an enum in the child class that is
|
||||
// a duplicate of the one in the parent, so remove it.
|
||||
iterator.remove();
|
||||
|
@ -437,6 +437,22 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
return processed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Map<String, Object>> buildEnumVars(List<Object> values, String dataType) {
|
||||
List<Map<String, Object>> enumVars = super.buildEnumVars(values, dataType);
|
||||
|
||||
// this is needed for enumRefs like OuterEnum marked as nullable and also have string values
|
||||
// keep isString true so that the index will be used as the enum value instead of a string
|
||||
// this is inline with C# enums with string values
|
||||
if ("string?".equals(dataType)){
|
||||
enumVars.forEach((enumVar) -> {
|
||||
enumVar.put("isString", true);
|
||||
});
|
||||
}
|
||||
|
||||
return enumVars;
|
||||
}
|
||||
|
||||
/**
|
||||
* C# differs from other languages in that Enums are not _true_ objects; enums are compiled to integral types.
|
||||
* So, in C#, an enum is considers more like a user-defined primitive.
|
||||
@ -544,7 +560,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
model.vendorExtensions.put("x-enum-string", true);
|
||||
}
|
||||
|
||||
// Since we iterate enumVars for modelnnerEnum and enumClass templates, and CodegenModel is missing some of CodegenProperty's properties,
|
||||
// Since we iterate enumVars for modelInnerEnum and enumClass templates, and CodegenModel is missing some of CodegenProperty's properties,
|
||||
// we can take advantage of Mustache's contextual lookup to add the same "properties" to the model's enumVars scope rather than CodegenProperty's scope.
|
||||
List<Map<String, String>> enumVars = (ArrayList<Map<String, String>>) model.allowableValues.get("enumVars");
|
||||
List<Map<String, Object>> newEnumVars = new ArrayList<Map<String, Object>>();
|
||||
@ -821,7 +837,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
@ -850,7 +866,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = sanitizeName(name.replaceAll("-", "_"));
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
@ -304,32 +304,32 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// Not using the supertype invocation, because we want to UpperCamelize
|
||||
// the type.
|
||||
String scheamType = getSchemaType(p);
|
||||
if (typeMapping.containsKey(scheamType)) {
|
||||
return typeMapping.get(scheamType);
|
||||
String schemaType = getSchemaType(p);
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
return typeMapping.get(schemaType);
|
||||
}
|
||||
|
||||
if (typeMapping.containsValue(scheamType)) {
|
||||
return scheamType;
|
||||
if (typeMapping.containsValue(schemaType)) {
|
||||
return schemaType;
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.contains(scheamType)) {
|
||||
return scheamType;
|
||||
if (languageSpecificPrimitives.contains(schemaType)) {
|
||||
return schemaType;
|
||||
}
|
||||
|
||||
return toModelName(scheamType);
|
||||
return toModelName(schemaType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String scheamType = super.getSchemaType(p);
|
||||
String schemaType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(scheamType)) {
|
||||
type = typeMapping.get(scheamType);
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
type = typeMapping.get(schemaType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return (type);
|
||||
} else
|
||||
type = scheamType;
|
||||
type = schemaType;
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -518,15 +518,15 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// Iterate over all of the parent model properties
|
||||
boolean removedChildEnum = false;
|
||||
for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) {
|
||||
for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) {
|
||||
// Look for enums
|
||||
if (parentModelCodegenPropery.isEnum) {
|
||||
if (parentModelCodegenProperty.isEnum) {
|
||||
// Now that we have found an enum in the parent class,
|
||||
// and search the child class for the same enum.
|
||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CodegenProperty codegenProperty = iterator.next();
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) {
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenProperty)) {
|
||||
// We found an enum in the child class that is
|
||||
// a duplicate of the one in the parent, so remove it.
|
||||
iterator.remove();
|
||||
|
@ -346,7 +346,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
/*
|
||||
* F# does not allow forward declarations, so files must be imported in the correct order.
|
||||
* Output of CodeGen models must therefore bein dependency order (rather than alphabetical order, which seems to be the default).
|
||||
* Output of CodeGen models must therefore be in dependency order (rather than alphabetical order, which seems to be the default).
|
||||
* This could probably be made more efficient if absolutely needed.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@ -452,7 +452,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
model.vendorExtensions.put("x-enum-string", true);
|
||||
}
|
||||
|
||||
// Since we iterate enumVars for modelnnerEnum and enumClass templates, and CodegenModel is missing some of CodegenProperty's properties,
|
||||
// Since we iterate enumVars for modelInnerEnum and enumClass templates, and CodegenModel is missing some of CodegenProperty's properties,
|
||||
// we can take advantage of Mustache's contextual lookup to add the same "properties" to the model's enumVars scope rather than CodegenProperty's scope.
|
||||
List<Map<String, String>> enumVars = (ArrayList<Map<String, String>>) model.allowableValues.get("enumVars");
|
||||
List<Map<String, Object>> newEnumVars = new ArrayList<Map<String, Object>>();
|
||||
@ -679,7 +679,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
@ -701,7 +701,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
@ -420,7 +420,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
* <p>
|
||||
* Note the 'parent' attribute in the codegen model is used in the following scenarios:
|
||||
* - Indicate a polymorphic association with some other type (e.g. class inheritance).
|
||||
* - If the specification has a discriminator, cogegen create a “parent” based on the discriminator.
|
||||
* - If the specification has a discriminator, codegen create a “parent” based on the discriminator.
|
||||
* - Use of the 'additionalProperties' attribute in the OAS specification.
|
||||
* This is the specific scenario when codegen invokes this function.
|
||||
*
|
||||
|
@ -153,7 +153,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = sanitizeName(name.replaceAll("-", "_"));
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
|
@ -17,7 +17,56 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.meta.features.ClientModificationFeature;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.meta.features.GlobalFeature;
|
||||
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
@ -250,8 +299,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
cliOptions.add(CliOption.newBoolean(DISABLE_HTML_ESCAPING, "Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)", disableHtmlEscaping));
|
||||
cliOptions.add(CliOption.newString(BOOLEAN_GETTER_PREFIX, "Set booleanGetterPrefix").defaultValue(this.getBooleanGetterPrefix()));
|
||||
cliOptions.add(CliOption.newBoolean(IGNORE_ANYOF_IN_ENUM, "Ignore anyOf keyword in enum", ignoreAnyOfInEnum));
|
||||
cliOptions.add(CliOption.newString(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "Additional annotations for model type(class level annotations)"));
|
||||
cliOptions.add(CliOption.newString(ADDITIONAL_ENUM_TYPE_ANNOTATIONS, "Additional annotations for enum type(class level annotations)"));
|
||||
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)"));
|
||||
cliOptions.add(CliOption.newBoolean(OPENAPI_NULLABLE, "Enable OpenAPI Jackson Nullable library", this.openApiNullable));
|
||||
|
||||
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_GROUP_ID, CodegenConstants.PARENT_GROUP_ID_DESC));
|
||||
@ -297,8 +346,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
if (additionalProperties.containsKey(ADDITIONAL_MODEL_TYPE_ANNOTATIONS)) {
|
||||
String additionalAnnotationsList = additionalProperties.get(ADDITIONAL_MODEL_TYPE_ANNOTATIONS).toString();
|
||||
|
||||
this.setAdditionalModelTypeAnnotations(Arrays.asList(additionalAnnotationsList.split(";")));
|
||||
this.setAdditionalModelTypeAnnotations(new ArrayList<>(Sets.newHashSet(additionalAnnotationsList.trim().split("\\s*(;|\\r?\\n)\\s*"))));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(ADDITIONAL_ENUM_TYPE_ANNOTATIONS)) {
|
||||
@ -708,7 +756,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
name = "_" + name;
|
||||
}
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z0-9_]*$")) {
|
||||
return name;
|
||||
}
|
||||
@ -1481,15 +1529,15 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// Iterate over all of the parent model properties
|
||||
boolean removedChildEnum = false;
|
||||
for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) {
|
||||
for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) {
|
||||
// Look for enums
|
||||
if (parentModelCodegenPropery.isEnum) {
|
||||
if (parentModelCodegenProperty.isEnum) {
|
||||
// Now that we have found an enum in the parent class,
|
||||
// and search the child class for the same enum.
|
||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CodegenProperty codegenProperty = iterator.next();
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) {
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenProperty)) {
|
||||
// We found an enum in the child class that is
|
||||
// a duplicate of the one in the parent, so remove it.
|
||||
iterator.remove();
|
||||
@ -1879,6 +1927,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.parentOverridden = parentOverridden;
|
||||
}
|
||||
|
||||
public List<String> getAdditionalModelTypeAnnotations() {
|
||||
return additionalModelTypeAnnotations;
|
||||
}
|
||||
|
||||
public void setAdditionalModelTypeAnnotations(final List<String> additionalModelTypeAnnotations) {
|
||||
this.additionalModelTypeAnnotations = additionalModelTypeAnnotations;
|
||||
}
|
||||
@ -1890,7 +1942,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
|
||||
if (!supportsAdditionalPropertiesWithComposedSchema) {
|
||||
// The additional (undeclared) propertiees are modeled in Java as a HashMap.
|
||||
// The additional (undeclared) properties are modeled in Java as a HashMap.
|
||||
//
|
||||
// 1. supportsAdditionalPropertiesWithComposedSchema is set to false:
|
||||
// The generated model class extends from the HashMap. That does not work
|
||||
|
@ -61,7 +61,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
apiPackage = "org.openapitools.api";
|
||||
modelPackage = "org.openapitools.model";
|
||||
|
||||
// clioOptions default redifinition need to be updated
|
||||
// clioOptions default redefinition need to be updated
|
||||
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
|
||||
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
|
||||
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
|
@ -881,7 +881,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
name = "_u";
|
||||
}
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z0-9_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
public String toModelName(String name) {
|
||||
name = toGenericName(name);
|
||||
|
||||
// add prefix and/or suffic only if name does not start wth \ (e.g. \DateTime)
|
||||
// add prefix and/or suffix only if name does not start wth \ (e.g. \DateTime)
|
||||
if (!name.matches("^\\\\.*")) {
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
|
@ -188,7 +188,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
// remove dollar sign
|
||||
name = name.replaceAll("$", "");
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
// if it's all upper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
}
|
||||
if (!fixedPath.equals(pathname)) {
|
||||
LOGGER.warn(
|
||||
"Path '{}' is not consistant with Python variable names. It will be replaced by '{}'",
|
||||
"Path '{}' is not consistent with Python variable names. It will be replaced by '{}'",
|
||||
pathname, fixedPath);
|
||||
paths.remove(pathname);
|
||||
path.addExtension("x-python-connexion-openapi-name", pathname);
|
||||
@ -376,7 +376,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
String pythonParameterName = this.toParamName(swaggerParameterName);
|
||||
if (!swaggerParameterName.equals(pythonParameterName)) {
|
||||
LOGGER.warn(
|
||||
"Parameter name '{}' is not consistant with Python variable names. It will be replaced by '{}'",
|
||||
"Parameter name '{}' is not consistent with Python variable names. It will be replaced by '{}'",
|
||||
swaggerParameterName, pythonParameterName);
|
||||
parameter.addExtension("x-python-connexion-openapi-name", swaggerParameterName);
|
||||
parameter.setName(pythonParameterName);
|
||||
@ -439,7 +439,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
}
|
||||
break;
|
||||
case OPENIDCONNECT:
|
||||
LOGGER.warn("Security type {} is not supported by connextion yet", securityScheme.getType().toString());
|
||||
LOGGER.warn("Security type {} is not supported by connexion yet", securityScheme.getType().toString());
|
||||
case OAUTH2:
|
||||
addSecurityExtension(securityScheme, "x-tokenInfoFunc", baseFunctionName + "info_from_" + securityName);
|
||||
addSecurityExtension(securityScheme, "x-scopeValidateFunc", baseFunctionName + "validate_scope_" + securityName);
|
||||
@ -503,7 +503,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
String openapiPathname = (String) pathExtensions.remove("x-python-connexion-openapi-name");
|
||||
if (openapiPathname != null && !openapiPathname.equals(pythonPathname)) {
|
||||
LOGGER.info(
|
||||
"Path '{}' is not consistant with the original OpenAPI definition. It will be replaced back by '{}'",
|
||||
"Path '{}' is not consistent with the original OpenAPI definition. It will be replaced back by '{}'",
|
||||
pythonPathname, openapiPathname);
|
||||
paths.remove(pythonPathname);
|
||||
paths.put(openapiPathname, path);
|
||||
@ -652,7 +652,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
operation.vendorExtensions.put("x-prefered-consume", consume);
|
||||
} else if (operation.consumes.size() > 1) {
|
||||
Map<String, String> consume = operation.consumes.get(0);
|
||||
skipTests.put("reason", "Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760");
|
||||
skipTests.put("reason", "Connexion does not support multiple consumes. See https://github.com/zalando/connexion/pull/760");
|
||||
operation.vendorExtensions.put("x-prefered-consume", consume);
|
||||
if ("multipart/form-data".equals(consume.get(MEDIA_TYPE))) {
|
||||
operation.isMultipart = Boolean.TRUE;
|
||||
|
@ -85,6 +85,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
|
||||
typeMapping.put("List", "Array");
|
||||
typeMapping.put("map", "Hash");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("AnyType", "Object");
|
||||
typeMapping.put("file", "File");
|
||||
typeMapping.put("binary", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
@ -174,7 +175,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
|
||||
@Override
|
||||
public String toVarName(final String name) {
|
||||
String varName = sanitizeName(name);
|
||||
// if it's all uppper case, convert to lower case
|
||||
// if it's all upper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
varName = varName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
"case",
|
||||
"catch",
|
||||
"class",
|
||||
"clone",
|
||||
"def",
|
||||
"do",
|
||||
"else",
|
||||
@ -244,7 +245,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
varName = "_u";
|
||||
}
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (!varName.matches("^[A-Z_0-9]*$")) {
|
||||
varName = getNameUsingModelPropertyNaming(varName);
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
sanName = camelize(sanName);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
// this is unlikely to happen, because we have just camelized the name, while reserved words are usually all lowcase
|
||||
// this is unlikely to happen, because we have just camelized the name, while reserved words are usually all lowercase
|
||||
if (isReservedWord(sanName)) {
|
||||
String modelName = safePrefix + sanName;
|
||||
LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", sanName, modelName);
|
||||
|
@ -162,7 +162,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC));
|
||||
|
||||
supportedLibraries.put("volley", "HTTP client: Volley 1.0.19 (default)");
|
||||
supportedLibraries.put("httpclient", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1. IMPORTANT: Android client using HttpClient is not actively maintained and will be depecreated in the next major release.");
|
||||
supportedLibraries.put("httpclient", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1. IMPORTANT: Android client using HttpClient is not actively maintained and will be deprecated in the next major release.");
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
library.setEnum(supportedLibraries);
|
||||
cliOptions.add(library);
|
||||
@ -260,7 +260,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
if ("abstract".equals(classModifier.getOptValue())) {
|
||||
operationModifier.setOptValue(classModifier.getOptValue());
|
||||
additionalProperties.put(OPERATION_MODIFIER, operationModifier.getOptValue());
|
||||
LOGGER.warn("classModifier is {} so forcing operatonModifier to {}", classModifier.getOptValue(), operationModifier.getOptValue());
|
||||
LOGGER.warn("classModifier is {} so forcing operationModifier to {}", classModifier.getOptValue(), operationModifier.getOptValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Allow the user to force the script to always include certain cURL
|
||||
* comamnds
|
||||
* commands
|
||||
*/
|
||||
cliOptions.add(CliOption.newString(CURL_OPTIONS, "Default cURL options"));
|
||||
cliOptions.add(CliOption.newBoolean(PROCESS_MARKDOWN,
|
||||
@ -529,7 +529,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
* remove standalone '\'
|
||||
*
|
||||
* replace " with \"
|
||||
* outter unescape to retain the original multi-byte characters
|
||||
* outer unescape to retain the original multi-byte characters
|
||||
*/
|
||||
result = escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
|
@ -553,7 +553,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
// if it's all uppper case, convert to lower case
|
||||
// if it's all upper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
@ -868,7 +868,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
|
||||
return; // skip if C_POST_PROCESS_FILE env variable is not defined
|
||||
}
|
||||
|
||||
// only procees the following type (or we can simply rely on the file extension to check if it's a .c or .h file)
|
||||
// only process the following type (or we can simply rely on the file extension to check if it's a .c or .h file)
|
||||
Set<String> supportedFileType = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"supporting-mustache",
|
||||
|
@ -75,7 +75,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// By default, generated code is considered public
|
||||
protected boolean nonPublicApi = Boolean.FALSE;
|
||||
|
||||
// use KellermanSoftware.CompareNetObjects for deep recursive object comparision
|
||||
// use KellermanSoftware.CompareNetObjects for deep recursive object comparison
|
||||
protected boolean useCompareNetObjects = Boolean.FALSE;
|
||||
|
||||
// To make API response's headers dictionary case insensitive
|
||||
@ -750,15 +750,15 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
// Iterate over all of the parent model properties
|
||||
boolean removedChildEnum = false;
|
||||
for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) {
|
||||
for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) {
|
||||
// Look for enums
|
||||
if (parentModelCodegenPropery.isEnum) {
|
||||
if (parentModelCodegenProperty.isEnum) {
|
||||
// Now that we have found an enum in the parent class,
|
||||
// and search the child class for the same enum.
|
||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CodegenProperty codegenProperty = iterator.next();
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) {
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenProperty)) {
|
||||
// We found an enum in the child class that is
|
||||
// a duplicate of the one in the parent, so remove it.
|
||||
iterator.remove();
|
||||
@ -815,7 +815,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
@ -890,7 +890,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
@ -926,15 +926,15 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
// Iterate over all of the parent model properties
|
||||
boolean removedChildEnum = false;
|
||||
for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) {
|
||||
for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) {
|
||||
// Look for enums
|
||||
if (parentModelCodegenPropery.isEnum) {
|
||||
if (parentModelCodegenProperty.isEnum) {
|
||||
// Now that we have found an enum in the parent class,
|
||||
// and search the child class for the same enum.
|
||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CodegenProperty codegenProperty = iterator.next();
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) {
|
||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenProperty)) {
|
||||
// We found an enum in the child class that is
|
||||
// a duplicate of the one in the parent, so remove it.
|
||||
iterator.remove();
|
||||
|
@ -273,7 +273,7 @@ public class CppQtAbstractCodegen extends AbstractCppCodegen implements CodegenC
|
||||
String varName = name;
|
||||
varName = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
// if it's all upper case, convert to lower case
|
||||
if (varName.matches("^[A-Z_]*$")) {
|
||||
varName = varName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
||||
|
||||
// Write defaults namespace in properties so that it can be accessible in templates.
|
||||
// At this point command line has not been parsed so if value is given
|
||||
// in command line it will superseed this content
|
||||
// in command line it will supersede this content
|
||||
additionalProperties.put("cppNamespace", cppNamespace);
|
||||
additionalProperties.put("unrealModuleName", unrealModuleName);
|
||||
|
||||
@ -145,7 +145,8 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
||||
"TArray",
|
||||
"TArray<uint8>", // For byte arrays
|
||||
"TMap",
|
||||
"TSharedPtr<FJsonObject>")
|
||||
"TSharedPtr<FJsonObject>",
|
||||
"TSharedPtr<FJsonValue>")
|
||||
);
|
||||
|
||||
supportingFiles.add(new SupportingFile("model-base-header.mustache", publicFolder, modelNamePrefix + "BaseModel.h"));
|
||||
@ -185,6 +186,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
||||
typeMapping.put("Object", "TSharedPtr<FJsonObject>");
|
||||
typeMapping.put("file", "HttpFileInput");
|
||||
typeMapping.put("UUID", "FGuid");
|
||||
typeMapping.put("AnyType", "TSharedPtr<FJsonValue>");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
importMapping.put("HttpFileInput", "#include \"" + modelNamePrefix + "Helpers.h\"");
|
||||
@ -492,7 +494,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
||||
// sanitize name
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
// if it's all upper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
|
||||
String varName;
|
||||
// sanitize name
|
||||
varName = sanitizeName(name);
|
||||
// if it's all uppper case, convert to lower case
|
||||
// if it's all upper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
varName = varName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -275,37 +275,9 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
||||
// enums are generated with built_value and make use of BuiltSet
|
||||
model.imports.add("BuiltSet");
|
||||
}
|
||||
|
||||
property.getVendorExtensions().put("x-built-value-serializer-type", createBuiltValueSerializerType(property));
|
||||
}
|
||||
}
|
||||
|
||||
private String createBuiltValueSerializerType(CodegenProperty property) {
|
||||
final StringBuilder sb = new StringBuilder("const FullType(");
|
||||
if (property.isContainer) {
|
||||
appendBuiltValueCollection(sb, property);
|
||||
} else {
|
||||
sb.append(property.datatypeWithEnum);
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void appendBuiltValueCollection(StringBuilder sb, CodegenProperty property) {
|
||||
sb.append(property.baseType);
|
||||
sb.append(", [FullType(");
|
||||
if (property.isMap) {
|
||||
// a map always has string keys
|
||||
sb.append("String), FullType(");
|
||||
}
|
||||
if (property.items.isContainer) {
|
||||
appendBuiltValueCollection(sb, property.items);
|
||||
} else {
|
||||
sb.append(property.items.datatypeWithEnum);
|
||||
}
|
||||
sb.append(")]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
@ -356,7 +356,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
* Returns the number of required parameters plus 1.
|
||||
*
|
||||
* @param os List of Codegen Parameters
|
||||
* @return the string representation of the number of required paramters plus 1
|
||||
* @return the string representation of the number of required parameters plus 1
|
||||
*/
|
||||
String length(Object os) {
|
||||
int l = 1;
|
||||
@ -371,7 +371,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
* Returns the number of required parameters or body parameters.
|
||||
*
|
||||
* @param os List of Codegen Parameters
|
||||
* @return the number of required paramters or body parameters
|
||||
* @return the number of required parameters or body parameters
|
||||
*/
|
||||
int lengthRequired(List<CodegenParameter> allParams) {
|
||||
int l = 0;
|
||||
|
@ -290,7 +290,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
// if it's all upper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class GraphQLNodeJSExpressServerCodegen extends AbstractGraphQLCodegen im
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
|
||||
// IMPORTANT NOTE we add the braces within template because there we have the possibility to differenciate
|
||||
// IMPORTANT NOTE we add the braces within template because there we have the possibility to differentiate
|
||||
// between some specific types for GraphQL:
|
||||
// return "[" + getTypeDeclaration(inner) + "]";
|
||||
return getTypeDeclaration(inner);
|
||||
@ -137,7 +137,7 @@ public class GraphQLNodeJSExpressServerCodegen extends AbstractGraphQLCodegen im
|
||||
return getTypeDeclaration(inner);
|
||||
}
|
||||
|
||||
// IMPORANT NOTE Not using the supertype invocation, because we want to UpperCamelize the type:
|
||||
// IMPORTANT NOTE Not using the supertype invocation, because we want to UpperCamelize the type:
|
||||
String schemaType = getSchemaType(p);
|
||||
String nullable = ModelUtils.isNullable(p) ? "" : "!";
|
||||
|
||||
|
@ -881,6 +881,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
if (returnType == null || returnType.equals("null")) {
|
||||
returnType = "NoContent";
|
||||
SetNoContent(op, VENDOR_EXTENSION_X_INLINE_ACCEPT);
|
||||
op.hasProduces = false;
|
||||
}
|
||||
if (returnType.contains(" ")) {
|
||||
returnType = "(" + returnType + ")";
|
||||
@ -952,10 +953,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
}
|
||||
}
|
||||
|
||||
private void SetNoContent(CodegenOperation op, String inlineExtentionName) {
|
||||
private void SetNoContent(CodegenOperation op, String inlineExtensionName) {
|
||||
Map<String, String> m = new HashMap<>();
|
||||
m.put(X_MEDIA_DATA_TYPE, MIME_NO_CONTENT);
|
||||
op.vendorExtensions.put(inlineExtentionName, m);
|
||||
op.vendorExtensions.put(inlineExtensionName, m);
|
||||
}
|
||||
|
||||
private String toDedupedModelName(String paramNameType, String dataType, Boolean appendDataType) {
|
||||
@ -1417,7 +1418,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
// remove \t, \n, \r
|
||||
// replace \ with \\
|
||||
// replace " with \"
|
||||
// outter unescape to retain the original multi-byte characters
|
||||
// outer unescape to retain the original multi-byte characters
|
||||
// finally escalate characters avoiding code injection
|
||||
return escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
|
@ -0,0 +1,633 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.dashize;
|
||||
|
||||
public class HaskellYesodServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public static final String PROJECT_NAME = "projectName";
|
||||
public static final String API_MODULE_NAME = "apiModuleName";
|
||||
|
||||
private static final Pattern LEADING_UNDERSCORE = Pattern.compile("^_+");
|
||||
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(HaskellYesodServerCodegen.class);
|
||||
|
||||
protected String projectName;
|
||||
protected String apiModuleName;
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "haskell-yesod";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a haskell-yesod server.";
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getApiModuleName() {
|
||||
return apiModuleName;
|
||||
}
|
||||
|
||||
public void setApiModuleName(String apiModuleName) {
|
||||
this.apiModuleName = apiModuleName;
|
||||
}
|
||||
|
||||
public HaskellYesodServerCodegen() {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON))
|
||||
.securityFeatures(EnumSet.of(
|
||||
SecurityFeature.BasicAuth,
|
||||
SecurityFeature.ApiKey,
|
||||
SecurityFeature.OAuth2_Implicit
|
||||
))
|
||||
.excludeGlobalFeatures(
|
||||
GlobalFeature.Callbacks
|
||||
)
|
||||
.excludeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.Polymorphism
|
||||
)
|
||||
);
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
// override the mapping to keep the original mapping in Haskell
|
||||
specialCharReplacements.put("-", "Dash");
|
||||
specialCharReplacements.put(">", "GreaterThan");
|
||||
specialCharReplacements.put("<", "LessThan");
|
||||
|
||||
// backslash and double quote need double the escapement for both Java and Haskell
|
||||
specialCharReplacements.remove("\\");
|
||||
specialCharReplacements.remove("\"");
|
||||
specialCharReplacements.put("\\\\", "Back_Slash");
|
||||
specialCharReplacements.put("\\\"", "Double_Quote");
|
||||
|
||||
outputFolder = "generated-code" + File.separator + "haskell-yesod";
|
||||
apiTemplateFiles.put("api.mustache", ".hs");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".hs");
|
||||
embeddedTemplateDir = templateDir = "haskell-yesod";
|
||||
apiNameSuffix = "";
|
||||
|
||||
// Haskell keywords and reserved function names, taken mostly from https://wiki.haskell.org/Keywords
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// Keywords
|
||||
"as", "case", "of",
|
||||
"class", "data", "family",
|
||||
"default", "deriving",
|
||||
"do", "forall", "foreign", "hiding",
|
||||
"if", "then", "else",
|
||||
"import", "infix", "infixl", "infixr",
|
||||
"instance", "let", "in",
|
||||
"mdo", "module", "newtype",
|
||||
"proc", "qualified", "rec",
|
||||
"type", "where"
|
||||
)
|
||||
);
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"Bool",
|
||||
"Int",
|
||||
"Int64",
|
||||
"Float",
|
||||
"Double",
|
||||
"Text",
|
||||
"Day",
|
||||
"UTCTime"
|
||||
)
|
||||
);
|
||||
|
||||
typeMapping.clear();
|
||||
typeMapping.put("boolean", "Bool"); // type:boolean
|
||||
typeMapping.put("integer", "Int"); // type:integer+format:int32, type:integer
|
||||
typeMapping.put("long", "Int64"); // type:integer+format:int64
|
||||
typeMapping.put("number", "Double"); // type:number
|
||||
typeMapping.put("float", "Float"); // type:number+format:float
|
||||
typeMapping.put("double", "Double"); // type:number+format:double
|
||||
typeMapping.put("string", "Text"); // type:string
|
||||
typeMapping.put("date", "Day"); // type:string+format:date
|
||||
typeMapping.put("DateTime", "UTCTime"); // type:string+format:date-time
|
||||
typeMapping.put("decimal", "Text"); // type:string+format:number
|
||||
typeMapping.put("URI", "Text"); // type:string+format:uri
|
||||
typeMapping.put("UUID", "Text"); // type:string+format:uuid
|
||||
typeMapping.put("ByteArray", "Text"); // type:string+format:byte
|
||||
typeMapping.put("binary", "Text"); // type:string+format:binary
|
||||
typeMapping.put("file", "Text"); // type:string+format:binary(OAS3), type:file(OAS2)
|
||||
typeMapping.put("AnyType", "Value"); // type not specified
|
||||
|
||||
// See getTypeDeclaration() for the followings.
|
||||
// typeMapping.put("array", "List"); // type:array (ArraySchema)
|
||||
// typeMapping.put("set", "List"); // type:array+uniqueItems:true (ArraySchema)
|
||||
// typeMapping.put("map", "Map.Map"); // type:object+additionalProperties:true/<object> (MapSchema)
|
||||
|
||||
// type:object is defined as a separate data type, so the type mapping is not required.
|
||||
// typeMapping.put("object", "Value"); // type:object
|
||||
|
||||
importMapping.clear();
|
||||
|
||||
cliOptions.add(new CliOption(PROJECT_NAME,
|
||||
"name of the project (Default: generated from info.title or \"openapi-haskell-yesod-server\")"));
|
||||
cliOptions.add(new CliOption(API_MODULE_NAME,
|
||||
"name of the API module (Default: generated from info.title or \"API\")"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + "src" + File.separator + "Handler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return outputFolder + File.separator + "test" + File.separator + "Handler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
return toApiName(name) + "Spec";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("HASKELL_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Hint: Environment variable HASKELL_POST_PROCESS_FILE not defined so the Haskell code may not be properly formatted. To define it, try 'export HASKELL_POST_PROCESS_FILE=\"$HOME/.local/bin/hfmt -w\"' (Linux/Mac)");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PROJECT_NAME)) {
|
||||
this.setProjectName((String) additionalProperties.get(PROJECT_NAME));
|
||||
}
|
||||
if (additionalProperties.containsKey(API_MODULE_NAME)) {
|
||||
this.setApiModuleName((String) additionalProperties.get(API_MODULE_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
|
||||
* those terms here. This logic is only called if a variable matches the reserved words
|
||||
*
|
||||
* @return the escaped term
|
||||
*/
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
|
||||
if (openAPI.getInfo() != null) {
|
||||
Info info = openAPI.getInfo();
|
||||
if (StringUtils.isBlank(projectName) && info.getTitle() != null) {
|
||||
// when projectName is not specified, generate it from info.title
|
||||
projectName = dashize(sanitizeName(info.getTitle()));
|
||||
}
|
||||
if (StringUtils.isBlank(apiModuleName) && info.getTitle() != null) {
|
||||
// when apiModuleName is not specified, generate it from info.title
|
||||
apiModuleName = camelize(sanitizeName(info.getTitle()));
|
||||
}
|
||||
}
|
||||
|
||||
// default values
|
||||
if (StringUtils.isBlank(projectName)) {
|
||||
projectName = "openapi-haskell-yesod-server";
|
||||
}
|
||||
if (StringUtils.isBlank(apiModuleName)) {
|
||||
apiModuleName = "API";
|
||||
}
|
||||
|
||||
additionalProperties.put(PROJECT_NAME, projectName);
|
||||
additionalProperties.put(API_MODULE_NAME, apiModuleName);
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("app/DevelMain.mustache", "app", "DevelMain.hs"));
|
||||
supportingFiles.add(new SupportingFile("app/devel.mustache", "app", "devel.hs"));
|
||||
supportingFiles.add(new SupportingFile("app/main.hs", "app", "main.hs"));
|
||||
supportingFiles.add(new SupportingFile("config/keter.mustache", "config", "keter.yml"));
|
||||
supportingFiles.add(new SupportingFile("config/routes.mustache", "config", "routes.yesodroutes"));
|
||||
supportingFiles.add(new SupportingFile("config/settings.yml", "config", "settings.yml"));
|
||||
supportingFiles.add(new SupportingFile("config/test-settings.yml", "config", "test-settings.yml"));
|
||||
supportingFiles.add(new SupportingFile("dir-locals.el", "", ".dir-locals.el"));
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.yaml"));
|
||||
supportingFiles.add(new SupportingFile("src/API/Types.mustache", "src" + File.separator + apiModuleName, "Types.hs"));
|
||||
supportingFiles.add(new SupportingFile("src/Application.mustache", "src", "Application.hs"));
|
||||
supportingFiles.add(new SupportingFile("src/Error.hs", "src", "Error.hs"));
|
||||
supportingFiles.add(new SupportingFile("src/Foundation.hs", "src", "Foundation.hs"));
|
||||
supportingFiles.add(new SupportingFile("src/Import/NoFoundation.mustache", "src" + File.separator + "Import", "NoFoundation.hs"));
|
||||
supportingFiles.add(new SupportingFile("src/Import.hs", "src", "Import.hs"));
|
||||
supportingFiles.add(new SupportingFile("src/Settings/StaticFiles.hs", "src" + File.separator + "Settings", "StaticFiles.hs"));
|
||||
supportingFiles.add(new SupportingFile("src/Settings.hs", "src", "Settings.hs"));
|
||||
supportingFiles.add(new SupportingFile("stack.yaml", "", "stack.yaml"));
|
||||
supportingFiles.add(new SupportingFile("static/gitkeep", "static", ".gitkeep"));
|
||||
supportingFiles.add(new SupportingFile("test/Spec.hs", "test", "Spec.hs"));
|
||||
supportingFiles.add(new SupportingFile("test/TestImport.hs", "test", "TestImport.hs"));
|
||||
|
||||
List<Map<String, Object>> replacements = new ArrayList<>();
|
||||
Object[] replacementChars = specialCharReplacements.keySet().toArray();
|
||||
for (Object replacementChar : replacementChars) {
|
||||
String c = (String) replacementChar;
|
||||
Map<String, Object> o = new HashMap<>();
|
||||
o.put("char", c);
|
||||
o.put("replacement", "'" + specialCharReplacements.get(c));
|
||||
replacements.add(o);
|
||||
}
|
||||
additionalProperties.put("specialCharReplacements", replacements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional - type declaration. This is a String which is used by the templates to instantiate your
|
||||
* types. There is typically special handling for different property types
|
||||
*
|
||||
* @return a string value used as the `dataType` field for model templates, `returnType` for api templates
|
||||
*/
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = getAdditionalProperties(p);
|
||||
return "(Map.Map String " + getTypeDeclaration(inner) + ")";
|
||||
}
|
||||
return fixModelChars(super.getTypeDeclaration(p));
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
|
||||
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
|
||||
*
|
||||
* @return a string value of the type or complex model for this property
|
||||
*/
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String schemaType = super.getSchemaType(p);
|
||||
LOGGER.debug("debugging OpenAPI type: {}, {} => {}", p.getType(), p.getFormat(), schemaType);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
type = typeMapping.get(schemaType);
|
||||
return type;
|
||||
//if (languageSpecificPrimitives.contains(type))
|
||||
// return toModelName(type);
|
||||
} else if (typeMapping.containsValue(schemaType)) {
|
||||
// TODO what's this case for?
|
||||
type = schemaType + "_";
|
||||
} else {
|
||||
type = schemaType;
|
||||
}
|
||||
// it's a model
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toInstantiationType(Schema p) {
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
Schema additionalProperties2 = getAdditionalProperties(p);
|
||||
String type = additionalProperties2.getType();
|
||||
if (null == type) {
|
||||
LOGGER.error("No Type defined for Additional Property {}\n\tIn Property: {}", additionalProperties2, p);
|
||||
}
|
||||
String inner = getSchemaType(additionalProperties2);
|
||||
return "(Map.Map Text " + inner + ")";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
String inner = getSchemaType(ap.getItems());
|
||||
// Return only the inner type; the wrapping with QueryList is done
|
||||
// somewhere else, where we have access to the collection format.
|
||||
return inner;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> pathToComponents(String path, List<CodegenParameter> pathParams) {
|
||||
// Map the capture params by their names.
|
||||
HashMap<String, String> captureTypes = new HashMap<String, String>();
|
||||
for (CodegenParameter param : pathParams) {
|
||||
captureTypes.put(param.baseName, param.dataType);
|
||||
}
|
||||
|
||||
// Cut off the leading slash, if it is present.
|
||||
if (path.startsWith("/")) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
|
||||
// Convert the path into a list of yesod path components.
|
||||
List<String> components = new ArrayList<String>();
|
||||
for (String piece : path.split("/")) {
|
||||
if (piece.startsWith("{") && piece.endsWith("}")) {
|
||||
String name = piece.substring(1, piece.length() - 1);
|
||||
components.add("#" + captureTypes.get(name));
|
||||
} else {
|
||||
components.add(piece);
|
||||
}
|
||||
}
|
||||
|
||||
return components;
|
||||
}
|
||||
|
||||
private String pathToYesodPath(String path, List<CodegenParameter> pathParams) {
|
||||
return "/" + String.join("/", pathToComponents(path, pathParams));
|
||||
}
|
||||
|
||||
private String pathToYesodResource(String path, List<CodegenParameter> pathParams) {
|
||||
String resource = "";
|
||||
for (String component : pathToComponents(path, pathParams)) {
|
||||
if (component.startsWith("#")) {
|
||||
resource += "By" + camelize(component.substring(1));
|
||||
} else {
|
||||
resource += camelize(component);
|
||||
}
|
||||
}
|
||||
if (resource.isEmpty()) {
|
||||
resource = camelize(apiModuleName) + "Home";
|
||||
}
|
||||
resource += "R";
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, List<Server> servers) {
|
||||
CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation, servers);
|
||||
|
||||
String path = pathToYesodPath(op.path, op.pathParams);
|
||||
String resource = pathToYesodResource(op.path, op.pathParams);
|
||||
|
||||
List<Map<String, Object>> routes = (List<Map<String, Object>>) additionalProperties.get("routes");
|
||||
if (routes == null) {
|
||||
routes = new ArrayList<Map<String, Object>>();
|
||||
additionalProperties.put("routes", routes);
|
||||
}
|
||||
|
||||
// https://www.yesodweb.com/book/routing-and-handlers#routing-and-handlers_overlap_checking
|
||||
if (hasOverlappedPath(path, routes)) {
|
||||
path = "!" + path;
|
||||
}
|
||||
|
||||
Boolean found = false;
|
||||
for (Map<String, Object> route : routes) {
|
||||
if (path.equals(route.get("path"))) {
|
||||
List<String> methods = (List<String>) route.get("methods");
|
||||
methods.add(op.httpMethod);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
Map<String, Object> route = new HashMap<String, Object>();
|
||||
route.put("path", path);
|
||||
route.put("resource", resource);
|
||||
List<String> methods = new ArrayList<String>();
|
||||
methods.add(op.httpMethod);
|
||||
route.put("methods", methods);
|
||||
routes.add(route);
|
||||
}
|
||||
|
||||
// values used in api.mustache/api_test.mustache
|
||||
String handler = httpMethod.toLowerCase(Locale.ROOT) + resource;
|
||||
String paramIndent = StringUtils.repeat(" ", handler.length());
|
||||
op.vendorExtensions.put("x-handler", handler);
|
||||
op.vendorExtensions.put("x-param-indent", paramIndent);
|
||||
op.vendorExtensions.put("x-resource", resource);
|
||||
op.vendorExtensions.put("x-is-get-or-post", op.httpMethod.equals("GET") || op.httpMethod.equals("POST"));
|
||||
for (CodegenParameter param : op.pathParams) {
|
||||
param.vendorExtensions.put("x-handler", handler);
|
||||
param.vendorExtensions.put("x-param-indent", paramIndent);
|
||||
param.vendorExtensions.put("x-test-value", getParameterTestValue(param));
|
||||
}
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
public Boolean hasOverlappedPath(String path, List<Map<String, Object>> routes) {
|
||||
for (Map<String, Object> route : routes) {
|
||||
String processedPath = (String) route.get("path");
|
||||
if (processedPath.startsWith("!")) {
|
||||
continue;
|
||||
}
|
||||
if (isOverlappedPath(path, processedPath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Boolean isOverlappedPath(String pathA, String pathB) {
|
||||
if (pathA.equals(pathB)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] componentsA = pathA.split("/");
|
||||
String[] componentsB = pathB.split("/");
|
||||
if (componentsA.length != componentsB.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < componentsA.length; i++) {
|
||||
if (componentsA[i].equals(componentsB[i])) {
|
||||
continue;
|
||||
} else if (componentsA[i].startsWith("#") || componentsB[i].startsWith("#")) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getParameterTestValue(CodegenParameter codegenParameter) {
|
||||
if (Boolean.TRUE.equals(codegenParameter.isBoolean)) {
|
||||
return codegenParameter.example; // "true";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isLong)) {
|
||||
return codegenParameter.example; // "789";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isInteger)) {
|
||||
return codegenParameter.example; // "56";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isFloat)) {
|
||||
return codegenParameter.example; // "3.4";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isDouble)) {
|
||||
return codegenParameter.example; // "1.2";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isNumber)) {
|
||||
return codegenParameter.example; // "8.14";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isBinary)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "BINARY_DATA_HERE";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isByteArray)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "BYTE_ARRAY_DATA_HERE";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isFile)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "/path/to/file.txt";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isDate)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "2013-10-20";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isDateTime)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "2013-10-20T19:20:30+01:00";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isUuid)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "38400000-8cf0-11bd-b23e-10b96e4ef00d";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isUri)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "https://openapi-generator.tech";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isString)) {
|
||||
return "\"" + codegenParameter.example + "\""; // codegenParameter.paramName + "_example";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isFreeFormObject)) {
|
||||
return "\"" + codegenParameter.example + "\""; // "Object";
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
private String fixOperatorChars(String string) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String name = string;
|
||||
//Check if it is a reserved word, in which case the underscore is added when property name is generated.
|
||||
if (string.startsWith("_")) {
|
||||
if (reservedWords.contains(string.substring(1, string.length()))) {
|
||||
name = string.substring(1, string.length());
|
||||
} else if (reservedWordsMappings.containsValue(string)) {
|
||||
name = LEADING_UNDERSCORE.matcher(string).replaceFirst("");
|
||||
}
|
||||
}
|
||||
for (char c : name.toCharArray()) {
|
||||
String cString = String.valueOf(c);
|
||||
if (specialCharReplacements.containsKey(cString)) {
|
||||
sb.append("'");
|
||||
sb.append(specialCharReplacements.get(cString));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// Remove characters from a string that do not belong in a model classname
|
||||
private String fixModelChars(String string) {
|
||||
return string.replace(".", "").replace("-", "");
|
||||
}
|
||||
|
||||
// Override fromModel to create the appropriate model namings
|
||||
@Override
|
||||
public CodegenModel fromModel(String name, Schema mod) {
|
||||
CodegenModel model = super.fromModel(name, mod);
|
||||
|
||||
// setGenerateToSchema(model);
|
||||
|
||||
// Clean up the class name to remove invalid characters
|
||||
model.classname = fixModelChars(model.classname);
|
||||
if (typeMapping.containsValue(model.classname)) {
|
||||
model.classname += "_";
|
||||
}
|
||||
|
||||
// From the model name, compute the prefix for the fields.
|
||||
String prefix = camelize(model.classname, true);
|
||||
for (CodegenProperty prop : model.vars) {
|
||||
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
|
||||
}
|
||||
|
||||
// Create newtypes for things with non-object types
|
||||
String dataOrNewtype = "data";
|
||||
if (!"object".equals(model.dataType) && typeMapping.containsKey(model.dataType)) {
|
||||
String newtype = typeMapping.get(model.dataType);
|
||||
// note; newtype is a single lowercase word in Haskell (not separated by hyphen)
|
||||
model.vendorExtensions.put("x-custom-newtype", newtype);
|
||||
}
|
||||
|
||||
// Provide the prefix as a vendor extension, so that it can be used in the ToJSON and FromJSON instances.
|
||||
model.vendorExtensions.put("x-prefix", prefix);
|
||||
model.vendorExtensions.put("x-data", dataOrNewtype);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("{-", "{_-").replace("-}", "-_}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
String haskellPostProcessFile = System.getenv("HASKELL_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(haskellPostProcessFile)) {
|
||||
return; // skip if HASKELL_POST_PROCESS_FILE env variable is not defined
|
||||
}
|
||||
|
||||
// only process files with hs extension
|
||||
if ("hs".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = haskellPostProcessFile + " " + file.toString();
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user