Compare commits

..

114 Commits

Author SHA1 Message Date
William Cheng
59c4e381d1 Prepare 4.1.0 release (#3597)
* update pom

* update doc

* update version

* add dep for nullable annotaiton
2019-08-09 22:25:32 +08:00
Jérémie Bresson
1ab7b9ceb6 [java][client][jax-rs] Add a constant for Jackson @JsonProperty (#3560) 2019-08-09 11:01:23 +08:00
William Cheng
65c7c1b39b restore openapi3 petstore.yaml (#3590) 2019-08-09 01:32:50 +08:00
William Cheng
2d7cc778db Add a new NodeJS Express server generator (#3567)
* create nodejs express esrver

* 1st commit of the express.js module. Express server working, api-docs loads properly. No real paths yet

* 1st commit of the express.js module. Express server working, api-docs loads properly. No real paths yet (#2839)

* Working Express server with successful routing to controllers.

* rewrote controllers and services. Haven't tested yet

* controllers and services have passed tests successfully

* Added documentation

* Added documentation

* Support for openApi v3, using 'express-openapi-validator' for parsing and validation, and an internal router to pass arguments to controllers and services. /controllers/Pet.js and /services/PetService.js should be used for reverse engineering for future codegen script

* update generator and template

* update samples

* more update

* update service, controller

* add vendor extensions

* some updates to adapt to changes in the generator (removing references to swager); some work on handling file uploads; some work on tests

* Update NodeJS server generator and templates based on new output (#3261)

* update generator and template

* update samples

* more update

* update service, controller

* add vendor extensions

* update doc

* Changed routing code to follow the following convention:
Each path operation has a 'x-openapi-router-controller' and 'x-openapi-router-service'. Automated files will be placed under /controllers and /services respectively.
Controller file names will end with 'Controller.js'.
Removed swaggerRouter, replaced it with openapiRouter
Routing works and simple tests show a return of 200 to requests.

* [nodejs-express-server] various updates, fixes (#3319)

* various fix

* remove dot from service

* add space

* better method empty argument

* remove test service (#3379)

* add new doc

* 1. routingTests.js runs through all operations described in openapi.yaml and tries calling them, expecting 200 in return. Currently not all tests pass - not supporting xml, and problems with formData
2. Removed old testing files.
3. Added model files - contain data and structure as defined in openapi.yaml. Model.js has static methods relevant to all model files.
4. Changed openapi.yaml to allow running tests easily.

* 1. routingTests.js runs through all operations described in openapi.yaml and tries calling them, expecting 200 in return. Currently not all tests pass - not supporting xml, and problems with formData (#3442)

2. Removed old testing files.
3. Added model files - contain data and structure as defined in openapi.yaml. Model.js has static methods relevant to all model files.
4. Changed openapi.yaml to allow running tests easily.

* added model classes. Currently as a concept only. Seems like won't be in use

* Updated README.md to be a detailed description of the project.
Removed test files that are not needed.
Removed utils/writer.js which is not needed, and the references to it in the codegen files

* Removed redundant file app.js - this file has no benefit at this point. index.js now calls ExpressServer.js directly. Updated files that used to call app.js. Updated README.md accordingly
Added a path to call the openapi.yaml, and a test file for all endpoints that are not in the openapi.yaml, ensuring that they return 200. Updated README.md accordingly

* Remove test controller (#3575)

* remove test controller

* add back changes to templates

* remove app.js

* update wording
2019-08-09 00:30:47 +08:00
Mario De Schaepmeester
fbb2f1e05a [C#][client][csharp-netcore] Fix csharp netcore defaultheaders (#3562)
* [csharp-netcore] Send default HTTP headers with requests

* [csharp-netcore] Add DefaultHeaders in favor of DefaultHeader
2019-08-09 00:24:47 +08:00
dan-drl
752030890f Fix issue deserializing to nullptr (#3572)
* Fix issue deserializing to nullptr

* Update codegen files
2019-08-09 00:17:54 +08:00
William Cheng
36dd848440 [OCaml] Add file post-processing (#3583)
* post process file in ocaml, remove unused sample

* auto-format ocaml petstore

* revert formatting

* remove openapi3 ocaml client
2019-08-09 00:17:24 +08:00
Paul Mundt
4b0fc3013f [dart2] Fix up test code generation, double deserialization, 'new' keyword deprecation (#3576)
* dart2: Use the correct classname in test generation

At present test generation has a stray hard-coded reference to the pet
store Pet() class, which should reflect the actual classname under test.

* dart2: Call toDouble() in generated code for double types

At present the generated code does not correctly handle transitioning
to double when dealing with non-integer types in JSON deserialization.
This ends up with dart raising an unhandled type mismatch exception:

Unhandled exception: type 'int' is not a subtype of type 'double' where
...

Using the .toDouble() conversion when a double type is expected fixes
this up by making the typing explicit.

* dart2: Drop use of deprecated 'new' keyword in generated code

The use of the 'new' keyword in dart2 is deprecated and should be
avoided, as per the official guidance of the dart2 authors:

https://dart.dev/guides/language/effective-dart/usage#dont-use-new

* dart2: Regenerate samples for mustache template changes
2019-08-09 00:15:45 +08:00
Martin Delille
1152af4d02 Run Qt5 client sample test (#3415) 2019-08-08 23:59:50 +08:00
Jean-François Côté
b28ef78145 typescript-fetch: allow configuration of headers and credentials (#3586)
* Fix #3402 by giving the possibility to set additional headers and the credentials parameters to the fetch query.

* Fix #3402 : Changes from code review
2019-08-08 14:48:45 +02:00
William Cheng
7f36f26422 using partials in ruby api_client (#3564) 2019-08-08 09:49:01 +08:00
cgensoul
411199bc99 [OCaml] Added optional params support in API operations (#3568)
* Added handling of api keys in headers.

* Added handling of optional arguments in api functions.

* Optional header params.

* Fixed a bug in path param replacement.

* Relaxed deserializing of model records with @@deriving yojson { strict = false }. It allows receiving more fields in the JSon payload than declared in the OCaml record, fields not matching any record field are ignored.

* Reformatted api-impl.mustache.

* Generate shorter enum value names by allowing underscore character.

* Cleanup of optional params generation.

* Updated the OCaml samples with the latest version of the generator.

* Corrected a bug encountered when generating default value for optional enum fields.

* Added v3 version of the samples for the OCaml generator.
2019-08-07 11:25:32 +08:00
Richard Whitehouse
4478f42927 [Rust Server] Generate valid Rustdocs for lazy_static items (#3556)
Generate valid Rustdocs for lazy_static items and update samples
2019-08-06 18:44:51 +01:00
Jean-François Côté
9e659d13ed Fix NPM build for Typescript-fetch (#3403)
* -Fix bug in fetch -> Missing "runtime"
-Move fetch files to an "src" folder instead of doing everything at the root which removes the bugs when using the library itself
-Fix the distribution of fetch using npm

* Move the .ts files to an `src` folder which is more common in npm package

* Add missing mustache

* Add missing .npmignore
2019-08-06 16:08:38 +02:00
unintended
b8295afa27 Expand path templates via resttemplate's uriTemplateHandler (#3500)
* Expand path templates via resttemplate's uriTemplateHandler

* fix tests and compilation on lower jdk version

* fix typo

* re-generate samples
2019-08-06 12:56:43 +02:00
Anıl Can Aydın
3538c08a8b Readme updated with a new tutorial and company using OpenAPI Generator (#3566) 2019-08-06 16:24:29 +08:00
Juang, Yi-Lin
5ab1c9c75b Fix logic of getNullableType of csharp server and client. (#3537)
* Fix default nullable

* Fix tests

* Update samples

* Fix template default value

* Update samples

* Also fix for interface

* update samples
2019-08-06 10:26:50 +08:00
William Cheng
2bbebf9752 [Ruby] clean up Ruby dev dependencies (#3551)
* clean up ruby dev dependencies

* update ensure uptodate to cover ruby faraday
2019-08-06 09:52:48 +09:00
Prateek Malhotra
f756bd5e11 typescript-fetch: Properly detect and encode container request body param (#3517)
Signed-off-by: Prateek Malhotra <someone1@gmail.com>
Co-Authored-By: Esteban Gehring <esteban.gehring@gmail.com>
2019-08-05 19:48:52 +02:00
Jeremie Bresson
fae073874b Update samples 2019-08-05 15:07:26 +02:00
Cristian Achille
00f7134eb3 #2956 [typescript] change accessToken name parameter to optional (#3555)
* [typescript] change accessToken name parameter to optional

* [typescript] update samples for ts-fetch and ts-rxjs
2019-08-05 12:37:13 +02:00
Dennis Melzer
b20118b87c java-springcloud: No dependency management if parent overridden (#3301)
* If a separate parent pom is specified, there
should be no depdendency management

#3230

* Add Bean Validation framework

* Fix test and depedencies

* Format pom
2019-08-05 10:49:58 +02:00
Esteban Gehring
a48df102d6 #3542: typescript-angular fix string cast (#3558) 2019-08-05 10:40:18 +02:00
William Cheng
3f7653a5c9 Add a link to join the Slack workspace (#3554) 2019-08-04 23:57:19 +08:00
William Cheng
4df1e1928c update rust server samples 2019-08-04 23:06:14 +08:00
Richard Whitehouse
83f17941b9 [Rust Server] Allow more than 32 configured paths (#3494) 2019-08-04 12:55:33 +01:00
Richard Whitehouse
6963e5eeb0 [Rust Server] Support multipart/form_data request bodies (#2846)
[Rust Server] Support multipart/form_data

- Support multipart/form_data in the Rust Server
- Add a new test API to test the change.
- Update the examples to match
2019-08-04 12:54:24 +01:00
William Cheng
86228e9964 [Ruby] remove auto-generated Gemfile.lock (#3541)
* remove auto-generated gemlock file

* update test file to conform to rubocop format
2019-08-03 16:36:22 +08:00
William Cheng
480d6baf3b Add @meganemura @dkliban as the template creator of Ruby Faraday client (#3544) 2019-08-03 14:54:18 +08:00
William Cheng
8b44c9dff1 update spring samples 2019-08-03 01:30:49 +08:00
Dennis Melzer
ba63aa55a5 Add lowercase lamda (#3501)
* Add lowercase lamda

#3381

* Add lowercase prefix for spring

#3381

* Add lamda prefix

* Add lamda lower case to @Value

* Add properties for braces

#3381

* Add property for braces

* Start CI

* Revert
2019-08-02 15:24:04 +02:00
William Cheng
d45e306480 Use partial for Ruby HTTP libraries (#3539)
* use partial for ruby http libraries

* fix isFaraday

* add back client side validation switch

* remove blank lines
2019-08-02 21:18:24 +08:00
cgensoul
1c36fa9fe3 Fixed #3521. Response headers were not processed for enums collection. (#3526)
* Fixed #3521. Response headers were not processed for enums collection.

* Replace " by '' in text fields to allow these to be used in OCaml comments.

* Added support of ByteArray (i.e. base64 encoded data) body and free form object as request body. Added support of free form object in response body as well.

* Added result as a reserved word to prevent generating model files with this name (having a result.ml model file confuses dune into thinking some other model modules depend on Result when they don't).

* Updated samples to reflect the latest changes in the OCaml generator.
2019-08-02 19:04:53 +08:00
Steven Masala
d0f0e17542 remove fixme by setting param to final and creating local variable for sanitising model name (#3525)
- general cleanup

(cherry picked from commit 88cf7e801f78a6611fc0d63479c78296e7312419)
2019-08-02 11:33:15 +02:00
William Cheng
ffaeb11a61 Add cgensoul to OCaml tech committee (#3536) 2019-08-02 14:15:49 +08:00
Dennis Kliban
4c1133be3f Problem: faraday ruby client does not respect TLS settings (#3527)
Solution: pass in tls settings to the faraday client
2019-08-02 12:20:16 +08:00
William Cheng
dff3386594 Remove Gitter badge 2019-08-02 09:44:42 +08:00
William Cheng
ca85ecb283 [Ruby][Faraday] Various improvements (#3520)
* update ruby faraday oas v2 samples

* skip some default tests in faraday

* add ruby faraday oas v3 client

* add tests, fix url

* add tests to CI

* fix file upload

* undo changes to ruby-client-petstore.sh

* test faraday first

* combine gemspec tempaltes

* test ruby faraday in drone.io

* use smaller image

* update bundler

* use official ruby image

* skip bundler installation

* skip autotest

* install make

* use different image

* skip ruby tests in drone.io
2019-08-02 07:00:29 +08:00
Juang, Yi-Lin
93ddf6e2ef Fix DateTimeOffset nullable issue (#3530) 2019-08-02 06:58:32 +08:00
Ivan Aksamentov
ed82aaae97 Fix PHP Symfony OpenAPI 3 sample location. Fixes #3531 (#3532)
* Fix PHP Symfony OpenAPI 3.0 sample location

* Update PHP Symfony OpenAPI 3.0 sample
2019-08-02 06:55:58 +08:00
Ivan Aksamentov
581131e0fe Fix PHP Symfony non-primitive return type being forced to be an array (#3515)
* Fix PHP Symfony non-primitive return type being forced to be an array

https://github.com/OpenAPITools/openapi-generator/issues/3514

* Update PHP Symfony samples
2019-08-02 06:54:13 +08:00
sunn
08415d1d83 Remove QRandomGenerator (#3508) 2019-08-01 20:50:28 +02:00
Mateusz Szychowski (Muttley)
4d285939a6 [C++][Pistache] Do not use JSON for primitive types in request body (#3509)
* [C++][Pistache] Do not use JSON for primitive types in request body

Request body can contain any input, simple strings, CSV text or something else

* [C++][Pistache] Update Petstore sample version
2019-08-01 13:49:17 +02:00
William Cheng
eca8ec3cf8 update doc 2019-08-01 15:58:45 +08:00
Marc Schlegel
0a7527b03e [java-client][okhttp-gson] fixes for interceptors in ApiClient.java (#3502)
ApiClient for Okhttp3 must not copy the interceptors when setting the HttpClient.
Enforce invariant that the HttpClient must never be null.
2019-08-01 06:39:47 +02:00
Dennis Kliban
bcc3a9ecf7 Ruby client faraday (#3405)
* WIP: add faraday support to Ruby client

* update samples

* bin/console

* https only

* ruby-faraday: Add a gemspec template for faraday

* Add a test for ruby-faraday client options

* Remove Gemfile.lock from ruby-client-faraday

* Implement faraday client

* Problem: can't use Faraday library for ruby clients

Solution: add support for Faraday library

This patch builds on the work started by @meganemura

* Problem: Faraday is set as default library

Solution: Make Typhoeus default

This patch also updates the api_client template for Faraday to include query params with requests.
2019-08-01 11:08:34 +08:00
Erik Seliger
f90f214121 fix(typescript-angular): improve small template issues (#3466)
* fix(typescript-angular): improve small template issues

* fix: template adjustments

* fix: repair hasSomeFormParamsLogic

* Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java

Co-Authored-By: Esteban Gehring <esteban.gehring@gmail.com>
2019-07-31 22:24:02 +02:00
Erik Seliger
0e621dcc29 feat(typescript-angular): add flag for using string enums (#3464)
* feat(typescript): add flag for using string enums

* fix: adjust templates

* fix: repair logic

* fix: remove sample

* fix: add to v7 sample

* fix: remove unneeded lines
2019-07-31 21:16:49 +02:00
William Cheng
8b054e6f8e update spring samples 2019-08-01 00:31:58 +08:00
Justin Black
88af8964fd [python-experimental] automatically use values for enums of length1 (#3118)
* Update python client java generator

* Updates python generator mustache files

* Python sample regenerated

* Switches from getfullargspec to getargspec for python2 compatibility

* Uses getattr to get model class init method to correctly see its arguments, linting fixes to pass python tests

* Updates comment in python centerator to restart CI tests

* Adds bin/windows/python-experimental-petstore.bat

* CHanges spec update to apply to the python-experimental spec

* Moves new python templates to python-experimental

* Moves generator python java code to python-experimental

* Reverts python generator mustache files

* Regenerates python, v3 python, python-experimental samples

* Test moved to python-experimental, unused python files removed
2019-07-31 21:18:30 +08:00
Richard Whitehouse
199447a398 Add richardwhiuk to the Rust Technical Committee (#3506) 2019-07-31 13:50:51 +02:00
Thibault Duperron
4c9d023468 Enable async option for spring-cloud library (#2670)
* Enable async option for spring-cloud library

* Samples
2019-07-31 14:22:05 +08:00
William Cheng
d46cabcd4f Better handling of dot in inline model name (#3498)
* better handling of dot in inline model name

* do nothing if title is present

* add comment
2019-07-31 13:50:29 +08:00
julaudo
6824bd8b24 #2694 [BUG][Typescript Axios] Content-type not set (#2695)
* #2694 [BUG][Typescript Axios] Content-type not set

* Test required allOf

* re-generate typescript-axios samples

* re-generate typescript-axios samples
2019-07-30 15:47:17 +02:00
Doxoh
f90507b527 [aspnetcore] Support cookie parameter (#3490)
* Fix typo useDefaultRoutng to useDefaultRouting

* support the cookie functionality in aspnetcore

* Changes like wing328 comments
2019-07-30 18:22:15 +08:00
timmiotool
3b584c2138 validation for primitive request bodies #3491 (#3492)
* Add parameters to primitive request bodies

Signed-off-by: tim.smyth <tim.smyth@kiwigrid.com>

* Replace tabs for spaces

Signed-off-by: tim.smyth <tim.smyth@kiwigrid.com>
2019-07-29 18:06:20 +02:00
Michal Foksa
37cdc8e493 Feature/mustache lambda documentation (#3476)
* Default outputFile value is `openapi/openapi.yaml`.

* Mustache Lambdas documentation.

* Default OpenAPIYamlGenerator outputFile value is `openapi/openapi.yaml`.
2019-07-29 15:34:50 +02:00
Benjamin Gill
c684505cba Stop deriving Eq for models (#3463)
It fails if the model contains a float, which don't implement Eq.

Fix for bug introduced in #3309.

We really need to improve the testing of the rust generator to catch this sort of mistake in future. I don't have time to do this now, though.
2019-07-29 14:01:01 +01:00
Sebastian Rühl
1bf8c15206 [BUG-1865] Added serialization support for typescript on complex object headers. (#1874)
* [BUG-1865] Added serialization support for typescript on complex object headers.

* Update api.mustache

integrate feedback from https://github.com/OpenAPITools/openapi-generator/pull/1874#discussion_r268981304

* [BUG-1865] post merge fixes

* [BUG-1865] addded windows scripts

* Apply suggestions from code review

Co-Authored-By: Esteban Gehring <esteban.gehring@gmail.com>

* [BUG-1865] regenerated samples
2019-07-29 11:31:42 +02:00
Steven Masala
b4f1581941 Fix: Remove spec 3 references keys in imports for TypeScript (#1932)
* fix name sanitation when using kebab case filenaming

* remove whitespaces

* sanitize names by removing spec 3 ref keys

* Revert "sanitize names by removing spec 3 ref keys"

This reverts commit 7e58719317.

* add pipes to datatype names

* split imports

* remove comment

* fix when using a mixture of (any|one) and standard imports

* sanitize names by removing spec 3 ref keys

* Revert "sanitize names by removing spec 3 ref keys"

This reverts commit 7e58719317.

* Merge conflict DefMerge branch 'master' into name-ref-fix

# Conflicts:
#	modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

* split imports

* remove comment

* fix when using a mixture of (any|one) and standard imports

* Fix merge error

import missing package, merge error.

* format

*  fix tests

* create test, fi regex
2019-07-29 11:30:34 +02:00
Doxoh
cf01bf4ae7 Fix typo useDefaultRoutng to useDefaultRouting (#3488) 2019-07-29 17:30:07 +08:00
scottydawg
74eeb07b22 Support importMapping definitions for TypeScriptNodeClientCodegen (#3469)
* Support importMapping definitions for TypeScriptNodeClientCodegen

* Use import mappings for all file references
2019-07-29 07:48:20 +02:00
William Cheng
981b3a53ef update ocaml openapi3 petstore script 2019-07-29 12:05:15 +08:00
tjnet
9cb3ae1048 remove unecessary null check as it cannot be reached due to the Null Pointer Exception (#3480) (#3481) 2019-07-29 10:34:57 +08:00
William Cheng
cbd78d7fca Test OCaml petstore client in drone.io (#3484)
* test ocaml petstore

* undo directory rename

* run eval

* install m4

* force yes

* fix permission issue

* specify build dir

* fix dune

* give full permission

* fix steps

* rename test

* update ocaml petstore path
2019-07-29 10:16:59 +08:00
William Cheng
6e3176557c [OCaml] various enhancements (#3483)
* add ocaml template creator

* various enhancement to ocaml generator

* update instruction

* update doc

* remove readme

* add back readme
2019-07-29 10:07:32 +08:00
cgensoul
1713c7610d [OCaml] new client generator (#3446)
* Début d'un générateur pour OCaml.

* Ajout du script bash de generation pour OCaml.

* Implémentation de la partie model du générateur OCaml.

* Suppression du fichier Model.mustache.

* Légère modification dans le générateur OCaml.

* Début d'implémentation de la génération des opérations.

* Avancées dans l'implémenatation des opérations.

* Avancée dans la gestion des enums : reste à traiter le fait que Yojson sérialize les variants comme des tableaux JSON.

* Prise en compte du fait que Yojson représente les variants constants sous forme d'un tableau JSON contenant une unique string.

* Utilisation des variants polymorphe pour les enums car il se peut que plusieurs énumérations partagent des valeurs communes ce que ne permettent pas les variants ordinaires au sein d'un même module.

* Avancées dans le générateur de code OCaml : le code produit compile et prendre en compte les pathParams, les queryParams, les headersParams, les bodyParams et la réponse JSON. Manque le support du multipart, du form encoded et des mécanismes d'authentification.

* More tests.

* Correction de problèmes dans la génération mis en évidence par l'utilisation d'un fichier OAS plus gros et complexe que Petstore.

* Mapping du case Error de Ppx_deriving_yojson_runtime.ok_error vers l'exception Failure pour avoir des types plus simples et non dépendants de Pppx_deriving_yoson_runtime dans les APIs générées.

* Ajout de la génération des fichiers d'interfaces .mli pour les APIs.

* Ajout du support des parametres de type x-www-form-urlencoded.

* Le paramètres d'url de type number étaient mal gérés.

* Cleanup.

* Replace block comment start and end sequences in input text.

* Make apis calls without a return type return unit rather than Yojson.Safe.t.

* Make modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml generate properly.

* Added generated code for modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml.

* Better handling of enums and map container and better sanitizing of generated identifiers to support all the corner cases present in modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml.

* Correcting a violation : using toLowerCase without relying on the default Locale.

* Changed authoring in partial_header.mustache.

* Deleted commented code.

* Collect enum schemas in items properties of operation parameters in the case of ArraySchema parameters. This allows correct processing of modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml.

* Collect enums also in additional properties schemas of operation parameters in the case of MapSchema parameters (if this type of parameter can is allowed).

* Removed copy-pasted Copyright notice from SmartBear.

* update doc

* Use Locale.ROOT instead of Locale.ENGLISH for toLowerCase calls.

* Make GET operations with body generate compilable code.

* Updated ocaml-client generated samples using the latest version of the OCaml code generator.

* Added [@default None] for record fields with option types so that if those fields are missing at deserialization time, None is assumed.

* Added support of api keys in query params.

* Updated generated ocaml samples to reflect latest changes in templates.

* Added [@default] on enum record fields for which the enum type has only one accepted value so that those fields can be deserialized even if the value is absent of the json payload.

* Delete useless space character in template.

* Added proper handling of http response codes.

* Updated generated ocaml samples to reflect latest changes in templates.
2019-07-28 21:50:53 +08:00
Guillaume SMAHA
049f69c55b Use range for dependencies in python-flask (#3470) 2019-07-28 10:40:10 +08:00
William Cheng
b9e863a9ca Add bbdouglas as the template creator of Java (Java 11 Native HTTP client) 2019-07-27 22:49:01 +08:00
Chris Couzens
6358b11516 Bash skip empty query param fix (#3290)
* Bash: Update samples

I'm about to make a fix to the bash generator. I'm regenerating the
samples in this commit so that the change I make isn't lost amongst
the noise.

https://github.com/OpenAPITools/openapi-generator/pull/3290

* Bash client: Fix query params seperation

Fix bug where empty query parameters weren't separated by ampersands.

For example, this
```bash
bash bash_keycloak/client.sh -v --oauth2-bearer "$access_token" --host "$api_host" realmUsersGet realm=demo_realm2 email=foo+bar@baz.com
```
would generate the path
`/auth/admin/realms/demo_realm2/users?briefRepresentation=email=foo+bar@baz.comfirst=firstName=lastName=max=search=username=`.

It now puts ampersands around them to make
`/auth/admin/realms/demo_realm2/users?briefRepresentation=&email=foo+bar@baz.com&first=&firstName=&lastName=&max=&search=&username=`

Instead of predicting if there is going to be a `parameter_value` ahead of
time, we now put in the ampersand if there is a `parameter_value` and existing
`query_request_part`.

https://github.com/OpenAPITools/openapi-generator/pull/3290

* Bash: Skip query parameters with empty value

I have a route with many optional query parameters.
I observed that when they weren't specified, they were still included in
the routes, but without a value.

Running:
```bash
bash bash_keycloak/client.sh -v --header "Authorization: Bearer $access_token" --host "$api_host" --dry-run realmUsersGet realm=demo_realm2 email=foo+bar@baz.com username=foo
```

Would produce the route:
`http://localhost:8080/auth/admin/realms/demo_realm2/users?briefRepresentation=&email=foo+bar@baz.com&first=&firstName=&lastName=&max=search=&username=foo`

After this change it produces the route:
``http://localhost:8080/auth/admin/realms/demo_realm2/users?email=foo+bar@baz.com&username=foo

---

I discussed with @wing328 in the pull request about if empty values (eg
`username=` should produce an empty query parameter, or if the query
parameter should be removed.

We decided it should remove the query parameter.

https://github.com/OpenAPITools/openapi-generator/pull/3290

----

The OpenAPI definition I was using:

Using:
https://github.com/ccouzens/keycloak-openapi/blob/master/keycloak/6.0.json
In particular:
```json
      "/{realm}/users": {
        "get": {
          "summary": "Get users   Returns a list of users, filtered according to query parameters",
          "parameters": [
            {
              "in": "query",
              "name": "briefRepresentation",
              "schema": {
                "type": "boolean"
              },
              "style": "form"
            },
            {
              "in": "query",
              "name": "email",
              "schema": {
                "type": "string"
              },
              "style": "form"
            },
            {
              "in": "query",
              "name": "first",
              "schema": {
                "type": "integer",
                "format": "int32"
              },
              "style": "form"
            },
            {
              "in": "query",
              "name": "firstName",
              "schema": {
                "type": "string"
              },
              "style": "form"
            },
            {
              "in": "query",
              "name": "lastName",
              "schema": {
                "type": "string"
              },
              "style": "form"
            },
            {
              "in": "query",
              "name": "max",
              "description": "Maximum results size (defaults to 100)",
              "schema": {
                "type": "integer",
                "format": "int32"
              },
              "style": "form"
            },
            {
              "in": "query",
              "name": "search",
              "description": "A String contained in username, first or last name, or email",
              "schema": {
                "type": "string"
              },
              "style": "form"
            },
            {
              "in": "query",
              "name": "username",
              "schema": {
                "type": "string"
              },
              "style": "form"
            }
          ],
```
2019-07-27 21:48:36 +08:00
William Cheng
652b14c28f Add drone.io CI for Java 11 test (#3472)
* add drone.yml

* use maven wrapper instead

* break the build

* Revert "break the build"

This reverts commit 69769d6cad.

* add drone.io badge to README

* update wording
2019-07-26 20:21:38 +08:00
William Cheng
93cb215531 update java native 11 samples 2019-07-26 15:21:23 +08:00
Erik Seliger
d5d8b7a118 fix(typescript-angular): use correct package with http-client (#3465) 2019-07-26 07:54:40 +02:00
William Cheng
45fcf3792a [Java] add nullable support to the clients (#3453)
* add nullable support, update samples

* update samples
2019-07-26 10:00:27 +08:00
Benjamin Douglas
43590582c5 Java 11 native HTTP client library (#3434)
* Initial commit of Java 11 native HTTP client port

* Rebase to master and add JSR305 for @Nullable

* Update samples with @Nullable annotations
2019-07-26 09:59:21 +08:00
William Cheng
8253c28d6e [Java] Replace "useNullForUnknownEnumValue" option with the nullable attribute (#3455)
* add nullable support to enum

* update test spec with nullable enum

* update samples

* update samples
2019-07-26 09:49:44 +08:00
Martin Delille
fabe021fb0 Revert "qt5 client: use openapi 3 spec (#3400)" (#3458)
This reverts commit 40f1f920df.
2019-07-25 18:25:17 +02:00
Bernd Hacker
8231cbfe81 [typescript-rxjs]: support reponseType blob (#3437)
* feat(typescript-rxjs): add optional responseType to RequestOpts

* refactor(typescript-rxjs): remove redundant importMapping.clear() in codegen constructor

* feat(typescript-rxjs): update this.reservedWords

* fix(typescript-rxjs): add missing fields copied to ExtendedCodegenOperation

* feat(typescript-rxjs): add support for responseType blob

* feat(typescript-rxjs): regenerate samples
2019-07-25 15:16:54 +02:00
Freeman
a3cf964ce9 Upgrade babel packages for Javascript ES6 generator (#3424)
* Upgrade babel packages for Javascript ES6 generator

* Fix @babel/register in test script
2019-07-25 14:31:27 +02:00
William Cheng
d0b728794d update kotlin server samples 2019-07-25 18:56:59 +08:00
William Cheng
da62116c9d Add bkabrda to Go technical committee (#3454) 2019-07-25 15:35:55 +08:00
William Cheng
2c9bfdf29a Merge branch 'master' of https://github.com/OpenAPITools/openapi-generator 2019-07-25 15:30:30 +08:00
William Cheng
64c2069256 update java samples 2019-07-25 15:30:13 +08:00
Martin Delille
3f3ecb6879 add modelNamePrefix option for qt5 (#3431)
* qt5: Remove duplicate cppNamespace additional property

* qt5: Add modelNamePrefix additional property
2019-07-25 09:23:51 +02:00
Fjolnir-Dvorak
2f479f493f [Java] Fix numeric field names (#3436)
* Fix for OpenAPITools/openapi-generator#3293. Number fields in java generators are escaped now.

* Added a few tests for number to varName to persist and ensure this behaviour for future breaking changes OpenAPITools/openapi-generator#3293.

* I also added a few test for convertModelName to prevent similar breaking changes in the future. OpenAPITools/openapi-generator#3293.
2019-07-25 07:38:49 +02:00
kassim
ee538be964 [Java] add nullable annotation to pojo template for non-required fields (#3409)
* add nullable annotation to pojo template

* add jsr305 dependency

* jsr305 dependency on all java build.gradle files

* jsr305 dependency on all java pom.xml files

* update samples

* more pom updates

* more sample/template updates
2019-07-25 10:35:18 +08:00
Jérémie Bresson
a0dd7394ac [java] Support for number enum (#3328)
* [java] Support for number enum

*  [core] add isLong, isNumber, isNumeric, isFloat, isDouble to CodegenModel

* [java-gson] fix Enum TypeAdapter in BigDecimal case.
2019-07-25 10:32:50 +08:00
William Cheng
3f7725c9e2 update brew instruction (#3445) 2019-07-25 10:19:40 +08:00
William Cheng
ab644f9912 Add GoDaddy as domain name sponsor (#3443)
* add godaddy as domain name sponsor

* resize godaddy logo

* add back new line

* remove space

* highlight sponsor
2019-07-25 00:43:19 +08:00
Benoît Courtine
28a16bea24 [Rust][Client] Correct the Rust client generated documentation (#3419)
Fixes #3418. Only generated API markdown files are impacted.
2019-07-24 17:33:11 +01:00
Gabriel Féron
2e81e612fc Fix enum types in structs (#3309)
I already contributed proper enum supports a few weeks ago, but somehow missed actually using them when they're used as a property. This PR fixes that.

I also took the liberty of fixing a bunch of unused warnings.

* Make sure we use the enum types in Rust

* Fix unused warnings in Rust and regenerate samples

* Use crate:: import path that works both with Rust 2015 and 2018

* Derive PartialEq and Eq in generated Rust structs and enums
2019-07-24 17:29:43 +01:00
Ramanth Addala
a4b1c269d8 fix(r): updated example in doc(.md) file (#3429)
* fix(r): updated doc(.md) files

* fix(r): changed enum representation
2019-07-24 23:15:21 +08:00
Akihito Nakano
2c4fdd0792 Update links (#3410) 2019-07-24 13:48:17 +09:00
Aadi Bajpai
00c7d6f46b Add back Flask tests (#3387)
fixes #3286
2019-07-24 13:46:10 +09:00
Martin Delille
40f1f920df qt5 client: use openapi 3 spec (#3400) 2019-07-23 22:26:42 +02:00
Jeremy Bohrer
5775813031 2745 typescript date format (#3423)
* fix axios issue

* fix typo
2019-07-23 15:44:34 +02:00
Bernd Hacker
d2576f411e [typescript-rxjs] runtime and api cleanup (#3316)
* feat(typescript-rxjs): use interfaces from rxjs/ajax, use shorthands

* feat(typescript-rxjs): regenerate samples

* docs(typescript-rxjs): extend readme by middleware howto

* feat(typescript-rxjs): stop generating empty comment when there is no description in model

* feat(typescript-rxjs): import throwIfRequired and COLLECTION_FORMATS only when needed

* feat(typescript-rxjs): generate HttpHeaders and HttpQuery only if needed, improve formatting

* feat(typescript-rxjs): conditionally import HttpHeaders and HttpQuery

* feat(typescript-rxjs): add encodeURI helper, refactor queryString helper

* feat(typescript-rxjs): improve condition for hasListContainers

* feat(typescript-rxjs): regenerate samples
2019-07-22 11:21:37 +02:00
Silas Boyd-Wickizer
76fecf744b [typescript-node] Promise-based Authentication interface (#3408) 2019-07-22 10:54:48 +02:00
Daniel Grünberger
f436904359 [typescript-angular] Add encoder configuration, fix default encoder (#3372) (#3389)
* [typescript-angular] Add encoder configuration and fix default encoder (#3372)

* Add encoder to configuration
* Fix import indention
* Default encoder workaround for https://github.com/angular/angular/issues/18261

* [typescript-angular] Refactor api.service template

* Extract encoder class variable initialized in constructor

* [typescript-angular] Updated samples

* [typescript-angular] Add missing imports

* [typescript-angular] Update samples

* [typescript-angular] Update samples

* [typescript-angular] Fix tests

* Fix typo
* Add missing interface method implementation
* Update samples
2019-07-22 10:54:14 +02:00
Daiki Matsudate
5cba55f8fb [Swift4] Introduce XcodeGen (#3396)
* add XcodeGen.mustache

* generate code

* add dependencies
2019-07-22 17:12:34 +09:00
Martin Delille
1413775e0e qt5 client: strip whitespace (#3406) 2019-07-21 22:23:15 +02:00
John Wang
21e29d7177 fix README.md missing paren typo (#3391) 2019-07-19 09:44:31 +02:00
wing328
5c7d902c4c fix link to open summit presentation 2019-07-19 15:15:22 +08:00
William Cheng
e58cc2a282 Update README.md 2019-07-19 15:10:01 +08:00
Prateek Malhotra
84e2f60d6b typescript-fetch: fix basic type errors (#3380)
* use proper response for simple object return types
* exclude api and/or model support files and imports if none are generated

Signed-off-by: Prateek Malhotra <someone1@gmail.com>
2019-07-19 08:04:27 +02:00
Jim Schubert
944e1c3468 [fix] Assign template directory to additional properties (#3385)
* [fix] Assign template directory to additional properties
2019-07-18 09:50:54 -04:00
Benoît Courtine
26b8d1f4c2 Better Rust client imports (#3332)
* Better Rust client imports.

* No more "unused_imports" in models for serde_json::Value.
* No more compilation problem for apis requiring serde_json::Value.
* "crate::" prefix for models and apis imports, for compatibility with Rust 2018 edition.

* Rust samples regeneration using new code.
2019-07-18 10:08:48 +01:00
Slavek Kabrda
0fec25e92e [Go][experimental-client]: make struct members pointers, provide custom marshalling (#3371)
* [Go][experimental-client] Properly define packageName for go-experimental sample client

* [Go][experimental-client] make structure members pointers, provide custom marshalling.
2019-07-18 15:52:37 +09:00
Josh Burton
1aa8a2bec4 [dart-jaguar] Fixes error accessing default converters (#3361)
`this.converters` was causing errors as the default converters are declared outside of the API client.
2019-07-18 15:28:15 +09:00
Akihito Nakano
1e735c69fa Add Logs section to the Debugging page. (#3357) 2019-07-18 15:04:27 +09:00
Jérémie Bresson
4223743ee0 [java rest-assured] prevent reqSpec reuse between requests (#3375)
* [java rest-assured] prevent reqSpec reuse between requests

* Update sample
2019-07-18 14:46:44 +09:00
james-beer
29a85d54a2 Adds default property values in ASP .NET Core models (#3369)
* Fixes docker-entrypoint.sh

* Adds default property values to C# model templates (#3359).
2019-07-18 14:22:12 +09:00
Michal Foksa
a85bd0f8f9 Include common lambdas in generators (#3368)
* Include commonly used Mustache lambdas in DefaultCodegen.
* Use or extend common Mustache lambdas from DefaultCodegen.
* Extract OnChangeLambda to own file.
* Javadoc fixed in addMustacheLambdas().
2019-07-18 06:28:40 +02:00
Jean-François Côté
610ca28681 Fix #3349 : [typescript-fetch] Proposition to follow spec (#3351)
* Fix 3349 : Proposition to follow spec closely

* Fix #3349 : Changes suggested by code review. Add an option for the single request parameter.

* Fix #3349 : Add sample with the use of the single request parameter

* Fix #3349 : Small fix that wasn't passing the tests

* Fix #3349 : Remove cariage return that might create an error

* Fix #3349 : Add chmod to make new sh file executable and fix the CircleCI issue

* Fix #3349 : Add windows sample generation

* Fix #3349 : Rename everything because of default value change

* Fix #3349 : Indentation fix

* Fix #3349 : Add 755 to typescript-fetch-petstore-multiple-parameters.sh

* Fix #3349 : Auto generation of the documentations

* Fix #3349 : Revert back a change that was auto-generated.
2019-07-17 22:30:27 +02:00
4672 changed files with 148622 additions and 46244 deletions

View File

@@ -1094,36 +1094,6 @@
"Client: Swift"
]
},
{
"input": "swift5-petstore-promisekit.sh",
"matches": [
"Client: Swift"
]
},
{
"input": "swift5-petstore-rxswift.sh",
"matches": [
"Client: Swift"
]
},
{
"input": "swift5-petstore-unwrapRequired.sh",
"matches": [
"Client: Swift"
]
},
{
"input": "swift5-petstore.sh",
"matches": [
"Client: Swift"
]
},
{
"input": "swift5-test.sh",
"matches": [
"Client: Swift"
]
},
{
"input": "typescript-angular-v2-petstore-interfaces.sh",
"matches": [

4
.gitignore vendored
View File

@@ -232,3 +232,7 @@ samples/client/petstore/elm/index.html
# C
samples/client/petstore/c/build
samples/client/petstore/c/*.so
# Ruby
samples/openapi3/client/petstore/ruby/Gemfile.lock
samples/openapi3/client/petstore/ruby-faraday/Gemfile.lock

View File

@@ -94,6 +94,12 @@ before_install:
# - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18).
# - . ~/otp/18.2.1/activate && erl -version
#- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH"
# install Qt 5.10
- sudo add-apt-repository --yes ppa:beineri/opt-qt-5.10.1-trusty
- sudo apt-get update -qq
- sudo apt-get install qt510-meta-minimal
- source /opt/qt510/bin/qt510-env.sh
- qmake -v
# show host table to confirm petstore.swagger.io is mapped to localhost
- cat /etc/hosts

20
CI/.drone.yml Normal file
View File

@@ -0,0 +1,20 @@
kind: pipeline
name: default
steps:
# test Java 11 HTTP client
- name: java11-test
image: hirokimatsumoto/alpine-openjdk-11
commands:
- ./mvnw clean install
- ./mvnw --quiet verify -Psamples.droneio
# test ocaml petstore client
- name: ocaml-test
image: ocaml/opam2:4.07
commands:
- sudo apt-get -y install m4
- cd samples/client/petstore/ocaml
- opam install ppx_deriving_yojson cohttp ppx_deriving cohttp-lwt-unix
- eval $(opam env)
- sudo chmod -R 777 .
- dune build --build-dir=./_build

View File

@@ -10,6 +10,7 @@ import java.util.TimeZone;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
public class ApiClientTest {
@@ -329,24 +330,18 @@ public class ApiClientTest {
assertEquals("sun.gif", apiClient.sanitizeFilename(".\\sun.gif"));
}
@Test
public void testInterceptorCleanupWithNewClient() {
public void testNewHttpClient() {
OkHttpClient oldClient = apiClient.getHttpClient();
assertEquals(1, oldClient.networkInterceptors().size());
OkHttpClient newClient = new OkHttpClient();
apiClient.setHttpClient(newClient);
assertEquals(1, apiClient.getHttpClient().networkInterceptors().size());
apiClient.setHttpClient(newClient);
assertEquals(1, apiClient.getHttpClient().networkInterceptors().size());
apiClient.setHttpClient(oldClient.newBuilder().build());
assertThat(apiClient.getHttpClient(), is(not(oldClient)));
}
@Test
public void testInterceptorCleanupWithSameClient() {
OkHttpClient oldClient = apiClient.getHttpClient();
assertEquals(1, oldClient.networkInterceptors().size());
apiClient.setHttpClient(oldClient);
assertEquals(1, apiClient.getHttpClient().networkInterceptors().size());
/**
* Tests the invariant that the HttpClient for the ApiClient must never be null
*/
@Test(expected = NullPointerException.class)
public void testNullHttpClient() {
apiClient.setHttpClient(null);
}
}

View File

@@ -0,0 +1,26 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>TypeScriptAngularBuildPestoreClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>TS Fetch Multiple Parameters Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -6,16 +6,18 @@
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=master)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/master)](https://cloud.drone.io/OpenAPITools/openapi-generator)
[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/5.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/5.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=5.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=5.0.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/5.0.x)](https://cloud.drone.io/OpenAPITools/openapi-generator)
</div>
<div align="center">
[![Join the chat at https://gitter.im/OpenAPITools/openapi-generator](https://badges.gitter.im/OpenAPITools/openapi-generator.svg)](https://gitter.im/OpenAPITools/openapi-generator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Jion the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM)
[![Stable releaases in the Maven store](https://img.shields.io/maven-metadata/v/http/central.maven.org/maven2/org/openapitools/openapi-generator/maven-metadata.xml.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22)
[![Follow OpenAPI Generator Twitter account to get the latest update](https://img.shields.io/twitter/follow/oas_generator.svg?style=social&label=Follow)](https://twitter.com/oas_generator)
@@ -46,12 +48,18 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
[![NamSor](https://openapi-generator.tech/img/companies/namsor.png)](https://www.namsor.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[![LightBow](https://openapi-generator.tech/img/companies/lightbow.png)](https://www.lightbow.net/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
#### Thank you GoDaddy for sponsoring the domain names and Linode for sponsoring the VPS
[<img src="https://openapi-generator.tech/img/companies/godaddy.png" width="150">](https://www.godaddy.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
[![Linode](https://www.linode.com/media/images/logos/standard/light/linode-logo_standard_light_small.png)](https://www.linode.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
## Overview
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported:
| | Languages/Frameworks |
|-|-|
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, 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)
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpp-restsdk, 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/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **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, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **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/)
@@ -94,7 +102,7 @@ OpenAPI Generator Version | Release Date | Notes
---------------------------- | ------------ | -----
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
4.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.0-SNAPSHOT/)| 31.07.2019 | Minor release (breaking changes with fallbacks)
[4.0.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.3) (latest stable release) | 09.07.2019 | Patch release (bug fixes, minor enhancements, etc)
[4.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.1.0) (latest stable release) | 09.07.2019 | Patch release (bug fixes, minor enhancements, etc)
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
@@ -150,16 +158,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar`
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar`
For **Mac/Linux** users:
```sh
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar -O openapi-generator-cli.jar
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar -O openapi-generator-cli.jar
```
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@@ -217,9 +225,9 @@ openapi-generator-cli version # is always 3.0.2, unless any of the above overrid
To build from source, you need the following installed and available in your `$PATH:`
* [Java 8](http://java.oracle.com)
* [Java 8](https://www.oracle.com/technetwork/java/index.html)
* [Apache Maven 3.3.4 or greater](http://maven.apache.org/)
* [Apache Maven 3.3.4 or greater](https://maven.apache.org/)
After cloning the project, you can build it from source with this command:
```sh
@@ -242,6 +250,17 @@ openapi-generator generate -i https://raw.githubusercontent.com/openapitools/ope
To reinstall with the latest master, run `brew uninstall openapi-generator && brew install --HEAD openapi-generator`
To install OpenJDK (pre-requisites), please run
```sh
brew cask install adoptopenjdk12
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/
```
To install Maven, please run
```sh
brew install maven
```
### [1.6 - Docker](#table-of-contents)
#### Public Pre-built Docker images
@@ -342,7 +361,7 @@ Right now: no solution for this one :|
#### Run Docker in Vagrant
Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
```sh
git clone http://github.com/openapitools/openapi-generator.git
git clone https://github.com/openapitools/openapi-generator.git
cd openapi-generator
vagrant up
vagrant ssh
@@ -363,10 +382,10 @@ openapi-generator version
```
<!-- RELEASE_VERSION -->
Or install a particular OpenAPI Generator version (e.g. v4.0.3):
Or install a particular OpenAPI Generator version (e.g. v4.1.0):
```sh
npm install @openapitools/openapi-generator-cli@cli-4.0.3 -g
npm install @openapitools/openapi-generator-cli@cli-4.1.0 -g
```
Or install it as dev-dependency:
@@ -390,7 +409,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`)
<!-- RELEASE_VERSION -->
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar)
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.0/openapi-generator-cli-4.1.0.jar)
<!-- /RELEASE_VERSION -->
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
@@ -500,8 +519,8 @@ Please refer to [integration.md](docs/integration.md) on how to integrate OpenAP
Here are the public online services:
- latest stable version: http://api.openapi-generator.tech
- latest master: http://api-latest-master.openapi-generator.tech (updated with latest master every hour)
- latest stable version: https://api.openapi-generator.tech
- latest master: https://api-latest-master.openapi-generator.tech (updated with latest master every hour)
The server is sponsored by [Linode](https://www.linode.com/) [![Linode Logo](https://www.linode.com/media/images/logos/standard/light/linode-logo_standard_light_small.png)](https://www.linode.com/)
@@ -531,6 +550,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [CAM](https://www.cam-inc.co.jp/)
- [Camptocamp](https://www.camptocamp.com/en)
- [codecentric AG](https://www.codecentric.de/)
- [Commencis](https://www.commencis.com/)
- [Cupix](https://www.cupix.com/)
- [DB Systel](https://www.dbsystel.de)
- [FormAPI](https://formapi.io/)
@@ -575,6 +595,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2018/12/09 - [openapi-generator をカスタマイズする方法](https://qiita.com/watiko/items/0961287c02eac9211572) by [@watiko](https://qiita.com/watiko)
- 2019/01/03 - [Calling a Swagger service from Apex using openapi-generator](https://lekkimworld.com/2019/01/03/calling-a-swagger-service-from-apex-using-openapi-generator/) by [Mikkel Flindt Heisterberg](https://lekkimworld.com)
- 2019/01/13 - [OpenAPI GeneratorでRESTful APIの定義書から色々自動生成する](https://ky-yk-d.hatenablog.com/entry/2019/01/13/234108) by [@ky_yk_d](https://twitter.com/ky_yk_d)
- 2019/01/20 - [Contract-First API Development with OpenAPI Generator and Connexion](https://medium.com/commencis/contract-first-api-development-with-openapi-generator-and-connexion-b21bbf2f9244) by [Anil Can Aydin](https://github.com/anlcnydn)
- 2019/01/30 - [Rapid Application Development With API First Approach Using Open-API Generator](https://dzone.com/articles/rapid-api-development-using-open-api-generator) by [Milan Sonkar](https://dzone.com/users/828329/milan_sonkar.html)
- 2019/02/02 - [平静を保ち、コードを生成せよ 〜 OpenAPI Generator誕生の背景と軌跡 〜](https://speakerdeck.com/akihito_nakano/gunmaweb34) by [中野暁人](https://github.com/ackintosh) at [Gunma.web #34 スキーマ駆動開発](https://gunmaweb.connpass.com/event/113974/)
- 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/)
@@ -597,6 +618,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019-07-04 - [REST API のためのコード生成入門 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh), [和田拓朗](https://github.com/taxpon)
- 2019-07-08 - [OpenAPI Generator にコントリビュートしたら社名が載った話。(CAM) - CAM TECH BLOG](https://tech.cam-inc.co.jp/entry/2019/07/08/140000) by [CAM, Inc.](https://www.cam-inc.co.jp/)
- 2019-07-14 - [OpenAPI GeneratorでPythonのクライアントライブラリを作成した](https://qiita.com/yuji38kwmt/items/dfb929316a1335a161c0) by [yuji38kwmt](https://qiita.com/yuji38kwmt)
- 2019-07-19 - [Developer Experience (DX) for Open-Source Projects: How to Engage Developers and Build a Growing Developer Community](https://speakerdeck.com/wing328/developer-experience-dx-for-open-source-projects-english-japanese) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh) at [Open Source Summit Japan 2019](https://events.linuxfoundation.org/events/open-source-summit-japan-2019/)
## [6 - About Us](#table-of-contents)
@@ -653,16 +675,19 @@ Here is a list of template creators:
* Java (Vertx): @lopesmcc
* Java (Google APIs Client Library): @charlescapps
* Java (Rest-assured): @viclovsky
* Java (Java 11 Native HTTP client): @bbdouglas
* Javascript/NodeJS: @jfiala
* Javascript (Closure-annotated Angular) @achew22
* Javascript (Flow types) @jaypea
* JMeter: @davidkiss
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Lua: @daurnimator
* OCaml: @cgensoul
* Perl: @wing328 [:heart:](https://www.patreon.com/wing328)
* PHP (Guzzle): @baartosz
* PowerShell: @beatcracker
* R: @ramnov
* Ruby (Faraday): @meganemura @dkliban
* Rust: @farcaller
* Rust (rust-server): @metaswitch
* Scala (scalaz & http4s): @tbrown1979
@@ -705,6 +730,7 @@ Here is a list of template creators:
* JAX-RS RestEasy (JBoss EAP): @jfiala
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Kotlin (Spring Boot): @dr4ke616
* NodeJS Express: @YishTish
* PHP Laravel: @renepardon
* PHP Lumen: @abcsun
* PHP Slim: @jfastnacht
@@ -773,7 +799,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Elm | @eriktim (2018/09) |
| Erlang | @tsloughter (2017/11) @jfacorro (2018/10) @robertoaloi (2018/10) |
| F# | @nmfisher (2019/05) |
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09 |
| Go | @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09) @bkabrda (2019/07) |
| GraphQL | @renepardon (2018/12) |
| Groovy | |
| Haskell | |
@@ -782,13 +808,14 @@ If you want to join the committee, please kindly apply by sending an email to te
| Lua | @daurnimator (2017/08) |
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
| ObjC | |
| OCaml | @cgensoul (2019/08) |
| Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) |
| PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ackintosh (2017/09) [:heart:](https://www.patreon.com/ackintosh/overview), @ybelenko (2018/07), @renepardon (2018/12) |
| PowerShell | |
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) |
| R | @Ramanth (2019/07) @saigiridhar21 (2019/07) |
| Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) |
| Rust | @frol (2017/07) @farcaller (2017/08) @bjgill (2017/12) |
| Rust | @frol (2017/07) @farcaller (2017/08) @bjgill (2017/12) @richardwhiuk (2019/07) |
| Scala | @clasnake (2017/07), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @shijinkui (2018/01), @ramzimaalej (2018/03) |
| Swift | @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @d-date (2018/03) |
| TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) |
@@ -861,7 +888,7 @@ Copyright 2018 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -34,6 +34,6 @@ rm -rf $STUB_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR --additional-properties packageName=petstore $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -7,6 +7,7 @@
./bin/java-petstore-feign-10x.sh
./bin/java-petstore-okhttp-gson.sh
./bin/java-petstore-okhttp-gson-parcelable.sh
./bin/java-petstore-native.sh
./bin/java-petstore-retrofit.sh
./bin/java-petstore-retrofit2.sh
./bin/java-petstore-retrofit2rx.sh

View File

@@ -27,7 +27,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 --additional-properties hideGenerationTimestamp=true --library=jersey1 --additional-properties useNullForUnknownEnumValue=true $@"
ags="generate --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 --additional-properties hideGenerationTimestamp=true --library=jersey1 $@"
echo "Removing files and folders under samples/client/petstore/java/jersey1/src/main"
rm -rf samples/client/petstore/java/jersey1/src/main

View File

@@ -1,7 +1,4 @@
{
"library": "jersey2",
"artifactId": "petstore-jersey2",
"additionalProperties" : {
"useNullForUnknownEnumValue" : true
}
"artifactId": "petstore-jersey2"
}

View File

@@ -0,0 +1,4 @@
{
"library": "native",
"artifactId": "petstore-native"
}

View File

@@ -27,20 +27,9 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore.json -o samples/client/petstore/swift5/default --generate-alias-as-model $@"
ags="generate -t modules/openapi-generator/src/main/resources/Java/libraries/native -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin/java-petstore-native.json -o samples/client/petstore/java/native --additional-properties hideGenerationTimestamp=true $@"
echo "Removing files and folders under samples/client/petstore/java/httpclient/src/main"
rm -rf samples/client/petstore/java/native/src/main
find samples/client/petstore/java/native -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags
cd samples/client/petstore/swift5/default
if type "xcodegen" > /dev/null 2>&1; then
xcodegen generate
if type "carthage" > /dev/null 2>&1; then
carthage update --no-use-binaries --platform ios --cache-builds
fi
fi
if type "swiftlint" > /dev/null 2>&1; then
swiftlint autocorrect --quiet
fi

View File

@@ -27,20 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift4Test.json -g swift5 -c ./bin/swift5-test.json -o samples/client/test/swift5default $@"
ags="generate -t modules/openapi-generator/src/main/resources/nodejs-express-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-express-server -o samples/server/petstore/nodejs-express-server -Dservice $@"
java $JAVA_OPTS -jar $executable $ags
cd samples/client/test/swift5default
if type "xcodegen" > /dev/null 2>&1; then
xcodegen generate
if type "carthage" > /dev/null 2>&1; then
carthage update --no-use-binaries --platform ios --cache-builds
fi
fi
if type "swiftlint" > /dev/null 2>&1; then
swiftlint autocorrect --quiet
fi

34
bin/ocaml-petstore.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/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 -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
args="generate -t modules/openapi-generator/src/main/resources/ocaml -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ocaml -o samples/client/petstore/ocaml --additional-properties packageName=petstore_client $@"
echo "java ${JAVA_OPTS} -jar ${executable} ${args}"
java $JAVA_OPTS -jar $executable $args

View File

@@ -0,0 +1,34 @@
#!/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 -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DdebugOperations -DloggerPath=conf/log4j.properties"
args="generate -t modules/openapi-generator/src/main/resources/ocaml -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ocaml -o samples/openapi3/client/petstore/ocaml/ --additional-properties packageName=petstore_client $@"
echo "java ${JAVA_OPTS} -jar ${executable} ${args}"
java $JAVA_OPTS -jar $executable $args

View File

@@ -23,7 +23,7 @@ if [ ! -d "${APP_DIR}" ]; then
fi
# Make sure that we are regenerating the sample by removing any existing target directory
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-symfony/SymfonyBundle-php"
TARGET_DIR="$SCRIPT_DIR/../../samples/openapi3/server/petstore/php-symfony/SymfonyBundle-php"
if [ -d "$TARGET_DIR" ]; then
rm -rf $TARGET_DIR
fi

View File

@@ -0,0 +1,43 @@
#!/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
# purge lib/doc folder
echo "purge ruby petstore lib, docs folder"
rm -Rf samples/openapi3/client/petstore/ruby-faraday/lib
rm -Rf samples/openapi3/client/petstore/ruby-faraday/docs
# purge test files other than integration test
# NOTE: spec/custom/*.rb and spec/petstore_helper.rb are not generated files
echo "purge ruby petstore spec"
find samples/openapi3/client/petstore/ruby-faraday/spec -type d -not -name spec -not -name custom | xargs rm -Rf
find samples/openapi3/client/petstore/ruby-faraday/spec -type f -not -name petstore_helper.rb -not -iwholename '*/spec/custom/*' | xargs rm -Rf
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/openapi3/ruby-petstore-faraday.json -o samples/openapi3/client/petstore/ruby-faraday --additional-properties skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,6 @@
{
"gemName": "petstore",
"moduleName": "Petstore",
"library": "faraday",
"gemVersion": "1.0.0"
}

View File

@@ -0,0 +1,32 @@
#!/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 -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/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-faraday.json -o samples/client/petstore/ruby-faraday $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,6 @@
{
"gemName": "petstore",
"moduleName": "Petstore",
"library": "faraday",
"gemVersion": "1.0.0"
}

View File

@@ -1,5 +1,6 @@
{
"gemName": "petstore",
"library": "typhoeus",
"moduleName": "Petstore",
"gemVersion": "1.0.0"
}

View File

@@ -2,6 +2,7 @@
# Generate clients:
./bin/spring-cloud-feign-petstore.sh
./bin/spring-cloud-feign-async-petstore.sh
./bin/spring-stubs.sh
# Generate spring-mvc servers:

View File

@@ -27,20 +27,9 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-rxswift.json -o samples/client/petstore/swift5/rxswift --generate-alias-as-model $@"
ags="generate -t modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g spring -c bin/spring-cloud-feign-petstore.json -o samples/client/petstore/spring-cloud-async --additional-properties hideGenerationTimestamp=true,java8=true,async=true $@"
echo "Removing files and folders under samples/client/petstore/spring-cloud-async/src/main"
rm -rf samples/client/petstore/spring-cloud-async/src/main
find samples/client/petstore/spring-cloud-async -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags
cd samples/client/petstore/swift5/rxswift
if type "xcodegen" > /dev/null 2>&1; then
xcodegen generate
if type "carthage" > /dev/null 2>&1; then
carthage update --no-use-binaries --platform ios --cache-builds
fi
fi
if type "swiftlint" > /dev/null 2>&1; then
swiftlint autocorrect --quiet
fi

View File

@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-objcCompatible.json -o samples/client/petstore/swift4/objcCompatible $@"
java $JAVA_OPTS -jar $executable $ags
if type "xcodegen" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/objcCompatible
xcodegen generate
fi
if type "swiftlint" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/objcCompatible
swiftlint autocorrect
fi

View File

@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-promisekit.json -o samples/client/petstore/swift4/promisekit --generate-alias-as-model $@"
java $JAVA_OPTS -jar $executable $ags
if type "xcodegen" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/promisekit
xcodegen generate
fi
if type "swiftlint" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/promisekit
swiftlint autocorrect
fi

View File

@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-rxswift.json -o samples/client/petstore/swift4/rxswift --generate-alias-as-model $@"
java $JAVA_OPTS -jar $executable $ags
if type "xcodegen" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/rxswift
xcodegen generate
fi
if type "swiftlint" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/rxswift
swiftlint autocorrect
fi

View File

@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-unwrapRequired.json -o samples/client/petstore/swift4/unwrapRequired --generate-alias-as-model $@"
java $JAVA_OPTS -jar $executable $ags
if type "xcodegen" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/unwrapRequired
xcodegen generate
fi
if type "swiftlint" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/unwrapRequired
swiftlint autocorrect
fi

View File

@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore.json -o samples/client/petstore/swift4/default --generate-alias-as-model $@"
java $JAVA_OPTS -jar $executable $ags
if type "xcodegen" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/default
xcodegen generate
fi
if type "swiftlint" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/default
swiftlint autocorrect
fi

View File

@@ -30,3 +30,13 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/swift4Test.json -g swift4 -c ./bin/swift4-test.json -o samples/client/test/swift4/default $@"
java $JAVA_OPTS -jar $executable $ags
if type "xcodegen" > /dev/null 2>&1; then
cd samples/client/test/swift4/default
xcodegen generate
fi
if type "swiftlint" > /dev/null 2>&1; then
cd samples/client/test/swift4/default
swiftlint autocorrect
fi

View File

@@ -1,4 +0,0 @@
#!/bin/sh
./bin/swift5-petstore-all.sh
./bin/swift5-test.sh

View File

@@ -1,6 +0,0 @@
#!/bin/sh
./bin/swift5-petstore.sh
./bin/swift5-petstore-promisekit.sh
./bin/swift5-petstore-rxswift.sh
./bin/swift5-petstore-unwrapRequired.sh

View File

@@ -1,8 +0,0 @@
{
"podSummary": "PetstoreClient",
"podHomepage": "https://github.com/openapitools/openapi-generator",
"podAuthors": "",
"projectName": "PetstoreClient",
"onlyPlainInterface": false,
"responseAs": "PromiseKit"
}

View File

@@ -1,8 +0,0 @@
{
"podSummary": "PetstoreClient",
"podHomepage": "https://github.com/openapitools/openapi-generator",
"podAuthors": "",
"projectName": "PetstoreClient",
"onlyPlainInterface": false,
"responseAs": "RxSwift"
}

View File

@@ -1,7 +0,0 @@
{
"podSummary": "PetstoreClient",
"podHomepage": "https://github.com/openapitools/openapi-generator",
"podAuthors": "",
"projectName": "PetstoreClient",
"unwrapRequired": true
}

View File

@@ -1,46 +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 -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-unwrapRequired.json -o samples/client/petstore/swift5/unwrapRequired --generate-alias-as-model $@"
java $JAVA_OPTS -jar $executable $ags
cd samples/client/petstore/swift5/unwrapRequired
if type "xcodegen" > /dev/null 2>&1; then
xcodegen generate
if type "carthage" > /dev/null 2>&1; then
carthage update --no-use-binaries --platform ios --cache-builds
fi
fi
if type "swiftlint" > /dev/null 2>&1; then
swiftlint autocorrect --quiet
fi

View File

@@ -1,6 +0,0 @@
{
"podSummary": "PetstoreClient",
"podHomepage": "https://github.com/openapitools/openapi-generator",
"podAuthors": "",
"projectName": "PetstoreClient"
}

View File

@@ -1,6 +0,0 @@
{
"podSummary": "TestClient",
"podHomepage": "https://github.com/openapitools/openapi-generator",
"podAuthors": "",
"projectName": "TestClient"
}

View File

@@ -1,6 +1,7 @@
{
"npmName": "@openapitools/typescript-angular-petstore",
"npmVersion": "1.0.0",
"npmRepository" : "https://skimdb.npmjs.com/registry",
"snapshot" : false
"stringEnums": true,
"npmRepository": "https://skimdb.npmjs.com/registry",
"snapshot": false
}

View File

@@ -3,5 +3,6 @@
./bin/typescript-axios-petstore-target-es6.sh
./bin/typescript-axios-petstore-with-npm-version.sh
./bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh
./bin/typescript-axios-petstore-with-complex-headers.sh
./bin/typescript-axios-petstore-interfaces.sh
./bin/typescript-axios-petstore.sh

View File

@@ -0,0 +1,32 @@
#!/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 -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 -i modules/openapi-generator/src/test/resources/3_0/petstore-with-complex-headers.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/with-complex-headers $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -4,3 +4,4 @@
./bin/typescript-fetch-petstore-with-npm-version.sh
./bin/typescript-fetch-petstore-interfaces.sh
./bin/typescript-fetch-petstore.sh
./bin/typescript-fetch-petstore-multiple-parameters.sh

View File

@@ -0,0 +1,4 @@
{
"snapshot" : false,
"useSingleRequestParameter": false
}

View File

@@ -27,20 +27,8 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-promisekit.json -o samples/client/petstore/swift5/promisekit --generate-alias-as-model $@"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-multiple-parameters.json -o samples/client/petstore/typescript-fetch/builds/multiple-parameters $@"
java $JAVA_OPTS -jar $executable $ags
cd samples/client/petstore/swift5/promisekit
if type "xcodegen" > /dev/null 2>&1; then
xcodegen generate
if type "carthage" > /dev/null 2>&1; then
carthage update --no-use-binaries --platform ios --cache-builds
fi
fi
if type "swiftlint" > /dev/null 2>&1; then
swiftlint autocorrect --quiet
fi
cp CI/samples.ci/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml samples/client/petstore/typescript-fetch/builds/multiple-parameters/pom.xml
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml

View File

@@ -13,7 +13,7 @@ sleep 5
declare -a scripts=(
# SAMPLES
"./bin/openapi3/ruby-client-petstore.sh"
"./bin/ruby-client-petstore.sh"
"./bin/openapi3/ruby-client-faraday-petstore.sh"
"./bin/java-petstore-all.sh"
"./bin/java-jaxrs-petstore-server-all.sh"
"./bin/java-msf4j-petstore-server.sh"

View File

@@ -2,6 +2,7 @@ call .\bin\windows\java-petstore-jersey1.bat
call .\bin\windows\java-petstore-jersey2.bat
call .\bin\windows\java-petstore-feign.bat
call .\bin\windows\java-petstore-feign-10x.bat
call .\bin\windows\java-petstore-native.bat
call .\bin\windows\java-petstore-okhttp-gson.bat
call .\bin\windows\java-petstore-okhttp-gson-parcelable.bat
call .\bin\windows\java-petstore-retrofit.bat

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\Java\libraries\native -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin\java-petstore-native.json -o samples\client\petstore\java\native --additional-properties hideGenerationTimestamp=true
java %JAVA_OPTS% -jar %executable% %ags%

10
bin/windows/ocaml-petstore.bat Executable file
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 -DloggerPath=conf/log4j.properties
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g ocaml -o samples\client\petstore\ocaml
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 -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples\client\petstore\python-experimental -DpackageName=petstore_api
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -2,6 +2,7 @@
call bin\windows\typescript-axios-petstore.bat
call bin\windows\typescript-axios-petstore-target-es6.bat
call bin\windows\typescript-axios-petstore-with-complex-headers.bat
call bin\windows\typescript-axios-petstore-with-npm-version.bat
call bin\windows\typescript-axios-petstore-interfaces.bat
call bin\windows\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat

View File

@@ -0,0 +1,12 @@
@ECHO OFF
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-with-complex-headers.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\with-complex-headers
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -4,3 +4,4 @@ call bin\windows\typescript-fetch-petstore.bat
call bin\windows\typescript-fetch-petstore-target-es6.bat
call bin\windows\typescript-fetch-petstore-with-npm-version.bat
call bin\windows\typescript-fetch-petstore-interfaces.bat
call bin\windows\typescript-fetch-petstore-multiple-parameters.bat

View File

@@ -0,0 +1,12 @@
@ECHO OFF
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 typescript-fetch -c bin\typescript-fetch-petstore-multiple-parameters.json -o samples\client\petstore\typescript-fetch\builds\multiple-parameters
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -19,7 +19,7 @@ if [[ -f "${codegen}" && -n "$(java ${JAVA_OPTS} -jar "${codegen}" completion |
command=$1
shift
exec java ${JAVA_OPTS} -jar "${codegen}" "${command}" "$@"
elif [[ -n "$(echo commands | tr ',' '\n' | grep "^$1\$" )" ]]; then
elif [[ -n "$(echo $commands | tr ',' '\n' | grep "^$1\$" )" ]]; then
# If CLI jar does not exist, and $1 is a known CLI command, build the CLI jar and run that command.
if [[ ! -f "${codegen}" ]]; then
(cd "${GEN_DIR}" && exec mvn -am -pl "modules/openapi-generator-cli" -Duser.home=$(dirname $MAVEN_CONFIG) package)

View File

@@ -62,3 +62,26 @@ The steps are shown here for a specific version of the generator, but apply the
Listening for transport dt_socket at address: 5005
```
* Set breakpoints in code, and then attach your remote debugger from your IDE (see above). The generator will automatically unblock once the remote debugger is attached. You can now step through the code.
## Logs
You can try to enable debugging log with `-Dlog.level=debug` option to the `JAVA_OPTS` environment variable to see more information:
```bash
export JAVA_OPTS="${JAVA_OPTS} -Dlog.level=debug"
```
Set the option then DEBUG logs are printed out:
```bash
openapi-generator generate -g go ...
...
...
[main] DEBUG o.o.codegen.DefaultCodegen - debugging fromProperty for files : class Schema {
type: null
format: null
$ref: #/components/schemas/File
...
...
```

View File

@@ -39,6 +39,7 @@ The following generators are available:
- [kotlin](generators/kotlin.md)
- [lua](generators/lua.md)
- [objc](generators/objc.md)
- [ocaml](generators/ocaml.md)
- [perl](generators/perl.md)
- [php](generators/php.md)
- [powershell](generators/powershell.md)
@@ -54,7 +55,6 @@ The following generators are available:
- [swift2-deprecated](generators/swift2-deprecated.md) (deprecated)
- [swift3-deprecated](generators/swift3-deprecated.md) (deprecated)
- [swift4](generators/swift4.md)
- [swift5](generators/swift5.md)
- [typescript-angular](generators/typescript-angular.md)
- [typescript-angularjs](generators/typescript-angularjs.md)
- [typescript-aurelia](generators/typescript-aurelia.md)
@@ -94,6 +94,7 @@ The following generators are available:
- [jaxrs-spec](generators/jaxrs-spec.md)
- [kotlin-server](generators/kotlin-server.md)
- [kotlin-spring](generators/kotlin-spring.md)
- [nodejs-express-server](generators/nodejs-express-server.md) (beta)
- [nodejs-server-deprecated](generators/nodejs-server-deprecated.md) (deprecated)
- [php-laravel](generators/php-laravel.md)
- [php-lumen](generators/php-lumen.md)

View File

@@ -47,7 +47,6 @@ The following generators are available:
- [swift2-deprecated](swift2-deprecated.md)
- [swift3-deprecated](swift3-deprecated.md)
- [swift4](swift4.md)
- [swift5](swift5.md)
- [typescript-angular](typescript-angular.md)
- [typescript-angularjs](typescript-angularjs.md)
- [typescript-aurelia](typescript-aurelia.md)

View File

@@ -12,5 +12,5 @@ sidebar_label: cpp-qt5-client
|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|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|
|optionalProjectFile|Generate client.pri.| |true|

View File

@@ -12,4 +12,4 @@ sidebar_label: cpp-qt5-qhttpengine-server
|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|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|

View File

@@ -55,4 +55,4 @@ sidebar_label: java
|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|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|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'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</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>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**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 : 4.x. JSON processing: Gson 2.x. 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'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</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>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**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 : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dl>|okhttp-gson|

View File

@@ -0,0 +1,14 @@
---
id: generator-opts-server-nodejs-express-server
title: Config Options for nodejs-express-server
sidebar_label: nodejs-express-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|
|serverPort|TCP port to listen on.| |null|

View File

@@ -0,0 +1,13 @@
---
id: generator-opts-client-ocaml-client
title: Config Options for ocaml-client
sidebar_label: ocaml-client
---
| 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|

13
docs/generators/ocaml.md Normal file
View File

@@ -0,0 +1,13 @@
---
id: generator-opts-client-ocaml
title: Config Options for ocaml
sidebar_label: ocaml
---
| 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|

View File

@@ -11,4 +11,4 @@ sidebar_label: openapi-yaml
|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|
|outputFile|output filename| |null|
|outputFile|Output filename| |openapi/openapi.yaml|

View File

@@ -22,3 +22,4 @@ sidebar_label: ruby
|gemAuthor|gem author (only one is supported).| |null|
|gemAuthorEmail|gem author email (only one is supported).| |null|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|library|HTTP library template (sub-template) to use|<dl><dt>**faraday**</dt><dd>Faraday (https://github.com/lostisland/faraday) (Beta support)</dd><dt>**typhoeus**</dt><dd>Typhoeus &gt;= 1.0.1 (https://github.com/typhoeus/typhoeus)</dd><dl>|typhoeus|

View File

@@ -26,3 +26,4 @@ sidebar_label: typescript-angular
|modelSuffix|The suffix of the generated model.| |null|
|modelFileSuffix|The suffix of the file of the generated model (model&lt;suffix&gt;.ts).| |null|
|fileNaming|Naming convention for the output files: 'camelCase', 'kebab-case'.| |camelCase|
|stringEnums|Generate string enums instead of objects for enum values.| |false|

View File

@@ -18,3 +18,4 @@ sidebar_label: typescript-fetch
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|

View File

@@ -16,7 +16,7 @@ The transform logic needs to implement [CodegenConfig.java](https://github.com/o
> OpenAPI Generator applies user-defined templates via options:
> * CLI: `-t/--template` CLI options
> * Maven Plugin: `templateDirectory`
> * Gradle Plugin: `templateDir`
> * Gradle Plugin: `templateDir`
Built-in templates are written in Mustache and processed by [jmustache](https://github.com/samskivert/jmustache). Beginning with version 4.0.0, we support experimental Handlebars and user-defined template engines via plugins.
@@ -26,7 +26,7 @@ OpenAPI Generator supports user-defined templates. This approach is often the ea
### Custom Logic
For this example, let's modify a Java client to use AOP via [jcabi/jcabi-aspects](https://github.com/jcabi/jcabi-aspects). We'll log API method execution at the `INFO` level. The jcabi-aspects project could also be used to implement method retries on failures; this would be a great exercise to further play around with templating.
For this example, let's modify a Java client to use AOP via [jcabi/jcabi-aspects](https://github.com/jcabi/jcabi-aspects). We'll log API method execution at the `INFO` level. The jcabi-aspects project could also be used to implement method retries on failures; this would be a great exercise to further play around with templating.
The Java generator supports a `library` option. This option works by defining base templates, then applying library-specific template overrides. This allows for template reuse for libraries sharing the same programming language. Templates defined as a library need only modify or extend the templates concerning the library, and generation falls back to the root templates (the "defaults") when not extended by the library. Generators which support the `library` option will only support the libraries known by the generator at compile time, and will throw a runtime error if you try to provide a custom library name.
@@ -77,7 +77,7 @@ index 3b40702..a6d12e0 100644
+++ b/libraries/resteasy/build.gradle.mustache
@@ -134,6 +134,7 @@ ext {
}
dependencies {
+ compile "com.jcabi:jcabi-aspects:0.22.6"
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
@@ -95,7 +95,7 @@ index a4d0f9f..49b17c7 100644
+++ b/libraries/resteasy/api.mustache
@@ -1,5 +1,6 @@
package {{package}};
+import com.jcabi.aspects.Loggable;
import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiClient;
@@ -134,7 +134,7 @@ index 04a9d55..7a93c50 100644
apply plugin: 'idea'
apply plugin: 'eclipse'
+apply plugin: 'aspectj'
group = '{{groupId}}'
version = '{{artifactVersion}}'
@@ -12,6 +13,7 @@ buildscript {
@@ -144,14 +144,14 @@ index 04a9d55..7a93c50 100644
+ classpath "net.uberfoo.gradle:gradle-aspectj:2.2"
}
}
@@ -140,9 +142,18 @@ ext {
jersey_version = "1.19.4"
jodatime_version = "2.9.9"
junit_version = "4.12"
+ aspectjVersion = '1.9.0'
}
+sourceCompatibility = '1.8'
+targetCompatibility = '1.8'
+
@@ -199,7 +199,7 @@ Make sure your custom template compiles:
```bash
cd ~/.openapi-generator/example
gradle assemble
# or, regenerate the wrapper
# or, regenerate the wrapper
gradle wrapper --gradle-version 4.8 --distribution-type all
./gradlew assemble
```
@@ -291,7 +291,7 @@ Modifications to the new project's `build.gradle` should be made in the `plugins
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
id "com.github.johnrengelman.shadow" version "5.0.0"
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "org.openapitools:openapi-generator-core:4.0.0-SNAPSHOT"
@@ -301,7 +301,7 @@ Modifications to the new project's `build.gradle` should be made in the `plugins
The above configuration for the `shadow` plugin is strictly optional. It is not needed, for instance, if you plan to publish your adapter and consume it via the Maven or Gradle plugins.
Next, create a new class file called `PebbleTemplateEngineAdapter` under `src/kotlin`. We'll define the template adapter's name as `pebble` and we'll also list this as the only supported file extension. We'll implement the adapter by extending `AbstractTemplatingEngineAdapter`, which includes reusable logic, such as retrieving a list of all possible template names for our provided template extensions(s).
Next, create a new class file called `PebbleTemplateEngineAdapter` under `src/kotlin`. We'll define the template adapter's name as `pebble` and we'll also list this as the only supported file extension. We'll implement the adapter by extending `AbstractTemplatingEngineAdapter`, which includes reusable logic, such as retrieving a list of all possible template names for our provided template extensions(s).
The class in its simplest form looks like this (with inline comments):
@@ -374,7 +374,7 @@ import (
{% endfor %}
)
type Generated{{classname}}Servicer
type Generated{{classname}}Servicer
// etc
```
@@ -402,7 +402,7 @@ type {{item.classname}} struct {
> Find object structures passed to templates later in this document's **Structures** section.
Finally, we can compile some code by explicitly defining our classpath and jar entrypoint for CLI (be sure to modify `/your/path` below)
Finally, we can compile some code by explicitly defining our classpath and jar entrypoint for CLI (be sure to modify `/your/path` below)
```bash
java $JAVA_OPTS -cp /your/path/build/libs/pebble-template-adapter-1.0-SNAPSHOT-all.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \
@@ -428,49 +428,49 @@ Examples for the following structures will be presented using the following spec
```yaml
swagger: "2.0"
info:
info:
version: "1.0.0"
title: "Swagger Petstore"
description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"
termsOfService: "http://swagger.io/terms/"
contact:
contact:
name: "Swagger API Team"
license:
license:
name: "MIT"
host: "petstore.swagger.io"
basePath: "/api"
schemes:
schemes:
- "http"
consumes:
consumes:
- "application/json"
produces:
produces:
- "application/json"
paths:
/pets:
get:
paths:
/pets:
get:
description: "Returns all pets from the system that the user has access to"
produces:
produces:
- "application/json"
responses:
responses:
"200":
description: "A list of pets."
schema:
schema:
type: "array"
items:
items:
$ref: "#/definitions/Pet"
definitions:
Pet:
definitions:
Pet:
type: "object"
required:
required:
- "id"
- "name"
properties:
id:
properties:
id:
type: "integer"
format: "int64"
name:
name:
type: "string"
tag:
tag:
type: "string"
```
@@ -478,9 +478,9 @@ Examples for the following structures will be presented using the following spec
### Operations
> Inspect operation structures passed to templates with system property `-DdebugOpenAPI`
>
>
> Example:
>
>
> ```bash
> openapi-generator generate -g go \
> -o out \
@@ -510,9 +510,9 @@ Here, an Operation with tag `Pet` will generate two files: `SWGPetApi.h` and `SW
### Models
> Inspect models passed to templates with system property `-DdebugModels`
>
>
> Execute:
>
>
> ```bash
> openapi-generator generate -g go \
> -o out \
@@ -730,14 +730,14 @@ Templates are passed redundant properties, depending on the semantics of the arr
* `readOnlyVars` lists all model properties marked with `readonly` in the spec document
* `allVars` lists all model properties. This may include the same set as `vars`, but may also include generator-defined properties
We expose the same properties in multiple sets because this allows us to conditionally iterate over properties based on some condition ("is it required" or "is it readonly"). This is driven by the use of the logic-less Mustache templates. It is possible that models passed to the templating engine may be cleaned up as we support more template engines, but such an effort will go through a deprecation phase and would be communicated at runtime through log messages.
We expose the same properties in multiple sets because this allows us to conditionally iterate over properties based on some condition ("is it required" or "is it readonly"). This is driven by the use of the logic-less Mustache templates. It is possible that models passed to the templating engine may be cleaned up as we support more template engines, but such an effort will go through a deprecation phase and would be communicated at runtime through log messages.
### supportingFiles
> Inspect supportingFiles passed to templates with system property `-DdebugSupportingFiles`
>
>
> Execute:
>
>
> ```bash
> openapi-generator generate -g go \
> -o out \
@@ -755,10 +755,25 @@ Supporting files can either be processed through the templating engine or copied
> This is a very limited list of variable name explanations. Feel free to [open a pull request](https://github.com/OpenAPITools/openapi-generator/pull/new/master) to add to this documentation!
- **complexType**: stores the name of the model (e.g. Pet)
- **complexType**: stores the name of the model (e.g. Pet)
- **isContainer**: true if the parameter or property is an array or a map.
- **isPrimitiveType**: true if the parameter or property type is a primitive type (e.g. string, integer, etc) as defined in the spec.
## Mustache Lambdas
Many generators (*those extending DefaultCodegen*) come with a small set of lambda functions available under the key `lambda`:
- `lowercase` - Converts all of the characters in this fragment to lower case using the rules of the `ROOT` locale.
- `uppercase` - Converts all of the characters in this fragment to upper case using the rules of the `ROOT` locale.
- `titlecase` - Converts text in a fragment to title case. For example `once upon a time` to `Once Upon A Time`.
- `camelcase` - Converts text in a fragment to camelCase. For example `Input-text` to `inputText`.
- `indented` - Prepends 4 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_8` - Prepends 8 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_12` - Prepends 12 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_16` -Prepends 16 spaces indention from second line of a fragment on. First line will be indented by Mustache.
Lambda is invoked by `lambda.[lambda name]` expression. For example: `{{#lambda.lowercase}}FRAGMENT TO LOWERCASE{{/lambda.lowercase}}` to lower case text between `lambda.lowercase`.
## Extensions
OpenAPI supports a concept called "Extensions". These are called "Specification Extensions" [in 3.x](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#specificationExtensions) and "Vendor Extensions" [in 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#vendorExtensions).
@@ -861,7 +876,7 @@ paths:
#### x-mysqlSchema
MySQL schema generator creates vendor extensions based on openapi `dataType` and `dataFormat`. When user defined extensions with same key already exists codegen accepts those as is. It means it won't validate properties or correct it for you. Every model in `definitions` can contain table related and column related extensions like in example below:
MySQL schema generator creates vendor extensions based on openapi `dataType` and `dataFormat`. When user defined extensions with same key already exists codegen accepts those as is. It means it won't validate properties or correct it for you. Every model in `definitions` can contain table related and column related extensions like in example below:
```yaml
definitions:

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -6,7 +6,7 @@
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<!-- RELEASE_VERSION -->
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -45,7 +45,7 @@ compileJava.dependsOn tasks.openApiGenerate
[source,group]
----
plugins {
id "org.openapi.generator" version "4.0.3"
id "org.openapi.generator" version "4.1.0"
}
----
@@ -61,7 +61,7 @@ buildscript {
// url "https://plugins.gradle.org/m2/"
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.3"
classpath "org.openapitools:openapi-generator-gradle-plugin:4.1.0"
}
}
@@ -609,7 +609,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.3') {
classpath('org.openapitools:openapi-generator-gradle-plugin:4.1.0') {
exclude group: 'com.google.guava'
}
}

View File

@@ -1,5 +1,5 @@
# RELEASE_VERSION
openApiGeneratorVersion=4.1.0-SNAPSHOT
openApiGeneratorVersion=4.1.0
# /RELEASE_VERSION
# BEGIN placeholders

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
```bash
gradle -PopenApiGeneratorVersion=4.0.3 openApiValidate
gradle -PopenApiGeneratorVersion=4.1.0 openApiValidate
```

View File

@@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=4.0.3
openApiGeneratorVersion=4.1.0
# /RELEASE_VERSION

View File

@@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.3</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.3</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -88,6 +88,13 @@
<version>${jersey-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>

View File

@@ -19,7 +19,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.3</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>
@@ -101,6 +101,13 @@
<version>${jersey-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>

View File

@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.3</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.3</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@@ -5,7 +5,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>

View File

@@ -203,10 +203,10 @@ public class CodegenConstants {
public static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'";
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names. Default is the empty string.";
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string.";
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names.";
public static final String GIT_USER_ID = "gitUserId";
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";

View File

@@ -46,7 +46,7 @@ public class CodegenModel {
public String defaultValue;
public String arrayModelType;
public boolean isAlias; // Is this effectively an alias of another simple type
public boolean isString, isInteger;
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); // all properties (without parent's properties)
public List<CodegenProperty> allVars = new ArrayList<CodegenProperty>(); // all properties (with parent's properties)
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties
@@ -61,7 +61,7 @@ public class CodegenModel {
public Set<String> allMandatory = new TreeSet<String>(); // with parent's required properties
public Set<String> imports = new TreeSet<String>();
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel;
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel;
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocumentation externalDocumentation;
@@ -96,7 +96,12 @@ public class CodegenModel {
.append("arrayModelType", arrayModelType)
.append("isAlias", isAlias)
.append("isString", isString)
.append("isNumeric", isNumeric)
.append("isInteger", isInteger)
.append("isLong", isLong)
.append("isNumber", isNumber)
.append("isFloat", isFloat)
.append("isDouble", isDouble)
.append("vars", vars)
.append("requiredVars", requiredVars)
.append("optionalVars", optionalVars)
@@ -113,6 +118,7 @@ public class CodegenModel {
.append("hasMoreModels", hasMoreModels)
.append("hasEnums", hasEnums)
.append("isEnum", isEnum)
.append("isNullable", isEnum)
.append("hasRequired", hasRequired)
.append("hasOptional", hasOptional)
.append("isArrayModel", isArrayModel)
@@ -133,86 +139,86 @@ public class CodegenModel {
CodegenModel that = (CodegenModel) o;
return Objects.equals(parent, that.parent) &&
Objects.equals(parentSchema, that.parentSchema) &&
Objects.equals(interfaces, that.interfaces) &&
Objects.equals(allParents, that.allParents) &&
Objects.equals(parentModel, that.parentModel) &&
Objects.equals(interfaceModels, that.interfaceModels) &&
Objects.equals(name, that.name) &&
Objects.equals(classname, that.classname) &&
Objects.equals(title, that.title) &&
Objects.equals(description, that.description) &&
Objects.equals(classVarName, that.classVarName) &&
Objects.equals(modelJson, that.modelJson) &&
Objects.equals(dataType, that.dataType) &&
Objects.equals(xmlPrefix, that.xmlPrefix) &&
Objects.equals(xmlNamespace, that.xmlNamespace) &&
Objects.equals(xmlName, that.xmlName) &&
Objects.equals(classFilename, that.classFilename) &&
Objects.equals(unescapedDescription, that.unescapedDescription) &&
Objects.equals(discriminator, that.discriminator) &&
Objects.equals(defaultValue, that.defaultValue) &&
Objects.equals(vars, that.vars) &&
Objects.equals(requiredVars, that.requiredVars) &&
Objects.equals(optionalVars, that.optionalVars) &&
Objects.equals(allVars, that.allVars) &&
Objects.equals(allowableValues, that.allowableValues) &&
Objects.equals(mandatory, that.mandatory) &&
Objects.equals(allMandatory, that.allMandatory) &&
Objects.equals(imports, that.imports) &&
Objects.equals(hasVars, that.hasVars) &&
Objects.equals(emptyVars, that.emptyVars) &&
Objects.equals(hasMoreModels, that.hasMoreModels) &&
Objects.equals(hasEnums, that.hasEnums) &&
Objects.equals(isEnum, that.isEnum) &&
Objects.equals(externalDocumentation, that.externalDocumentation) &&
Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly) &&
Objects.equals(hasChildren, that.hasChildren) &&
Objects.equals(parentVars, that.parentVars) &&
Objects.equals(vendorExtensions, that.vendorExtensions);
Objects.equals(parentSchema, that.parentSchema) &&
Objects.equals(interfaces, that.interfaces) &&
Objects.equals(allParents, that.allParents) &&
Objects.equals(parentModel, that.parentModel) &&
Objects.equals(interfaceModels, that.interfaceModels) &&
Objects.equals(name, that.name) &&
Objects.equals(classname, that.classname) &&
Objects.equals(title, that.title) &&
Objects.equals(description, that.description) &&
Objects.equals(classVarName, that.classVarName) &&
Objects.equals(modelJson, that.modelJson) &&
Objects.equals(dataType, that.dataType) &&
Objects.equals(xmlPrefix, that.xmlPrefix) &&
Objects.equals(xmlNamespace, that.xmlNamespace) &&
Objects.equals(xmlName, that.xmlName) &&
Objects.equals(classFilename, that.classFilename) &&
Objects.equals(unescapedDescription, that.unescapedDescription) &&
Objects.equals(discriminator, that.discriminator) &&
Objects.equals(defaultValue, that.defaultValue) &&
Objects.equals(vars, that.vars) &&
Objects.equals(requiredVars, that.requiredVars) &&
Objects.equals(optionalVars, that.optionalVars) &&
Objects.equals(allVars, that.allVars) &&
Objects.equals(allowableValues, that.allowableValues) &&
Objects.equals(mandatory, that.mandatory) &&
Objects.equals(allMandatory, that.allMandatory) &&
Objects.equals(imports, that.imports) &&
Objects.equals(hasVars, that.hasVars) &&
Objects.equals(emptyVars, that.emptyVars) &&
Objects.equals(hasMoreModels, that.hasMoreModels) &&
Objects.equals(hasEnums, that.hasEnums) &&
Objects.equals(isEnum, that.isEnum) &&
Objects.equals(externalDocumentation, that.externalDocumentation) &&
Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly) &&
Objects.equals(hasChildren, that.hasChildren) &&
Objects.equals(parentVars, that.parentVars) &&
Objects.equals(vendorExtensions, that.vendorExtensions);
}
@Override
public int hashCode() {
return Objects.hash(
parent,
parentSchema,
interfaces,
allParents,
parentModel,
interfaceModels,
name,
classname,
title,
description,
classVarName,
modelJson,
dataType,
xmlPrefix,
xmlNamespace,
xmlName,
classFilename,
unescapedDescription,
discriminator,
defaultValue,
vars,
requiredVars,
optionalVars,
allVars,
allowableValues,
mandatory,
allMandatory,
imports,
hasVars,
emptyVars,
hasMoreModels,
hasEnums,
isEnum,
externalDocumentation,
vendorExtensions,
hasOnlyReadOnly,
hasChildren,
parentVars);
parent,
parentSchema,
interfaces,
allParents,
parentModel,
interfaceModels,
name,
classname,
title,
description,
classVarName,
modelJson,
dataType,
xmlPrefix,
xmlNamespace,
xmlName,
classFilename,
unescapedDescription,
discriminator,
defaultValue,
vars,
requiredVars,
optionalVars,
allVars,
allowableValues,
mandatory,
allMandatory,
imports,
hasVars,
emptyVars,
hasMoreModels,
hasEnums,
isEnum,
externalDocumentation,
vendorExtensions,
hasOnlyReadOnly,
hasChildren,
parentVars);
}
public String getParent() {

View File

@@ -19,7 +19,11 @@ package org.openapitools.codegen;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Mustache.Compiler;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
@@ -48,6 +52,11 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.serializer.SerializerUtils;
import org.openapitools.codegen.templating.MustacheEngineAdapter;
import org.openapitools.codegen.templating.mustache.CamelCaseLambda;
import org.openapitools.codegen.templating.mustache.IndentedLambda;
import org.openapitools.codegen.templating.mustache.LowercaseLambda;
import org.openapitools.codegen.templating.mustache.TitlecaseLambda;
import org.openapitools.codegen.templating.mustache.UppercaseLambda;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -199,6 +208,47 @@ public class DefaultCodegen implements CodegenConfig {
}
}
/***
* Preset map builder with commonly used Mustache lambdas.
*
* To extend the map, override addMustacheLambdas(), call parent method
* first and then add additional lambdas to the returned builder.
*
* If common lambdas are not desired, override addMustacheLambdas() method
* and return empty builder.
*
* @return preinitialized map builder with common lambdas
*/
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
return new ImmutableMap.Builder<String, Mustache.Lambda>()
.put("lowercase", new LowercaseLambda().generator(this))
.put("uppercase", new UppercaseLambda())
.put("titlecase", new TitlecaseLambda())
.put("camelcase", new CamelCaseLambda().generator(this))
.put("indented", new IndentedLambda())
.put("indented_8", new IndentedLambda(8, " "))
.put("indented_12", new IndentedLambda(12, " "))
.put("indented_16", new IndentedLambda(16, " "));
}
private void registerMustacheLambdas() {
ImmutableMap<String, Lambda> lambdas = addMustacheLambdas().build();
if (lambdas.size() == 0) {
return;
}
if (additionalProperties.containsKey("lambda")) {
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
"You'll likely need to use a custom template, " +
"see https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md. ");
additionalProperties.put("_lambda", lambdas);
} else {
additionalProperties.put("lambda", lambdas);
}
}
// override with any special post-processing for all models
@SuppressWarnings({"static-method", "unchecked"})
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
@@ -1060,6 +1110,9 @@ public class DefaultCodegen implements CodegenConfig {
// initialize special character mapping
initalizeSpecialCharacterMapping();
// Register common Mustache lambdas.
registerMustacheLambdas();
}
/**
@@ -1519,11 +1572,11 @@ public class DefaultCodegen implements CodegenConfig {
} else if (ModelUtils.isURISchema(schema)) {
return "URI";
} else if (ModelUtils.isStringSchema(schema)) {
if(typeMapping.containsKey(schema.getFormat())) {
if (typeMapping.containsKey(schema.getFormat())) {
// If the format matches a typeMapping (supplied with the --typeMappings flag)
// then treat the format as a primitive type.
// This allows the typeMapping flag to add a new custom type which can then
// be used in the format field.
// be used in the format field.
return schema.getFormat();
}
return "string";
@@ -1817,6 +1870,9 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if(composed.getRequired() != null) {
required.addAll(composed.getRequired());
}
addVars(m, unaliasPropertySchema(properties), required, unaliasPropertySchema(allProperties), allRequired);
// end of code block for composed schema
@@ -1831,14 +1887,28 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isMapSchema(schema)) {
addAdditionPropertiesToCodeGenModel(m, schema);
m.isMapModel = true;
}
if (ModelUtils.isIntegerSchema(schema)) { // integer type
if (!ModelUtils.isLongSchema(schema)) { // long type is not integer
} else if (ModelUtils.isIntegerSchema(schema)) { // integer type
m.isNumeric = Boolean.TRUE;
if (ModelUtils.isLongSchema(schema)) { // int64/long format
m.isLong = Boolean.TRUE;
} else { // int32 format
m.isInteger = Boolean.TRUE;
}
}
if (ModelUtils.isStringSchema(schema)) {
} else if (ModelUtils.isStringSchema(schema)) {
m.isString = Boolean.TRUE;
} else if (ModelUtils.isNumberSchema(schema)) {
m.isNumeric = Boolean.TRUE;
if (ModelUtils.isFloatSchema(schema)) { // float
m.isFloat = Boolean.TRUE;
} else if (ModelUtils.isDoubleSchema(schema)) { // double
m.isDouble = Boolean.TRUE;
} else { // type is number and without format
m.isNumber = Boolean.TRUE;
}
}
if (Boolean.TRUE.equals(schema.getNullable())) {
m.isNullable = Boolean.TRUE;
}
// passing null to allProperties and allRequired as there's no parent
@@ -1908,6 +1978,10 @@ public class DefaultCodegen implements CodegenConfig {
addProperties(properties, required, component);
}
if(schema.getRequired() != null) {
required.addAll(schema.getRequired());
}
if (composedSchema.getOneOf() != null) {
throw new RuntimeException("Please report the issue: Cannot process oneOf (Composed Scheme) in addProperties: " + schema);
}
@@ -2006,7 +2080,7 @@ public class DefaultCodegen implements CodegenConfig {
String type = getSchemaType(p);
if (ModelUtils.isIntegerSchema(p)) { // integer type
property.isNumeric = Boolean.TRUE;
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(p.getFormat())) { // int64/long format
if (ModelUtils.isLongSchema(p)) { // int64/long format
property.isLong = Boolean.TRUE;
} else { // int32 format
property.isInteger = Boolean.TRUE;
@@ -2584,7 +2658,7 @@ public class DefaultCodegen implements CodegenConfig {
if (requestBody != null) {
if (getContentType(requestBody) != null &&
(getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) {
getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) {
// process form parameters
formParams = fromRequestBodyToFormParameters(requestBody, imports);
for (CodegenParameter cp : formParams) {
@@ -2952,7 +3026,7 @@ public class DefaultCodegen implements CodegenConfig {
}
Schema s;
if(parameter.getSchema() != null) {
if (parameter.getSchema() != null) {
s = parameter.getSchema();
} else if (parameter.getContent() != null) {
Content content = parameter.getContent();
@@ -3950,6 +4024,19 @@ public class DefaultCodegen implements CodegenConfig {
* @return sanitized string
*/
public String sanitizeName(String name, String removeCharRegEx) {
return sanitizeName(name, removeCharRegEx, new ArrayList<String>());
}
/**
* Sanitize name (parameter, property, method, etc)
*
* @param name string to be sanitize
* @param removeCharRegEx a regex containing all char that will be removed
* @param exceptionList a list of matches which should not be sanitized (i.e expections)
* @return sanitized string
*/
@SuppressWarnings("static-method")
public String sanitizeName(String name, String removeCharRegEx, ArrayList<String> exceptionList) {
// NOTE: performance wise, we should have written with 2 replaceAll to replace desired
// character with _ or empty character. Below aims to spell out different cases we've
// encountered so far and hopefully make it easier for others to add more special
@@ -3967,27 +4054,27 @@ public class DefaultCodegen implements CodegenConfig {
}
// input[] => input
name = name.replaceAll("\\[\\]", ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
name = this.sanitizeValue(name, "\\[\\]", "", exceptionList);
// input[a][b] => input_a_b
name = name.replaceAll("\\[", "_");
name = name.replaceAll("\\]", "");
name = this.sanitizeValue(name, "\\[", "_", exceptionList);
name = this.sanitizeValue(name, "\\]", "", exceptionList);
// input(a)(b) => input_a_b
name = name.replaceAll("\\(", "_");
name = name.replaceAll("\\)", "");
name = this.sanitizeValue(name, "\\(", "_", exceptionList);
name = this.sanitizeValue(name, "\\)", "", exceptionList);
// input.name => input_name
name = name.replaceAll("\\.", "_");
name = this.sanitizeValue(name, "\\.", "_", exceptionList);
// input-name => input_name
name = name.replaceAll("-", "_");
name = this.sanitizeValue(name, "-", "_", exceptionList);
// a|b => a_b
name = name.replace("|", "_");
name = this.sanitizeValue(name, "\\|", "_", exceptionList);
// input name and age => input_name_and_age
name = name.replaceAll(" ", "_");
name = this.sanitizeValue(name, " ", "_", exceptionList);
// /api/films/get => _api_films_get
// \api\films\get => _api_films_get
@@ -4005,6 +4092,13 @@ public class DefaultCodegen implements CodegenConfig {
return name;
}
private String sanitizeValue(String value, String replaceMatch, String replaceValue, ArrayList<String> exceptionList) {
if (exceptionList.size() == 0 || !exceptionList.contains(replaceMatch)) {
return value.replaceAll(replaceMatch, replaceValue);
}
return value;
}
/**
* Sanitize tag
*
@@ -4841,6 +4935,15 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.dataType = codegenProperty.dataType;
codegenParameter.description = codegenProperty.description;
codegenParameter.paramName = toParamName(codegenParameter.baseName);
codegenParameter.minimum = codegenProperty.minimum;
codegenParameter.maximum = codegenProperty.maximum;
codegenParameter.exclusiveMinimum = codegenProperty.exclusiveMinimum;
codegenParameter.exclusiveMaximum = codegenProperty.exclusiveMaximum;
codegenParameter.minLength = codegenProperty.minLength;
codegenParameter.maxLength = codegenProperty.maxLength;
codegenParameter.pattern = codegenProperty.pattern;
if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);
@@ -4876,7 +4979,7 @@ public class DefaultCodegen implements CodegenConfig {
}
protected void removeOption(String key) {
for(int i = 0; i < cliOptions.size(); i++) {
for (int i = 0; i < cliOptions.size(); i++) {
if (key.equals(cliOptions.get(i).getOpt())) {
cliOptions.remove(i);
break;

View File

@@ -407,9 +407,19 @@ public class InlineModelResolver {
}
}
/**
* Generates a unique model name. Non-alphanumeric characters will be replaced
* with underscores
*
* @param title String title field in the schema if present
* @param key String model name
*/
private String resolveModelName(String title, String key) {
if (title == null) {
return uniqueName(key);
// for auto-generated schema name, replace non-alphanumeric characters with underscore
// to avoid bugs with schema look up with inline schema created on the fly
// e.g. io.schema.User_name => io_schema_User_name
return uniqueName(key).replaceAll("[^A-Za-z0-9]", "_");
} else {
return uniqueName(title);
}
@@ -589,4 +599,4 @@ public class InlineModelResolver {
target.addExtension(extName, vendorExtensions.get(extName));
}
}
}
}

View File

@@ -223,6 +223,7 @@ public class CodegenConfigurator {
}
public CodegenConfigurator setImportMappings(Map<String, String> importMappings) {
this.importMappings = importMappings;
generatorSettingsBuilder.withImportMappings(importMappings);
return this;
}
@@ -234,6 +235,7 @@ public class CodegenConfigurator {
}
public CodegenConfigurator setInstantiationTypes(Map<String, String> instantiationTypes) {
this.instantiationTypes = instantiationTypes;
generatorSettingsBuilder.withInstantiationTypes(instantiationTypes);
return this;
}
@@ -295,6 +297,7 @@ public class CodegenConfigurator {
}
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
this.reservedWordMappings = reservedWordMappings;
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
return this;
}
@@ -310,6 +313,7 @@ public class CodegenConfigurator {
}
public CodegenConfigurator setSystemProperties(Map<String, String> systemProperties) {
this.systemProperties = systemProperties;
workflowSettingsBuilder.withSystemProperties(systemProperties);
return this;
}
@@ -326,6 +330,7 @@ public class CodegenConfigurator {
}
public CodegenConfigurator setTypeMappings(Map<String, String> typeMappings) {
this.typeMappings = typeMappings;
generatorSettingsBuilder.withTypeMappings(typeMappings);
return this;
}
@@ -454,6 +459,12 @@ public class CodegenConfigurator {
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordMappings());
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
// any other additional properties?
String templateDir = workflowSettings.getTemplateDir();
if (templateDir != null) {
config.additionalProperties().put(CodegenConstants.TEMPLATE_DIR, workflowSettings.getTemplateDir());
}
ClientOptInput input = new ClientOptInput()
.config(config);

View File

@@ -17,8 +17,9 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import com.google.common.collect.ImmutableMap.Builder;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
@@ -152,13 +153,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
"DateTime?",
"DateTime",
"DateTimeOffset?",
"DataTimeOffset",
"DateTimeOffset",
"Boolean",
"Double",
"Int32",
"Int64",
"Float",
"Guid?",
"Guid",
"System.IO.Stream", // not really a primitive, we include it to avoid model import
"Object")
);
@@ -191,7 +193,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// nullable type
nullableType = new HashSet<String>(
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "Guid")
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "DateTimeOffset", "Guid")
);
// value Types
valueTypes = new HashSet<String>(
@@ -225,9 +227,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
public void useDateTimeOffset(boolean flag) {
this.useDateTimeOffsetFlag = flag;
if (flag) {
typeMapping.put("DateTime", "DateTimeOffset?");
typeMapping.put("DateTime", "DateTimeOffset");
} else {
typeMapping.put("DateTime", "DateTime?");
typeMapping.put("DateTime", "DateTime");
}
}
@@ -359,32 +361,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// This either updates additionalProperties with the above fixes, or sets the default if the option was not specified.
additionalProperties.put(CodegenConstants.INTERFACE_PREFIX, interfacePrefix);
addMustacheLambdas(additionalProperties);
}
private void addMustacheLambdas(Map<String, Object> objs) {
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
.put("lowercase", new LowercaseLambda().generator(this))
.put("uppercase", new UppercaseLambda())
.put("titlecase", new TitlecaseLambda())
.put("camelcase", new CamelCaseLambda().generator(this))
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
.put("indented", new IndentedLambda())
.put("indented_8", new IndentedLambda(8, " "))
.put("indented_12", new IndentedLambda(12, " "))
.put("indented_16", new IndentedLambda(16, " "))
.build();
if (objs.containsKey("lambda")) {
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
"You'll likely need to use a custom template, " +
"see https://github.com/swagger-api/swagger-codegen#modifying-the-client-library-format. ");
objs.put("_lambda", lambdas);
} else {
objs.put("lambda", lambdas);
}
@Override
protected Builder<String, Lambda> addMustacheLambdas() {
return super.addMustacheLambdas()
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true));
}
@Override

View File

@@ -17,8 +17,8 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import com.google.common.collect.ImmutableMap.Builder;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
@@ -35,7 +35,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.Map;
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCppCodegen.class);
@@ -260,22 +259,12 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
LOGGER.info("Environment variable CPP_POST_PROCESS_FILE not defined so the C++ code may not be properly formatted. To define it, try 'export CPP_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)");
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
}
addMustacheLambdas(additionalProperties);
}
private void addMustacheLambdas(Map<String, Object> objs) {
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
.put("multiline_comment_4", new IndentedLambda(4, " ", "///"))
.build();
if (objs.containsKey("lambda")) {
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'.");
objs.put("_lambda", lambdas);
} else {
objs.put("lambda", lambdas);
}
@Override
protected Builder<String, Lambda> addMustacheLambdas() {
return super.addMustacheLambdas()
.put("multiline_comment_4", new IndentedLambda(4, " ", "///"));
}
@Override
@@ -304,17 +293,17 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
}
}
}
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
URL url = URLPathUtils.getServerURL(openAPI);
String port = URLPathUtils.getPort(url, "");
String host = url.getHost();
if(!port.isEmpty()) {
this.additionalProperties.put("serverPort", port);
this.additionalProperties.put("serverPort", port);
}
if(!host.isEmpty()) {
this.additionalProperties.put("serverHost", host);
}
this.additionalProperties.put("serverHost", host);
}
}
}

View File

@@ -16,8 +16,9 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import com.google.common.collect.ImmutableMap.Builder;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
@@ -67,7 +68,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
protected Set<String> collectionTypes;
protected Set<String> mapTypes;
// true if nullable types will be supported (as option)
// true if nullable types will be supported (as option)
protected boolean supportNullable = Boolean.TRUE;
protected Set<String> nullableType = new HashSet<String>();
@@ -329,32 +330,12 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
// This either updates additionalProperties with the above fixes, or sets the default if the option was not specified.
additionalProperties.put(CodegenConstants.INTERFACE_PREFIX, interfacePrefix);
addMustacheLambdas(additionalProperties);
}
private void addMustacheLambdas(Map<String, Object> objs) {
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
.put("lowercase", new LowercaseLambda().generator(this))
.put("uppercase", new UppercaseLambda())
.put("titlecase", new TitlecaseLambda())
.put("camelcase", new CamelCaseLambda().generator(this))
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
.put("indented", new IndentedLambda())
.put("indented_8", new IndentedLambda(8, " "))
.put("indented_12", new IndentedLambda(12, " "))
.put("indented_16", new IndentedLambda(16, " "))
.build();
if (objs.containsKey("lambda")) {
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
"You'll likely need to use a custom template, " +
"see https://github.com/swagger-api/swagger-codegen#modifying-the-client-library-format. ");
objs.put("_lambda", lambdas);
} else {
objs.put("lambda", lambdas);
}
@Override
protected Builder<String, Lambda> addMustacheLambdas() {
return super.addMustacheLambdas()
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true));
}
@Override

View File

@@ -52,7 +52,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public static final String SUPPORT_JAVA6 = "supportJava6";
public static final String DISABLE_HTML_ESCAPING = "disableHtmlEscaping";
public static final String BOOLEAN_GETTER_PREFIX = "booleanGetterPrefix";
public static final String USE_NULL_FOR_UNKNOWN_ENUM_VALUE = "useNullForUnknownEnumValue";
protected String dateLibrary = "threetenbp";
protected boolean supportAsync = false;
@@ -86,7 +85,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected boolean supportJava6 = false;
protected boolean disableHtmlEscaping = false;
protected String booleanGetterPrefix = "get";
protected boolean useNullForUnknownEnumValue = false;
protected String parentGroupId = "";
protected String parentArtifactId = "";
protected String parentVersion = "";
@@ -220,10 +218,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.setBooleanGetterPrefix(additionalProperties.get(BOOLEAN_GETTER_PREFIX).toString());
}
additionalProperties.put(BOOLEAN_GETTER_PREFIX, booleanGetterPrefix);
if (additionalProperties.containsKey(USE_NULL_FOR_UNKNOWN_ENUM_VALUE)) {
this.setUseNullForUnknownEnumValue(Boolean.valueOf(additionalProperties.get(USE_NULL_FOR_UNKNOWN_ENUM_VALUE).toString()));
}
additionalProperties.put(USE_NULL_FOR_UNKNOWN_ENUM_VALUE, useNullForUnknownEnumValue);
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
@@ -417,6 +411,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// imports for pojos
importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty");
importMapping.put("ApiModel", "io.swagger.annotations.ApiModel");
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes");
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
@@ -585,6 +580,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
name = "_u";
}
// numbers are not allowed at the beginning
if (name.matches("^\\d.*")) {
name = "_" + name;
}
// if it's all uppper case, do nothing
if (name.matches("^[A-Z0-9_]*$")) {
return name;
@@ -944,6 +944,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
codegenModel = AbstractJavaCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
}
if ("BigDecimal".equals(codegenModel.dataType)) {
codegenModel.imports.add("BigDecimal");
}
return codegenModel;
}
@@ -1107,7 +1110,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// number
if ("Integer".equals(datatype) || "Long".equals(datatype) ||
"Float".equals(datatype) || "Double".equals(datatype)) {
"Float".equals(datatype) || "Double".equals(datatype) || "BigDecimal".equals(datatype)) {
String varName = "NUMBER_" + value;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
@@ -1134,6 +1137,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} else if ("Float".equals(datatype)) {
// add f to number, e.g. 3.14 => 3.14f
return value + "f";
} else if ("BigDecimal".equals(datatype)) {
// use BigDecimal String constructor
return "new BigDecimal(\"" + value + "\")";
} else {
return "\"" + escapeText(value) + "\"";
}
@@ -1393,10 +1399,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.booleanGetterPrefix = booleanGetterPrefix;
}
public void setUseNullForUnknownEnumValue(boolean useNullForUnknownEnumValue) {
this.useNullForUnknownEnumValue = useNullForUnknownEnumValue;
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection

View File

@@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.io.FilenameUtils;
@@ -54,6 +55,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
protected String npmName = null;
protected String npmVersion = "1.0.0";
protected String enumSuffix = "Enum";
protected String classEnumSeparator = ".";
public AbstractTypeScriptClientCodegen() {
super();
@@ -94,7 +98,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
"object"
));
languageGenericTypes = new HashSet<>(Arrays.asList(
languageGenericTypes = new HashSet<>(Collections.singletonList(
"Array"
));
@@ -144,8 +148,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
if (StringUtils.isEmpty(System.getenv("TS_POST_PROCESS_FILE"))) {
LOGGER.info("Hint: Environment variable 'TS_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export TS_POST_PROCESS_FILE=\"/usr/local/bin/prettier --write\"' (Linux/Mac)");
LOGGER.info("Note: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
}
else if (!this.isEnablePostProcessFile()) {
} else if (!this.isEnablePostProcessFile()) {
LOGGER.info("Warning: Environment variable 'TS_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
}
@@ -177,7 +180,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
this.setNpmVersion(openAPI.getInfo().getVersion());
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.parseBoolean(additionalProperties.get(SNAPSHOT).toString())) {
if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) {
this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
} else {
@@ -260,45 +263,45 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
final String regex = "^.*[+*:;,.()-]+.*$";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(str);
boolean matches = matcher.matches();
return matches;
return matcher.matches();
}
@Override
public String toModelName(String name) {
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
public String toModelName(final String name) {
ArrayList<String> exceptions = new ArrayList<String>(Arrays.asList("\\|", " "));
String sanName = sanitizeName(name, "(?![| ])\\W", exceptions);
if (!StringUtils.isEmpty(modelNamePrefix)) {
name = modelNamePrefix + "_" + name;
sanName = modelNamePrefix + "_" + sanName;
}
if (!StringUtils.isEmpty(modelNameSuffix)) {
name = name + "_" + modelNameSuffix;
sanName = sanName + "_" + modelNameSuffix;
}
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = camelize("model_" + name);
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
if (isReservedWord(sanName)) {
String modelName = camelize("model_" + sanName);
LOGGER.warn(sanName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
return modelName;
}
// model name starts with number
if (name.matches("^\\d.*")) {
String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
if (sanName.matches("^\\d.*")) {
String modelName = camelize("model_" + sanName); // e.g. 200Response => Model200Response (after camelize)
LOGGER.warn(sanName + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
return modelName;
}
if (languageSpecificPrimitives.contains(name)) {
String modelName = camelize("model_" + name);
LOGGER.warn(name + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
if (languageSpecificPrimitives.contains(sanName)) {
String modelName = camelize("model_" + sanName);
LOGGER.warn(sanName + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
return modelName;
}
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
return camelize(sanName);
}
@Override
@@ -549,8 +552,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
@Override
public String toEnumName(CodegenProperty property) {
String enumName = toModelName(property.name) + "Enum";
String enumName = toModelName(property.name) + enumSuffix;
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
@@ -569,14 +571,14 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
// name enum with model name, e.g. StatusEnum => Pet.StatusEnum
for (CodegenProperty var : cm.vars) {
if (Boolean.TRUE.equals(var.isEnum)) {
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "." + var.enumName);
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + classEnumSeparator + var.enumName);
}
}
if (cm.parent != null) {
for (CodegenProperty var : cm.allVars) {
if (Boolean.TRUE.equals(var.isEnum)) {
var.datatypeWithEnum = var.datatypeWithEnum
.replace(var.enumName, cm.classname + "." + var.enumName);
.replace(var.enumName, cm.classname + classEnumSeparator + var.enumName);
}
}
}
@@ -696,4 +698,14 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
}
}
}
@Override
public String toAnyOfName(List<String> names, ComposedSchema composedSchema) {
return String.join(" | ", names);
}
@Override
public String toOneOfName(List<String> names, ComposedSchema composedSchema) {
return String.join(" | ", names);
}
}

View File

@@ -22,6 +22,7 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -353,7 +354,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("Filters" + File.separator + "GeneratePathParamsValidationFilter.mustache",
packageFolder + File.separator + "Filters", "GeneratePathParamsValidationFilter.cs"));
}
supportingFiles.add(new SupportingFile("Authentication" + File.separator + "ApiAuthentication.mustache",packageFolder + File.separator + "Authentication", "ApiAuthentication.cs"));
}
@@ -407,12 +408,12 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
@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;
if (languageSpecificPrimitives.contains(type)) {
if (isSupportNullable() && ModelUtils.isNullable(p) && nullableType.contains(type)) {
return type + "?";
} else {
return type;
}
} else {
return null;
}

View File

@@ -879,15 +879,15 @@ 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;
if (languageSpecificPrimitives.contains(type)) {
if (isSupportNullable() && ModelUtils.isNullable(p) && nullableType.contains(type)) {
return type + "?";
} else {
return type;
}
} else {
return null;
}

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.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
@@ -34,6 +35,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
}
// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
addOption(CodegenConstants.MODEL_NAME_PREFIX, CodegenConstants.MODEL_NAME_PREFIX_DESC, this.modelNamePrefix);
/*
* Additional Properties. These values can be passed to the templates and
@@ -45,9 +47,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
// Write defaults namespace in properties so that it can be accessible in templates.
// At this point command line has not been parsed so if value is given
// in command line it will supersede this content
additionalProperties.put("cppNamespace", cppNamespace);
// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
additionalProperties.put("cppNamespace", cppNamespace);
/*
* Language Specific Primitives. These types will not trigger imports by
* the client generator
@@ -112,7 +112,9 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
}
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
if (additionalProperties.containsKey("modelNamePrefix")) {
modelNamePrefix = (String) additionalProperties.get("modelNamePrefix");
typeMapping.put("object", modelNamePrefix + "Object");
additionalProperties().put("prefix", modelNamePrefix);
}

View File

@@ -359,7 +359,10 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
} else if (ModelUtils.isStringSchema(p)) {
return "utility::conversions::to_string_t(\"\")";
} else if (ModelUtils.isFreeFormObject(p)) {
return "new Object()";
}
return "nullptr";
}

View File

@@ -16,15 +16,23 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
public class GoClientExperimentalCodegen extends GoClientCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(GoClientExperimentalCodegen.class);
public GoClientExperimentalCodegen() {
super();
outputFolder = "generated-code/go-experimental";
embeddedTemplateDir = templateDir = "go-experimental";
}
/**
@@ -49,4 +57,35 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
return "Generates a Go client library (experimental and may subject to breaking changes without further notice).";
}
@Override
public void processOpts() {
super.processOpts();
supportingFiles.add(new SupportingFile("utils.mustache", "", "utils.go"));
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
boolean addedErrorsImport = false;
List<Map<String, Object>> models = (List<Map<String, Object>>) objs.get("models");
for (Map<String, Object> m : models) {
Object v = m.get("model");
if (v instanceof CodegenModel) {
CodegenModel model = (CodegenModel) v;
if (!model.isEnum) {
imports.add(createMapping("import", "encoding/json"));
}
for (CodegenProperty param : model.vars) {
if (!addedErrorsImport && param.required) {
imports.add(createMapping("import", "errors"));
addedErrorsImport = true;
}
}
}
}
return objs;
}
}

View File

@@ -67,6 +67,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String GOOGLE_API_CLIENT = "google-api-client";
public static final String JERSEY1 = "jersey1";
public static final String JERSEY2 = "jersey2";
public static final String NATIVE = "native";
public static final String OKHTTP_GSON = "okhttp-gson";
public static final String RESTEASY = "resteasy";
public static final String RESTTEMPLATE = "resttemplate";
@@ -139,6 +140,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
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 : 4.x. JSON processing: Gson 2.x. Only for Java8");
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
@@ -166,7 +168,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
@Override
public void processOpts() {
if (WEBCLIENT.equals(getLibrary()) && "threetenbp".equals(dateLibrary)) {
if ((WEBCLIENT.equals(getLibrary()) && "threetenbp".equals(dateLibrary)) || NATIVE.equals(getLibrary())) {
dateLibrary = "java8";
}
@@ -254,12 +256,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
writeOptional(outputFolder, new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
if (!(RESTTEMPLATE.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
if (!(RESTTEMPLATE.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()))) {
supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java"));
}
// google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
if (!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
if (!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()))) {
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java"));
supportingFiles.add(new SupportingFile("auth/HttpBearerAuth.mustache", authFolder, "HttpBearerAuth.java"));
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
@@ -293,7 +295,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
}
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()))) {
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
}
@@ -325,6 +327,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
additionalProperties.put("jackson", "true");
} else if (NATIVE.equals(getLibrary())) {
setJava8Mode(true);
additionalProperties.put("java8", "true");
additionalProperties.put("jackson", "true");
} else if (RESTEASY.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
additionalProperties.put("jackson", "true");
@@ -412,7 +418,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
additionalProperties.remove("gson");
}
if (additionalProperties.containsKey("jackson")) {
if (additionalProperties.containsKey("jackson") && !NATIVE.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
@@ -500,7 +506,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
// google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
if ((!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || usePlayWS)) && ProcessUtils.hasOAuthMethods(objs)) {
if ((!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || usePlayWS || NATIVE.equals(getLibrary()))) && ProcessUtils.hasOAuthMethods(objs)) {
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java"));
}

View File

@@ -18,13 +18,11 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.templating.mustache.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -211,31 +209,6 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", File.separator);
supportingFiles.add(new SupportingFile("ApiKeyAuth.kt.mustache", infrastructureFolder, "ApiKeyAuth.kt"));
addMustacheLambdas(additionalProperties);
}
private void addMustacheLambdas(Map<String, Object> objs) {
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
.put("lowercase", new LowercaseLambda().generator(this))
.put("uppercase", new UppercaseLambda())
.put("titlecase", new TitlecaseLambda())
.put("camelcase", new CamelCaseLambda().generator(this))
.put("indented", new IndentedLambda())
.put("indented_8", new IndentedLambda(8, " "))
.put("indented_12", new IndentedLambda(12, " "))
.put("indented_16", new IndentedLambda(16, " "))
.build();
if (objs.containsKey("lambda")) {
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
"You'll likely need to use a custom template, " +
"see https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md. ");
objs.put("_lambda", lambdas);
} else {
objs.put("lambda", lambdas);
}
}
public static class Constants {

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