Compare commits

..

81 Commits

Author SHA1 Message Date
William Cheng
605030dfeb add windows batch file 2019-04-01 22:56:57 +08:00
William Cheng
ecb11fbe7f remove unused files 2019-04-01 22:54:02 +08:00
William Cheng
5cd3a16e56 add nodejs fastify server generator 2019-04-01 22:53:07 +08:00
William Cheng
182264cbdd fix EmitDefaultValue default vallue with false (#2558) 2019-04-01 15:56:16 +08:00
Luis Alejandro Herrera León
ee69861a90 Added API Key auth to rust-server (#2459) 2019-04-01 15:41:36 +08:00
William Cheng
69ad9a9957 remove initialCaps and replace with camelize (#2546) 2019-04-01 11:21:11 +08:00
Thibault Duperron
9c7d4073f4 Add packageName configuration to maven (#2429) 2019-03-31 22:28:22 -04:00
Vincent Devos
f4fa941e2b [Typescript AngularJS] fix Extra package prefix in api parameters operations (#2522) 2019-04-01 09:55:06 +08:00
Igor Luzhanov
c81c09b941 #1023 - [Scala] Use status family during response processing (#1024)
* #1023 - [Scala] Use status family during response processing

* #1023 - [Scala] Use status family during response processing - adding REDIRECTION & INFORMATIONAL support
2019-03-31 19:06:39 +08:00
Karol Dudzinski
822234dd76 Generate setters for readonly properties in server code (#1582)
* generate setters for readonly properties in server code

* rollback DefaultGenerator change and remove isReadOnly tags from jaxrs server template

* updating petstore

* more petstore updates
2019-03-31 17:11:26 +08:00
William Cheng
18b500218a [JS] fix NPE for null string and improve Travis config file (#2553)
* fix NPE with null string

* update travis for nodejs

* update js samples
2019-03-31 16:15:09 +08:00
Andy
977df6e232 [elm] Update ISO 8601 library (fixes missing time zone designator) (#2545)
This updates works with ISO 8601 strings with missing ending "Z". This
is e.g. the default configuration used by spring boot in java.

See <https://github.com/rtfeldman/elm-iso8601-date-strings/pull/18>
2019-03-30 20:58:17 +01:00
Vincent Devos
976ab4fd0f [csharp] update sample after #2528 (#2550)
* [csharp] update sample after #2528

* [csharp] update sample after #2528

* [csharp] update sample after #2528
2019-03-30 16:53:50 +08:00
Vincent Devos
8977d7b366 [JavaScript] fix index.js, ApiClient.js and test files generated to incorrect location (#2511)
remove outdated samples files
update test dependencies
2019-03-30 10:04:44 +08:00
drl-max
c4d982f775 Aspnetcore nullable support (#2529)
* Added nullable support to aspnetcore server

* Regenerated aspnetcore Petstore sample

* Implemented changes based on #1819.
2019-03-30 09:39:53 +08:00
drl-max
f26d7bdea7 Csharp nullable support (#2528)
* Added nullable-type support to CSharpClientCodegen

Overrode getNullableType method
Added non-nullable type varients to 'typeMapping' collection
Removed nullable type shorthand from api template

* Added testcase for nullable support

Set Integer property to not be nullable. Expect no '?' in baseType
Set String property to be nullable. Expect no '?' in baseType

* Implemented changes to 'csharp' generator from PR #1819.
2019-03-30 09:38:23 +08:00
sunn
3bb4edf865 [C++] [Qt5] Add enum support for client and server (#2339)
* Add enum support to Qt5 client and server

* Correct model name prefix

* Remove tabs

* Correct wrong filename when prefix used
2019-03-30 09:32:06 +08:00
Tanguy Invernizzi
0bc06f8d4d Fixed typo in migration-from-swagger-codegen.md (#2548) 2019-03-29 23:35:05 +08:00
Vincent Devos
d056df6250 [TypeScript Client] fix install Aurelia + fix use deprecated function (#2514)
* [TypeScript Client] fix install Aurelia + fix use deprecated function in typescript client codegen

* [TypeScript Client] Aurelia - update typescript version

* [TypeScript Client] Aurelia - update typescript version
2019-03-29 18:07:30 +08:00
Vincent Devos
cd6779584f [KOTLIN] fix var name not correctly sanitized (#2537) 2019-03-29 17:57:37 +08:00
Jérémie Bresson
09ba78b26a Update swagger-parser to '2.0.11-OpenAPITools.org-1' (#2262)
* Update swagger-parser to '2.0.10-SNAPSHOT'

* Add a TODO

* Update input spec

* Update input spec again

* Update samples

* Set version to 2.0.10-OpenAPITools.org-1

* Ensure up-to-date

* Update to 2.0.11-OpenAPITools.org-1

* Run bin/utils/export_docs_generators.sh

* update dart-jaguar doc
2019-03-29 17:53:54 +08:00
William Cheng
e58d7d09d5 Add @karismann to Java and Kotlin technical committee (#2542)
Add @karismann to Java and Kotlin technical committee
2019-03-29 00:13:08 +08:00
William Cheng
9d10ffdb38 Add GoDaddy to the list of companies using OpenAPI Generator (#2541)
Add GoDaddy to the list of companies using OpenAPI Generator
2019-03-29 00:12:55 +08:00
Esteban Marin
88cdbbc41f [Kotlin SpringBoot Server] alternative: fix optional parameter not correctly declared in service (#2539)
* fix kotlin optional parameters

* ensure kotlin samples up to date
2019-03-28 22:30:58 +08:00
William Cheng
3a0d520c38 improve indentation, update dependencies (#2521) 2019-03-27 23:02:03 +08:00
William Cheng
1313cff93a update kotlin spring samples 2019-03-27 22:16:28 +08:00
Lukáš Vasek
a079f70fb2 [JAVA] Use specified data type in enum's fromValue instead of string (#2347)
* Use specified data type in enum's fromValue instead of string

* updated samples

* update samples

* remoe String.valueOf
2019-03-27 22:10:02 +08:00
sylvainmoindron
74fbd3454b [kotlin-spring] use spring resource for file handling (#2455)
* [kotlin-spring] use org.springframework.core.io.Resource for file handling

* run ./bin/kotlin-springboot-petstore-server.sh

* run ./bin/kotlin-springboot-petstore-server.sh after building the CLI

* use MultipartFile for file in form and the specified type otherwise

* remplace tab with space

* [kotlin-springboot] replace all instance of MultipartFile by Resource

* run ./bin/kotlin-springboot-petstore-server.sh
2019-03-27 21:44:24 +08:00
Erik Timmers
46e8ccbd1e [elm] Import types in operations (#2488)
* [elm] Import types in operations

And stringify UUIDs. Fixes #2484.

* [elm] Improve operation dependency detection
2019-03-27 17:42:34 +08:00
William Cheng
0f99cd0d37 update dart jaguar doc 2019-03-27 16:32:35 +08:00
davidwcarlson
7ab73ff587 Instantiate HttpBearerToken authentications if so declared and add helper methods. (#2485) 2019-03-27 14:07:43 +08:00
William Cheng
1c1c1ef9c3 Fix Kotlin default value (#2513)
* fix kotlin default value

* fix test cases
2019-03-27 14:04:52 +08:00
William Cheng
2ce3574868 Add a link to the article "Access any REST service with the SAP S/4HANA Cloud SDK" (#2520)
Add a link to the article "Access any REST service with the SAP S/4HANA Cloud SDK"
2019-03-27 10:26:37 +08:00
Mathieu Lemoine
81c57eefd5 [BUG][Kotlin Client] API using case other than camelCase not generated properly (#2391)
* Add Json import for all data classes

* Add `@Json` annotation for data class required variables

* Add `@json` annotation for data class optional variables

* Update samples code (petstore, strings, threetenbp)

* Fix annotation to match Kotlin coding style
2019-03-27 09:59:39 +08:00
Michael Stummvoll
6e7c621629 Fix JavaDoc errors in ApiClient for resttemplate (#2515) 2019-03-27 09:58:56 +08:00
Jaumard
41b5d0e8fc [Dart][Jaguar] and proto serialization support (#1793)
* add proto format support for jaguar generator

* Add openApiType to CodegenProperties
Finish proto generation
2019-03-27 09:48:09 +08:00
William Cheng
09d27e82e7 Minor enhancements to Scala Play server generator (#2512)
* minor enhancements to openapi-generator

* update doc

* remove oudated doc
2019-03-27 09:47:47 +08:00
William Cheng
393f5e499e Add link to the article "OpenAPI generatorを試してみる" (#2517)
Add link to the article "OpenAPI generatorを試してみる"
2019-03-27 09:44:23 +08:00
Vincent Devos
d795c4e9d0 [TypeScript Client] fix npm version when snapshot is true and npmversion is snapshot too (#2401) 2019-03-27 00:03:24 +08:00
Jérémie Bresson
01e8c67da9 Add rule to maven-enforcer-plugin to prevent usage of SNAPSHOT versions (#2509) 2019-03-26 15:05:49 +01:00
William Cheng
d4244be654 fix scala akka return type (#2510) 2019-03-26 18:54:09 +08:00
William Cheng
5a6f4cb4a9 Update Java Vertx client dependency (#2507)
* update java vertx client dep

* update java client description

* update sample
2019-03-26 18:52:34 +08:00
Andy Bao
5d05cc0e66 Fix body serialization in javascript-flowtyped generator when body is falsy (#2499) 2019-03-26 18:23:23 +08:00
Adi Gerber
28ae33cb13 New generator - Scala Play Framework (#2421)
* Added new generator for Scala + Play Framework (WIP)

* scala-play-framework: default values reintroduced (mostly); datatype -> dataType

* reintroduced missing EOF newline

* Support single/collection params for header/query params

* Rename apiFutures > supportAsync, implStubs > skipStubs (opt-out instead of opt-in)

* Deleted license and small fixes

* Generate extraction of form parameters from request body

* Added missing call to executeApi for unit methods when supportAsync=false

* Polished some stuff and added routes, application.conf, logback.xml, better default responses

* Disabled generation of Json.format for models with files

* Added README

* Multiple additions and improvements.

- Fix Indentation using mustache lambdas
- Option to set routes file name (default: routes) - allows uninterrupted manual maintenance of main routes file, which may include a subroute to the generated routes file
- Move supporting file classes to a package and update application.conf generation accordingly
- Option to generate custom exceptions (default: true) which are used in the controller to differentiate between API call exceptions and validation exceptions
- Generate error handler with basic exception mapping
- Option to generate API docs under /api route
- Reorder routes file so parameter-less paths are given priority over parameterized paths. Prevents case like /v2/user/:username activating before /v2/user/login (thus shadowing the login route completely) as observed using v3 petstore.yaml
- Option to set base package name (default: org.openapitools) to allow placing supporting files under a different package

* Revert supportAsync default to false

* Added binaries and default api/model packages

* Added scala-play-framework sample

* Add missing contextPath to README and controller comment
2019-03-26 16:04:48 +08:00
dragosnutu
9e391efd1d [#2442] - implement yamlsample config help output; (#2443) 2019-03-26 15:22:59 +08:00
Jim Schubert
173ae6f368 Remove gradle portal for snapshot publish, as the portal does not overwrite previous snapshots 2019-03-25 22:15:50 -04:00
Jim Schubert
7af272a249 Include system properties for gradle publishing 2019-03-25 21:24:49 -04:00
Jim Schubert
879d47ccd0 [gradle] Sign on gradle portal plugin publishing 2019-03-25 20:42:44 -04:00
William Cheng
65e36e8369 Merge branch 'master' of https://github.com/openapitools/openapi-generator 2019-03-25 22:45:18 +08:00
William Cheng
f015363dbd update samples 2019-03-25 22:44:05 +08:00
Gocha Ossinkine
3677bdcfc7 Replace deprecated Controller with new one (#2146) 2019-03-25 22:07:40 +08:00
Alok Prateek
3810d12086 [#2441] Update documentation mustache templates for proper linting. (#2458)
* [#2441] Update documentation mustache files for PHP client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* [#2441] Update documentation mustache files for ruby client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* [#2441] Update documentation mustache files for javascript client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* [#2441] Update documentation mustache files for Java client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* [#2441] Update documentation mustache files for GO client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* [#2441] Update documentation mustache files for Rust client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* [#2441] Update documentation mustache files for C# client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* [#2441] Update documentation mustache files for Android client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
Issues with generated markdown files as reported by markdownlint for node.js are:

- MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
- MD002 first-heading-h1/first-header-h1 - First heading should be a top level heading
- MD007 ul-indent - Unordered list indentation
- MD009 no-trailing-spaces - Trailing spaces
- MD010 no-hard-tabs - Hard tabs
- MD011 no-reversed-links - Reversed link syntax
- MD025 single-h1 - Multiple top level headings in the same document
- MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- MD032 blanks-around-lists - Lists should be surrounded by blank lines
- MD040 fenced-code-language - Fenced code blocks should have a language specified
- MD041 first-line-h1 - First line in file should be a top level heading

* Update README.mustache

* [#2441] Update documentation mustache files for Ada client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]

* [#2441] Update documentation mustache files for Apex client

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]

* [#2441] Update documentation mustache files for bash

This commit fixes issues with Markdown/CommonMark parsing by linting and enforcing consistent style.[#2441]
2019-03-25 21:48:22 +08:00
Jochen Scheib
c918d7ad64 go-server: Support additional properties as command line arguments (#1555)
* Support additionalPorperties as command line arguments

* Move Readme into main dir

* Update Mustache

* Update sample

* Test coverage

* Move cli options

* Revert options

* Remove tabs

* openapi 3 examples

* Update readme

* serverPort to int

* Move package version cli option to AbstractGoCodegen

* Update samples

* Tab to spaces

* Update docs and sample with xml

* Manual update doc

* Another doc try

* Regenerate go-gin-server doc
2019-03-25 21:19:06 +08:00
William Cheng
5346eb4c34 Add a link to Qitta blog post on OpenAPI Generator (#2497)
Add a link to Qitta blog post on OpenAPI Generator
2019-03-25 13:13:41 +08:00
William Cheng
3e065db2c6 better operation id handling in scala generators (#2490) 2019-03-25 13:13:09 +08:00
Joël Vimenet
5074f4d9c5 Update akka scala generator (#2472)
* Update akka scala generator

* Upgrade scala version to 2.12.8
* Upgrade Akka version
* Migrate from spray to Akka HTTP

* Update client sample

* Fix pom.xml generation to be equivalent to build.sbt
2019-03-25 13:12:56 +08:00
Jim Schubert
df0d53795c Publish to gradle plugin prior to sonatype (#2496) 2019-03-24 22:19:19 -04:00
William Cheng
3b017c59f1 Add better example code for R object (#2492)
* add better example for r object

* better code format
2019-03-24 23:21:31 +08:00
William Cheng
e0caa6fd66 better code format for kotlin, python (#2491) 2019-03-24 21:45:33 +08:00
Thibault Duperron
0935f5345d Kotlin model name camelize (#2430)
* Kotlin model name camelize

* Update samples
2019-03-24 10:47:05 +08:00
Tom Ghyselinck
f7943257c5 Python flask pythonic params (#2374)
* Using connexion `pythonic_params` support while keeping OpenAPI spec file correct with reference to the original spec file.

* - Add `camelCase` query parameter which shows the incorrectnes of the conversion of the OpenAPI spec file in Python server implementation(s).

* Also use `pythonic_params=True` for the `python-aiohttp` implementation.

* - Updated Python related samples.

* The unit tests must provide the correct query parameters.

* - Updated Python related samples.
2019-03-24 10:36:26 +08:00
Akira Tanimura
033ab8a6f5 [Ruby] Use Integer instead of Fixnum in Ruby client (#2475) (#2481)
* use Integer instead of Fixnum in Ruby client (#2475)

* update samples (#2475)
2019-03-23 18:48:10 +08:00
davidwcarlson
1adc962f2b java-jersey2 - Always render setBearerToken regardless of whether OAuth2 is in use. (#2479) 2019-03-23 18:38:00 +08:00
Akira Tanimura
94c267ee42 [Ruby] Auto recreate directories in Ruby samples (#2476)
* purge lib, doc, spec directories before generate Ruby client sample

* update Ruby client samples
2019-03-23 18:35:47 +08:00
vtitov
4a7dfecf24 Bugfix/maven classpath schema (#2409)
* multi-module example for maven plugin master

* read byte source from classpath like swagger-parser does

* renamed schema to openapi.yaml for multi-module examples

* renamed schema to openapi.yaml for multi-module examples
2019-03-23 18:34:04 +08:00
Jan Buchar
db1b63780d Add return type declaration to typescript-fetch runtime (#2466)
* Add return type declaration to typescript-fetch runtime

closes #2461

* Regenerate samples
2019-03-22 14:42:31 +08:00
Vincent Devos
e3716262e5 [Kotlin client]fix warning when else all covered (#2470) 2019-03-22 14:40:14 +08:00
Gaurav Yadav
ee75366051 Added proxy headers option for urllib3 (#2467)
* adding headers option to pass in rest client

* running ensure uptodate
2019-03-22 11:22:10 +08:00
Hector Jusforgues
d839af5b1e [typescript-axios] Fix JSON serialization of falsy request bodies (#2446)
* [typescript-axios] Fix JSON serialization of falsy request bodies

Fix #2445

* [typescript-axios] update petstore samples
2019-03-22 10:57:53 +08:00
William Cheng
2e777c04d4 Better handling of operationId with slashes (#2469)
* better handling of operation id with slashes

* update smaples
2019-03-22 10:41:53 +08:00
Justin Black
b1955f3517 Adds exceptions module to python clients (#2393)
* Adds python client exceptions module and updates samples

* Adds python style updates, detects integers in exception paths with six

* Updates to ruby samples which circleci needs

* Removes petstore-security-tests samples

* readme char removal (triggers ci tests)

* Readme fix, triggers CI tests

* Updates python client sample
2019-03-22 10:40:32 +08:00
Gaurav Yadav
45ad72b032 Adding retries option to override default value 3 of urllib3 (#2460)
* adding retries option to override default value 3 of urllib3

* running petstore for python

* adding files for samples in petstore run

* running ensure-up-to-date
2019-03-22 08:24:23 +08:00
William Cheng
2101780a09 test kotlin in shippable (#2465) 2019-03-22 07:58:23 +08:00
Kevin Smith
1a19edb0e5 Add build script and remove babel (#2439)
* Add build script and remove babel

This change adds a build script which uses babel to transpile generated es6 source to es5, such that it can then be used in node projects or published as a package to npm. The `babel` package is also removed as it is deprecated, and superseded by `babel-cli`.

See https://github.com/OpenAPITools/openapi-generator/issues/2126#issuecomment-473926663

* update samples
2019-03-21 22:36:56 +08:00
Kevin Turner
2f8e4fe32b [TypeScript][Node] async promises and imports (#2452)
* async promises and imports

* Sample regen

* Correct licence info

* update samples
2019-03-21 22:27:38 +08:00
Akihito Nakano
77545df80d Add RuboCop to Gemfile (#2464)
* Add Rubocop

* Update samples

./bin/openapi3/ruby-client-petstore.sh
./bin/ruby-client-petstore.sh
2019-03-21 22:00:08 +08:00
john lilley
dc78405a68 1391 jel minimal overwrite option (#2451)
Option to overwrite only changed files
2019-03-21 00:17:10 +08:00
William Cheng
fef2970dab commnet out kotlin client jdk7 test 2019-03-20 23:47:44 +08:00
William Cheng
522ccee7f3 remove publishPlugins 2019-03-20 22:40:53 +08:00
William Cheng
d32564da51 comment out kotlin tests 2019-03-20 22:34:49 +08:00
Michael Ramstein
49f3e9a355 [Elixir] Deserialize responses based on status code (#2355)
* Update Tesla dependency and replace Poison with Jason

* Use new Tesla method to set headers

* Fix jason dependency definition

* Use list for Headers instead of a map

* Rollback to Poison because Jason does not support 'as:' option to decode to arbitrary struct

* Use new return signature from Tesla 1.0 in decode function

* catch error when a struct is given as second parameter to RequestBuilder.decode

* Update modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache

Co-Authored-By: yknx4 <yknx.4.b@gmail.com>

* Update modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache

Co-Authored-By: yknx4 <yknx.4.b@gmail.com>

* Evaluate response based on status code

* Generate Petstore

* pin poison to ~> 3.0.0 since 4.0.0 does not work atm

* run ./bin/openapi3/elixir-petstore.sh
2019-03-20 21:35:50 +08:00
3465 changed files with 51100 additions and 47746 deletions

View File

@@ -1 +1 @@
oracle64-1.8.0.152
oracle64-1.8.0.152

View File

@@ -133,18 +133,16 @@ after_success:
cd modules/openapi-generator-gradle-plugin;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
echo "Finished ./gradlew uploadArchives";
#./gradlew publishPlugins;
#echo "Finished ./gradlew publishPlugins (plugin portal)";
popd;
elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then
mvn clean deploy --settings CI/settings.xml;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET --no-daemon;
echo "Finished ./gradlew publishPlugins (plugin portal)";
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
echo "Finished ./gradlew uploadArchives";
#./gradlew publishPlugins;
#echo "Finished ./gradlew publishPlugins (plugin portal)";
popd;
fi;
fi;

View File

@@ -39,7 +39,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| | Languages/Frameworks |
|-|-|
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **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), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra)
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
**API documentation generators** | **HTML**, **Confluence Wiki**
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
**Others** | **GraphQL**, **JMeter**, **MySQL Schema**
@@ -511,6 +511,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [FormAPI](https://formapi.io/)
- [GenFlow](https://github.com/RepreZen/GenFlow)
- [GMO Pepabo](https://pepabo.com/en/)
- [GoDaddy](https://godaddy.com)
- [JustStar](https://www.juststarinfo.com)
- [Klarna](https://www.klarna.com/)
- [Metaswitch](https://www.metaswitch.com/)
@@ -551,6 +552,10 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019/02/20 - [An adventure in OpenAPI V3 code generation](https://mux.com/blog/an-adventure-in-openapi-v3-api-code-generation/) by [Phil Cluff](https://mux.com/blog/author/philc/)
- 2019/02/26 - [Building API Services: A Beginners Guide](https://medium.com/google-cloud/building-api-services-a-beginners-guide-7274ae4c547f) by [Ratros Y.](https://medium.com/@ratrosy) in [Google Cloud Platofrm Blog](https://medium.com/google-cloud)
- 2019/02/26 - [Building APIs with OpenAPI: Continued](https://medium.com/@ratrosy/building-apis-with-openapi-continued-5d0faaed32eb) by [Ratros Y.](https://medium.com/@ratrosy) in [Google Cloud Platofrm Blog](https://medium.com/google-cloud)
- 2019-03-07 - [OpenAPI Generator で Spring Boot と Angular をタイプセーフに繋ぐ](https://qiita.com/chibato/items/e4a748db12409b40c02f) by [Tomofumi Chiba](https://github.com/chibat)
- 2019-03-25 - [Access any REST service with the SAP S/4HANA Cloud SDK](https://blogs.sap.com/2019/03/25/integrate-sap-s4hana-cloud-sdk-with-open-api/) by [Alexander Duemont](https://people.sap.com/alexander.duemont)
- 2019-03-25 - [OpenAPI generatorを試してみる](https://qiita.com/amuyikam/items/e8a45daae59c68be0fc8) by [@amuyikam](https://twitter.com/amuyikam)
## [6 - About Us](#table-of-contents)
@@ -662,6 +667,7 @@ Here is a list of template creators:
* Rust (rust-server): @metaswitch
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Scala Lagom: @gmkumar2005
* Scala Play: @adigerber
* Documentation
* HTML Doc 2: @jhitchcock
* Confluence Wiki: @jhitchcock
@@ -722,8 +728,8 @@ If you want to join the committee, please kindly apply by sending an email to te
| GraphQL | @renepardon (2018/12) |
| Groovy | |
| Haskell | |
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) |
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) |
| Lua | @daurnimator (2017/08) |
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
| ObjC | |

View File

@@ -35,6 +35,14 @@ java $JAVA_OPTS -jar $executable $ags
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
java $JAVA_OPTS -jar $executable $ags
# Generate proto and put it to the flutter sample app
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi -Dserialization=proto -DhideGenerationTimestamp=true -DpubName=openapi"
java $JAVA_OPTS -jar $executable $ags
# Generate proto and put it to the sample
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/openapi_proto -Dserialization=proto -DhideGenerationTimestamp=true -DpubName=openapi"
java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment:
# https://github.com/munificent/dep-interface-libraries
# When this is implemented there will only be one library.

View File

@@ -1,4 +1,5 @@
{
"library": "vertx",
"dateLibrary": "java8",
"artifactId": "petstore-vertx"
}

View File

@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
mvn -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g cpp-qt5-client -o samples/client/petstore-security-test/cpp-qt5 $@"
ags="generate -t modules/openapi-generator/src/main/resources/nodejs-fastify-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-fastify-server -o samples/server/petstore/nodejs-fastify-server $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -25,6 +25,11 @@ then
mvn -B clean package
fi
echo "purge ruby petstore lib, docs, spec folder"
rm -Rf samples/client/petstore/ruby/lib
rm -Rf samples/client/petstore/ruby/docs
rm -Rf samples/client/petstore/ruby/spec
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"

View File

@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
mvn -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g scala-httpclient -o samples/client/petstore-security-test/scala-httpclient $@"
ags="generate -t modules/openapi-generator/src/main/resources/scala-play-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-play-server -o samples/server/petstore/scala-play-server $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g csharp -o samples/client/petstore-security-test/csharp/SwaggerClient --additional-properties packageGuid={8CE139DF-64BC-4591-85F8-8506C2B67514} $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,39 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
SPEC="modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml"
GENERATOR="go"
STUB_DIR="samples/client/petstore-security-test/go"
echo "Removing files and folders under $STUB_DIR"
rm -rf $STUB_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/go -i $SPEC -g $GENERATOR -o $STUB_DIR $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,34 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore-security-test/java/okhttp-gson -DhideGenerationTimestamp=true $@"
rm -rf samples/client/petstore-security-test/java/okhttp-gson/src/main
find samples/client/petstore-security-test/java/okhttp-gson -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g javascript-closure-angular -o samples/client/petstore-security-test/javascript-closure-angular $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/Javascript -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g javascript -o samples/client/petstore-security-test/javascript -DappName=PetstoreClient $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/lumen -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-lumen -o samples/server/petstore-security-test/lumen $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/mysql-schema -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g mysql-schema -o samples/schema/petstore-security-test/mysql $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/objc -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g objc -o samples/client/petstore-security-test/objc $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,38 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# cleanup tests
TEST_DIR="./samples/client/petstore-security-test/php/OpenAPIToolsClient-php/test"
if [ -d $TEST_DIR ]; then
rm -rf $TEST_DIR
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-security-test.yaml -g php -o samples/openapi3/client/petstore-security-test/php/OpenAPIClient-php $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,10 +0,0 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-security-test.yaml -g php -o samples\openapi3\client\petstore-security-test\php\OpenAPIClient-php
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -1,35 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# complex module name used for testing
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g perl -o samples/client/petstore-security-test/perl $@"
java $JAVA_OPTS -jar $executable $ags
java $JAVA_OPTS -jar $executable $ags --additional-properties moduleName=Something::Deep -o samples/client/petstore-security-test/perl/deep_module_test

View File

@@ -1,38 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# cleanup tests
TEST_DIR="./samples/client/petstore-security-test/php/OpenAPIToolsClient-php/test"
if [ -d $TEST_DIR ]; then
rm -rf $TEST_DIR
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php -o samples/client/petstore-security-test/php/OpenAPIClient-php $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/php-slim-server -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-slim -o samples/server/petstore-security-test/php-slim $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g python -o samples/client/petstore-security-test/python -DpackageName=petstore_api $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,15 +0,0 @@
#!/bin/bash -e
for SCRIPT in ./bin/security/*.sh
do
if [ -f $SCRIPT -a -x $SCRIPT ]
then
$SCRIPT
rc=$?
if [[ $rc != 0 ]]
then
echo "ERROR!! FAILED TO RUN $SCRIPT"
exit $rc;
fi
fi
done

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-silex -o samples/server/petstore-security-test/silex/SwaggerServer $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g swift2-deprecated -o samples/client/petstore-security-test/swift $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/typescript-angular -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-angular -o samples/client/petstore-security-test/typescript-angular $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-angular -o samples/client/petstore-security-test/typescript-angular2 $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/typescript-fetch -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-fetch -o samples/client/petstore-security-test/typescript-fetch $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/typescript-inversify -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-inversify -o samples/client/petstore-security-test/typescript-inversify $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,37 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
echo "Typescript jquery Petstore API client (default setting)"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-jquery -o samples/client/petstore-security-test/typescript-jquery/default $@"
java $JAVA_OPTS -jar $executable $ags
echo "Typescript jquery Petstore API client with npm setting"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-jquery -c bin/typescript-petstore-npm.json -o samples/client/petstore-security-test/typescript-jquery/npm $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/typescript-node -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g typescript-node -o samples/client/petstore-security-test/typescript-node $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,10 +0,0 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g csharp -o samples/client/petstore-security-test/csharp/SwaggerClient --additional-properties packageGuid={8CE139DF-64BC-4591-85F8-8506C2B67514}
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -1,10 +0,0 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -t modules/openapi-generator/src/main/resources/cpp-qt5-client -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g qt5cpp -o samples\client\petstore-security-test\qt5cpp
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -24,6 +24,7 @@ declare -a scripts=(
"./bin/kotlin-client-string.sh"
"./bin/kotlin-client-threetenbp.sh"
"./bin/kotlin-server-petstore.sh"
"./bin/kotlin-springboot-petstore-server.sh"
"./bin/mysql-schema-petstore.sh"
"./bin/python-petstore-all.sh"
"./bin/openapi3/python-petstore.sh"
@@ -34,7 +35,9 @@ declare -a scripts=(
"./bin/php-slim-server-petstore.sh"
"./bin/php-ze-ph-petstore-server.sh"
"./bin/openapi3/php-petstore.sh"
"./bin/typescript-angularjs-petstore.sh"
"./bin/typescript-angular-petstore-all.sh"
"./bin/typescript-aurelia-petstore.sh"
"./bin/typescript-axios-petstore-all.sh"
"./bin/typescript-fetch-petstore-all.sh"
"./bin/typescript-node-petstore-all.sh"

View File

@@ -1,10 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin-spring -o samples\server\petstore\kotlin-springboot --additional-properties=library=spring-boot
java %JAVA_OPTS% -jar %executable% %ags%
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin-spring -o samples\server\petstore\kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -t modules\openapi-generator\src\main\resources\nodejs-fastify-server -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g nodejs-fastify-server -o samples\server\petstore\nodejs-fastify-server
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g php -o samples\client\petstore-security-test\php\OpenAPIClient-php
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g scala-play-server -o samples\server\petstore\scala-play-server
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -105,6 +105,7 @@ The following generators are available:
- [rust-server](generators/rust-server.md)
- [scala-finch](generators/scala-finch.md)
- [scala-lagom-server](generators/scala-lagom-server.md)
- [scala-play-server](generators/scala-play-server.md)
- [scalatra](generators/scalatra.md)
- [spring](generators/spring.md)

View File

@@ -19,3 +19,4 @@ sidebar_label: dart-jaguar
|sourceFolder|source folder for generated code| |null|
|supportDart2|support dart2| |true|
|nullableFields|Is the null fields should be in the JSON payload| |null|
|serialization|Choose serialization format JSON or PROTO is supported| |null|

View File

@@ -8,4 +8,5 @@ sidebar_label: go-gin-server
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|

View File

@@ -8,4 +8,7 @@ sidebar_label: go-server
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|sourceFolder|source folder for generated code| |go|
|serverPort|The network port the generated server binds to| |8080|

View File

@@ -8,8 +8,8 @@ sidebar_label: go
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|Go package name (convention: lowercase).| |openapi|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|packageVersion|Go package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in 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|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|

View File

@@ -54,4 +54,4 @@ sidebar_label: java
|useRuntimeException|Use RuntimeException instead of Exception| |false|
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.9</dd><dt>**okhttp-gson**</dt><dd>HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.8.0. JSON processing: Gson 2.6.1 (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.8.9</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.0.7-RELEASE. JSON processing: Jackson 2.9.5</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.8.9</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.8.9</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 3.1.0. JSON processing: Gson 2.6.1. Only for Java8</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.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**okhttp-gson**</dt><dd>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>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</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]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.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.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8</dd><dl>|okhttp-gson|

View File

@@ -0,0 +1,22 @@
---
id: generator-opts-server-scala-play-framework
title: Config Options for scala-play-framework
sidebar_label: scala-play-framework
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|modelPackage|package for generated models| |null|
|apiPackage|package for generated api classes| |null|
|sourceFolder|source folder for generated code| |null|
|routesFileName|Name of the routes file to generate.| |routes|
|routesFileName|Base package in which supporting classes are generated.| |org.openapitools|
|skipStubs|If set, skips generation of stub classes.| |false|
|supportAsync|If set, wraps API return types with Futures and generates async actions.| |false|
|generateCustomExceptions|If set, generates custom exception types.| |true|
|useSwaggerUI|Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies| |true|

View File

@@ -0,0 +1,22 @@
---
id: generator-opts-server-scala-play-server
title: Config Options for scala-play-server
sidebar_label: scala-play-server
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|modelPackage|package for generated models| |null|
|apiPackage|package for generated api classes| |null|
|sourceFolder|source folder for generated code| |null|
|routesFileName|Name of the routes file to generate.| |routes|
|routesFileName|Base package in which supporting classes are generated.| |org.openapitools|
|skipStubs|If set, skips generation of stub classes.| |false|
|supportAsync|If set, wraps API return types with Futures and generates async actions.| |false|
|generateCustomExceptions|If set, generates custom exception types.| |true|
|useSwaggerUI|Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies| |true|

View File

@@ -249,4 +249,4 @@ If your API client is using named parameters in the function call (e.g. Perl req
## Default basePath
The default `basePath` has been changed from `https://localhost` to `http://locallhost` (http without s)
The default `basePath` has been changed from `https://localhost` to `http://localhost` (http without s)

View File

@@ -72,8 +72,8 @@ SYNOPSIS
OPTIONS
-f <output format>, --format <output format>
Write output files in the desired format. Options are 'text' and
'markdown'. Default is 'text'.
Write output files in the desired format. Options are 'text',
'markdown' or 'yamlsample'. Default is 'text'.
-g <generator name>, --generator-name <generator name>
generator to get config help for

View File

@@ -29,8 +29,8 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.nio.file.Paths;
import java.util.Map;
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
import static org.apache.commons.lang3.StringUtils.isEmpty;
@@ -40,30 +40,34 @@ public class ConfigHelp implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
@Option(name = {"-g", "--generator-name"}, title = "generator name",
description = "generator to get config help for")
public static final String FORMAT_TEXT = "text";
public static final String FORMAT_MARKDOWN = "markdown";
public static final String FORMAT_YAMLSAMPLE = "yamlsample";
@Option(name = {"-g",
"--generator-name"}, title = "generator name", description = "generator to get config help for")
private String generatorName;
@Option(name = {"--named-header"}, title = "named header",
description = "Header includes the generator name, for clarity in output")
@Option(name = {
"--named-header"}, title = "named header", description = "Header includes the generator name, for clarity in output")
private Boolean namedHeader;
@Option(name = {"-o", "--output"}, title = "output location",
description = "Optionally write help to this location, otherwise default is standard output")
@Option(name = {"-o",
"--output"}, title = "output location", description = "Optionally write help to this location, otherwise default is standard output")
private String outputFile;
@Option(name = {"-f", "--format"}, title = "output format",
description = "Write output files in the desired format. Options are 'text' and 'markdown'. Default is 'text'.")
@Option(name = {"-f",
"--format"}, title = "output format", description = "Write output files in the desired format. Options are 'text', 'markdown' or 'yamlsample'. Default is 'text'.", allowedValues = {
FORMAT_TEXT, FORMAT_MARKDOWN, FORMAT_YAMLSAMPLE})
private String format;
@Option(name = {"--markdown-header"}, title = "markdown header",
description = "When format=markdown, include this option to write out markdown headers (e.g. for docusaurus).")
@Option(name = {
"--markdown-header"}, title = "markdown header", description = "When format=markdown, include this option to write out markdown headers (e.g. for docusaurus).")
private Boolean markdownHeader;
private String newline = System.lineSeparator();
@Override
public void run() {
@Override public void run() {
if (isEmpty(generatorName)) {
LOGGER.error("[error] A generator name (--generator-name / -g) is required.");
System.exit(1);
@@ -73,20 +77,34 @@ public class ConfigHelp implements Runnable {
StringBuilder sb = new StringBuilder();
CodegenConfig config = CodegenConfigLoader.forName(generatorName);
if (StringUtils.isEmpty(format) || "text".equalsIgnoreCase(format)) {
generatePlainTextHelp(sb, config);
} else if ("markdown".equalsIgnoreCase(format)) {
generateMarkdownHelp(sb, config);
} else {
LOGGER.warn("[warning] Unrecognized format option: %s.%n", format);
String desiredFormat = StringUtils.defaultIfBlank(format, FORMAT_TEXT);
switch (desiredFormat) {
case FORMAT_MARKDOWN:
generateMarkdownHelp(sb, config);
break;
case FORMAT_YAMLSAMPLE:
generateYamlSample(sb, config);
break;
case FORMAT_TEXT:
generatePlainTextHelp(sb, config);
break;
default:
LOGGER.warn("[warning] Unrecognized format option: {}", format);
break;
}
if (!isEmpty(outputFile)) {
File out = Paths.get(outputFile).toFile();
//noinspection ResultOfMethodCallIgnored
out.getParentFile().mkdirs();
File parentFolder = out.getParentFile();
if (parentFolder != null && parentFolder.isDirectory()) {
parentFolder.mkdirs();
}
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out), StandardCharsets.UTF_8))) {
try (Writer writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(out), StandardCharsets.UTF_8))) {
writer.write(sb.toString());
}
} else {
@@ -101,12 +119,41 @@ public class ConfigHelp implements Runnable {
}
}
private void generateYamlSample(StringBuilder sb, CodegenConfig config) {
for (CliOption langCliOption : config.cliOptions()) {
sb.append("# Description: ").append(langCliOption.getDescription()).append(newline);
Map<String, String> enums = langCliOption.getEnum();
if (enums != null) {
sb.append("# Available Values:").append(newline);
for (Map.Entry<String, String> entry : enums.entrySet()) {
sb.append("# ").append(entry.getKey()).append(newline);
sb.append("# ").append(entry.getValue()).append(newline);
}
}
String defaultValue = langCliOption.getDefault();
if (defaultValue != null) {
sb.append(langCliOption.getOpt()).append(": ").append(defaultValue).append(newline);
} else {
sb.append("# ").append(langCliOption.getOpt()).append(": ").append(newline);
}
sb.append(newline);
}
}
private void generateMarkdownHelp(StringBuilder sb, CodegenConfig config) {
sb.append(newline);
if (Boolean.TRUE.equals(markdownHeader)) {
sb.append("---").append(newline);
sb.append("id: generator-opts-").append(config.getTag().toValue()).append("-").append(config.getName()).append(newline);
sb.append("id: generator-opts-").append(config.getTag().toValue()).append("-")
.append(config.getName()).append(newline);
sb.append("title: Config Options for ").append(generatorName).append(newline);
sb.append("sidebar_label: ").append(generatorName).append(newline);
sb.append("---").append(newline);
@@ -167,7 +214,8 @@ public class ConfigHelp implements Runnable {
for (CliOption langCliOption : config.cliOptions()) {
sb.append("\t").append(langCliOption.getOpt());
sb.append(newline);
sb.append("\t ").append(langCliOption.getOptionHelp().replaceAll("\n", System.lineSeparator() + "\t "));
sb.append("\t ").append(langCliOption.getOptionHelp()
.replaceAll("\n", System.lineSeparator() + "\t "));
sb.append(newline);
sb.append(newline);
}

View File

@@ -217,6 +217,11 @@ public class Generate implements Runnable {
@Option(name = {"--generate-alias-as-model"}, title = "generate alias (array, map) as model", description = CodegenConstants.GENERATE_ALIAS_AS_MODEL_DESC)
private Boolean generateAliasAsModel;
@Option(name = {"--minimal-update"},
title = "Minimal update",
description = "Only write output files that have changed.")
private Boolean minimalUpdate;
@Override
public void run() {
if (logToStderr != null) {
@@ -346,6 +351,9 @@ public class Generate implements Runnable {
if (generateAliasAsModel != null) {
configurator.setGenerateAliasAsModel(generateAliasAsModel);
}
if (minimalUpdate != null) {
configurator.setEnableMinimalUpdate(minimalUpdate);
}
applySystemPropertiesKvpList(systemProperties, configurator);
applyInstantiationTypesKvpList(instantiationTypes, configurator);

View File

@@ -0,0 +1,142 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.openapitools</groupId>
<artifactId>multi-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>java-client</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>java-client</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<!-- activate the plugin -->
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sample-schema</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- specify the OpenAPI spec -->
<inputSpec>openapi.yaml</inputSpec>
<!-- target to generate java client code -->
<generatorName>java</generatorName>
<!-- hint: if you want to generate java server code, e.g. based on Spring Boot,
you can use the following target: <generatorName>spring</generatorName> -->
<!-- pass any necessary config options -->
<configOptions>
<dateLibrary>joda</dateLibrary>
</configOptions>
<!-- override the default library to jersey2 -->
<library>jersey2</library>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- dependencies are needed for the client being generated -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<!-- You can find the dependencies for the library configuation 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 -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-version}</version>
</dependency>
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
<!-- Joda time: if you use it -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>multi-parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>parent-project</name>
<url>http://maven.apache.org</url>
<modules>
<module>sample-schema</module>
<module>java-client</module>
</modules>
<properties>
<swagger-annotations-version>1.5.8</swagger-annotations-version>
<jersey-version>2.27</jersey-version>
<jackson-version>2.8.9</jackson-version>
<jodatime-version>2.7</jodatime-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
</properties>
</project>

View File

@@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.openapitools</groupId>
<artifactId>multi-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>sample-schema</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>sample-schema</name>
<url>http://maven.apache.org</url>
</project>

View File

@@ -0,0 +1,702 @@
---
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about\
\ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\
\ For this sample, you can use the api key `special-key` to test the authorization\
\ filters."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
- name: "pet"
description: "Everything about your Pets"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
- name: "store"
description: "Access to Petstore orders"
- name: "user"
description: "Operations about user"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
schemes:
- "http"
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "addPet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
405:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
put:
tags:
- "pet"
summary: "Update an existing pet"
description: ""
operationId: "updatePet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
405:
description: "Validation exception"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
/pet/findByStatus:
get:
tags:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "status"
in: "query"
description: "Status values that need to be considered for filter"
required: true
type: "array"
items:
type: "string"
enum:
- "available"
- "pending"
- "sold"
default: "available"
collectionFormat: "csv"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Pet"
400:
description: "Invalid status value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
/pet/findByTags:
get:
tags:
- "pet"
summary: "Finds Pets by tags"
description: "Multiple tags can be provided with comma separated strings. Use\
\ tag1, tag2, tag3 for testing."
operationId: "findPetsByTags"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "tags"
in: "query"
description: "Tags to filter by"
required: true
type: "array"
items:
type: "string"
collectionFormat: "csv"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Pet"
400:
description: "Invalid tag value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
/pet/{petId}:
get:
tags:
- "pet"
summary: "Find pet by ID"
description: "Returns a single pet"
operationId: "getPetById"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet to return"
required: true
type: "integer"
format: "int64"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Pet"
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
security:
- api_key: []
post:
tags:
- "pet"
summary: "Updates a pet in the store with form data"
description: ""
operationId: "updatePetWithForm"
consumes:
- "application/x-www-form-urlencoded"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be updated"
required: true
type: "integer"
format: "int64"
- name: "name"
in: "formData"
description: "Updated name of the pet"
required: false
type: "string"
- name: "status"
in: "formData"
description: "Updated status of the pet"
required: false
type: "string"
responses:
405:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
delete:
tags:
- "pet"
summary: "Deletes a pet"
description: ""
operationId: "deletePet"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "api_key"
in: "header"
required: false
type: "string"
- name: "petId"
in: "path"
description: "Pet id to delete"
required: true
type: "integer"
format: "int64"
responses:
400:
description: "Invalid pet value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
/pet/{petId}/uploadImage:
post:
tags:
- "pet"
summary: "uploads an image"
description: ""
operationId: "uploadFile"
consumes:
- "multipart/form-data"
produces:
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet to update"
required: true
type: "integer"
format: "int64"
- name: "additionalMetadata"
in: "formData"
description: "Additional data to pass to server"
required: false
type: "string"
- name: "file"
in: "formData"
description: "file to upload"
required: false
type: "file"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/ApiResponse"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
/store/inventory:
get:
tags:
- "store"
summary: "Returns pet inventories by status"
description: "Returns a map of status codes to quantities"
operationId: "getInventory"
produces:
- "application/json"
parameters: []
responses:
200:
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "integer"
format: "int32"
security:
- api_key: []
/store/order:
post:
tags:
- "store"
summary: "Place an order for a pet"
description: ""
operationId: "placeOrder"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "order placed for purchasing the pet"
required: true
schema:
$ref: "#/definitions/Order"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Order"
400:
description: "Invalid Order"
/store/order/{orderId}:
get:
tags:
- "store"
summary: "Find purchase order by ID"
description: "For valid response try integer IDs with value <= 5 or > 10. Other\
\ values will generated exceptions"
operationId: "getOrderById"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
maximum: 5.0
minimum: 1.0
format: "int64"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Order"
400:
description: "Invalid ID supplied"
404:
description: "Order not found"
delete:
tags:
- "store"
summary: "Delete purchase order by ID"
description: "For valid response try integer IDs with value < 1000. Anything\
\ above 1000 or nonintegers will generate API errors"
operationId: "deleteOrder"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of the order that needs to be deleted"
required: true
type: "string"
minimum: 1.0
responses:
400:
description: "Invalid ID supplied"
404:
description: "Order not found"
/user:
post:
tags:
- "user"
summary: "Create user"
description: "This can only be done by the logged in user."
operationId: "createUser"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Created user object"
required: true
schema:
$ref: "#/definitions/User"
responses:
default:
description: "successful operation"
/user/createWithArray:
post:
tags:
- "user"
summary: "Creates list of users with given input array"
description: ""
operationId: "createUsersWithArrayInput"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: true
schema:
type: "array"
items:
$ref: "#/definitions/User"
responses:
default:
description: "successful operation"
/user/createWithList:
post:
tags:
- "user"
summary: "Creates list of users with given input array"
description: ""
operationId: "createUsersWithListInput"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: true
schema:
type: "array"
items:
$ref: "#/definitions/User"
responses:
default:
description: "successful operation"
/user/login:
get:
tags:
- "user"
summary: "Logs user into the system"
description: ""
operationId: "loginUser"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "query"
description: "The user name for login"
required: true
type: "string"
- name: "password"
in: "query"
description: "The password for login in clear text"
required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
type: "string"
headers:
X-Rate-Limit:
type: "integer"
format: "int32"
description: "calls per hour allowed by the user"
X-Expires-After:
type: "string"
format: "date-time"
description: "date in UTC when toekn expires"
400:
description: "Invalid username/password supplied"
/user/logout:
get:
tags:
- "user"
summary: "Logs out current logged in user session"
description: ""
operationId: "logoutUser"
produces:
- "application/xml"
- "application/json"
parameters: []
responses:
default:
description: "successful operation"
/user/{username}:
get:
tags:
- "user"
summary: "Get user by user name"
description: ""
operationId: "getUserByName"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
description: "The name that needs to be fetched. Use user1 for testing. "
required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/User"
400:
description: "Invalid username supplied"
404:
description: "User not found"
put:
tags:
- "user"
summary: "Updated user"
description: "This can only be done by the logged in user."
operationId: "updateUser"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
description: "name that need to be deleted"
required: true
type: "string"
- in: "body"
name: "body"
description: "Updated user object"
required: true
schema:
$ref: "#/definitions/User"
responses:
400:
description: "Invalid user supplied"
404:
description: "User not found"
delete:
tags:
- "user"
summary: "Delete user"
description: "This can only be done by the logged in user."
operationId: "deleteUser"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
description: "The name that needs to be deleted"
required: true
type: "string"
responses:
400:
description: "Invalid username supplied"
404:
description: "User not found"
securityDefinitions:
petstore_auth:
type: "oauth2"
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
flow: "implicit"
scopes:
write:pets: "modify pets in your account"
read:pets: "read your pets"
api_key:
type: "apiKey"
name: "api_key"
in: "header"
definitions:
Order:
type: "object"
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer"
format: "int32"
shipDate:
type: "string"
format: "date-time"
status:
type: "string"
description: "Order Status"
enum:
- "placed"
- "approved"
- "delivered"
complete:
type: "boolean"
default: false
xml:
name: "Order"
Category:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Category"
User:
type: "object"
properties:
id:
type: "integer"
format: "int64"
username:
type: "string"
firstName:
type: "string"
lastName:
type: "string"
email:
type: "string"
password:
type: "string"
phone:
type: "string"
userStatus:
type: "integer"
format: "int32"
description: "User Status"
xml:
name: "User"
Tag:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
Pet:
type: "object"
required:
- "name"
- "photoUrls"
properties:
id:
type: "integer"
format: "int64"
category:
$ref: "#/definitions/Category"
name:
type: "string"
example: "doggie"
photoUrls:
type: "array"
xml:
name: "photoUrl"
wrapped: true
items:
type: "string"
tags:
type: "array"
xml:
name: "tag"
wrapped: true
items:
$ref: "#/definitions/Tag"
status:
type: "string"
description: "pet status in the store"
enum:
- "available"
- "pending"
- "sold"
xml:
name: "Pet"
ApiResponse:
type: "object"
properties:
code:
type: "integer"
format: "int32"
type:
type: "string"
message:
type: "string"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"

View File

@@ -37,6 +37,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.io.ByteSource;
import com.google.common.io.CharSource;
import io.swagger.v3.parser.util.ClasspathHelper;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -163,6 +166,12 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "invokerPackage")
private String invokerPackage;
/**
* The default package to use for the generated objects
*/
@Parameter(name = "packageName")
private String packageName;
/**
* groupId in generated pom.xml
*/
@@ -507,6 +516,10 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setInvokerPackage(invokerPackage);
}
if (isNotEmpty(packageName)) {
configurator.setPackageName(packageName);
}
if (isNotEmpty(groupId)) {
configurator.setGroupId(groupId);
}
@@ -672,7 +685,12 @@ public class CodeGenMojo extends AbstractMojo {
// Store a checksum of the input spec
File storedInputSpecHashFile = getHashFile(inputSpecFile);
String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
ByteSource inputSpecByteSource =
inputSpecFile.exists()
? Files.asByteSource(inputSpecFile)
: CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecFile.toString().replaceAll("\\\\","/")))
.asByteSource(Charsets.UTF_8);
String inputSpecHash =inputSpecByteSource.hash(Hashing.sha256()).toString();
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
File parent = new File(storedInputSpecHashFile.getParent());

View File

@@ -17,6 +17,10 @@
package org.openapitools.codegen;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,23 +32,78 @@ import java.util.regex.Pattern;
public abstract class AbstractGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGenerator.class);
/**
* Is the minimal-file-update option enabled?
*
* @return Option value
*/
public abstract boolean getEnableMinimalUpdate();
@SuppressWarnings("static-method")
/**
* Write String to a file, formatting as UTF-8
*
* @param filename The name of file to write
* @param contents The contents string.
* @return File representing the written file.
* @throws IOException If file cannot be written.
*/
public File writeToFile(String filename, String contents) throws IOException {
LOGGER.info("writing file " + filename);
return writeToFile(filename, contents.getBytes(Charset.forName("UTF-8")));
}
/**
* Write bytes to a file
*
* @param filename The name of file to write
* @param contents The contents bytes. Typically this is a UTF-8 formatted string.
* @return File representing the written file.
* @throws IOException If file cannot be written.
*/
@SuppressWarnings("static-method")
public File writeToFile(String filename, byte contents[]) throws IOException {
if (getEnableMinimalUpdate()) {
String tempFilename = filename + ".tmp";
// Use Paths.get here to normalize path (for Windows file separator, space escaping on Linux/Mac, etc)
File outputFile = Paths.get(filename).toFile();
File tempFile = null;
try {
tempFile = writeToFileRaw(tempFilename, contents);
if (!filesEqual(tempFile, outputFile)) {
LOGGER.info("writing file " + filename);
Files.move(tempFile.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
tempFile = null;
} else {
LOGGER.info("skipping unchanged file " + filename);
}
} finally {
if (tempFile != null && tempFile.exists()) {
try {
tempFile.delete();
} catch (Exception ex) {
LOGGER.error("Error removing temporary file " + tempFile, ex);
}
}
}
return outputFile;
} else {
LOGGER.info("writing file " + filename);
return writeToFileRaw(filename, contents);
}
}
private boolean filesEqual(File file1, File file2) throws IOException {
return file1.exists() && file2.exists() && Arrays.equals(Files.readAllBytes(file1.toPath()), Files.readAllBytes(file2.toPath()));
}
private File writeToFileRaw(String filename, byte[] contents) throws IOException {
// Use Paths.get here to normalize path (for Windows file separator, space escaping on Linux/Mac, etc)
File output = Paths.get(filename).toFile();
if (output.getParent() != null && !new File(output.getParent()).exists()) {
File parent = new File(output.getParent());
File parent = Paths.get(output.getParent()).toFile();
parent.mkdirs();
}
try (Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(output), "UTF-8"))) {
out.write(contents);
}
Files.write(output.toPath(), contents);
return output;
}

View File

@@ -260,4 +260,8 @@ public interface CodegenConfig {
*/
void setOpenAPI(OpenAPI openAPI);
public boolean isEnableMinimalUpdate();
public void setEnableMinimalUpdate(boolean isEnableMinimalUpdate);
}

View File

@@ -20,7 +20,7 @@ package org.openapitools.codegen;
import java.util.*;
public class CodegenProperty implements Cloneable {
public String baseName, complexType, getter, setter, description, dataType,
public String openApiType, baseName, complexType, getter, setter, description, dataType,
datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam,
baseType, containerType, title;
@@ -415,6 +415,7 @@ public class CodegenProperty implements Cloneable {
return Objects.hash(
_enum,
allowableValues,
openApiType,
baseName,
baseType,
complexType,
@@ -501,6 +502,7 @@ public class CodegenProperty implements Cloneable {
final CodegenProperty other = (CodegenProperty) obj;
return Objects.equals(baseName, other.baseName) &&
Objects.equals(openApiType, other.openApiType) &&
Objects.equals(complexType, other.complexType) &&
Objects.equals(getter, other.getter) &&
Objects.equals(setter, other.setter) &&
@@ -600,6 +602,7 @@ public class CodegenProperty implements Cloneable {
public java.lang.String toString() {
return "CodegenProperty{" +
"baseName='" + baseName + '\'' +
", openApiType='" + openApiType + '\'' +
", complexType='" + complexType + '\'' +
", getter='" + getter + '\'' +
", setter='" + setter + '\'' +

View File

@@ -111,6 +111,8 @@ public class DefaultCodegen implements CodegenConfig {
protected String ignoreFilePathOverride;
// flag to indicate whether to use environment variable to post process file
protected boolean enablePostProcessFile = false;
// flag to indicate whether to only update files whose contents have changed
protected boolean enableMinimalUpdate = false;
// make openapi available to all methods
protected OpenAPI openAPI;
@@ -778,7 +780,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the file name of the model
*/
public String toModelFilename(String name) {
return initialCaps(name);
return camelize(name);
}
/**
@@ -788,7 +790,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the file name of the model
*/
public String toModelTestFilename(String name) {
return initialCaps(name) + "Test";
return camelize(name) + "Test";
}
/**
@@ -798,7 +800,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the file name of the model
*/
public String toModelDocFilename(String name) {
return initialCaps(name);
return camelize(name);
}
/**
@@ -1474,17 +1476,6 @@ public class DefaultCodegen implements CodegenConfig {
return (name.length() > 0) ? (Character.toLowerCase(name.charAt(0)) + name.substring(1)) : "";
}
/**
* Capitalize the string. Please use org.openapitools.codegen.utils.StringUtils.camelize instead as this method will be deprecated.
*
* @param name string to be capitalized
* @return capitalized string
* @deprecated use {@link org.openapitools.codegen.utils.StringUtils#camelize(String)} instead
*/
@SuppressWarnings("static-method")
public String initialCaps(String name) {
return camelize(name);
}
/**
* Output the type declaration of a given name
@@ -1574,7 +1565,7 @@ public class DefaultCodegen implements CodegenConfig {
if (name.length() == 0) {
return "DefaultApi";
}
return initialCaps(name) + "Api";
return camelize(name) + "Api";
}
/**
@@ -1585,7 +1576,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return capitalized model name
*/
public String toModelName(final String name) {
return initialCaps(modelNamePrefix + "_" + name + "_" + modelNameSuffix);
return camelize(modelNamePrefix + "_" + name + "_" + modelNameSuffix);
}
/**
@@ -1898,6 +1889,11 @@ public class DefaultCodegen implements CodegenConfig {
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
property.name = toVarName(name);
property.baseName = name;
if (p.getType() == null) {
property.openApiType = getSchemaType(p);
} else {
property.openApiType = p.getType();
}
property.nameInCamelCase = camelize(property.name, false);
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
property.description = escapeText(p.getDescription());
@@ -3257,7 +3253,7 @@ public class DefaultCodegen implements CodegenConfig {
if (builder.toString().length() == 0) {
part = Character.toLowerCase(part.charAt(0)) + part.substring(1);
} else {
part = initialCaps(part);
part = camelize(part);
}
builder.append(part);
}
@@ -3854,6 +3850,11 @@ public class DefaultCodegen implements CodegenConfig {
// input name and age => input_name_and_age
name = name.replaceAll(" ", "_");
// /api/films/get => _api_films_get
// \api\films\get => _api_films_get
name = name.replaceAll("/", "_");
name = name.replaceAll("\\\\", "_");
// remove everything else other than word, number and _
// $php_variable => php_variable
if (allowUnicodeIdentifiers) { //could be converted to a single line with ?: operator
@@ -4834,4 +4835,22 @@ public class DefaultCodegen implements CodegenConfig {
this.enablePostProcessFile = enablePostProcessFile;
}
/**
* Get the boolean value indicating the state of the option for updating only changed files
*/
@Override
public boolean isEnableMinimalUpdate() {
return enableMinimalUpdate;
}
/**
* Set the boolean value indicating the state of the option for updating only changed files
*
* @param enableMinimalUpdate true to enable minimal update
*/
@Override
public void setEnableMinimalUpdate(boolean enableMinimalUpdate) {
this.enableMinimalUpdate = enableMinimalUpdate;
}
}

View File

@@ -67,6 +67,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
private String contextPath;
private Map<String, String> generatorPropertyDefaults = new HashMap<>();
@Override
public boolean getEnableMinimalUpdate() {
return config.isEnableMinimalUpdate();
}
@Override
public Generator opts(ClientOptInput opts) {
this.opts = opts;
@@ -797,16 +802,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
}
protected File writeInputStreamToFile(String filename, InputStream in, String templateFile) throws FileNotFoundException, IOException {
File outputFile = java.nio.file.Paths.get(filename).toFile();
if (in != null) {
OutputStream out = new FileOutputStream(outputFile, false);
LOGGER.info("writing file " + outputFile);
IOUtils.copy(in, out);
out.close();
byte bytes[] = IOUtils.toByteArray(in);
return writeToFile(filename, bytes);
} else {
LOGGER.error("can't open '" + templateFile + "' for input; cannot write '" + filename + "'");
return null;
}
return outputFile;
}
private Map<String, Object> buildSupportFileBundle(List<Object> allOperations, List<Object> allModels) {

View File

@@ -101,11 +101,13 @@ public class CodegenConfigurator implements Serializable {
private boolean logToStderr;
private boolean validateSpec;
private boolean enablePostProcessFile;
private boolean enableMinimalUpdate;
private String templateDir;
private String auth;
private String apiPackage;
private String modelPackage;
private String invokerPackage;
private String packageName;
private String modelNamePrefix;
private String modelNameSuffix;
private String groupId;
@@ -239,6 +241,15 @@ public class CodegenConfigurator implements Serializable {
return this;
}
public boolean getEnableMinimalUpdate() {
return enableMinimalUpdate;
}
public CodegenConfigurator setEnableMinimalUpdate(boolean enableMinimalUpdate) {
this.enableMinimalUpdate = enableMinimalUpdate;
return this;
}
public boolean isGenerateAliasAsModel() {
return ModelUtils.isGenerateAliasAsModel();
}
@@ -349,6 +360,15 @@ public class CodegenConfigurator implements Serializable {
return this;
}
public String getPackageName() {
return packageName;
}
public CodegenConfigurator setPackageName(String packageName) {
this.packageName = packageName;
return this;
}
public String getGroupId() {
return groupId;
}
@@ -545,6 +565,7 @@ public class CodegenConfigurator implements Serializable {
config.setIgnoreFilePathOverride(ignoreFileOverride);
config.setRemoveOperationIdPrefix(removeOperationIdPrefix);
config.setEnablePostProcessFile(enablePostProcessFile);
config.setEnableMinimalUpdate(enableMinimalUpdate);
config.instantiationTypes().putAll(instantiationTypes);
config.typeMapping().putAll(typeMappings);
@@ -555,6 +576,7 @@ public class CodegenConfigurator implements Serializable {
checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE);
checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE);
checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE);
checkAndSetAdditionalProperty(packageName, CodegenConstants.PACKAGE_NAME);
checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID);
checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID);
checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);

View File

@@ -112,7 +112,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
.defaultValue("openapi"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
.defaultValue("1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
.defaultValue(Boolean.TRUE.toString()));
}

View File

@@ -360,7 +360,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
if (additionalProperties.containsKey(CodegenConstants.PARCELIZE_MODELS)) {
this.setParcelizeModels(Boolean.valueOf((String)additionalProperties.get(CodegenConstants.PARCELIZE_MODELS)));
this.setParcelizeModels(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.PARCELIZE_MODELS)));
LOGGER.info(CodegenConstants.PARCELIZE_MODELS + " depends on the android framework and " +
"experimental parcelize feature. Make sure your build applies the android plugin:\n" +
"apply plugin: 'com.android.library' OR apply plugin: 'com.android.application'.\n" +
@@ -597,10 +597,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
private String sanitizeKotlinSpecificNames(final String name) {
String word = name;
for (Map.Entry<String, String> specialCharacters : specialCharReplacements.entrySet()) {
// Underscore is the only special character we'll allow
if (!specialCharacters.getKey().equals("_")) {
word = word.replaceAll("\\Q" + specialCharacters.getKey() + "\\E", specialCharacters.getValue());
}
word = replaceSpecialCharacters(word, specialCharacters);
}
// Fallback, replace unknowns with underscore.
@@ -617,6 +614,38 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return word;
}
private String replaceSpecialCharacters(String word, Map.Entry<String, String> specialCharacters) {
String specialChar = specialCharacters.getKey();
String replacementChar = specialCharacters.getValue();
// Underscore is the only special character we'll allow
if (!specialChar.equals("_") && word.contains(specialChar)) {
return replaceCharacters(word, specialChar, replacementChar);
}
return word;
}
private String replaceCharacters(String word, String oldValue, String newValue) {
if (!word.contains(oldValue)) {
return word;
}
if (word.equals(oldValue)) {
return newValue;
}
int i = word.indexOf(oldValue);
String start = word.substring(0, i);
String end = recurseOnEndOfWord(word, oldValue, newValue, i);
return start + newValue + end;
}
private String recurseOnEndOfWord(String word, String oldValue, String newValue, int lastReplacedValue) {
String end = word.substring(lastReplacedValue + 1);
if (!end.isEmpty()) {
end = titleCase(end);
end = replaceCharacters(end, oldValue, newValue);
}
return end;
}
private String titleCase(final String input) {
return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
}
@@ -676,6 +705,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toVarName(String name) {
// sanitize name
name = sanitizeKotlinSpecificNames(name);
name = sanitizeName(name, "\\W-[\\$]");
if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) {
@@ -756,4 +786,31 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
}
}
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
} else if (ModelUtils.isDateSchema(p)) {
// TODO
} else if (ModelUtils.isDateTimeSchema(p)) {
// TODO
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
} else if (ModelUtils.isIntegerSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
} else if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
return "'" + p.getDefault() + "'";
}
}
return null;
}
}

View File

@@ -333,4 +333,29 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
}
}
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), true);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
operationId = camelize("call_" + operationId, true);
}
return operationId;
}
}

View File

@@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
@@ -82,6 +83,18 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
cliOptions.clear();
typeMapping.put("boolean", "bool");
typeMapping.put("integer", "int");
typeMapping.put("float", "float");
typeMapping.put("long", "long");
typeMapping.put("double", "double");
typeMapping.put("number", "decimal");
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("UUID", "Guid");
setSupportNullable(Boolean.TRUE);
// CLI options
addOption(CodegenConstants.LICENSE_URL,
CodegenConstants.LICENSE_URL_DESC,
@@ -375,4 +388,17 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
public String toRegularExpression(String pattern) {
return escapeText(pattern);
}
@Override
public String getNullableType(Schema p, String type) {
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
if (isNullableExpected && languageSpecificPrimitives.contains(type + "?")) {
return type + "?";
} else if (languageSpecificPrimitives.contains(type)) {
return type;
} else {
return null;
}
}
}

View File

@@ -35,6 +35,8 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(BashClientCodegen.class);
@@ -743,7 +745,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toModelFilename(String name) {
return initialCaps(name);
return camelize(name);
}

View File

@@ -86,6 +86,18 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
cliOptions.clear();
typeMapping.put("boolean", "bool");
typeMapping.put("integer", "int");
typeMapping.put("float", "float");
typeMapping.put("long", "long");
typeMapping.put("double", "double");
typeMapping.put("number", "decimal");
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("UUID", "Guid");
setSupportNullable(Boolean.TRUE);
// CLI options
addOption(CodegenConstants.PACKAGE_NAME,
"C# package name (convention: Title.Case).",
@@ -862,4 +874,18 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
return null;
}
}
@Override
public String getNullableType(Schema p, String type) {
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
if (isNullableExpected && languageSpecificPrimitives.contains(type + "?")) {
return type + "?";
} else if (languageSpecificPrimitives.contains(type)) {
return type;
} else {
return null;
}
}
}

View File

@@ -29,7 +29,7 @@ import org.openapitools.codegen.utils.ModelUtils;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.underscore;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppPistacheServerCodegen extends AbstractCppCodegen {
protected String implFolder = "impl";
@@ -265,7 +265,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
@Override
public String toModelFilename(String name) {
return initialCaps(toModelName(name));
return camelize(toModelName(name));
}
@Override
@@ -286,7 +286,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
@Override
public String toApiFilename(String name) {
return modelNamePrefix + initialCaps(name) + "Api";
return modelNamePrefix + camelize(name) + "Api";
}
/**

View File

@@ -5,6 +5,7 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.utils.ModelUtils;
@@ -280,7 +281,19 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel> ();
for(Object moObj : allModels) {
CodegenModel mo = ((Map<String, CodegenModel>) moObj).get("model");
if(mo.isEnum) {
codegenModels.put(mo.classname, mo);
}
}
for (CodegenOperation operation : operations) {
if(operation.returnType != null) {
if(codegenModels.containsKey(operation.returnType)){
operation.vendorExtensions.put("returnsEnum", true);
}
}
// Check all return parameter baseType if there is a necessity to include, include it if not
// already done
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
@@ -316,6 +329,21 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
return objs;
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return postProcessModelsEnum(objs);
}
@Override
public String toEnumValue(String value, String datatype) {
return escapeText(value);
}
@Override
public boolean isDataTypeString(String dataType) {
return "QString".equals(dataType);
}
private Map<String, String> createMapping(String key, String value) {
Map<String, String> customImport = new HashMap<String, String>();
customImport.put(key, toModelImport(value));

View File

@@ -24,6 +24,8 @@ import org.openapitools.codegen.SupportingFile;
import java.io.File;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
// source folder where to write the files
@@ -75,6 +77,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
if (optionalProjectFileFlag) {
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
}
@@ -100,6 +103,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
@@ -163,7 +167,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
@Override
public String toApiFilename(String name) {
return modelNamePrefix + sanitizeName(initialCaps(name)) + "Api";
return modelNamePrefix + sanitizeName(camelize(name)) + "Api";
}
public void setOptionalProjectFileFlag(boolean flag) {

View File

@@ -23,6 +23,8 @@ import org.openapitools.codegen.SupportingFile;
import java.io.File;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
protected final String SRC_DIR = "/src";
@@ -83,6 +85,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, PREFIX + "Enum.h"));
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
@@ -106,6 +109,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Enum.h"));
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
@@ -187,7 +191,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
@Override
public String toApiFilename(String name) {
return modelNamePrefix + sanitizeName(initialCaps(name)) + "ApiHandler";
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
}
}

View File

@@ -31,6 +31,7 @@ import org.openapitools.codegen.utils.ModelUtils;
import java.util.*;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppRestSdkClientCodegen extends AbstractCppCodegen {
@@ -288,12 +289,12 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
@Override
public String toModelFilename(String name) {
return sanitizeName(initialCaps(name));
return sanitizeName(camelize(name));
}
@Override
public String toApiFilename(String name) {
return sanitizeName(initialCaps(name) + "Api");
return sanitizeName(camelize(name) + "Api");
}
/**

View File

@@ -27,6 +27,8 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public class CppRestbedServerCodegen extends AbstractCppCodegen {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CppRestbedServerCodegen.class);
@@ -191,12 +193,12 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
@Override
public String toModelFilename(String name) {
return initialCaps(name);
return camelize(name);
}
@Override
public String toApiFilename(String name) {
return initialCaps(name) + "Api";
return camelize(name) + "Api";
}
@SuppressWarnings("unchecked")

View File

@@ -247,17 +247,17 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
@Override
public String toModelFilename(String name) {
return initialCaps(name);
return camelize(name);
}
@Override
public String toApiName(String name) {
return initialCaps(name) + "Manager";
return camelize(name) + "Manager";
}
@Override
public String toApiFilename(String name) {
return initialCaps(name) + "Manager";
return camelize(name) + "Manager";
}
@Override

View File

@@ -16,10 +16,16 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.ProcessUtils;
import java.io.File;
import java.util.*;
@@ -28,16 +34,25 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
public class DartJaguarClientCodegen extends DartClientCodegen {
private static final String NULLABLE_FIELDS = "nullableFields";
private static final String SERIALIZATION_FORMAT = "serialization";
private static final String IS_FORMAT_JSON = "jsonFormat";
private static final String IS_FORMAT_PROTO = "protoFormat";
private static Set<String> modelToIgnore = new HashSet<>();
private HashMap<String, String> protoTypeMapping = new HashMap<>();
static {
modelToIgnore.add("datetime");
modelToIgnore.add("map");
modelToIgnore.add("list");
modelToIgnore.add("file");
modelToIgnore.add("uint8list");
}
private static final String SERIALIZATION_JSON = "json";
private static final String SERIALIZATION_PROTO = "proto";
private boolean nullableFields = true;
private String serialization = SERIALIZATION_JSON;
public DartJaguarClientCodegen() {
super();
@@ -46,6 +61,33 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
embeddedTemplateDir = templateDir = "dart-jaguar";
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
cliOptions.add(new CliOption(SERIALIZATION_FORMAT, "Choose serialization format JSON or PROTO is supported"));
typeMapping.put("file", "Uint8List");
typeMapping.put("binary", "Uint8List");
protoTypeMapping.put("Array", "repeated");
protoTypeMapping.put("array", "repeated");
protoTypeMapping.put("List", "repeated");
protoTypeMapping.put("boolean", "bool");
protoTypeMapping.put("string", "string");
protoTypeMapping.put("char", "string");
protoTypeMapping.put("int", "int32");
protoTypeMapping.put("long", "int64");
protoTypeMapping.put("short", "int32");
protoTypeMapping.put("number", "double");
protoTypeMapping.put("float", "float");
protoTypeMapping.put("double", "double");
protoTypeMapping.put("object", "google.protobuf.Any");
protoTypeMapping.put("integer", "int32");
protoTypeMapping.put("Date", "google.protobuf.Timestamp");
protoTypeMapping.put("date", "google.protobuf.Timestamp");
protoTypeMapping.put("File", "bytes");
protoTypeMapping.put("file", "bytes");
protoTypeMapping.put("binary", "bytes");
protoTypeMapping.put("UUID", "string");
protoTypeMapping.put("ByteArray", "bytes");
}
@Override
@@ -77,6 +119,20 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
}
if (additionalProperties.containsKey(SERIALIZATION_FORMAT)) {
serialization = ((String) additionalProperties.get(SERIALIZATION_FORMAT));
boolean isProto = serialization.equalsIgnoreCase(SERIALIZATION_PROTO);
additionalProperties.put(IS_FORMAT_JSON, serialization.equalsIgnoreCase(SERIALIZATION_JSON));
additionalProperties.put(IS_FORMAT_PROTO, isProto);
modelTemplateFiles.put("model.mustache", isProto ? ".proto" : ".dart");
} else {
//not set, use to be passed to template
additionalProperties.put(IS_FORMAT_JSON, true);
additionalProperties.put(IS_FORMAT_PROTO, false);
}
if (additionalProperties.containsKey(PUB_NAME)) {
this.setPubName((String) additionalProperties.get(PUB_NAME));
} else {
@@ -133,6 +189,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
List<Object> models = (List<Object>) objs.get("models");
ProcessUtils.addIndexToProperties(models, 1);
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
Set<String> modelImports = new HashSet<>();
@@ -142,6 +199,16 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
modelImports.add(underscore(modelImport));
}
}
for (CodegenProperty p : cm.vars) {
String protoType = protoTypeMapping.get(p.openApiType);
if (p.isListContainer) {
String innerType = protoTypeMapping.get(p.mostInnerItems.openApiType);
protoType = protoType + " " + (innerType == null ? p.mostInnerItems.openApiType : innerType);
}
p.vendorExtensions.put("x-proto-type", protoType == null ? p.openApiType : protoType);
}
cm.imports = modelImports;
cm.vendorExtensions.put("hasVars", cm.vars.size() > 0);
}
@@ -155,17 +222,20 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
Set<String> modelImports = new HashSet<>();
Set<String> fullImports = new HashSet<>();
for (CodegenOperation op : operationList) {
op.httpMethod = StringUtils.capitalize(op.httpMethod.toLowerCase(Locale.ROOT));
boolean isJson = true; //default to JSON
boolean isForm = false;
boolean isProto = false;
boolean isMultipart = false;
if (op.consumes != null) {
for (Map<String, String> consume : op.consumes) {
if (consume.containsKey("mediaType")) {
String type = consume.get("mediaType");
isJson = type.equalsIgnoreCase("application/json");
isProto = type.equalsIgnoreCase("application/octet-stream");
isForm = type.equalsIgnoreCase("application/x-www-form-urlencoded");
isMultipart = type.equalsIgnoreCase("multipart/form-data");
break;
@@ -173,7 +243,27 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
}
}
for (CodegenParameter param : op.allParams) {
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
param.baseType = "MultipartFile";
param.dataType = "MultipartFile";
}
}
for (CodegenParameter param : op.formParams) {
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
param.baseType = "MultipartFile";
param.dataType = "MultipartFile";
}
}
for (CodegenParameter param : op.bodyParams) {
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
param.baseType = "MultipartFile";
param.dataType = "MultipartFile";
}
}
op.vendorExtensions.put("isJson", isJson);
op.vendorExtensions.put("isProto", isProto);
op.vendorExtensions.put("isForm", isForm);
op.vendorExtensions.put("isMultipart", isMultipart);
@@ -181,6 +271,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
for (String item : op.imports) {
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
imports.add(underscore(item));
} else if (item.equalsIgnoreCase("Uint8List")) {
fullImports.add("dart:typed_data");
}
}
modelImports.addAll(imports);
@@ -205,6 +297,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
}
objs.put("modelImports", modelImports);
objs.put("fullImports", fullImports);
return objs;
}

View File

@@ -23,6 +23,7 @@ import io.swagger.v3.oas.models.OpenAPI;
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.responses.ApiResponse;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
@@ -53,7 +54,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
List<String> extraApplications = Arrays.asList(":logger");
List<String> deps = Arrays.asList(
"{:tesla, \"~> 1.0.0\"}",
"{:poison, \">= 1.0.0\"}"
"{:poison, \"~> 3.0.0\"}"
);
public ElixirClientCodegen() {
@@ -310,6 +311,11 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
return new ExtendedCodegenModel(cm);
}
@Override
public CodegenResponse fromResponse(String responseCode, ApiResponse resp) {
return new ExtendedCodegenResponse(super.fromResponse(responseCode, resp));
}
// We should use String.join if we can use Java8
String join(CharSequence charSequence, Iterable<String> iterable) {
StringBuilder buf = new StringBuilder();
@@ -515,6 +521,91 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
return toModelName(type);
}
class ExtendedCodegenResponse extends CodegenResponse {
public boolean isDefinedDefault;
public ExtendedCodegenResponse(CodegenResponse o) {
super();
this.headers.addAll(o.headers);
this.code = o.code;
this.message = o.message;
this.hasMore = o.hasMore;
this.examples = o.examples;
this.dataType = o.dataType;
this.baseType = o.baseType;
this.containerType = o.containerType;
this.hasHeaders = o.hasHeaders;
this.isString = o.isString;
this.isNumeric = o.isNumeric;
this.isInteger = o.isInteger;
this.isLong = o.isLong;
this.isNumber = o.isNumber;
this.isFloat = o.isFloat;
this.isDouble = o.isDouble;
this.isByteArray = o.isByteArray;
this.isBoolean = o.isBoolean;
this.isDate = o.isDate;
this.isDateTime = o.isDateTime;
this.isUuid = o.isUuid;
this.isEmail = o.isEmail;
this.isModel = o.isModel;
this.isFreeFormObject = o.isFreeFormObject;
this.isDefault = o.isDefault;
this.simpleType = o.simpleType;
this.primitiveType = o.primitiveType;
this.isMapContainer = o.isMapContainer;
this.isListContainer = o.isListContainer;
this.isBinary = o.isBinary;
this.isFile = o.isFile;
this.schema = o.schema;
this.jsonSchema = o.jsonSchema;
this.vendorExtensions = o.vendorExtensions;
this.isDefinedDefault = (this.code.equals("0") || this.code.equals("default"));
}
public String codeMappingKey(){
if(this.isDefinedDefault) {
return ":default";
}
if(code.matches("^\\d{3}$")){
return code;
}
LOGGER.warn("Unknown HTTP status code: " + this.code);
return "\"" + code + "\"";
}
public String decodedStruct() {
// Let Poison decode the entire response into a generic blob
if (isMapContainer) {
return "%{}";
}
// Primitive return type, don't even try to decode
if (baseType == null || (simpleType && primitiveType)) {
return "false";
} else if (isListContainer && languageSpecificPrimitives().contains(baseType)) {
return "[]";
}
StringBuilder sb = new StringBuilder();
if (isListContainer) {
sb.append("[");
}
sb.append("%");
sb.append(moduleName);
sb.append(".Model.");
sb.append(baseType);
sb.append("{}");
if (isListContainer) {
sb.append("]");
}
return sb.toString();
}
}
class ExtendedCodegenOperation extends CodegenOperation {
private List<String> pathTemplateNames = new ArrayList<String>();
private String replacedPathName;
@@ -688,32 +779,6 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
sb.append(".t");
}
}
public String decodedStruct() {
// Let Poison decode the entire response into a generic blob
if (isMapContainer) {
return "";
}
// Primitive return type, don't even try to decode
if (returnBaseType == null || (returnSimpleType && returnTypeIsPrimitive)) {
return "false";
} else if (isListContainer && languageSpecificPrimitives().contains(returnBaseType)) {
return "[]";
}
StringBuilder sb = new StringBuilder();
if (isListContainer) {
sb.append("[");
}
sb.append("%");
sb.append(moduleName);
sb.append(".Model.");
sb.append(returnBaseType);
sb.append("{}");
if (isListContainer) {
sb.append("]");
}
return sb.toString();
}
}
class ExtendedCodegenModel extends CodegenModel {

View File

@@ -30,7 +30,9 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.Collator;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@@ -234,7 +236,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
if (name.length() == 0) {
return "Default";
}
return initialCaps(name);
return camelize(name);
}
@Override
@@ -411,14 +413,26 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
return postProcessModelsEnum(objs);
}
private static boolean anyOperationParam(final List<CodegenOperation> operations, final Predicate<CodegenParameter> predicate) {
return operations.stream()
.flatMap(operation -> Stream.of(
operation.bodyParams.stream(),
operation.queryParams.stream(),
operation.pathParams.stream(),
operation.headerParams.stream()
))
.flatMap(a -> a)
.filter(predicate)
.findAny()
.isPresent();
}
@Override
@SuppressWarnings({"static-method", "unchecked"})
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
boolean hasDateTime = false;
boolean hasDate = false;
final Map<String, Set<String>> dependencies = new HashMap<>();
for (CodegenOperation op : ops) {
@@ -427,8 +441,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
for (CodegenParameter param : op.pathParams) {
final String var = paramToString("params", param, false, null);
path = path.replace("{" + param.paramName + "}", "\" ++ " + var + " ++ \"");
hasDateTime = hasDateTime || param.isDateTime;
hasDate = hasDate || param.isDate;
}
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
} else {
@@ -437,8 +449,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
for (CodegenParameter param : op.pathParams) {
String str = paramToString("params", param, false, null);
path = path.replace("{" + param.paramName + "}", str);
hasDateTime = hasDateTime || param.isDateTime;
hasDate = hasDate || param.isDate;
}
op.path = path;
@@ -487,6 +497,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
elmImport.hasExposures = true;
elmImports.add(elmImport);
}
final boolean hasDate = anyOperationParam(ops, param -> param.isDate);
if (hasDate) {
final ElmImport elmImport = new ElmImport();
elmImport.moduleName = "DateOnly";
@@ -495,6 +506,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
elmImport.hasExposures = true;
elmImports.add(elmImport);
}
final boolean hasDateTime = anyOperationParam(ops, param -> param.isDateTime);
if (hasDateTime) {
final ElmImport elmImport = new ElmImport();
elmImport.moduleName = "DateTime";
@@ -503,6 +515,15 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
elmImport.hasExposures = true;
elmImports.add(elmImport);
}
final boolean hasUuid = anyOperationParam(ops, param -> param.isUuid);
if (hasUuid) {
final ElmImport elmImport = new ElmImport();
elmImport.moduleName = "Uuid";
elmImport.exposures = new TreeSet<>();
elmImport.exposures.add("Uuid");
elmImport.hasExposures = true;
elmImports.add(elmImport);
}
operations.put("elmImports", elmImports);
return operations;
@@ -553,7 +574,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
}
String mapFn = null;
if (param.isString || param.isUuid || param.isBinary || param.isByteArray) {
if (param.isString || param.isBinary || param.isByteArray) {
mapFn = "";
} else if (param.isBoolean) {
mapFn = "(\\val -> if val then \"true\" else \"false\")";
@@ -561,6 +582,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
mapFn = "DateTime.toString";
} else if (param.isDate) {
mapFn = "DateOnly.toString";
} else if (param.isUuid) {
mapFn = "Uuid.toString";
} else if (ElmVersion.ELM_018.equals(elmVersion)) {
mapFn = "toString";
} else if (param.isInteger || param.isLong) {

View File

@@ -51,8 +51,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
// default HIDE_GENERATION_TIMESTAMP to true
hideGenerationTimestamp = Boolean.TRUE;
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
.defaultValue("1.0.0"));
cliOptions.add(CliOption.newBoolean(WITH_GO_CODEGEN_COMMENT, "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs"));
cliOptions.add(CliOption.newBoolean(WITH_XML, "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)"));

View File

@@ -17,6 +17,7 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
@@ -30,16 +31,25 @@ public class GoServerCodegen extends AbstractGoCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(GoServerCodegen.class);
protected String apiVersion = "1.0.0";
protected String packageVersion = "1.0.0";
protected int serverPort = 8080;
protected String projectName = "openapi-server";
protected String apiPath = "go";
protected String sourceFolder = "go";
public GoServerCodegen() {
super();
// set the output folder here
outputFolder = "generated-code/go";
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)
.defaultValue(sourceFolder));
CliOption optServerPort = new CliOption("serverPort", "The network port the generated server binds to");
optServerPort.setType("int");
optServerPort.defaultValue(Integer.toString(serverPort));
cliOptions.add(optServerPort);
/*
* Models. You can write model files using the modelTemplateFiles map.
@@ -88,21 +98,35 @@ public class GoServerCodegen extends AbstractGoCodegen {
@Override
public void processOpts() {
super.processOpts();
/*
* Additional Properties. These values can be passed to the templates and
* are available in models, apis, and supporting files
*/
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {
setPackageName("openapi");
}
/*
* Additional Properties. These values can be passed to the templates and
* are available in models, apis, and supporting files
*/
additionalProperties.put("apiVersion", apiVersion);
additionalProperties.put("serverPort", serverPort);
additionalProperties.put("apiPath", apiPath);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
this.setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
}
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
} else {
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder);
}
if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof Integer) {
this.setServerPort((int) additionalProperties.get("serverPort"));
} else {
additionalProperties.put("serverPort", serverPort);
}
modelPackage = packageName;
apiPackage = packageName;
@@ -115,14 +139,14 @@ public class GoServerCodegen extends AbstractGoCodegen {
supportingFiles.add(new SupportingFile("openapi.mustache", "api", "openapi.yaml"));
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go"));
supportingFiles.add(new SupportingFile("logger.mustache", apiPath, "logger.go"));
writeOptional(outputFolder, new SupportingFile("README.mustache", apiPath, "README.md"));
supportingFiles.add(new SupportingFile("routers.mustache", sourceFolder, "routers.go"));
supportingFiles.add(new SupportingFile("logger.mustache", sourceFolder, "logger.go"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
}
@Override
public String apiPackage() {
return apiPath;
return sourceFolder;
}
/**
@@ -172,5 +196,16 @@ public class GoServerCodegen extends AbstractGoCodegen {
public String modelFileFolder() {
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
}
public void setSourceFolder(String sourceFolder) {
this.sourceFolder = sourceFolder;
}
public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}
public void setServerPort(int serverPort) {
this.serverPort = serverPort;
}
}

View File

@@ -116,18 +116,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(FEIGN_VERSION, "Version of OpenFeign: '10.x', '9.x' (default)"));
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.9");
supportedLibraries.put(OKHTTP_GSON, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.8.0. JSON processing: Gson 2.6.1 (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.8.9");
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.0.7-RELEASE. JSON processing: Jackson 2.9.5");
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9");
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.8.9");
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.8.9");
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 3.1.0. JSON processing: Gson 2.6.1. Only for Java8");
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x");
supportedLibraries.put(OKHTTP_GSON, "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'.");
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);

View File

@@ -51,8 +51,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{
new String[]{"package.mustache", "package.json"},
new String[]{"index.mustache", "src/index.js"},
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
// new String[]{"index.mustache", "src/index.js", },
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
new String[]{"git_push.sh.mustache", "git_push.sh"},
new String[]{"README.mustache", "README.md"},
new String[]{"mocha.opts", "mocha.opts"},
@@ -61,8 +61,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = new String[][]{
new String[]{"package.mustache", "package.json"},
new String[]{"index.mustache", "src/index.js"},
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
// new String[]{"index.mustache", "src/index.js"},
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
new String[]{"git_push.sh.mustache", "git_push.sh"},
new String[]{"README.mustache", "README.md"},
new String[]{"mocha.opts", "mocha.opts"},
@@ -85,7 +85,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
protected String modelDocPath = "docs/";
protected String apiTestPath = "api/";
protected String modelTestPath = "model/";
protected boolean useES6 = true; // default is ES5
protected boolean useES6 = true; // default is ES6
private String modelPropertyNaming = "camelCase";
public JavascriptClientCodegen() {
@@ -205,7 +205,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String getHelp() {
return "Generates a Javascript client library.";
return "Generates a JavaScript client library.";
}
@Override
@@ -337,6 +337,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
for (String[] supportingTemplateFile : supportingTemplateFiles) {
supportingFiles.add(new SupportingFile(supportingTemplateFile[0], "", supportingTemplateFile[1]));
}
supportingFiles.add(new SupportingFile("index.mustache", createPath(sourceFolder, invokerPackage), "index.js"));
supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js"));
}
@Override
@@ -373,12 +377,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String apiTestFileFolder() {
return (outputFolder + "/test/" + apiTestPath).replace('/', File.separatorChar);
return createPath(outputFolder, "test", invokerPackage, apiTestPath);
}
@Override
public String modelTestFileFolder() {
return (outputFolder + "/test/" + modelTestPath).replace('/', File.separatorChar);
return createPath(outputFolder, "test", invokerPackage, modelTestPath);
}
@Override
@@ -788,7 +792,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
* @param type Primitive type
* @return Normalized type
*/
public String normalizeType(String type) {
private String normalizeType(String type) {
return type.replaceAll("\\b(Boolean|Integer|Number|String|Date|Blob)\\b", "'$1'");
}
@@ -867,10 +871,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return codegenModel;
}
/*
private String sanitizePath(String p) {
//prefer replace a ', instead of a fuLL URL encode for readability
return p.replaceAll("'", "%27");
}
}*/
private String trimBrackets(String s) {
if (s != null) {
@@ -959,7 +964,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
List<String> argList = new ArrayList<String>();
List<String> argList = new ArrayList<>();
boolean hasOptionalParams = false;
for (CodegenParameter p : operation.allParams) {
if (p.required) {
@@ -976,7 +981,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
if (hasOptionalParams) {
argList.add("opts");
}
}
if (!usePromises) {
argList.add("callback");
@@ -1014,7 +1019,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
// NOTE: can't use 'mandatory' as it is built from ModelImpl.getRequired(), which sorts names
// alphabetically and in any case the document order of 'required' and 'properties' can differ.
List<CodegenProperty> required = new ArrayList<>();
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<CodegenProperty>() : required;
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<>() : required;
cm.vendorExtensions.put("x-required", required);
cm.vendorExtensions.put("x-all-required", allRequired);
@@ -1120,15 +1125,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return codegenModel;
}
private static String sanitizePackageName(String packageName) { // FIXME parameter should not be assigned. Also declare it as "final"
packageName = packageName.trim();
packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_");
if (Strings.isNullOrEmpty(packageName)) {
return "invalidPackageName";
}
return packageName;
}
@Override
public String toEnumName(CodegenProperty property) {
return sanitizeName(camelize(property.name)) + "Enum";
@@ -1160,12 +1156,18 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String escapeQuotationMark(String input) {
if (input == null) {
return "";
}
// remove ', " to avoid code injection
return input.replace("\"", "").replace("'", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
if (input == null) {
return "";
}
return input.replace("*/", "*_/").replace("/*", "/_*");
}

View File

@@ -164,7 +164,12 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) {
this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
else {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
}
additionalProperties.put(NPM_VERSION, npmVersion);

View File

@@ -44,7 +44,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
LoggerFactory.getLogger(KotlinSpringServerCodegen.class);
private static final HashSet<String> VARIABLE_RESERVED_WORDS =
new HashSet<String>(Arrays.asList(
new HashSet<>(Arrays.asList(
"ApiClient",
"ApiException",
"ApiResponse"
@@ -109,6 +109,10 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
importMapping.put("Date", "java.time.LocalDate");
importMapping.put("DateTime", "java.time.OffsetDateTime");
// use resource for file handling
typeMapping.put("file", "org.springframework.core.io.Resource");
languageSpecificPrimitives.addAll(Arrays.asList(
"Any",
"Byte",
@@ -562,4 +566,33 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
return m;
}
/**
* Output the proper model name (capitalized).
* In case the name belongs to the TypeSystem it won't be renamed.
*
* @param name the name of the model
* @return capitalized model name
*/
@Override
public String toModelName(final String name) {
// Allow for explicitly configured spring.*
if (name.startsWith("org.springframework.") ) {
return name;
}
return super.toModelName(name);
}
/**
* Check the type to see if it needs import the library/module/package
*
* @param type name of the type
* @return true if the library/module/package of the corresponding type needs to be imported
*/
@Override
protected boolean needToImport(String type) {
// provides extra protection against improperly trying to import language primitives and java types
boolean imports = !type.startsWith("org.springframework.") && super.needToImport(type);
return imports;
}
}

View File

@@ -0,0 +1,153 @@
/*
* 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
*
* http://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.info.Info;
import org.openapitools.codegen.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
public class NodeJSFastifyServerCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(NodeJSServerCodegen.class);
protected String projectName = "openapi-server";
public NodeJSFastifyServerCodegen() {
super();
outputFolder = "generated-code/nodejs-fastify";
modelTemplateFiles.clear();
apiTemplateFiles.clear();
embeddedTemplateDir = templateDir = "nodejs-fastify";
setReservedWordsLowerCase(
Arrays.asList(
"break", "case", "class", "catch", "const", "continue", "debugger",
"default", "delete", "do", "else", "export", "extends", "finally",
"for", "function", "if", "import", "in", "instanceof", "let", "new",
"return", "super", "switch", "this", "throw", "try", "typeof", "var",
"void", "while", "with", "yield")
);
supportingFiles.add(new SupportingFile("index.mustache", "", "index.js"));
supportingFiles.add(new SupportingFile("readme.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("openapi.mustache", "", "openapi.json"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
}
/**
* Configures the type of generator.
*
* @return the CodegenType for this generator
* @see org.openapitools.codegen.CodegenType
*/
@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}
/**
* Configures a friendly name for the generator. This will be used by the generator
* to select the library with the -g flag.
*
* @return the friendly name for the generator
*/
@Override
public String getName() {
return "nodejs-fastify-server";
}
/**
* Returns human-friendly help for the generator. Provide the consumer with help
* tips, parameters here
*
* @return A string value for the help message
*/
@Override
public String getHelp() {
return "Generates a NodeJS Fastify server library";
}
@Override
public void processOpts() {
super.processOpts();
writeOptional(outputFolder, new SupportingFile("service.mustache", "", "service.js"));
}
@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
generateJSONSpecFile(objs);
return super.postProcessSupportingFileData(objs);
}
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
if (openAPI.getInfo() != null) {
Info info = openAPI.getInfo();
if (info.getTitle() != null) {
// when info.title is defined, use it for projectName
// used in package.json
projectName = info.getTitle()
.replaceAll("[^a-zA-Z0-9]", "-")
.replaceAll("^[-]*", "")
.replaceAll("[-]*$", "")
.replaceAll("[-]{2,}", "-")
.toLowerCase(Locale.ROOT);
}
}
this.additionalProperties.put("projectName", projectName);
}
/**
* 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 String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
return input.replace("\"", "");
}
}

View File

@@ -38,6 +38,8 @@ import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.*;
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(NodeJSServerCodegen.class);
@@ -160,7 +162,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
if (name.length() == 0) {
return "DefaultController";
}
return initialCaps(name);
return camelize(name);
}
@Override

View File

@@ -30,6 +30,8 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public class PhpSlimServerCodegen extends AbstractPhpCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
@@ -175,7 +177,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
if (name.length() == 0) {
return toAbstractName("DefaultApi");
}
return toAbstractName(initialCaps(name) + "Api");
return toAbstractName(camelize(name) + "Api");
}
@Override
@@ -183,7 +185,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
if (name.length() == 0) {
return "DefaultApiTest";
}
return initialCaps(name) + "ApiTest";
return camelize(name) + "ApiTest";
}
/**

View File

@@ -324,10 +324,10 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
// Fix path parameters to be in snake_case
if (pathname.contains("{")) {
String fixedPath = new String();
for (String token: pathname.substring(1).split("/")) {
for (String token : pathname.substring(1).split("/")) {
if (token.startsWith("{")) {
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length()-1)) + "}";
if(!token.equals(snake_case_token)) {
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length() - 1)) + "}";
if (!token.equals(snake_case_token)) {
token = snake_case_token;
}
}
@@ -336,6 +336,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
if (!fixedPath.equals(pathname)) {
LOGGER.warn("Path '" + pathname + "' is not consistant with Python variable names. It will be replaced by '" + fixedPath + "'");
paths.remove(pathname);
path.addExtension("x-python-connexion-openapi-name", pathname);
paths.put(fixedPath, path);
}
}
@@ -359,11 +360,12 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
);
}
if (operation.getParameters() != null) {
for (Parameter parameter: operation.getParameters()) {
for (Parameter parameter : operation.getParameters()) {
String swaggerParameterName = parameter.getName();
String pythonParameterName = this.toParamName(swaggerParameterName);
if (!swaggerParameterName.equals(pythonParameterName)) {
LOGGER.warn("Parameter name '" + swaggerParameterName + "' is not consistant with Python variable names. It will be replaced by '" + pythonParameterName + "'");
parameter.addExtension("x-python-connexion-openapi-name", swaggerParameterName);
parameter.setName(pythonParameterName);
}
if (swaggerParameterName.isEmpty()) {
@@ -377,8 +379,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
String bodyParameterName = "body";
if (operation.getExtensions() != null && operation.getExtensions().containsKey("x-codegen-request-body-name")) {
bodyParameterName = (String) operation.getExtensions().get("x-codegen-request-body-name");
}
else {
} else {
// Used by code generator
operation.addExtension("x-codegen-request-body-name", bodyParameterName);
}
@@ -392,7 +393,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
// Sort path names after variable name fix
List<String> fixedPathnames = new ArrayList(paths.keySet());
Collections.sort(fixedPathnames);
for (String pathname: fixedPathnames) {
for (String pathname : fixedPathnames) {
PathItem pathItem = paths.remove(pathname);
paths.put(pathname, pathItem);
}
@@ -401,7 +402,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
}
private void addSecurityExtension(SecurityScheme securityScheme, String extensionName, String functionName) {
if (securityScheme.getExtensions() == null || ! securityScheme.getExtensions().containsKey(extensionName)) {
if (securityScheme.getExtensions() == null || !securityScheme.getExtensions().containsKey(extensionName)) {
securityScheme.addExtension(extensionName, functionName);
}
}
@@ -410,18 +411,17 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
Components components = openAPI.getComponents();
if (components != null && components.getSecuritySchemes() != null) {
Map<String, SecurityScheme> securitySchemes = components.getSecuritySchemes();
for(String securityName: securitySchemes.keySet()) {
for (String securityName : securitySchemes.keySet()) {
SecurityScheme securityScheme = securitySchemes.get(securityName);
String baseFunctionName = controllerPackage + ".security_controller_.";
switch(securityScheme.getType()) {
switch (securityScheme.getType()) {
case APIKEY:
addSecurityExtension(securityScheme, "x-apikeyInfoFunc", baseFunctionName + "info_from_" + securityName);
break;
case HTTP:
if ("basic".equals(securityScheme.getScheme())) {
addSecurityExtension(securityScheme, "x-basicInfoFunc", baseFunctionName + "info_from_" + securityName);
}
else if ("bearer".equals(securityScheme.getScheme())) {
} else if ("bearer".equals(securityScheme.getScheme())) {
addSecurityExtension(securityScheme, "x-bearerInfoFunc", baseFunctionName + "info_from_" + securityName);
}
break;
@@ -474,6 +474,68 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
// XXX - Revert the original parameter (and path) names to make sure we have
// a consistent REST interface across other server/client languages:
//
// XXX - Reverts `x-python-connexion-openapi-name` back to the original (query/path) parameter name.
// We do not want to have our REST API itself being converted to pythonic params.
// This would be incompatible with other server implementations.
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
Map<String, PathItem> paths = openAPI.getPaths();
if (paths != null) {
List<String> pathnames = new ArrayList(paths.keySet());
for (String pythonPathname : pathnames) {
PathItem path = paths.get(pythonPathname);
// Fix path parameters back to original casing
Map<String, Object> pathExtensions = path.getExtensions();
if (pathExtensions != null) {
// Get and remove the (temporary) vendor extension
String openapiPathname = (String) pathExtensions.remove("x-python-connexion-openapi-name");
if (openapiPathname != null && openapiPathname != pythonPathname) {
LOGGER.info("Path '" + pythonPathname + "' is not consistant with the original OpenAPI definition. It will be replaced back by '" + openapiPathname + "'");
paths.remove(pythonPathname);
paths.put(openapiPathname, path);
}
}
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
if (operationMap != null) {
for (HttpMethod method : operationMap.keySet()) {
Operation operation = operationMap.get(method);
if (operation.getParameters() != null) {
for (Parameter parameter : operation.getParameters()) {
Map<String, Object> parameterExtensions = parameter.getExtensions();
if (parameterExtensions != null) {
// Get and remove the (temporary) vendor extension
String swaggerParameterName = (String) parameterExtensions.remove("x-python-connexion-openapi-name");
if (swaggerParameterName != null) {
String pythonParameterName = parameter.getName();
if (swaggerParameterName != pythonParameterName) {
LOGGER.info("Reverting name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' back to '" + swaggerParameterName + "'");
parameter.setName(swaggerParameterName);
} else {
LOGGER.debug("Name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' was unchanged.");
}
} else {
LOGGER.debug("x-python-connexion-openapi-name was not set on parameter '" + parameter.getName() + "' of operation '" + operation.getOperationId() + "'");
}
}
}
}
}
}
}
// Sort path names after variable name fix
List<String> recoveredPathnames = new ArrayList(paths.keySet());
Collections.sort(recoveredPathnames);
for (String pathname : recoveredPathnames) {
PathItem pathItem = paths.remove(pathname);
paths.put(pathname, pathItem);
}
}
generateYAMLSpecFile(objs);
for (Map<String, Object> operations : getOperations(objs)) {
@@ -581,6 +643,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
/**
* Return the default value of the property
*
* @param p OpenAPI property object
* @return string presentation of the default value of the property
*/
@@ -691,8 +754,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
if (example == null) {
if (Boolean.TRUE.equals(p.isListContainer)) {
example = "[]";
}
else {
} else {
example = "None";
}
} else if (Boolean.TRUE.equals(p.isListContainer)) {
@@ -799,7 +861,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
for (CodegenOperation operation : operationList) {
Map<String, String> skipTests = new HashMap<>();
// Set flag to deactivate tests due to connexion issue.
if (operation.consumes != null ) {
if (operation.consumes != null) {
if (operation.consumes.size() == 1) {
Map<String, String> consume = operation.consumes.get(0);
if (!("application/json".equals(consume.get(MEDIA_TYPE))
@@ -810,8 +872,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
}
}
operation.vendorExtensions.put("x-prefered-consume", consume);
}
else if (operation.consumes.size() > 1) {
} 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");
operation.vendorExtensions.put("x-prefered-consume", consume);
@@ -819,8 +880,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
operation.isMultipart = Boolean.TRUE;
}
}
}
else {
} else {
// A body without consumes means '*/*' has been used instead of application/json
if (operation.bodyParam != null) {
Map<String, String> consume = new HashMap<>();
@@ -830,19 +890,19 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
}
}
// Choose to consume 'application/json' if available, else choose the last one.
if (operation.produces != null ) {
for (Map<String, String> produce: operation.produces) {
if (operation.produces != null) {
for (Map<String, String> produce : operation.produces) {
operation.vendorExtensions.put("x-prefered-produce", produce);
if (produce.get(MEDIA_TYPE).equals("application/json")) {
break;
}
}
}
if (! skipTests.isEmpty()) {
if (!skipTests.isEmpty()) {
operation.vendorExtensions.put("x-skip-test", skipTests);
}
if (operation.requestBodyExamples != null) {
for (Map<String, String> example: operation.requestBodyExamples) {
for (Map<String, String> example : operation.requestBodyExamples) {
if (example.get("contentType") != null && example.get("contentType").equals("application/json")) {
operation.bodyParam.example = example.get("example");
}

View File

@@ -238,6 +238,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
supportingFiles.add(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py"));
supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + modelPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__api.mustache", packagePath() + File.separatorChar + apiPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("exceptions.mustache", packagePath(), "exceptions.py"));
if (Boolean.FALSE.equals(excludeTests)) {
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));

View File

@@ -539,6 +539,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
/**
* Return the default value of the property
*
* @param p OpenAPI property object
* @return string presentation of the default value of the property
*/
@@ -581,7 +582,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String apiTestFileFolder() {
return outputFolder + File.separator + testFolder;
return outputFolder + File.separator + testFolder;
}
@Override
@@ -598,4 +599,88 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
public String toModelTestFilename(String name) {
return "test_" + toModelFilename(name);
}
}
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
for (Object o : allModels) {
HashMap<String, Object> h = (HashMap<String, Object>) o;
CodegenModel m = (CodegenModel) h.get("model");
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
for (CodegenOperation operation : operations) {
for (CodegenParameter cp : operation.allParams) {
cp.vendorExtensions.put("x-r-example", constructExampleCode(cp, modelMaps));
}
}
return objs;
}
public String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps) {
if (codegenParameter.isListContainer) { // array
return "list(" + constructExampleCode(codegenParameter.items, modelMaps) + ")";
} else if (codegenParameter.isMapContainer) { // TODO: map
return "TODO";
} else if (languageSpecificPrimitives.contains(codegenParameter.dataType)) { // primitive type
if ("character".equals(codegenParameter.dataType)) {
return codegenParameter.example;
} else {
return codegenParameter.example;
}
} else { // model
// look up the model
if (modelMaps.containsKey(codegenParameter.dataType)) {
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps);
} else {
LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
return "TODO";
}
}
}
public String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps) {
if (codegenProperty.isListContainer) { // array
return "list(" + constructExampleCode(codegenProperty.items, modelMaps) + ")";
} else if (codegenProperty.isMapContainer) { // TODO: map
return "TODO";
} else if (languageSpecificPrimitives.contains(codegenProperty.dataType)) { // primitive type
if ("character".equals(codegenProperty.dataType)) {
if (StringUtils.isEmpty(codegenProperty.example)) {
return "\"" + codegenProperty.example + "\"";
} else {
return "\"" + codegenProperty.name + "_example\"";
}
} else { // numeric
if (StringUtils.isEmpty(codegenProperty.example)) {
return codegenProperty.example;
} else {
return "123";
}
}
} else {
// look up the model
if (modelMaps.containsKey(codegenProperty.dataType)) {
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps);
} else {
LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenProperty.dataType);
return "TODO";
}
}
}
public String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps) {
String example;
example = codegenModel.name + "$new(";
List<String> propertyExamples = new ArrayList<>();
for (CodegenProperty codegenProperty : codegenModel.vars) {
propertyExamples.add(constructExampleCode(codegenProperty, modelMaps));
}
example += StringUtils.join(propertyExamples, ", ");
example += ")";
return example;
}
}

View File

@@ -732,6 +732,14 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
header.nameInCamelCase = toModelName(header.baseName);
}
if (op.authMethods != null) {
for (CodegenSecurity s : op.authMethods) {
if (s.isApiKey && s.isKeyInHeader) {
s.vendorExtensions.put("x-apiKeyName", toModelName(s.keyParamName));
}
}
}
}
return objs;

View File

@@ -49,13 +49,7 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
protected boolean registerNonStandardStatusCodes = true;
protected boolean renderJavadoc = true;
protected boolean removeOAuthSecurities = true;
/**
* If set to true, only the default response (the one with le lowest 2XX code) will be considered as a success, and all
* others as ApiErrors.
* If set to false, all responses defined in the model will be considered as a success upon reception. Only http errors,
* unmarshalling problems and any other RuntimeException will be considered as ApiErrors.
*/
protected boolean onlyOneSuccess = true;
@SuppressWarnings("hiding")
protected Logger LOGGER = LoggerFactory.getLogger(ScalaAkkaClientCodegen.class);
@@ -92,7 +86,6 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
additionalProperties.put("fnCapitalize", new CapitalizeLambda());
additionalProperties.put("fnCamelize", new CamelizeLambda(false));
additionalProperties.put("fnEnumEntry", new EnumEntryLambda());
additionalProperties.put("onlyOneSuccess", onlyOneSuccess);
additionalProperties.put("mainPackage", mainPackage);
importMapping.remove("Seq");
@@ -235,16 +228,6 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
return codegenSecurities;
}
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
return super.toOperationId(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, operationId));
}
@Override
public String toParamName(String name) {
return formatIdentifier(name, false);

View File

@@ -0,0 +1,417 @@
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.mustache.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.rightPad;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implements CodegenConfig {
public static final String TITLE = "title";
public static final String SKIP_STUBS = "skipStubs";
public static final String SUPPORT_ASYNC = "supportAsync";
public static final String GENERATE_CUSTOM_EXCEPTIONS = "generateCustomExceptions";
public static final String USE_SWAGGER_UI = "useSwaggerUI";
public static final String ROUTES_FILE_NAME = "routesFileName";
public static final String BASE_PACKAGE = "basePackage";
static Logger LOGGER = LoggerFactory.getLogger(ScalaPlayFrameworkServerCodegen.class);
protected boolean skipStubs = false;
protected boolean supportAsync = false;
protected boolean generateCustomExceptions = true;
protected boolean useSwaggerUI = true;
protected String routesFileName = "routes";
protected String basePackage = "org.openapitools";
public ScalaPlayFrameworkServerCodegen() {
super();
outputFolder = "generated-code" + File.separator + "scala-play-server";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
embeddedTemplateDir = templateDir = "scala-play-server";
hideGenerationTimestamp = false;
sourceFolder = "app";
apiPackage = "api";
modelPackage = "model";
instantiationTypes.put("map", "Map");
instantiationTypes.put("array", "List");
typeMapping.put("DateTime", "OffsetDateTime");
typeMapping.put("Date", "LocalDate");
typeMapping.put("Integer", "Int");
typeMapping.put("binary", "Array[Byte]");
typeMapping.put("ByteArray", "Array[Byte]");
typeMapping.put("object", "JsObject");
typeMapping.put("file", "TemporaryFile");
importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
importMapping.put("LocalDate", "java.time.LocalDate");
importMapping.remove("BigDecimal");
importMapping.put("TemporaryFile", "play.api.libs.Files.TemporaryFile");
cliOptions.add(new CliOption(ROUTES_FILE_NAME, "Name of the routes file to generate.").defaultValue(routesFileName));
cliOptions.add(new CliOption(ROUTES_FILE_NAME, "Base package in which supporting classes are generated.").defaultValue(basePackage));
addCliOptionWithDefault(SKIP_STUBS, "If set, skips generation of stub classes.", skipStubs);
addCliOptionWithDefault(SUPPORT_ASYNC, "If set, wraps API return types with Futures and generates async actions.", supportAsync);
addCliOptionWithDefault(GENERATE_CUSTOM_EXCEPTIONS, "If set, generates custom exception types.", generateCustomExceptions);
addCliOptionWithDefault(USE_SWAGGER_UI, "Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies", useSwaggerUI);
}
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "scala-play-server";
}
public String getHelp() {
return "Generates a Scala server application (beta) with Play Framework.";
}
public void setSupportAsync(boolean supportAsync) {
this.supportAsync = supportAsync;
}
public void setSkipStubs(boolean skipStubs) {
this.skipStubs = skipStubs;
}
public void setGenerateCustomExceptions(boolean generateCustomExceptions) {
this.generateCustomExceptions = generateCustomExceptions;
}
public void setRoutesFileName(String routesFileName) {
this.routesFileName = routesFileName;
}
public void setBasePackage(String basePackage) {
this.basePackage = basePackage;
}
public void setUseSwaggerUI(boolean useSwaggerUI) {
this.useSwaggerUI = useSwaggerUI;
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey(SKIP_STUBS)) {
this.setSkipStubs(convertPropertyToBoolean(SKIP_STUBS));
}
writePropertyBack(SKIP_STUBS, skipStubs);
if (additionalProperties.containsKey(SUPPORT_ASYNC)) {
this.setSupportAsync(convertPropertyToBoolean(SUPPORT_ASYNC));
}
writePropertyBack(SUPPORT_ASYNC, supportAsync);
if (additionalProperties.containsKey(GENERATE_CUSTOM_EXCEPTIONS)) {
this.setGenerateCustomExceptions(convertPropertyToBoolean(GENERATE_CUSTOM_EXCEPTIONS));
}
writePropertyBack(GENERATE_CUSTOM_EXCEPTIONS, generateCustomExceptions);
if (additionalProperties.containsKey(USE_SWAGGER_UI)) {
this.setUseSwaggerUI(convertPropertyToBoolean(USE_SWAGGER_UI));
}
writePropertyBack(USE_SWAGGER_UI, useSwaggerUI);
if (additionalProperties.containsKey(ROUTES_FILE_NAME)) {
this.setRoutesFileName((String) additionalProperties.get(ROUTES_FILE_NAME));
} else {
additionalProperties.put(ROUTES_FILE_NAME, routesFileName);
}
if (additionalProperties.containsKey(BASE_PACKAGE)) {
this.setBasePackage((String) additionalProperties.get(BASE_PACKAGE));
} else {
additionalProperties.put(BASE_PACKAGE, basePackage);
}
apiTemplateFiles.remove("api.mustache");
if (!skipStubs) {
apiTemplateFiles.put("app/apiImplStubs.scala.mustache", "Impl.scala");
}
apiTemplateFiles.put("app/apiTrait.scala.mustache", ".scala");
apiTemplateFiles.put("app/apiController.scala.mustache", "Controller.scala");
supportingFiles.add(new SupportingFile("README.md.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
supportingFiles.add(new SupportingFile("conf/application.conf.mustache", "conf", "application.conf"));
supportingFiles.add(new SupportingFile("conf/logback.xml.mustache", "conf", "logback.xml"));
supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties"));
supportingFiles.add(new SupportingFile("project/plugins.sbt.mustache", "project", "plugins.sbt"));
supportingFiles.add(new SupportingFile("conf/routes.mustache", "conf", routesFileName));
supportingFiles.add(new SupportingFile("app/module.scala.mustache", getBasePackagePath(), "Module.scala"));
supportingFiles.add(new SupportingFile("app/errorHandler.scala.mustache", getBasePackagePath(), "ErrorHandler.scala"));
if (generateCustomExceptions) {
supportingFiles.add(new SupportingFile("app/exceptions.scala.mustache", getBasePackagePath(), "OpenApiExceptions.scala"));
}
if (this.useSwaggerUI) {
//App/Controllers
supportingFiles.add(new SupportingFile("public/openapi.json.mustache", "public", "openapi.json"));
supportingFiles.add(new SupportingFile("app/apiDocController.scala.mustache", String.format(Locale.ROOT, "app/%s", apiPackage.replace(".", File.separator)), "ApiDocController.scala"));
}
addMustacheLambdas(additionalProperties);
}
private void addMustacheLambdas(Map<String, Object> objs) {
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
.put("indented_4", new IndentedLambda(4, " "))
.put("indented_8", new IndentedLambda(8, " "))
.build();
objs.put("lambda", lambdas);
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, CodegenModel> models = new HashMap<>();
for (Object _mo : allModels) {
CodegenModel model = (CodegenModel) ((Map<String, Object>) _mo).get("model");
models.put(model.classname, model);
}
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
Pattern pathVariableMatcher = Pattern.compile("\\{([^}]+)}");
Matcher match = pathVariableMatcher.matcher(operation.path);
while (match.find()) {
String completeMatch = match.group();
String replacement = ":" + camelize(match.group(1), true);
operation.path = operation.path.replace(completeMatch, replacement);
}
if ("null".equals(operation.defaultResponse) && models.containsKey(operation.returnType)) {
operation.defaultResponse = models.get(operation.returnType).defaultValue;
}
}
}
return objs;
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
objs = super.postProcessAllModels(objs);
Map<String, CodegenModel> modelsByClassName = new HashMap<>();
for (Object _outer : objs.values()) {
Map<String, Object> outer = (Map<String, Object>) _outer;
List<Map<String, Object>> models = (List<Map<String, Object>>) outer.get("models");
for (Map<String, Object> mo : models) {
CodegenModel cm = (CodegenModel) mo.get("model");
postProcessModelsEnum(outer);
cm.classVarName = camelize(cm.classVarName, true);
modelsByClassName.put(cm.classname, cm);
boolean hasFiles = cm.vars.stream().anyMatch(var -> var.isFile);
cm.vendorExtensions.put("hasFiles", hasFiles);
}
}
for (CodegenModel model : modelsByClassName.values()) {
model.defaultValue = generateModelDefaultValue(model, modelsByClassName);
}
return objs;
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
objs = super.postProcessSupportingFileData(objs);
generateJSONSpecFile(objs);
// Prettify routes file
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
List<Map<String, Object>> apis = (List<Map<String, Object>>) apiInfo.get("apis");
List<CodegenOperation> ops = apis.stream()
.map(api -> (Map<String, Object>) api.get("operations"))
.flatMap(operations -> ((List<CodegenOperation>) operations.get("operation")).stream())
.collect(Collectors.toList());
int maxPathLength = ops.stream()
.mapToInt(op -> op.httpMethod.length() + op.path.length())
.reduce(0, Integer::max);
ops.forEach(op -> op.vendorExtensions.put("paddedPath", rightPad(op.path, maxPathLength - op.httpMethod.length())));
ops.forEach(op -> op.vendorExtensions.put("hasPathParams", op.getHasPathParams()));
return objs;
}
@Override
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
openAPIType = getAlias(openAPIType);
// don't apply renaming on types from the typeMapping
if (typeMapping.containsKey(openAPIType)) {
return typeMapping.get(openAPIType);
}
if (null == openAPIType) {
LOGGER.error("No Type defined for Schema " + p);
}
return toModelName(openAPIType);
}
@Override
public String toDefaultValue(Schema p) {
if (p.getRequired() != null && p.getRequired().contains(p.getName())) {
return "None";
}
if (p.getDefault() != null) {
return p.getDefault().toString();
}
if (ModelUtils.isBooleanSchema(p)) {
return "false";
}
if (ModelUtils.isDateSchema(p)) {
return "LocalDate.now";
}
if (ModelUtils.isDateTimeSchema(p)) {
return "OffsetDateTime.now";
}
if (ModelUtils.isDoubleSchema(p)) {
return "0.0";
}
if (ModelUtils.isFloatSchema(p)) {
return "0.0F";
}
if (ModelUtils.isIntegerSchema(p)) {
return "0";
}
if (ModelUtils.isLongSchema(p)) {
return "0L";
}
if (ModelUtils.isStringSchema(p)) {
return "\"\"";
}
if (ModelUtils.isMapSchema(p)) {
Schema ap = ModelUtils.getAdditionalProperties(p);
String inner = getSchemaType(ap);
return "Map.empty[String, " + inner + "]";
}
if (ModelUtils.isArraySchema(p)) {
Schema items = ((ArraySchema) p).getItems();
String inner = getSchemaType(items);
return "List.empty[" + inner + "]";
}
return "null";
}
@Override
public String toEnumName(CodegenProperty property) {
return camelize(property.name);
}
@Override
public String toEnumVarName(String value, String datatype) {
if (value.length() == 0) {
return "EMPTY";
}
String var = camelize(value.replaceAll("\\W+", "_"));
if (var.matches("\\d.*")) {
return "_" + var;
} else {
return var;
}
}
private void addCliOptionWithDefault(String name, String description, boolean defaultValue) {
cliOptions.add(CliOption.newBoolean(name, description).defaultValue(Boolean.toString(defaultValue)));
}
private String getBasePackagePath() {
return String.format(Locale.ROOT, "%s/%s", sourceFolder, basePackage.replace(".", File.separator));
}
private String generateModelDefaultValue(CodegenModel cm, Map<String, CodegenModel> models) {
StringBuilder defaultValue = new StringBuilder();
defaultValue.append(cm.classname).append('(');
for (CodegenProperty var : cm.vars) {
if (!var.required) {
defaultValue.append("None");
} else if (models.containsKey(var.dataType)) {
defaultValue.append(generateModelDefaultValue(models.get(var.dataType), models));
} else if (var.defaultValue != null) {
defaultValue.append(var.defaultValue);
} else if (var.isEnum) {
defaultValue.append(cm.classname).append('.').append(var.enumName).append(".values.head");
} else {
LOGGER.warn("Unknown default value for var {0} in class {1}", var.name, cm.classname);
defaultValue.append("null");
}
if (var.hasMore) {
defaultValue.append(", ");
}
}
if (cm.isMapModel) {
defaultValue.append(", Map.empty");
}
defaultValue.append(')');
return defaultValue.toString();
}
}

View File

@@ -443,7 +443,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
public String toApiName(String name) {
if (name.length() == 0)
return "DefaultAPI";
return initialCaps(name) + "API";
return camelize(name) + "API";
}
@Override

View File

@@ -552,7 +552,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
if (name.length() == 0) {
return "DefaultAPI";
}
return initialCaps(name) + "API";
return camelize(name) + "API";
}
@Override

View File

@@ -434,7 +434,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
public String toApiName(String name) {
if (name.length() == 0)
return "DefaultAPI";
return initialCaps(name) + "API";
return camelize(name) + "API";
}
@Override

View File

@@ -22,11 +22,11 @@ import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.SemVer;
import org.openapitools.codegen.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
@@ -208,9 +208,13 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
this.setNpmVersion(this.getVersionFromApi());
}
if (additionalProperties.containsKey(SNAPSHOT)
&& Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) {
this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
else {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
}
additionalProperties.put(NPM_VERSION, npmVersion);
@@ -445,9 +449,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
/**
* Finds and returns a path parameter of an operation by its name
*
* @param operation
* @param parameterName
* @return
* @param operation the operation
* @param parameterName the name of the parameter
* @return param
*/
private CodegenParameter findPathParameterByName(CodegenOperation operation, String parameterName) {
for (CodegenParameter param : operation.pathParams) {
@@ -509,7 +513,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
if (name.length() == 0) {
return "DefaultService";
}
return initialCaps(name) + serviceSuffix;
return camelize(name) + serviceSuffix;
}
@Override
@@ -564,6 +568,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
return toApiFilename(name);
}
/*
private String getModelnameFromModelFilename(String filename) {
String name = filename.substring((modelPackage() + "/").length());
// Remove the file suffix and add the class suffix.
@@ -574,6 +579,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
}
return camelize(name) + modelSuffix;
}
*/
@Override
public String toModelName(String name) {
@@ -654,7 +660,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
/**
* Returns version from OpenAPI info.
*
* @return
* @return version
*/
private String getVersionFromApi() {
if (this.openAPI != null && this.openAPI.getInfo() != null) {

View File

@@ -74,7 +74,7 @@ public class TypeScriptAngularJsClientCodegen extends AbstractTypeScriptClientCo
@Override
public void postProcessParameter(CodegenParameter parameter) {
super.postProcessParameter(parameter);
parameter.dataType = addModelPrefix(parameter.dataType);
// parameter.dataType = addModelPrefix(parameter.dataType);
}
private String getIndexDirectory() {

View File

@@ -18,9 +18,12 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.StringUtils;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public class TypeScriptAureliaClientCodegen extends AbstractTypeScriptClientCodegen {
public static final String NPM_NAME = "npmName";
@@ -104,7 +107,7 @@ public class TypeScriptAureliaClientCodegen extends AbstractTypeScriptClientCode
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
// Aurelia uses "asGet", "asPost", ... methods; change the method format
op.httpMethod = initialCaps(op.httpMethod.toLowerCase(Locale.ROOT));
op.httpMethod = camelize(op.httpMethod.toLowerCase(Locale.ROOT));
// Collect models to be imported
for (CodegenParameter param : op.allParams) {

View File

@@ -231,7 +231,12 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) {
this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
else {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
}
additionalProperties.put(NPM_VERSION, npmVersion);

View File

@@ -194,7 +194,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) {
this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
else {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
}
additionalProperties.put(NPM_VERSION, npmVersion);

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