Compare commits

...

130 Commits

Author SHA1 Message Date
Jérémie Bresson
5b3e9eb72f Revert "Fixed type assignment for referenced enums (#3186)"
This reverts commit c4d61af20b.
2019-07-09 08:20:03 +02:00
DonDi94
c4d61af20b Fixed type assignment for referenced enums (#3186)
Change-Id: Ie33e298bd3164499c717971c98d0c8fe807c6a71
2019-07-09 08:07:56 +02:00
William Cheng
7cef5ed8ab update java rest assured sample 2019-07-08 22:49:49 +08:00
Victor Orlovsky
0e37719162 [Java][Rest-assured] Bump rest-assured version (#3282)
* Update rest-assured version to 4.0.0

* Added rest-assured version 4.0.0 to documentation

* Remove CatAllOfTest and DogAllOfTest
2019-07-08 22:20:35 +08:00
Jérémie Bresson
3943d1cc9d [java] fix javadoc configuration (#3302)
* [java] fix javadoc configuration

* [java-pkmst-microservice] fix generated javadoc
2019-07-08 21:25:47 +08:00
William Cheng
3f9e374c8d update js flow dep to fix security issue (#3296) 2019-07-08 17:00:38 +08:00
Jérémie Bresson
7b7e147696 [typescript] remove duplicate TypeScriptJqueryClientCodegen.SNAPSHOT field (#3298)
Fix following issue:

The field TypeScriptJqueryClientCodegen.SNAPSHOT is hiding a field from type AbstractTypeScriptClientCodegen
2019-07-08 10:59:11 +02:00
Jim Schubert
51e7005373 [online] Remove GENERATOR_HOST defaults (#3289)
The defaults configured for GENERATOR_HOST didn't really make sense.
When running the docker container with `-P`, GENERATOR_HOST defaulted to
http://localhost. This caused download links for generated client/server
code to be incorrect. For most cases, there's no reason to provide
GENERATOR_HOST as the code already figures the appropriate
scheme/host/port from the originating request.

GENERATOR_HOST could still be used for more complex deployment
scenarios, for instance if a specific server is configured as a file
server. I haven't tested this scenario, and it may require mounting /tmp
as a volume when running within a container.
2019-07-07 10:25:43 -04:00
Erik Timmers
366ca24062 Add option to disable default interfaces (#3022) 2019-07-07 16:44:03 +08:00
Jim Schubert
45da167f8e [online] Revert GENERATOR_HOST explicit setting (#3287) 2019-07-06 17:18:34 -04:00
Justin Black
109808e60d [Python] Adds new client generator, python-experimental (#3244)
* Adds python-experimental generator

* Adds python-experimental samples folder which uses its own v2 spec

* Adds enusre-up-to-date updates

* Removes samples/client/petstore/perl/t/AnotherFakeApiTest.t

* Removes comment line from python-experimental generator

* Reverts perl docs file

* Updates perl sample client

* Adds python-experimental to pom.xml

* Copies the python test foldeers tests and testfiles into python-experimental

* Copies python test folder into python-experimental

* Moves python testing from Travis (samples pom.xml profile) to Circlci (samples.circleci pom.xml profile)

* Adds python-experimental pom.xml

* Adds python-experimental makefile and .sh files

* Chenges python-experimental to use gitignored venv rather than .venv which is not ignored when testing

* Adds dev-requiremnts.txt and removes .travis.yml from python-experimental so CI tests will pass

* Moves python-experimental from CicleCI to Travis to get support for multiple python environments

* Updates generator java comment so CI tests will run over again
2019-07-06 22:43:29 +08:00
Nathan Broadbent
78551d0180 Set error_reporting(E_ALL) in phpunit.xml settings, to crash on undefined variables (#3266)
* Set error_reporting(E_ALL) in phpunit.xml settings, so that undefined variables will always cause a test failure

* Update petstore sample for php-laravel
2019-07-06 22:21:41 +08:00
William Cheng
fa10103363 comment out python flask tests 2019-07-06 00:22:36 +08:00
William Cheng
e9809294a5 update travis, support java9+ (#3279) 2019-07-05 23:32:10 +08:00
Balázs Zsoldos
bd17a15572 Avoid nullsafe errors in typescript-rxjs runtime.ts (#3255)
* #3253 Avoid nullsafe errors in typescript-rxjs runtime.ts

* #3253 Updating samples
2019-07-05 18:42:30 +08:00
Prateek Malhotra
90bd90c41a [Typescript][Fetch] switch to vars from allVars in model JSON conversion functions (#2899)
Signed-off-by: Prateek Malhotra <someone1@gmail.com>
2019-07-05 18:22:07 +08:00
William Cheng
441f6327d9 Update R technical committee (#3284) 2019-07-05 15:49:19 +08:00
William Cheng
0b79c5b6be Add new Go client (experimental) generator (#3268)
* add new go experimental generator

* extends go client codegen

* add go samples and test

* comment out haskell client test
2019-07-04 22:56:49 +08:00
William Cheng
65fdce7036 Merge branch 'master' of https://github.com/OpenAPITools/openapi-generator 2019-07-04 22:50:02 +08:00
William Cheng
1e380850c0 update doc 2019-07-04 22:49:15 +08:00
William Cheng
267c9bdcf8 Add a link to Japanese eBook (REST API のためのコード生成入門 (OpenAPI Generator)) (#3280) 2019-07-04 22:24:35 +08:00
Jérémie Bresson
8d27857f83 [core] consider content in parameters and headers when computing unused schemas (#3243)
* [core] consider content in parameters and headers when computing unused schemas

* consider parameters in PathItem
2019-07-04 20:47:24 +08:00
Matthew Cachia
cbca86b43a Add unhandledException to 'spring' generator, which declares all operation methods to throw a generic exception, allowing implementations to unhandle checked exceptions. This is useful whenever it is unnecessary to handle specific exceptions and, more importantly, allow generic constructs (eg. Spring @ControllerAdvice) to tackle unhandled exceptions from a single point (for instance, tackle all unhandled exceptions as an HTTP500 while excluding the stacktrace in the response body). (#2482) 2019-07-04 20:19:40 +08:00
Kevin Locke
2c342cc2b4 [Java] Handle discriminator mapping non-ref name (#3247)
The `mapping` property of the [Discriminator Object] is "An object to
hold mappings between payload values and schema names or references."
The subsequent examples in the spec have `mapping`s of both types.
The `mapping` support introduced in #536 only supports references.

Update the code to support names (identified by lack of `/`) or
references and change a test mapping to cover this case.

[Discriminator Object]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#discriminatorObject

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2019-07-04 15:24:47 +08:00
Josh Burton
310f5feda0 [dart-jaguar] Makes converters publicly accessible so they can be used serialization/deserlization outside of the API client (#3245) 2019-07-04 15:13:23 +08:00
Ramanth Addala
0cb921251d feat(r): Added handling exception with ApiException class and better documentation (#3217)
* feat(r): Added handling exception with ApiException class and document generation

* feat(r):enhancements to exception handling and documentation

* fix(r): fixes and reverting the man folder

* fix(r): minor fix of import statement

* fix(r): generated the docs file

* fix(r) minor doc casing fixes
2019-07-03 22:05:21 +08:00
Matthias Neubert
dda2f3c141 Update README.md (#3273)
Added DB Systel as a company using OpenAPI-generator
2019-07-03 18:38:06 +08:00
Marc Etter
95ba9525f9 [elm][haskell-servant] Fix issue 3256 (#3262)
* [elm] fix empty operation exception (#3256)

* [haskell-servant] fix empty operation type (#3256)

* [elm][haskell-servant] update samples
2019-07-03 18:07:21 +08:00
William Cheng
35262aa7d1 move openapi 3 samples to the correct folder (#3267) 2019-07-03 13:18:52 +08:00
steco
b44f6c302a Update DefaultCodeGen to allow additional primitive types (#2799)
* Update DefaultCodeGen to allow additional primitive types

If a string field is specified with a format which is also defined using
--typeMappings, it will be treated as a primitive type

* Fixed typo in android-petstore-httpclient.bat
2019-07-03 09:12:38 +08:00
Jim Schubert
1fc7740f2e [online] Honor generator environment variable and system property (#3265)
Previously, this pulled from the GENERATOR_HOST system property. This
should have been an environment variable. Fallback is now generator.host
system property.
2019-07-02 13:07:17 -04:00
Jim Schubert
b87806834b [online] Honor GENERATOR_HOST env variable (#3263)
This sets "host" appropriately to the published host when GENERATOR_HOST
is configured.
2019-07-02 09:15:18 -04:00
William Cheng
4e62e92daf update doc 2019-07-02 17:17:57 +08:00
Jan Willem Harmelink
c012dcd754 Added RxJava2 to java-vertx server codegen. (#3240) 2019-07-02 16:46:02 +08:00
Thibault Duperron
dd0c2a84ee Check classVarName against reserved keywords (#3079)
Must fix #1831 and #13
2019-07-02 16:40:36 +08:00
Jérémie Bresson
40a293dcda Update to swagger-parser to 2.0.13-OpenAPITools.org-2 (#3239)
* Update to swagger-parser to 2.0.13-SNAPSHOT

* Update samples

* Update swagger-parser to 2.0.13-OpenAPITools.org-2
2019-07-02 16:37:41 +08:00
Michael Petö
1730a4efce Fix typo in javascript generator template (#3249)
* Fix typo in javascript generator template

* Update sample client
2019-06-30 12:07:49 +08:00
Jim Schubert
3e5e82460f [online] Apidocs ui (#3229)
* [online] Use rapidoc UI for api documentation
2019-06-29 20:30:45 -04:00
Mateusz Szychowski (Muttley)
731b162942 [C++][Pistache] Fix warnings (#3238)
* [C++][Pistache] Fix warnings

Remove unecessary semicolon (Wpedantic)
Remove unused parameter name (Wunused-parameter)

* [C++][Pistache] Update Petstore sample
2019-06-28 19:21:01 +02:00
Thiago Arrais
e46bd7dd18 [go] Serialize multipart array of complex objects as JSON (#2965)
* Serialize multipart array of complex objects as JSON

* Update sample client

* Update sample client
2019-06-28 23:14:13 +08:00
wing328
51014839fd add new perl file 2019-06-28 18:00:48 +08:00
Jérémie Bresson
23e63dccfa [java-client][okhttp-gson] support bearer authentication (#3236) 2019-06-28 17:55:51 +08:00
Sai Giridhar P
6578cef260 [python] : Make example code snippet compilable (#3148)
* feat(python): Making example compilable

* feat(python): Updating pet project

* feat(python): Updating comments

* feat(documentation): Fixing comments style

* feat(documentation): Updating documentation

* feat(documentation): Fixing comments style
2019-06-28 17:53:25 +08:00
wing328
a41448ab9c update perl petstore samples 2019-06-28 16:34:17 +08:00
Rainer Hermanns
3a1b29b90c Added special handling for 'string' types with format 'uri' (OpenAPITools#3160) (#3161)
- implemented Kotlin
- implemented Java

Fixes OpenAPITools#3160
2019-06-28 09:48:41 +08:00
Roman Müller
73966a0152 [KOTLIN Spring] add interfaceOnly option (#3050)
* move template definition to processOpts()

* add interfaceOnly option for kotlin-spring

* add template for interface only option
2019-06-27 12:23:50 -04:00
Mark Oude Veldhuis
325ed4b72e If a parameter is a date, format it as YYYY-MM-DD (#3218) 2019-06-27 08:09:38 +02:00
wing328
35a6f9d6e6 remove corrupted files 2019-06-27 12:12:44 +08:00
wing328
6c9fefa7b5 update doc 2019-06-27 10:47:05 +08:00
Mateusz Szychowski (Muttley)
68a5fa4c8b [C++][Pistache] Catch exception instead of runtime_error (#3225)
* [C++][Pistache] Replace runtime_error with std::exception

* [C++][Pistache] Update Petstore sample

* [C++][Pistache] Fix catch-value warning
2019-06-26 19:13:54 +02:00
DanielHabenicht
7af2bc8dff add link to the "new-generator" guide (#3227)
* add link to the new--generator guide

* Update CONTRIBUTING.md
2019-06-26 17:57:24 +02:00
William Cheng
f41cd234d9 Fix release table in the readme (#3221) 2019-06-26 22:09:16 +08:00
William Cheng
c1771c94bd Add template creator: C# ASP.NET Core 3.0: @A-Joshi (#3213) 2019-06-25 19:23:49 +08:00
Thibault Duperron
01f991a034 Fix inheritance with modelPrefix (#3151)
* Fix inheritance with modelPrefix

Fix #3150

* Fix typo
2019-06-25 14:46:19 +08:00
Amit Joshi
94c583b6ce [aspnetcore]: Preliminary support for ASP.NET 3.0 Core preview 5 (#2824)
* First set of fixes to support ver 3.0, useswashbuckle does not work yet

* Fix swashbuckle issues iwth aspnetcore 3.0

* Use default routing for 2.2 and turn off default for 3.0

* fix up documentation

* PR Feedback and wrong name in mustache file

* Fix for 2.1 usage too

* Change isFramework to useFrameworkReference as name to make thngs explicitly clear. Also fix small messages for the review comments

* Make JSON.NET version configurable

* Activate endpoint routing and use camel case NamingStrategy

* Make Newtonsoft version configurable to match ASP.NET Core preview 5

* Fix spelling of an option, remove a duplicate call and update docs
2019-06-25 14:40:05 +08:00
William Cheng
fe8dd343a8 Remove Jean from the core team in the public website (#3212) 2019-06-25 14:25:45 +08:00
Tomasz Prus
5b9283beca feat: configurable limit of simultaneous connections (python/asyncio) (#3200)
* feat: configurable limit of simultaneous connections (python/asyncio)

* fix: remove unused import (python/asyncio)
2019-06-25 14:13:43 +08:00
Ramanth
f681764067 [R] feat(r): Inclusion of useragent, timeout and serialization (#3084)
* feat(r): Inclusion of useragent timeout and serialization

* fix(r): fixing name of timeout parameter

* fix(r): fixing unit tests

* fix(r): fixing minor issues

* fix(r): updated r petstore batch command

* fix(r): minor unit test fix

* fix(r): refactor of useragent passing and other minor
2019-06-25 14:12:13 +08:00
Bernd
9518e2a02e [typescript-rxjs] refactor to arrow functions and short hand object creation (#3077)
* feat(typescript-rxjs): change BaseAPI to arrow functions, use shorthands where possible

* feat(typescript-rxjs): replace null checking with throwIfRequired helper function in api controllers

* feat(typescript-rxjs): use shorthand syntax for object creation of query and header params

* feat(typescript-rxjs): provide fallback for previously exported RequiredError and querystring

* refactor(typescript-rxjs): change order of query and headers definition

* feat(typescript-rxjs): regenerate samples

* fix(typescript-rxjs): missing closing curly

* fix(typescript-rxjs): add condition to prevent undefined parameters in header or query params
2019-06-25 12:04:40 +08:00
Johan Brandhorst
2b55413371 [Go][Client] Use configured Scheme and Host in requests (#3115)
* [Go][Client] Ensure test errors don't crash

Previously we did not interrupt execution of a test case
when an error was returned from an API call. This was
causing the tests to crash as soon as we try to
dereference the response.

We now fail the tests as soon as the first API error
is received.

* [Go][Client] Use configured Scheme and Host in requests

Previously we were simply setting the Host header and
completely ignoring the configured scheme.
2019-06-25 12:02:20 +08:00
William Cheng
74c569ebf8 Make sure Perl client samples are up-to-date (#3207)
* Make sure Perl samples are up-to-date

* update perl samples
2019-06-25 10:34:44 +08:00
Jim Schubert
3ee76a0662 [core] Initial implementation of a validation framework in core (#3183)
* Initial implementation of a validation framework in core

* Print surefire summary (helps evaluate errors)

* Bump versions: surefire plugin,jmockit

* Depend on jmockit within maven-surefire-plugin which requires it
2019-06-24 18:24:50 -04:00
Jim Schubert
6b428d65f6 Release versioning helper script(s) (#3110)
* Release versioning script with marker tags.

Introduces bump.sh which supports moving from version to version but
only within delimiting marker tags in the target file.

This script currently doesn't do validations or anything fancy.

* Allow bumping version according to type (major,minor,build,revision)

* bump.sh will display error if file contents are unchanged
2019-06-24 18:22:10 -04:00
Chris Couzens
034064be4c Ruby-client: Don't encode slashes if strict-spec false (#3204)
URL-special characters such as /,?,% should be encoded when inside path
parameters. I changed the Ruby-client to do so.
https://github.com/OpenAPITools/openapi-generator/pull/3039

Unfortunately, some projects relied on slashes not being expanded within
path paramters:
https://github.com/OpenAPITools/openapi-generator/issues/3119

With this commit, these projects can now pass `--strict-spec false` to
not have / converted to %2F.

strict spec not specified: / -> %2F
--strict-spec true: / -> %2F
--strict-spec false: / -> /
2019-06-25 00:30:00 +09:00
Michal Foksa
4ac33d80f0 [openapi-yaml] Config option outputFile was ignored by the generator. (#3199) 2019-06-24 16:58:38 +02:00
Mathieu Debove
06cfdbbdc6 Add missing javax dependencies for Java > 8 (#3188)
* Add missing javax dependencies for Java > 8

* update spring petstore samples
2019-06-24 21:42:49 +08:00
wing328
55ae485fd0 update kotlin samples 2019-06-24 21:01:36 +08:00
William Cheng
38008e669e Minor fix to presentation link 2019-06-24 14:42:01 +08:00
Thibault Duperron
a882e4b3a5 Add Flow import to kotlin spring reactive (#3107)
* Add Flow import to kotlin spring reactive

* Add runBlockingTest to api tests

* Add kotlin-springboot-petstore-server-reactive.sh to ensure-up-to-date

* add reactive check for  runBlockingTest

* Samples
2019-06-24 14:26:30 +08:00
Thibault Duperron
1d8c9dcc0b Ktor Fix KtorExperimentalAPI import (#3108)
* Ktor Fix KtorExperimentalAPI import

Fix #2967

* Samples
2019-06-24 14:23:22 +08:00
William Cheng
038afd6650 Add a link to the speaker deck at Kubernetes Contributor Summit (#3205)
Add a link to the speaker deck at Kubernetes Contributor Summit
2019-06-24 14:00:18 +08:00
Sai Giridhar P
2773b32c36 [csharp] Adding http response details on api_docs and making example snippet compilable (#3129)
* feat(csharp): Adding http response details

* feat(csharp): Updating pet project

* feat(csharp): Updating pet project

* feat(csharp): Updating pet project

* feat(csharp): Updating pet project

* feat(csharp): Updating pet project
2019-06-24 11:35:52 +08:00
Sai Giridhar P
a038fcc9c8 [java][jesery2]: "InjectionManagerFactory not found" issue (#3153)
* feat(java-jersey2): Fixing InjectionManagerFactory issue

* feat(java-jersey2): Update pet project
2019-06-24 11:33:57 +08:00
Martyn Garcia
f6c738ed9e Add #send to ruby reserved word list (#3146) 2019-06-22 01:33:16 +09:00
Thibault Duperron
e3fe12eacf Merge java8 doc for spring (#3122)
fix #3117
2019-06-21 22:13:19 +08:00
MBcom
1540ae7951 added api key authentication to aspnetcore 2.1 (#3089)
updated samples
2019-06-21 21:54:08 +08:00
William Cheng
b6bb13b93c Add "yue9944882" to Perl technical committee (#3194) 2019-06-21 21:52:35 +08:00
Sai Giridhar P
2a5af92cdf [csharp-netcore]: Adding http response details in api_docs and making example snippet compilable (#3128)
* feat(csharp-documentation): Improving documentation and example

* feat(csharp-documentation): Updating pet project

* feat(csharp-documentation): Minor updates

* feat(csharp-documentation): Updating pet project

* feat(csharp): Updating pet project

* feat(csharp-netcore): Updating pet project
2019-06-21 21:09:13 +08:00
Min Kim
b9451e91af generate travis configuration (#3193) 2019-06-21 21:01:23 +08:00
Min Kim
0e2eed6892 Perl: Basic bearer auth support (#3192)
* bearer token support

* [generator] running scripts
2019-06-21 18:32:11 +08:00
Ramanth
46c18ad4dd [R] feat(r) : Alternate PR for serialization fixes along with WithHttpInfo method enhancement (#3099)
* feat(r): fixing serialization and deserialization issues

* feat(r): pet store file generated with serialization fixes

* fix(r): updated the query params with keyname in get request

* fix(r):fix issue with package name and other minor

* fix(r): fixing unit tests

* feat(r): adding api calls WithHttpInfo method

* fix(r): reverting unit test changes

* feat(r): saving changes for reference

* Revert "feat(r): saving changes for reference"

This reverts commit 0d091b5c20.

* feat(r): minor refactor of method position

* fix(r): fixing bug in withhttpinfo method args passing

* fix(r): generated petstore with fix
2019-06-21 16:38:32 +08:00
William Cheng
8e0dc2f150 improve release checkout script (#3184) 2019-06-21 10:56:22 +08:00
William Cheng
8e11fd9fe4 Prepare 4.0.3-SNAPSHOT (#3185)
* update version to 4.0.3-SNAPSHOT

* update readme

* update gradle, maven plugin

* update release schedule

* update samples
2019-06-20 18:50:49 +08:00
William Cheng
fae9d4a37b 4.0.2 release (#3181)
* remove snapshot version

* update stable version

* remove build.gradle sample from relesae script
2019-06-20 12:39:15 +08:00
Rhuan
93edd7650b Fix rubocop obsolescence (#3175)
* Update obsolete rubocop configuration

* Update obsolete rubocop config

* Update obsolete rubocop config
2019-06-20 01:50:29 +09:00
William Cheng
4ead766b9e Add Fuse to the company list (#3164)
Add Fuse to the company list
2019-06-18 16:45:13 +08:00
Michael Edwards
242d296082 Idiomatic Rust returns for Error conversions (#2812)
* Idiomatic Rust returns for Error conversions

* Regenerate Rust samples
2019-06-14 09:26:36 +01:00
sunn
a864ae90de Add API timeout handling (#3078) 2019-06-12 20:16:12 +02:00
Thibault Duperron
314f18a2c1 Import inner items for map (#3123)
fix #3094
2019-06-09 11:56:22 +08:00
William Cheng
d86f3edc73 update core team in pom.xml (#3126) 2019-06-09 11:48:13 +08:00
Jim Schubert
ab9facd905 [gradle] Document consuming via gradle plugin portal (#3125) 2019-06-08 14:20:48 -04:00
Akihito Nakano
2a5a272300 Bump up babel-cli version to fix security alert (#3121)
* Bump up babel version

* Update samples

bin/javascript-flowtyped-petstore.sh

* The dependency `babel-preset-react-app` requires `NODE_ENV` or `BABEL_ENV`

* Run `env BABEL_ENV=development npm run build` to update the samples
2019-06-08 22:12:13 +08:00
sunn
6c98046ee6 [C++] [cpprestsdk] Add examples and test for cpprestsdk (#3109)
Add examples and test for cpprestsdk
2019-06-07 23:37:49 +02:00
Gabriel Féron
3df525ee33 Add enum support to rust and skip none option serialization in clients (#2244)
* Add support for enum schemas and properties to the rust generator

Also:
* Skip serializing a field with serde if it's optional and empty
* Fix borrow checker error when using &std::path::Path (should be std::path::PathBuf)
* Add script to generate sample with rust-reqwest
* Regenerate petstore sample for both rust targets
* Remove go code from README.md

* Fix formatting of serde skip_serializing_if attribute
2019-06-07 17:28:43 +01:00
Jim Schubert
c2f5038d75 Add/update new core team member: etherealjoy (#3116) 2019-06-06 15:36:00 -04:00
Jim Schubert
5de7f09ae9 Gradle sample on travis (#3114)
* Explicitly ignore .bak in gradle samples directory

* Add gradle wrapper to local-spec sample, make .java-version (jenv local) be less machine specific

* Include gradle plugin samples in travis build
2019-06-06 15:09:26 -04:00
Ken Rosaka
cd85210835 [typescript-fetch] add bearer token support (#3097)
* [typescript-fetch] added Bearer token support

* [typescript-fetch] executed ./bin/openapi3/typescript-fetch-petstore-all.sh

* [typescript-fetch] executed ./bin/typescript-fetch-petstore-all.sh
2019-06-06 16:58:31 +02:00
sunn
6660b74247 Add Q_DECLARE_METATYPE to the generated models and remove ref in signals (#3091) 2019-06-06 16:13:11 +02:00
William Cheng
19f47d0caa [Java][okhttp-gson] Update dependencies (#3103)
* update java client depedency to the latest version

* update java samples
2019-06-06 13:32:58 +08:00
Thibault Duperron
146c1fb255 Link query parameter to model object (#2710)
* Link query parameter to model object

Must fix #2655

* Fix import
2019-06-05 14:42:15 -04:00
Adi Gerber
0d701b7ce9 scala-play-server: fix enum names for reserved words (#3080) 2019-06-05 14:26:22 -04:00
William Cheng
e68426fda9 Add @sunn to openapi generator core team (#3105) 2019-06-06 02:10:21 +08:00
William Cheng
86e53d6f0b fix NPE in go generator (#3104) 2019-06-06 01:57:16 +08:00
Adi Gerber
6379022c42 scala-play-server: fix API doc url (#3096) 2019-06-06 01:50:39 +08:00
Jérémie Bresson
ad06496887 [maven-plugin] fix strictSpec parameter without alias (#3095)
* Revert "[maven-plugin] fix strictSpec parameter (#3071)"

This reverts commit 8c9a1512ae.

* [maven-plugin] fix strictSpec parameter without alias
2019-06-05 08:21:51 -04:00
Chris Couzens
4e9d226443 Ruby: Avoid double escaping path items (#3093)
`URI.encode` is obsolete. `CGI.escape`, `URI.encode_www_form` or
`URI.encode_www_form_component` are recommended instead.
https://ruby-doc.org/stdlib-2.6/libdoc/uri/rdoc/URI/Escape.html#method-i-escape

URI.encode has different behaviour to CGI.escape:

```ruby
URI.encode('hello/world?test%string')
=> "hello/world?test%25string"
CGI.escape('hello/world?test%string')
=> "hello%2Fworld%3Ftest%25string"
```

I recently raised pull request #3039
201cbdce29

That pull request escapes path items at insertion.

Before either pull request, the path item 'hello?world' would go into
the URL as 'hello?world'. That behaviour was insecure as if an attacker
could control the path item value, they could change the URL the
application connected to.

After #3039 'hello?world' would go in as 'hello%253Fworld'. This was
safer than before, but it's still not correct.
If I'd realised at the time, I would have made it correct at the time.

What this pull request does is make it go in as 'hello%35world', which
is correct.

ApiClient::build_request_url was URI.encoding the whole path.
This wasn't protecting against all undesirable characters in the path
items, but was escaping % characters a 2nd time which was unhelpful.

I have additionally removed URI.encode from Configuration::base_url as I
can't see any benefit it could be bringing.
There is no justification for it in the commit where it was originally
added: 47c8597d36
2019-06-05 19:54:23 +09:00
Slavek Kabrda
66bf0dce9e [Golang][client] Allow generating go client code as a submodule. (#3012) 2019-06-05 17:47:46 +08:00
William Cheng
9f1b9386f1 [CI] Test maven plugin in Travis, move jobs from Shippable to Circle CI (#3087)
* test plugin in travis, move jobs to circle CI

* Revert "[maven-plugin] fix strictSpec parameter (#3071)"

This reverts commit 8c9a1512ae.

* Revert "Revert "[maven-plugin] fix strictSpec parameter (#3071)""

This reverts commit c3e5723c5a.

* test with jdk8
2019-06-05 00:07:15 +08:00
MBcom
dcf3f420f9 general support to add scopes for bearer auth too (#1984)
* general support to add scopes for bearer auth too
implemented authorize workflow in aspnet core too

* petstore update

* fix missing )

* multi roles fix

* null pointer error prevention

* null point exception fixes

* null pointer fixes

* npe fix

* solved line break issue
2019-06-04 23:03:15 +08:00
Sai Giridhar P
dc3543981e feat(java-jersey2): Making response headers case-insensitive (#3072)
* feat(java-jersey2): Making headers case-insensitive

* feat(java-jersey2): Updating documentation
2019-06-04 22:03:01 +08:00
Vincent Devos
57560d365f [KOTLIN Spring] fix generation with modelNamePrefix/Suffix (#3038)
* [KOTLIN Spring] fix generation with modelNamePrefix/modelNameSuffix

* fix indent

* fix indent

* fix indent

* fix indent

* fix indent

* fix indent
2019-06-04 21:57:43 +08:00
William Cheng
c6207c0a49 Mark nodejs-server as deprecated (#3083)
* mark nodejs-server as deprecated

* update opeanpi3 script

* add new file
2019-06-04 21:38:28 +08:00
Jérémie Bresson
89d0c01764 Use 4.0.2-SNAPSHOT version in gradle samples (#3085) 2019-06-04 06:54:25 -04:00
Jérémie Bresson
8c9a1512ae [maven-plugin] fix strictSpec parameter (#3071) 2019-06-03 22:43:19 +08:00
William Cheng
e06a408141 Update C# client dependency (#2678)
* update csharp dependency

* fix appveyor test

* skip build error

* update nunit version

* fix nunit path

* update petstore test

* various fix
2019-06-03 21:17:17 +08:00
Andrej Završnik
caac76c265 Kotlin-Spring template fixes/improvements (#3007)
* Fixed case where invalid comma is added to consumes/produces list in case last element is empty.

* Changed default HttpStatus.OK response to match first response code in definition.
Allowing also other responses 201, 202 ...

* Changed default HttpStatus.OK response to match first response code in definition.
Allowing also other responses 201, 202 ...

* run ./bin/kotlin-springboot-petstore-server.sh
Updated APIs
2019-06-03 20:48:40 +08:00
Sai Giridhar P
6ff0512b31 [Java][jersey2]: Documentation changes and making example snippet compilable (#3056)
* feat(java-jersey2): Adding http response headers and making example compilable

* feat(java-jersey2): Updating pet project

* feat(java-jersey2): Removing uncessary lines from Readme

* feat(java-jersey2): Updating pet projects

* feat(java-jersey2): Updating pet projects
2019-06-03 15:42:41 +08:00
Matthias Preu
1eca97f738 Fix wrong include path in api-header template (#3062)
Change local json.hpp include path to correct value.

Update samples.
2019-06-03 15:41:45 +08:00
Michael Cristina
8d9eb5ba54 refactor(golang): Use http provided constants for http methods (#3028)
* refactor(golang): Use http constants for methods

* regenerate samples

* fix: Only import strings when needed

* regenerate samples

* Only import fmt and strings when needed

* regenerate samples
2019-06-03 15:41:21 +08:00
Sai Giridhar P
6b7c5edbce feat(java-okhttpgson): Making API response headers case insensitive (#3029)
* feat(java-okhttpgson): Making API response headers case insensitive

* feat(java-okhttpgson): Adding documentation

* feat(java-okhttpgson): Removing tabs

* feat(java-okhttpgson): Removing tabs
2019-06-03 15:40:22 +08:00
Fabrizio Ferrai
b5121745a8 [JavaScript] Remove default parameters syntax, as it's an ES6 feature (#2848)
* Remove default parameters in JS client, as it's an ES6 feature

* update js petstore samples
2019-06-03 15:38:30 +08:00
Sai Giridhar P
25dce23d81 fix(java-jersey2): Fixing javadocs warnings (#3040)
* edit fix(java-jersey2): Fixing javadocs warnings

* fix(java-jersey): Updating pet project
2019-06-03 15:37:55 +08:00
William Cheng
ded0bd6801 Update CI badges to 4.1.x (#3069)
Update CI badges to 4.1.x
2019-06-03 11:41:38 +08:00
Jim Schubert
740325f885 Updates sample generated content (#3068)
Generates samples to match with code introduced in #2934.
2019-06-02 19:35:49 -04:00
sylvainmoindron
7916f2f880 [kotlin-spring] add reactive behavior via Kotlin coroutines (#2934)
* kotlin spring : add reactivity via kotlin's coroutines

* add kotlin spring boot reactive samples

* bug : fix spring version and import for coroutines

* remove exception handler for reactive (webflux doesn't support it)

* add spring milestone repository to maven pom

* add reactive type for list in Api and ApiImpl methodes for mathching body responsive parameter

* fix baseType for ArraySchema

* regenerate samples

* updating documentation
2019-06-02 15:50:45 -04:00
William Cheng
b74fa4458d Update compatibility table
Update compatibility table
2019-06-03 00:03:16 +08:00
Chris Couzens
522a1a2372 Ruby client: escape path parameters (#3039)
* Ruby client: escape path parameters

Path parameters should be escaped when encoded into the path.

In the path '/pet/{petId}' let's pretend petId is a string instead of a
number.

If the user uses "Bobby" as the petId then they correctly get the path
'/pet/Bobby'.
But if they put 'Bobby/Tables' as the petId then they used to get the
path '/pet/Bobby/Tables' which will be interpreted by the server as a
different route.

Using CGI::Escape they now get '/pet/Bobby%2FTables' which is correct.

* Ruby client- regenerate further files

Thank you @autopp for noticing I needed to update
`samples/openapi3/client/petstore/ruby`.

Regenerated by running `bin/openapi3/ruby-client-petstore.sh`.

PR #3039
2019-06-03 00:24:30 +09:00
Jim Schubert
f667effa76 [gradle plugin] Release 4.0.1 fixes (#3051)
Fixes issues found during the 4.0.1 release
2019-06-01 23:36:17 -04:00
Jérémie Bresson
dc81574f2b Update version to 4.0.2-SNAPSHOT (#3047)
* Update version to 4.0.2-SNAPSHOT

* Update samples

* Change AppVeyor script (test of gradle sample)

* Fix release version bump script (gradle plugin, sample poms)

* Include sonatype snapshots in maven examples which reference 4.0.2-SNAPSHOT
2019-06-01 21:32:44 -04:00
sunn
7ecc99192d Map number to double time since float is also parsed as double in Qt5 C++ (#3046) 2019-05-31 19:23:07 +02:00
2581 changed files with 77084 additions and 18346 deletions

View File

@@ -28,7 +28,7 @@ WORKDIR ${TARGET_DIR}
COPY --from=builder ${GEN_DIR}/modules/openapi-generator-online/target/openapi-generator-online.jar ${TARGET_DIR}/openapi-generator-online.jar
ENV GENERATOR_HOST=http://localhost
ENV GENERATOR_HOST=""
EXPOSE 8080

View File

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

View File

@@ -131,6 +131,12 @@ script:
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
- mvn --quiet --batch-mode --show-version clean install
- mvn --quiet --batch-mode --show-version verify -Psamples
# test maven plugin
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml
- mvn clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
# test gradle plugin
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk)
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)
after_success:
# push to maven repo
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
@@ -140,7 +146,7 @@ after_success:
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishMavenJavaPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository";
popd;
elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then

View File

@@ -12,6 +12,16 @@ if [ "$NODE_INDEX" = "1" ]; then
#cp CI/pom.xml.circleci pom.xml
java -version
mvn --quiet verify -Psamples.circleci
mvn --quiet javadoc:javadoc -Psamples.circleci
# generate all petstore samples (client, servers, doc)
./bin/run-all-petstore
# generate all petstore samples (openapi3)
./bin/openapi3/run-all-petstore
# generate test scripts
./bin/tests/run-all-test
# test all generators with fake petstore spec (2.0, 3.0)
./bin/utils/test-fake-petstore-for-all.sh
elif [ "$NODE_INDEX" = "2" ]; then
# run ensure-up-to-date sample script on SNAPSHOT version only
project_version=`mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout`

View File

@@ -47,16 +47,16 @@ OpenAPI spec version: 1.0.0
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" />
<Reference Include="Newtonsoft.Json">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.5.2\lib\net45\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
@@ -65,10 +65,10 @@ OpenAPI spec version: 1.0.0
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@@ -31,6 +31,8 @@ Please file the pull request against the correct branch, e.g. `master` for non-b
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
### Templates
All the templates ([mustache](https://mustache.github.io/)) can be found in [modules/openapi-generator/src/main/resources](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources).

View File

@@ -2,15 +2,15 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.0.1`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.0.3`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![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)
[`4.1.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/4.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/4.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=4.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=4.0.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
[`4.1.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.1.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/4.1.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/4.1.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=4.1.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=4.1.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
[`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)
@@ -97,10 +97,10 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
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.2019 | Major release with breaking changes (no fallback)
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/)| 15.07.2019 | Minor release (breaking changes with fallbacks)
4.0.1 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.1-SNAPSHOT/)| 31.05.2019 | Patch release (minor bug fixes, etc)
[4.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.1) (latest stable release) | 31.05.2019 | Patch release (bug fixes, minor enhancements, etc)
4.0.3 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.3-SNAPSHOT/)| 04.07.2019 | Patch release (minor bug fixes, etc)
[4.0.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.2) (latest stable release) | 20.06.2019 | Patch release (bug fixes, minor enhancements, etc)
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
@@ -153,19 +153,19 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
* [Readme](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc)
### [1.3 - Download JAR](#table-of-contents)
<!-- 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.1/openapi-generator-cli-4.0.1.jar`
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.2/openapi-generator-cli-4.0.2.jar`
For **Mac/Linux** users:
```sh
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.1/openapi-generator-cli-4.0.1.jar -O openapi-generator-cli.jar
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.2/openapi-generator-cli-4.0.2.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.1/openapi-generator-cli-4.0.1.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.2/openapi-generator-cli-4.0.2.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@@ -175,7 +175,7 @@ For Mac users, please make sure Java 8 is installed (Tips: run `java -version` t
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
export PATH=${JAVA_HOME}/bin:$PATH
```
<!-- /RELEASE_VERSION -->
### Launcher Script
One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at [bin/utils/openapi-generator.cli.sh](./bin/utils/openapi-generator-cli.sh) which resolves this issue.
@@ -281,7 +281,7 @@ Example usage:
```sh
# Start container at port 8888 and save the container id
> CID=$(docker run -d -p 8888:8080 -e GENERATOR_HOST=http://localhost:8888 openapitools/openapi-generator-online)
> CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online)
# allow for startup
> sleep 10
@@ -368,10 +368,11 @@ npm install @openapitools/openapi-generator-cli -g
openapi-generator version
```
Or install a particualar OpenAPI Generator version (e.g. v4.0.1):
<!-- RELEASE_VERSION -->
Or install a particular OpenAPI Generator version (e.g. v4.0.2):
```sh
npm install @openapitools/openapi-generator-cli@cli-4.0.1 -g
npm install @openapitools/openapi-generator-cli@cli-4.0.2 -g
```
Or install it as dev-dependency:
@@ -379,7 +380,7 @@ Or install it as dev-dependency:
```sh
npm install @openapitools/openapi-generator-cli -D
```
<!-- /RELEASE_VERSION -->
## [2 - Getting Started](#table-of-contents)
To generate a PHP client for [petstore.yaml](https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml), please run the following
@@ -394,7 +395,9 @@ 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`)
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.1/openapi-generator-cli-4.0.1.jar)
<!-- 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.2/openapi-generator-cli-4.0.2.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`
@@ -535,7 +538,9 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [Camptocamp](https://www.camptocamp.com/en)
- [codecentric AG](https://www.codecentric.de/)
- [Cupix](https://www.cupix.com/)
- [DB Systel](https://www.dbsystel.de)
- [FormAPI](https://formapi.io/)
- [Fuse](https://www.fuse.no/)
- [GenFlow](https://github.com/RepreZen/GenFlow)
- [GMO Pepabo](https://pepabo.com/en/)
- [GoDaddy](https://godaddy.com)
@@ -590,7 +595,9 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019-05-01 - [Design and generate a REST API from Swagger / OpenAPI in Java, Python, C# and more](https://simply-how.com/design-and-generate-api-code-from-openapi) by [Simply How](https://simply-how.com/)
- 2019-05-17 - [Generate Spring Boot REST API using Swagger/OpenAPI](https://www.47northlabs.com/knowledge-base/generate-spring-boot-rest-api-using-swagger-openapi/) by [Antonie Zafirov](https://www.47northlabs.com/author/antonie-zafirov/)
- 2019-05-22 - [REST APIs代码生成指南(OpenAPI Generator)](https://gum.co/openapi_generator_ebook_gb) by [William Cheng](https://twitter.com/wing328), [Xin Meng](https://github.com/xmeng1)
- 2019-05/24 - [REST API 代碼生成指南 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328)
- 2019-05-24 - [REST API 代碼生成指南 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328)
- 2019-06-24 - [Kubernetes Clients and OpenAPI Generator](https://speakerdeck.com/wing328/kubernetes-clients-and-openapi-generator) by [William Cheng](https://twitter.com/wing328) at [Kubernetes Contributor Summits Shanghai 2019](https://www.lfasiallc.com/events/contributors-summit-china-2019/)
- 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)
## [6 - About Us](#table-of-contents)
@@ -603,7 +610,8 @@ OpenAPI Generator core team members are contributors who have been making signif
* [@jimschubert](https://github.com/jimschubert) (2016/05) [:heart:](https://www.patreon.com/jimschubert)
* [@cbornet](https://github.com/cbornet) (2016/05)
* [@ackintosh](https://github.com/ackintosh) (2018/02) [:heart:](https://www.patreon.com/ackintosh/overview)
* [@jmini](https://github.com/jmini) (2018/04)
* [@jmini](https://github.com/jmini) (2018/04) [:heart:](https://www.patreon.com/jmini)
* [@etherealjoy](https://github.com/etherealjoy) (2019/06)
:heart: = Link to support the contributor directly
@@ -675,7 +683,8 @@ Here is a list of template creators:
* TypeScript (Inversify): @gualtierim
* Server Stubs
* Ada: @stcarrez
* C# ASP.NET5: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* C# ASP.NET 5: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* C# ASP.NET Core 3.0: @A-Joshi
* C# NancyFX: @mstefaniuk
* C++ (Qt5 QHttpEngine): @etherealjoy
* C++ Pistache: @sebymiano
@@ -774,11 +783,11 @@ 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 | |
| Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) |
| 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 | |
| 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) |
| Scala | @clasnake (2017/07), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @shijinkui (2018/01), @ramzimaalej (2018/03) |
@@ -811,7 +820,7 @@ OpenAPI Generator is a fork of [Swagger Codegen](https://github.com/swagger-api/
- [Jean-François Côté](https://github.com/JFCote)
- [Jim Schubert](https://github.com/jimschubert)
- [Jon Schoning](https://github.com/jonschoning)
- [Jérémie Bresson](https://github.com/jmini)
- [Jérémie Bresson](https://github.com/jmini) [:heart:](https://www.patreon.com/jmini)
- [Jörn Ahrens](https://github.com/jayearn)
- [Keni Steward](https://github.com/kenisteward)
- [Marcin Stefaniuk](https://github.com/mstefaniuk)

View File

@@ -30,7 +30,6 @@ install:
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
- cmd: java -version
- cmd: gradle -v
- cmd: gradle -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --info
- cmd: dir/w
- git clone https://github.com/wing328/swagger-samples
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
@@ -50,6 +49,8 @@ build_script:
- msbuild samples\client\petstore\csharp\OpenAPIClientNetStandard\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
# install openapi-generator locally
- mvn clean install --quiet
# run the locally installed openapi-generator-gradle-plugin
- gradle -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --info
test_script:
# restore test-related files
- copy /b/v/y CI\samples.ci\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
@@ -57,9 +58,9 @@ test_script:
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClientCore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client
- nunit-console samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
- nunit3-console samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
# test c# API client (with PropertyChanged)
- nunit-console samples\client\petstore\csharp\OpenAPIClientWithPropertyChanged\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
- nunit3-console samples\client\petstore\csharp\OpenAPIClientWithPropertyChanged\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
# generate all petstore clients
- .\bin\windows\run-all-petstore.cmd

View File

@@ -27,6 +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/cpp-rest-sdk-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-restsdk -o samples/client/petstore/cpp-restsdk $@"
ags="generate -t modules/openapi-generator/src/main/resources/cpp-rest-sdk-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-restsdk -o samples/client/petstore/cpp-restsdk/client $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -32,6 +32,6 @@ ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-with-
java $JAVA_OPTS -jar $executable $ags
# restore csproj file
echo "restore csproject file: CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj"
echo "restore csproject file: CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj"
cp ./CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj ./samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/

39
bin/go-experimental-petstore.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/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
SPEC="modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml"
GENERATOR="go-experimental"
STUB_DIR="samples/client/petstore/go-experimental/go-petstore"
echo "Removing files and folders under $STUB_DIR"
rm -rf $STUB_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,4 @@
#!/bin/sh
./bin/kotlin-springboot-petstore-server.sh
./bin/kotlin-springboot-petstore-server-reactive.sh

View File

@@ -0,0 +1,35 @@
#!/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
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/petstore/kotlin-springboot-reactive --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,reactive=true"
echo "Cleaning previously generated files if any from samples/server/petstore/kotlin-springboot-reactive"
rm -rf samples/server/petstore/kotlin-springboot-reactive
echo "Generating Kotling Spring Boot reactive server..."
java $JAVA_OPTS -jar $executable $ags

View File

@@ -27,6 +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 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -27,6 +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/nodejs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server -o samples/server/petstore/nodejs -Dservice $@"
ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,39 @@
#!/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
SPEC="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml"
GENERATOR="go-experimental"
STUB_DIR="samples/openapi3/client/petstore/go-experimental/go-petstore"
echo "Removing files and folders under $STUB_DIR"
rm -rf $STUB_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,4 @@
#!/bin/sh
./bin/openapi3/kotlin-springboot-petstore-server.sh
./bin/openapi3/kotlin-springboot-petstore-server-reactive.sh

View File

@@ -0,0 +1,35 @@
#!/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
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot-reactive --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,reactive=true"
echo "Cleaning previously generated files if any from samples/server/openapi3/petstore/kotlin-springboot-reactive"
rm -rf samples/server/openapi3/petstore/kotlin-springboot-reactive
echo "Generating Kotling Spring Boot server..."
java $JAVA_OPTS -jar $executable $ags

View File

@@ -26,7 +26,7 @@ then
fi
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/openapi3/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
echo "Cleaning previously generated files if any from samples/server/openapi3/petstore/kotlin-springboot"
rm -rf samples/server/openapi3/petstore/kotlin-springboot

View File

@@ -27,6 +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 -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -27,6 +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/nodejs -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server -o samples/server/petstore/nodejs -Dservice $@"
ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -26,7 +26,7 @@ then
fi
input=modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
out_folder=samples/server/openapi3/petstore/php-ze-ph
out_folder=samples/openapi3/server/petstore/php-ze-ph
resources=modules/openapi-generator/src/main/resources/php-ze-ph
# if you've executed sbt assembly previously it will use that instead.

View File

@@ -27,7 +27,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
input=modules/openapi-generator/src/test/resources/3_0/petstore.yaml
out_folder=samples/server/openapi3/petstore/python-flask-python2
out_folder=samples/openapi3/server/petstore/python-flask-python2
resources=modules/openapi-generator/src/main/resources/python-flask
# if you've executed sbt assembly previously it will use that instead.

View File

@@ -27,7 +27,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
input=modules/openapi-generator/src/test/resources/3_0/petstore.yaml
out_folder=samples/server/openapi3/petstore/python-flask
out_folder=samples/openapi3/server/petstore/python-flask
resources=modules/openapi-generator/src/main/resources/python-flask
# if you've executed sbt assembly previously it will use that instead.

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} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/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

@@ -25,6 +25,7 @@ declare -a scripts=(
"./bin/kotlin-client-threetenbp.sh"
"./bin/kotlin-server-petstore.sh"
"./bin/kotlin-springboot-petstore-server.sh"
"./bin/kotlin-springboot-petstore-server-reactive.sh"
"./bin/mysql-schema-petstore.sh"
"./bin/python-petstore-all.sh"
"./bin/openapi3/python-petstore.sh"
@@ -51,9 +52,11 @@ declare -a scripts=(
"./bin/csharp-netcore-petstore-all.sh"
"./bin/elixir-petstore.sh"
"./bin/go-petstore.sh"
"./bin/go-petstore-withxml.sh"
"./bin/go-gin-petstore-server.sh"
"./bin/groovy-petstore.sh"
"./bin/apex-petstore.sh"
"./bin/perl-petstore-all.sh"
#"./bin/elm-petstore-all.sh"
"./bin/meta-codegen.sh"
# OTHERS

221
bin/utils/release/bump.sh Executable file
View File

@@ -0,0 +1,221 @@
#!/usr/bin/env bash
#
# This script bumps from one version to another
#
# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
declare -r version_regex="([0-9]+).([0-9]+).([0-9]+)-?(SNAPSHOT){0,1}"
declare start="<!-- RELEASE_VERSION -->"
declare end="<!-- \/RELEASE_VERSION -->"
declare from="${version_regex}"
declare to=""
declare debug=${debug:-false}
declare -a from_parts=()
declare -a to_parts=()
declare -ar inc=(major minor build snapshot)
USAGE="
USAGE: $0 OPTIONS input_file
This script will bump a version number (or other value) between marker tags.
OPTIONS:
-f The 'from' version
-t The 'to' version
-s The start tag regex
default: $start
-e The end tag regex
default: $end
-i Increase by one of: ${inc[@]}
-h Print this message
EXAMPLES:
Update to next snapshot version:
$0 -f 3.0.0 -t 3.0.1-SNAPSHOT pom.xml
Update build version only (useful for docs)
$0 -f 3.0.0 -t 3.0.1 pom.xml
Update from any version to any other version
$0 -f 1.2.3 -t 9.9.9-SNAPSHOT pom.xml
Customize the start/end tags
$0 -f 1.0.0 1.0.1-SNAPSHOT -s \"<!-- START -->\" -e \"<!-- END -->\" pom.xml
"
## print an error message and exit
err() {
>&2 echo -e "$1"
exit 1
}
## debug log messages. Run with debug=true ./bump.sh
d() {
if [[ true = "${debug}" ]]; then
echo "$1"
fi
}
## outputs usage and exits
usage()
{
err "${USAGE}"
exit 1
}
## usage: version input extracted_array
## - Checks that 'input' is a valid version
## - Extracts the version parts into 'extracted_array'
version()
{
if [[ "$#" -ne 2 ]]; then
err "Call function version with two parameters: version string arr"
fi
local v=$1
if [[ "${v}" =~ $version_regex ]]; then
local major=${BASH_REMATCH[1]}
local minor=${BASH_REMATCH[2]}
local build=${BASH_REMATCH[3]}
local snapshot=false
if [[ "SNAPSHOT" = "${BASH_REMATCH[4]}" ]]; then
snapshot=true
fi
d "major=$major minor=$minor build=$build snapshot=$snapshot"
eval "$2=(${major} ${minor} ${build} ${snapshot})"
else
err "Invalid version: $v"
fi
}
while getopts "hf:t:s:e:i:" OPTION
do
case ${OPTION} in
f)
from=${OPTARG}
;;
t)
to=${OPTARG}
;;
s)
start=${OPTARG}
;;
e)
end=${OPTARG}
;;
i)
increase=${OPTARG}
if [[ ! "${inc[@]}" =~ ${increase} ]];then
err "Only support increasing by one of: ${inc[@]}"
fi
;;
h)
usage
;;
esac
done
shift $((OPTIND-1))
file=( "$@" )
if [[ ${#file[@]} -eq 0 ]];then
echo "No file specified" >&2
usage
fi
if [[ -z "${from}" ]]; then
echo "No 'from' version specified." >&2
usage
fi
# TODO: compare steps in from_parts and to_parts.
version "${from}" from_parts
if [[ -z "${to}" ]]; then
if [[ -z "${increase}" ]]; then
err "No 'to' version specified."
else
case ${increase} in
major)
to="$(( ${from_parts[0]} + 1 )).0.0"
version "$to" to_parts
;;
minor)
to="${from_parts[0]}.$(( ${from_parts[1]} + 1 )).0"
version "$to" to_parts
;;
build)
to="${from_parts[0]}.${from_parts[1]}.$(( ${from_parts[2]} + 1 ))"
version "$to" to_parts
;;
snapshot)
if [[ true = ${from_parts[3]} ]]; then
err "Can't move from SNAPSHOT to SNAPSHOT (from=${from})."
else
to="${from_parts[0]}.${from_parts[1]}.$(( ${from_parts[2]} + 1 ))-SNAPSHOT"
version "$to" to_parts
fi
;;
esac
fi
else
version "${to}" to_parts
fi
if [[ ${from_parts[3]} = true && ${to_parts[3]} = true ]]; then
err "Moving from SNAPSHOT to SNAPSHOT is not supported."
fi
cat <<EOF > sedscript.sed
/${start}/,/${end}/{
s/${from}/${to}/g
}
EOF
d "Moving from=${from} to=${to}"
trap 'rm -f sedscript.sed' EXIT
sed_cross() {
# Cross-platform sed invocation. OSX has no option to show a version number in sed.
local target=$1
sed --version >/dev/null 2>&1 && sed -e -i '' -f sedscript.sed "$target" || sed -i '' -E -f sedscript.sed "$target"
}
update_file() {
local filename=$1
local error_message="ERROR: Failed to update $filename to target version ${to}"
local original_hash=$(ruby -r digest -e "p Digest::SHA2.file(\"$filename\").hexdigest")
local final_hash=""
if ! sed_cross ${filename}; then
# occurs if, for example, the file doesn't exist.
echo "ERROR: Failed to update $filename to target version ${to}" >&2
fi
local final_hash=$(ruby -r digest -e "p Digest::SHA2.file(\"$filename\").hexdigest")
if [[ "${original_hash}" = "${final_hash}" ]]; then
# occurs if, for example, the file doesn't have expected marker tags for replacement
echo "ERROR: $filename was not modified." >&2
else
echo "Updated $filename successfully!"
fi
}
for filename in "${file[@]}"; do
update_file ${filename}
done

View File

@@ -0,0 +1,96 @@
#!/usr/bin/env bash
#
# This script is used to update files to the "latest" version.
#
# usage: ./bin/utils/release_version_update.sh <from> <to>
# example: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1
#
# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
declare cwd=$(cd $(dirname "${BASH_SOURCE}") && pwd)
declare root=$(cd "$cwd" && cd ../../../ && pwd)
USAGE="
USAGE: $0 target
This script will convert the current version in target files to the specified 'target'
where target is one of:
major
minor
build
snapshot
EXAMPLES:
Update to new snapshot (1.0.0 -> 1.0.1-SNAPSHOT):
$0 snapshot
Update build version (1.0.0 -> 1.0.1)
$0 build
Update minor version (1.2.3 -> 1.3.0)
$0 minor
Update major version (1.2.3 -> 2.0.0)
$0 major
"
version=$(ruby -r rexml/document -e 'include REXML;
p XPath.first(Document.new($stdin), "/project/version/text()")' < ${cwd}/../../../pom.xml | tr -d '"')
if [[ -n "$1" ]]; then
case $1 in
--help|-h)
echo -e "$USAGE" >&2
exit 1
;;
major|minor|build|snapshot)
inc="$1"
;;
*)
echo "Invalid target.Must be one of: major minor build or snapshot" >&2
exit 1
;;
esac
else
inc="snapshot"
fi
echo "Release preparation: Moving from $version to next $inc version."
# These files should wrap target version replacement blocks with <!-- RELEASE_VERSION --> and <!-- /RELEASE_VERSION -->
# We can include xml and md files here.
declare -a xml_files=(
"${root}/modules/openapi-generator-cli/pom.xml"
"${root}/modules/openapi-generator-gradle-plugin/pom.xml"
"${root}/modules/openapi-generator-core/pom.xml"
"${root}/modules/openapi-generator-maven-plugin/pom.xml"
"${root}/modules/openapi-generator-online/pom.xml"
"${root}/modules/openapi-generator/pom.xml"
"${root}/modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml"
"${root}/modules/openapi-generator-maven-plugin/examples/java-client.xml"
"${root}/modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
"${root}/modules/openapi-generator-maven-plugin/examples/non-java.xml"
"${root}/samples/meta-codegen/lib/pom.xml"
"${root}/pom.xml"
)
# These files should wrap target version replacement blocks with # RELEASE_VERSION and # /RELEASE_VERSION
declare -a properties_files=(
"${root}/modules/openapi-generator-gradle-plugin/gradle.properties"
"${root}/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties"
)
${cwd}/bump.sh -f ${version} -i ${inc} ${xml_files[@]}
${cwd}/bump.sh -f ${version} -t ${inc} -s '# RELEASE_VERSION' -e '# \/RELEASE_VERSION' ${properties_files[@]}

View File

@@ -0,0 +1,115 @@
#!/usr/bin/env bash
#
# This script is used to update reference files to the "next" version.
#
# usage: ./bin/utils/release_version_update.sh <from> <to>
# example: ./bin/utils/release_version_update.sh 3.0.1 3.0.2
#
# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
declare cwd=$(cd $(dirname "${BASH_SOURCE}") && pwd)
declare root=$(cd "$cwd" && cd ../../../ && pwd)
USAGE="
USAGE: $0 version target
This script will convert the specified version in DOC target files to the 'target'
where target is one of:
major
minor
build
or an explicitly defined version number.
NOTE:
Files prepped by this script should never target SNAPSHOT, as the docs should refer to release artifacts.
If intending to update to/from snapshots, please add target files to release_version_update.sh instead.
EXAMPLES:
Update build version (1.0.0 -> 1.0.1)
$0 1.0.0 build
Update minor version (1.2.3 -> 1.3.0)
$0 1.2.3 minor
Update major version (1.2.3 -> 2.0.0)
$0 1.2.3 major
"
declare version=$(ruby -r rexml/document -e 'include REXML;
p XPath.first(Document.new($stdin), "/project/version/text()")' < ${cwd}/../../../pom.xml | tr -d '"')
declare target="${2:-build}"
declare inc=""
declare next_version=""
declare ags=""
if [[ -z "$1" ]]; then
echo "Missing argument." >&2
echo -e "$USAGE" >&2
exit 1
fi
# Get version number we're changing
case $1 in
--help|-h)
echo -e "$USAGE" >&2
exit 1
;;
*)
version="$1"
;;
esac
# Get the target…
case ${target} in
major|minor|build)
inc="$target"
;;
snapshot)
echo -e "Files prepped by this script should never target SNAPSHOT, as the docs should refer to release artifacts.
If intending to update to/from snapshots, please add target files to release_version_update.sh instead.
" >&2
exit 1
;;
*)
next_version="$target"
;;
esac
ags="-f ${version}"
if [[ -n "${next_version}" ]];then
echo "Release preparation: Moving from $version to ${next_version}."
ags="$ags -t ${next_version}"
else
echo "Release preparation: Moving from $version to next $inc version."
ags="$ags -i ${inc}"
fi
declare -a xml_files=(
"${root}/modules/openapi-generator-maven-plugin/README.md"
"${root}/modules/openapi-generator-gradle-plugin/samples/local-spec/README.md"
"${root}/README.md"
)
declare -a commented_files=(
"${root}/modules/openapi-generator-gradle-plugin/README.adoc"
)
${cwd}/bump.sh ${ags} ${xml_files[@]}
${cwd}/bump.sh ${ags} -s '# RELEASE_VERSION' -e '# \/RELEASE_VERSION' ${commented_files[@]}

View File

@@ -0,0 +1,17 @@
This is a test simple:
<!-- RELEASE_VERSION -->3.0.1<!-- /RELEASE_VERSION -->
Testing with other data:
<!-- RELEASE_VERSION -->
Version 1.2.3
<!-- /RELEASE_VERSION -->
Testing with -SNAPSHOT data:
<!-- RELEASE_VERSION -->
Version 2.3.4-SNAPSHOT
<!-- /RELEASE_VERSION -->
Testing with a value not to be replaced:
<!-- RELEASE_VERSION -->
Version 3.2.2
<!-- /RELEASE_VERSION -->

View File

@@ -0,0 +1,17 @@
This is a test simple:
<!-- RELEASE_VERSION -->3.0.1<!-- /RELEASE_VERSION -->
Testing with other data:
<!-- RELEASE_VERSION -->
Version 1.2.3
<!-- /RELEASE_VERSION -->
Testing with -SNAPSHOT data:
<!-- RELEASE_VERSION -->
Version 2.3.4-SNAPSHOT
<!-- /RELEASE_VERSION -->
Testing with a value not to be replaced:
<!-- RELEASE_VERSION -->
Version 3.2.2
<!-- /RELEASE_VERSION -->

View File

@@ -40,7 +40,8 @@ end
def check_openapi_generator_online_docker
print "Checking openapi-generator-online docker ... "
url = "https://hub.docker.com/r/openapitools/openapi-generator-online/tags/"
url = "https://hub.docker.com/v2/repositories/openapitools/openapi-generator-online/tags/?page_size=25&page=1"
docker_tag = "v#{$version}"
open(url) do |f|
content = f.read
@@ -56,7 +57,7 @@ end
def check_openapi_generator_cli_docker
print "Checking openapi-generator-cli docker ... "
url = "https://hub.docker.com/r/openapitools/openapi-generator-cli/tags/"
url = "https://hub.docker.com/v2/repositories/openapitools/openapi-generator-cli/tags/?page_size=25&page=1"
docker_tag = "v#{$version}"
open(url) do |f|
content = f.read
@@ -202,6 +203,8 @@ $version = ARGV[0]
puts "Running checkout on OpenAPI Generator release #{$version}"
check_openapi_generator_online_docker
check_openapi_generator_cli_docker
check_npmjs
check_homebrew
check_openapi_generator_jar
@@ -211,5 +214,3 @@ check_openapi_generator_gradle_plugin_jar
check_openapi_generator_online_jar
check_openapi_generator_project_pom
check_readme
check_openapi_generator_online_docker
check_openapi_generator_cli_docker

View File

@@ -1,60 +0,0 @@
#!/bin/bash
#
# usage: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1
#
# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
if [[ "$1" != "" ]]; then
FROM="$1"
else
echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1"
exit 1;
fi
if [[ "$2" != "" ]]; then
TO="$2"
else
echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1"
exit 1;
fi
echo "Release preparation: replacing $FROM with $TO in different files"
declare -a files=("modules/openapi-generator-cli/pom.xml"
"modules/openapi-generator-gradle-plugin/gradle.properties"
"modules/openapi-generator-gradle-plugin/pom.xml"
"modules/openapi-generator-core/pom.xml"
"modules/openapi-generator-maven-plugin/pom.xml"
"modules/openapi-generator-online/pom.xml"
"modules/openapi-generator/pom.xml"
"samples/meta-codegen/lib/pom.xml"
"pom.xml")
sedi () {
# Cross-platform version of sed -i that works both on Mac and Linux
sed --version >/dev/null 2>&1 && sed -i -e "$@" || sed -i "" "$@"
}
for filename in "${files[@]}"; do
# e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash
#echo "Running command: sed -i '' "s/$FROM/$TO/g" $filename"
if sedi "s/>$FROM</>$TO</g" $filename; then
echo "Updated $filename successfully!"
else
echo "ERROR: Failed to update $filename with the following command"
echo "sed -i '' \"s/$FROM/$TO/g\" $filename"
fi
done

View File

@@ -34,12 +34,13 @@ fi
echo "Release preparation: replacing $FROM with $TO in different files"
declare -a files=("modules/openapi-generator-maven-plugin/README.md"
"modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml"
"modules/openapi-generator-maven-plugin/examples/java-client.xml"
"modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
"modules/openapi-generator-maven-plugin/examples/non-java.xml"
"modules/openapi-generator-gradle-plugin/README.adoc"
"modules/openapi-generator-gradle-plugin/gradle.properties"
"modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties"
"modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle"
"modules/openapi-generator-gradle-plugin/samples/local-spec/README.md"
"README.md")

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
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 android -o samples\client\petstore\android\httpclient-Dlibrary=httpclient
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient -Dlibrary=httpclient
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
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 cpp-restsdk -o samples\client\petstore\cpp-restsdk
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g cpp-restsdk -o samples\client\petstore\cpp-restsdk\client
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -0,0 +1,21 @@
setlocal
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
set SPEC=modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml
set GENERATOR=go-experimental
set STUB_DIR=samples\client\petstore\go-experimental\go-petstore
echo Removing files and folders under %STUB_DIR%
del /F /S /Q %STUB_DIR%
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% -DpackageName=petstore
java %JAVA_OPTS% -jar %executable% %ags%
endlocal

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g kotlin-spring -o samples\server\openapi3\petstore\kotlin-springboot --additional-properties=library=spring-boot
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g kotlin-spring -o samples\openapi3\server\petstore\kotlin-springboot --additional-properties=library=spring-boot
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
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 r -o samples\client\petstore\R
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g r -o samples\client\petstore\R --additional-properties packageName=petstore,returnExceptionOnFailure=false,exceptionPackage=default
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -35,6 +35,8 @@ Please file the pull request against the correct branch, e.g. `master` for non-b
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
### Templates
All the templates ([mustache](https://mustache.github.io/)) can be found in [modules/openapi-generator/src/main/resources](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources).

View File

@@ -248,7 +248,7 @@ CONFIG OPTIONS
retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)
retrofit2 - HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2)
google-api-client - HTTP client: google-api-client 1.23.0. JSON processing: Jackson 2.8.9
rest-assured - HTTP client: rest-assured : 3.3.0. JSON processing: Gson 2.8.5. Only for Java8
rest-assured - HTTP client: rest-assured : 4.0.0. JSON processing: Gson 2.8.5. Only for Java8
```
Your config file for Java can look like

View File

@@ -27,6 +27,7 @@ The following generators are available:
- [erlang-proper](generators/erlang-proper.md)
- [flash](generators/flash.md)
- [go](generators/go.md)
- [go-experimental](generators/go-experimental.md)
- [groovy](generators/groovy.md)
- [haskell-http-client](generators/haskell-http-client.md)
- [java](generators/java.md)
@@ -42,6 +43,7 @@ The following generators are available:
- [php](generators/php.md)
- [powershell](generators/powershell.md)
- [python](generators/python.md)
- [python-experimental](generators/python-experimental.md)
- [r](generators/r.md)
- [ruby](generators/ruby.md)
- [rust](generators/rust.md)
@@ -91,7 +93,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-server](generators/nodejs-server.md)
- [nodejs-server-deprecated](generators/nodejs-server-deprecated.md) (deprecated)
- [php-laravel](generators/php-laravel.md)
- [php-lumen](generators/php-lumen.md)
- [php-silex](generators/php-silex.md)

View File

@@ -16,14 +16,19 @@ sidebar_label: aspnetcore
|packageVersion|C# package version.| |1.0.0|
|packageGuid|The GUID that will be associated with the C# project| |null|
|sourceFolder|source folder for generated code| |src|
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_1|
|aspnetCoreVersion|ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)| |2.2|
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_2|
|aspnetCoreVersion|ASP.NET Core version: 3.0 (preview4 only), 2.2, 2.1, 2.0 (deprecated)| |2.2|
|swashbuckleVersion|Swashbucke version: 3.0.0, 4.0.0| |3.0.0|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useCollection|Deserialize array types to Collection&lt;T&gt; instead of List&lt;T&gt;.| |false|
|returnICollection|Return ICollection&lt;T&gt; instead of the concrete type.| |false|
|useSwashbuckle|Uses the Swashbuckle.AspNetCore NuGet package for documentation.| |true|
|isLibrary|Is the build a library| |false|
|useFrameworkReference|Use frameworkReference for ASP.NET Core 3.0+ and PackageReference ASP.NET Core 2.2 or earlier.| |false|
|useNewtonsoft|Uses the Newtonsoft JSON library.| |true|
|newtonsoftVersion|Version for Microsoft.AspNetCore.Mvc.NewtonsoftJson for ASP.NET Core 3.0+| |3.0.0-preview5-19227-01|
|useDefaultRouting|Use default routing for the ASP.NET Core version. For 3.0 turn off default because it is not yet supported.| |true|
|classModifier|Class Modifier can be empty, abstract| ||
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|buildTarget|Target to build an application or library| |program|

View File

@@ -0,0 +1,16 @@
---
id: generator-opts-client-go-experimental
title: Config Options for go-experimental
sidebar_label: go-experimental
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|

View File

@@ -10,6 +10,7 @@ sidebar_label: go
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|

View File

@@ -43,4 +43,5 @@ sidebar_label: java-vertx
|parentVersion|parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|snapshotVersion|Uses a SNAPSHOT version.|<dl><dt>**true**</dt><dd>Use a SnapShot Version</dd><dt>**false**</dt><dd>Use a Release Version</dd><dl>|null|
|rxInterface|When specified, API interfaces are generated with RX and methods return Single&lt;&gt; and Comparable.| |false|
|rxVersion2|When specified in combination with rxInterface, API interfaces are generated with RxJava2.| |false|
|vertxSwaggerRouterVersion|Specify the version of the swagger router library| |null|

View File

@@ -54,4 +54,5 @@ sidebar_label: java
|useRuntimeException|Use RuntimeException instead of Exception| |false|
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|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 : 3.x. JSON processing: Gson 2.x. Only for Java8</dd><dl>|okhttp-gson|

View File

@@ -20,10 +20,12 @@ sidebar_label: kotlin-spring
|serverPort|configuration the port in which the sever is to run on| |8080|
|modelPackage|model package for generated code| |org.openapitools.model|
|apiPackage|api package for generated code| |org.openapitools.api|
|exceptionHandler|generate default global exception handlers| |true|
|exceptionHandler|generate default global exception handlers (not compatible with reactive. enabling reactive will disable exceptionHandler )| |true|
|gradleBuildFile|generate a gradle build file using the Kotlin DSL| |true|
|swaggerAnnotations|generate swagger annotations to go alongside controllers and models| |false|
|serviceInterface|generate service interfaces to go alongside controllers. In most cases this option would be used to update an existing project, so not to override implementations. Useful to help facilitate the generation gap pattern| |false|
|serviceImplementation|generate stub service implementations that extends service interfaces. If this is set to true service interfaces will also be generated| |false|
|useBeanValidation|Use BeanValidation API annotations to validate data types| |true|
|reactive|use coroutines for reactive behavior| |false|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dl>|spring-boot|

View File

@@ -0,0 +1,16 @@
---
id: generator-opts-server-nodejs-server-deprecated
title: Config Options for nodejs-server-deprecated
sidebar_label: nodejs-server-deprecated
---
| 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|
|googleCloudFunctions|When specified, it will generate the code which runs within Google Cloud Functions instead of standalone Node.JS server. See https://cloud.google.com/functions/docs/quickstart for the details of how to deploy the generated code.| |false|
|exportedName|When the generated code will be deployed to Google Cloud Functions, this option can be used to update the name of the exported function. By default, it refers to the basePath. This does not affect normal standalone nodejs server code.| |null|
|serverPort|TCP port to listen on.| |null|

View File

@@ -0,0 +1,17 @@
---
id: generator-opts-client-python-experimental
title: Config Options for python-experimental
sidebar_label: python-experimental
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|packageName|python package name (convention: snake_case).| |openapi_client|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|packageVersion|python package version.| |1.0.0|
|packageUrl|python package URL.| |null|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|

View File

@@ -10,3 +10,5 @@ sidebar_label: r
|packageName|R package name (convention: lowercase).| |openapi|
|packageVersion|R package version.| |1.0.0|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|returnExceptionOnFailure|Throw an exception on non success response codes| |false|
|exceptionPackage|Specify the exception handling package|<dl><dt>**default**</dt><dd>Use stop() for raising exceptions.</dd><dt>**rlang**</dt><dd>Use rlang package for exceptions.</dd><dl>|default|

View File

@@ -35,7 +35,7 @@ sidebar_label: spring
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date (if you really have a good reason not to use threetenbp</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+) - note: this also sets &quot;java8&quot; to true</dd><dt>**threetenbp**</dt><dd>Backport of JSR310 (preferred for jdk &lt; 1.8)</dd><dl>|threetenbp|
|java8|Option. Use Java8 classes instead of third party equivalents|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd><dl>|false|
|java8|Option. Use Java8 classes instead of third party equivalents|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64. Use java8 default interface when a responseWrapper is used</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd><dl>|false|
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
@@ -48,7 +48,7 @@ sidebar_label: spring
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|singleContentTypes|Whether to select only one produces/consumes content-type by operation.| |false|
|java8|use java8 default interface| |true|
|skipDefaultInterface|Whether to generate default implementations for java8 interfaces| |false|
|async|use async Callable controllers| |false|
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
|responseWrapper|wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)| |null|
@@ -62,4 +62,5 @@ sidebar_label: spring
|useOptional|Use Optional container for optional parameters| |false|
|hateoas|Use Spring HATEOAS library to allow adding HATEOAS links| |false|
|returnSuccessCode|Generated server returns 2xx code| |false|
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application using the SpringFox integration.</dd><dt>**spring-mvc**</dt><dd>Spring-MVC Server application using the SpringFox integration.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dl>|spring-boot|

View File

@@ -23,9 +23,7 @@ Example usage:
```bash
# Start container at port 8888 and save the container id
CID=$(docker run -d -p 8888:8080 \
-e GENERATOR_HOST=http://localhost:8888 \
openapitools/openapi-generator-online)
CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online)
# allow for startup
sleep 10

View File

@@ -3,7 +3,9 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,9 @@
<parent>
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,4 +15,11 @@
<artifactId>openapi-generator-core</artifactId>
<name>openapi-generator-core</name>
<url>https://github.com/openapitools/openapi-generator</url>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
import java.util.List;
/**
* A generic implementation of a validator instance which simply applies rules to an input instance.
*
* @param <TInput> The type of object being evaluated.
*/
@SuppressWarnings({"WeakerAccess"})
public class GenericValidator<TInput> implements Validator<TInput> {
private List<ValidationRule> rules;
/**
* Constructs a new instance of {@link GenericValidator}.
*
* @param rules The rules to be evaluated during validation.
*/
public GenericValidator(List<ValidationRule> rules) {
this.rules = rules;
}
/**
* Validates input, resulting in a instance of {@link ValidationResult} which provides details on all validations performed (success, error, warning).
*
* @param input The object instance to be validated.
*
* @return A {@link ValidationResult} which details the success, error, and warning validation results.
*/
@Override
public ValidationResult validate(TInput input) {
ValidationResult result = new ValidationResult();
if (rules != null) {
rules.forEach(it -> {
boolean passes = it.evaluate(input);
if (passes) {
result.addResult(Validated.valid(it));
} else {
result.addResult(Validated.invalid(it, it.getFailureMessage()));
}
});
}
return result;
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
/**
* Represents a {@link Validated} state which is "Invalid" to some degree of {@link Severity}.
*/
@SuppressWarnings({"WeakerAccess"})
public final class Invalid extends Validated {
private String message;
private ValidationRule rule;
/**
* Constructs a new {@link Invalid} instance.
*
* @param rule The rule which was evaluated and resulted in this state.
* @param message The message to be displayed for this invalid state.
*/
Invalid(ValidationRule rule, String message) {
this.rule = rule;
this.message = message;
}
@Override
String getMessage() {
return message;
}
@Override
ValidationRule getRule() {
return rule;
}
/**
* Get details about the severity of this invalid state.
* For instance, is this an {@link Severity#ERROR} or simply a {@link Severity#WARNING}.
*
* @return The {@link Severity} enum detailing this state's severity.
*/
public Severity getSeverity() {
return rule.getSeverity();
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
/**
* Defines different levels of severity to be used during validation.
*/
public enum Severity {
/**
* Lower severity indicating that the target state may be unpredictable, no longer supported, or known to have issues.
* Marking a type with this value should not result in application exceptions under normal operating circumstances.
*/
WARNING,
/**
* Higher severity indicating that the target state is not supported, or is known to cause problems with the application.
* Marking a type with this value should result in an application exception or error exit code under normal operating circumstances.
*/
ERROR
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
/**
* Represents a {@link Validated} state which is "valid" according to the defined rule.
*/
public final class Valid extends Validated {
private ValidationRule rule;
/**
* Defines whether or not the validation resulted in a "valid" condition.
*
* @return <code>true</code> if the instance passed validation of the rule returned by {@link Validated#getRule()}.
*/
@Override
boolean isValid() {
return true;
}
/**
* Constructs a new {@link Valid} instance.
*
* @param rule The rule which was evaluated and resulted in this state.
*/
Valid(ValidationRule rule) {
this.rule = rule;
}
@Override
public String getMessage() {
return null;
}
@Override
public ValidationRule getRule() {
return rule;
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
/**
* Provides details about the state of a completed validation.
*/
public abstract class Validated {
/**
* Defines whether or not the validation resulted in a "valid" condition.
*
* @return <code>true</code> if the instance passed validation of the rule returned by {@link Validated#getRule()}.
*/
boolean isValid() {
return false;
}
/**
* Gets the rule which was evaluated and resulted in this state.
*
* @return The instance of {@link ValidationRule} which was evaluated.
*/
abstract ValidationRule getRule();
/**
* Gets the message with details about this validated state.
*
* @return A string intended to be displayed to a user.
*/
abstract String getMessage();
/**
* Creates an instance of an {@link Invalid} validation state.
*
* @param rule The rule which was evaluated.
* @param message The message to display to a user.
*
* @return A {@link Validated} instance representing an invalid state according to the rule.
*/
public static Validated invalid(ValidationRule rule, String message) {
return new Invalid(rule, message);
}
/**
* Creates an instance of an {@link Valid} validation state.
*
* @param rule The rule which was evaluated.
*
* @return A {@link Validated} instance representing a valid state according to the rule.
*/
public static Validated valid(ValidationRule rule) {
return new Valid(rule);
}
}

View File

@@ -0,0 +1,104 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* Encapsulates details about the result of a validation test.
*/
@SuppressWarnings("WeakerAccess")
public final class ValidationResult {
private final List<Validated> validations;
/**
* Constructs a new {@link ValidationResult} instance, backed by the provided validations (useful for testing).
*
* @param validations A pre-defined set of validations to begin with.
*/
private ValidationResult(List<Validated> validations) {
this.validations = Collections.synchronizedList(validations);
}
/**
* Constructs a new {@link ValidationResult} instance.
*/
public ValidationResult() {
this(new ArrayList<>());
}
/**
* Gets all the validated states resulting from the evaluation. This includes all {@link Valid} and {@link Invalid} instances.
*
* @return All validated results.
*/
public List<Validated> getAll() {
return validations;
}
/**
* Gets a filtered list of {@link Valid} states.
*
* @return A list containing only {@link Valid} states.
*/
public List<Valid> getValid(){
return validations.stream().filter(Validated::isValid).map(it -> (Valid)it).collect(Collectors.toList());
}
/**
* Gets a filters list of {@link Invalid} states with the level of {@link Severity#ERROR}
*
* @return A list of all validation errors.
*/
public List<Invalid> getErrors(){
return validations.stream()
.filter(it -> !it.isValid())
.map(it -> (Invalid)it)
.filter(it -> it.getSeverity().equals(Severity.ERROR))
.collect(Collectors.toList());
}
/**
* Gets a filtered list of {@link Invalid} states with the level of {@link Severity#WARNING}
*
* @return A list of all validation warnings.
*/
public List<Invalid> getWarnings(){
return validations.stream()
.filter(it -> !it.isValid())
.map(it -> (Invalid)it)
.filter(it -> it.getSeverity().equals(Severity.WARNING))
.collect(Collectors.toList());
}
/**
* Adds a validation state to the final results.
*
* @param validated The {@link Valid} or {@link Invalid} instance to add to validations.
*/
public void addResult(Validated validated) {
synchronized (validations) {
ValidationRule rule = validated.getRule();
if (rule != null && !rule.equals(ValidationRule.empty())) {
validations.add(validated);
}
}
}
}

View File

@@ -0,0 +1,152 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
import java.util.function.Function;
/**
* Defines a rule to be evaluated against some target object.
*/
@SuppressWarnings("WeakerAccess")
public class ValidationRule {
private Severity severity;
private String description;
private String failureMessage;
private Function<Object, Boolean> test;
/**
* Constructs a new instance of {@link ValidationRule}
*
* @param severity The declared severity if this validation rule fails.
* @param description A description to help differentiate this rule from others (not intended to be user-facing).
* @param failureMessage The message to be displayed in the event of a test failure (intended to be user-facing).
* @param test The test condition to be applied as a part of this rule, when this function returns <code>true</code>,
* the evaluated instance will be considered "valid" according to this rule.
*/
ValidationRule(Severity severity, String description, String failureMessage, Function<Object, Boolean> test) {
this.severity = severity;
this.description = description;
this.failureMessage = failureMessage;
this.test = test;
}
/**
* Gets the message to be displayed in the event of a test failure (intended to be user-facing).
*
* @return A string message
*/
public String getFailureMessage() {
return failureMessage;
}
/**
* Evalute an instance of an object against this rule.
*
* @param input The instance to be evaluated.
*
* @return <code>true</code> if the object state is valid according to this rule, otherwise <code>false</code>.
*/
public boolean evaluate(Object input) {
return test.apply(input);
}
/**
* Get the level of severity which this rule considers a failure in evaluation. For example, if this is {@link Severity#WARNING} and
* a call to {@link ValidationRule#evaluate(Object)} returns <code>false</code>, a user should not expect an error to be thrown under
* normal operation.
*
* @return An enum defining how severe a failure to evaluate this rule should be considered by the caller.
*/
public Severity getSeverity() {
return severity;
}
/**
* Gets a description to help differentiate this rule from others (not intended to be user-facing).
*
* @return A string description.
*/
public String getDescription() {
return description;
}
/**
* Constructs an empty rule (useful for testing).
*
* @return An "empty" rule.
*/
static ValidationRule empty() {
return new ValidationRule(Severity.ERROR, "empty", "failure message", (i) -> false);
}
/**
* Create an instance of a {@link ValidationRule}
*
* @param severity The declared severity if this validation rule fails.
* @param description A description to help differentiate this rule from others (not intended to be user-facing).
* @param failureMessage The message to be displayed in the event of a test failure (intended to be user-facing).
* @param fn The test condition to be applied as a part of this rule, when this function returns <code>true</code>,
* the evaluated instance will be considered "valid" according to this rule.
* @param <T> The type of the object being evaluated.
*
* @return A new instance of a {@link ValidationRule}
*/
@SuppressWarnings("unchecked")
public static <T> ValidationRule create(Severity severity, String description, String failureMessage, Function<T, Boolean> fn) {
return new ValidationRule(severity, description, failureMessage, (Function<Object, Boolean>) fn);
}
/**
* Create an instance of a {@link ValidationRule} which should result in an error should the evaluate of this rule fail.
*
* @param failureMessage The message to be displayed in the event of a test failure (intended to be user-facing).
* @param fn The test condition to be applied as a part of this rule, when this function returns <code>true</code>,
* the evaluated instance will be considered "valid" according to this rule.
* @param <T> The type of the object being evaluated.
*
* @return A new instance of a {@link ValidationRule}
*/
@SuppressWarnings("unchecked")
public static <T> ValidationRule error(String failureMessage, Function<T, Boolean> fn) {
return new ValidationRule(Severity.ERROR, null, failureMessage, (Function<Object, Boolean>) fn);
}
/**
* Create an instance of a {@link ValidationRule} which should result in a warning should the evaluate of this rule fail.
*
* @param description A description to help differentiate this rule from others (not intended to be user-facing).
* @param failureMessage The message to be displayed in the event of a test failure (intended to be user-facing).
* @param fn The test condition to be applied as a part of this rule, when this function returns <code>true</code>,
* the evaluated instance will be considered "valid" according to this rule.
* @param <T> The type of the object being evaluated.
*
* @return A new instance of a {@link ValidationRule}
*/
@SuppressWarnings("unchecked")
public static <T> ValidationRule warn(String description, String failureMessage, Function<T, Boolean> fn) {
return new ValidationRule(Severity.WARNING, description, failureMessage, (Function<Object, Boolean>) fn);
}
@Override
public String toString() {
return "ValidationRule{" +
"severity=" + severity +
", description='" + description + '\'' +
", failureMessage='" + failureMessage + '\'' +
'}';
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
/**
* Defines a contract allowing some input to be validated.
*
* @param <TInput> The type of the input object.
*/
@FunctionalInterface
public interface Validator<TInput> {
/**
* Validates input, resulting in a instance of {@link ValidationResult} which provides details on all validations performed (success, error, warning).
*
* @param input The object instance to be validated.
*
* @return A {@link ValidationResult} which details the success, error, and warning validation results.
*/
ValidationResult validate(TInput input);
}

View File

@@ -0,0 +1,149 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
public class GenericValidatorTest {
class Person {
private int age;
private String name;
Person(String name, int age) {
this.age = age;
this.name = name;
}
}
private static boolean isValidAge(Person person) {
return person.age > 0;
}
private static boolean isAdult(Person person) {
return person.age > 18;
}
private static boolean isNameSet(Person person) {
return person.name != null && person.name.length() > 0;
}
private static boolean isNameValid(Person person) {
String pattern = "^[A-Z][a-z]*$";
return person.name.matches(pattern);
}
private static boolean isNameNormalLength(Person person) {
return person.name.length() < 10;
}
private List<ValidationRule> validationRules = Arrays.asList(
ValidationRule.error("Age must be positive and more than zero", GenericValidatorTest::isValidAge),
ValidationRule.error("Only adults (18 years old and older)", GenericValidatorTest::isAdult),
ValidationRule.error("Name isn't set!", GenericValidatorTest::isNameSet),
ValidationRule.error("Name isn't formatted correct", GenericValidatorTest::isNameValid),
ValidationRule.warn("Name too long?", "Name may be too long.", GenericValidatorTest::isNameNormalLength)
);
@Test
public void testGenericValidatorSuccesses(){
Person person = new Person("Jim", 23);
GenericValidator<Person> validator = new GenericValidator<>(validationRules);
ValidationResult result = validator.validate(person);
List<Validated> validated = result.getAll();
List<Valid> valid = result.getValid();
List<Invalid> invalid = result.getErrors();
assertEquals(validated.size(), 5, "Expected 5 validations to run.");
assertEquals(valid.size(), 5, "Expected all validations to succeed");
assertEquals(invalid.size(), 0, "Expected zero validations to fail.");
}
@Test
public void testGenericValidatorSingleConditionFails(){
Person person = new Person("Jim", 3);
GenericValidator<Person> validator = new GenericValidator<>(validationRules);
ValidationResult result = validator.validate(person);
List<Validated> validated = result.getAll();
List<Valid> valid = result.getValid();
List<Invalid> errors = result.getErrors();
List<Invalid> warnings = result.getWarnings();
assertEquals(validated.size(), 5, "Expected 5 validations to run.");
assertEquals(valid.size(), 4, "Expected 4 validations to succeed");
assertEquals(errors.size(), 1, "Expected 1 validation to fail.");
assertEquals(warnings.size(), 0, "Expected no warnings to be triggered.");
Invalid failed = errors.get(0);
assertEquals(failed.getMessage(), "Only adults (18 years old and older)");
}
@Test
public void testGenericValidatorMultipleConditionsFail(){
Person person = new Person("asdf", 3);
GenericValidator<Person> validator = new GenericValidator<>(validationRules);
ValidationResult result = validator.validate(person);
List<Validated> validated = result.getAll();
List<Valid> valid = result.getValid();
List<Invalid> errors = result.getErrors();
List<Invalid> warnings = result.getWarnings();
assertEquals(validated.size(), 5, "Expected 5 validations to run.");
assertEquals(valid.size(), 3, "Expected 3 validations to succeed");
assertEquals(errors.size(), 2, "Expected 2 validations to fail.");
assertEquals(warnings.size(), 0, "Expected no warnings to be triggered.");
Optional<Invalid> nameValidation = errors.stream().filter(it -> it.getMessage().contains("formatted")).findFirst();
Optional<Invalid> ageValidation = errors.stream().filter(it -> it.getMessage().contains("adults")).findFirst();
assertTrue(nameValidation.isPresent(), "Expected validation on name formatting to fail.");
assertTrue(ageValidation.isPresent(), "Expected validation on age requirements to fail.");
assertEquals(nameValidation.get().getMessage(), "Name isn't formatted correct");
assertEquals(ageValidation.get().getMessage(), "Only adults (18 years old and older)");
}
@Test
public void testGenericValidatorErrorsAndWarnings(){
Person person = new Person("0123456789asdfghjkl", 3);
GenericValidator<Person> validator = new GenericValidator<>(validationRules);
ValidationResult result = validator.validate(person);
List<Validated> validated = result.getAll();
List<Valid> valid = result.getValid();
List<Invalid> errors = result.getErrors();
List<Invalid> warnings = result.getWarnings();
assertEquals(validated.size(), 5, "Expected 5 validations to run.");
assertEquals(valid.size(), 2, "Expected 2 validations to succeed");
assertEquals(errors.size(), 2, "Expected 2 validations to fail.");
assertEquals(warnings.size(), 1, "Expected 1 warning to be triggered.");
Optional<Invalid> nameValidation = errors.stream().filter(it -> it.getMessage().contains("formatted")).findFirst();
Optional<Invalid> ageValidation = errors.stream().filter(it -> it.getMessage().contains("adults")).findFirst();
Invalid nameLengthWarning = warnings.get(0);
assertTrue(nameValidation.isPresent(), "Expected validation on name formatting to fail.");
assertTrue(ageValidation.isPresent(), "Expected validation on age requirements to fail.");
assertEquals(nameValidation.get().getMessage(), "Name isn't formatted correct");
assertEquals(ageValidation.get().getMessage(), "Only adults (18 years old and older)");
assertEquals(nameLengthWarning.getMessage(), "Name may be too long.");
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
public class ValidatedTest {
@Test
public void isValidTrueForValidType(){
boolean isValid = Validated.valid(ValidationRule.empty()).isValid();
assertTrue(isValid);
}
@Test
public void isValidFalseForInvalidType(){
boolean isValid = Validated.invalid(ValidationRule.empty(), "test").isValid();
assertFalse(isValid);
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.validation;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
public class ValidationRuleTest {
class Sample {
private String name;
public Sample(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
private static boolean checkName(Sample input) {
return input.getName() != null && input.getName().length() > 7;
}
private static boolean checkPattern(Sample input) {
String pattern = "^[A-Z][a-z]*$";
return input.getName() != null && input.getName().matches(pattern);
}
@Test
public void createMethodUsingMethodReference(){
Sample nil = new Sample(null);
Sample six = new Sample("123456");
Sample seven = new Sample("1234567");
Sample eight = new Sample("12345678");
ValidationRule result = ValidationRule.error("test", ValidationRuleTest::checkName);
assertFalse(result.evaluate(nil));
assertFalse(result.evaluate(six));
assertFalse(result.evaluate(seven));
assertTrue(result.evaluate(eight));
}
@Test
public void createMethodUsingLambda(){
Sample nil = new Sample(null);
Sample lowercase = new Sample("jim");
Sample titlecase = new Sample("Jim");
ValidationRule result = ValidationRule.error("test", i -> checkPattern((Sample)i));
assertFalse(result.evaluate(nil));
assertFalse(result.evaluate(lowercase));
assertTrue(result.evaluate(titlecase));
}
}

View File

@@ -40,25 +40,34 @@ compileJava.dependsOn tasks.openApiGenerate
== Plugin Setup
//# RELEASE_VERSION
[source,group]
----
plugins {
id "org.openapi.generator" version "4.0.3-SNAPSHOT"
}
----
Using https://docs.gradle.org/current/userguide/plugins.html#sec:old_plugin_application[legacy plugin application]:
[source,groovy]
----
buildscript {
repositories {
mavenLocal()
mavenCentral()
// or, via Gradle Plugin Portal:
// url "https://plugins.gradle.org/m2/"
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.1"
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.3-SNAPSHOT"
}
}
apply plugin: 'org.openapi.generator'
----
[NOTE]
====
The gradle plugin is not currently published to https://plugins.gradle.org/m2/.
====
//# /RELEASE_VERSION
== Configuration
@@ -591,6 +600,7 @@ Android Studio may experience a Windows-specific Guava dependency conflict with
As a workaround, you may force exclude conflicting Guava dependencies.
//# RELEASE_VERSION
```gradle
buildscript {
repositories {
@@ -599,7 +609,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.1') {
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.3-SNAPSHOT') {
exclude group: 'com.google.guava'
}
}
@@ -612,5 +622,6 @@ configurations {
// …
apply plugin: 'org.openapi.generator'
```
//# /RELEASE_VERSION
See https://github.com/OpenAPITools/openapi-generator/issues/1818[OpenAPITools/openapi-generator#1818] for more details.

View File

@@ -97,6 +97,10 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
}
artifacts {
archives javadocJar, sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
@@ -139,11 +143,14 @@ publishing {
}
}
nexusStaging {
username = project.properties["ossrhUsername"]
password = project.properties["ossrhPassword"]
}
nexusPublishing {
username = ossrhUsername
password = ossrhPassword
stagingProfileId = "org.openapitools"
packageGroup = "org.openapitools"
// To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile --no-daemon
stagingProfileId = "456297f829bbbe"
}
gradlePlugin {

View File

@@ -1,4 +1,6 @@
openApiGeneratorVersion=4.0.1-SNAPSHOT
# RELEASE_VERSION
openApiGeneratorVersion=4.0.3-SNAPSHOT
# /RELEASE_VERSION
# BEGIN placeholders
# these are just placeholders to allow contributors to build directly

View File

@@ -3,7 +3,9 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -0,0 +1 @@
.bak/

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.1 openApiValidate
gradle -PopenApiGeneratorVersion=4.0.3-SNAPSHOT openApiValidate
```

View File

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

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

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

View File

@@ -12,7 +12,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
@@ -50,6 +52,12 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- dependencies are needed for the client being generated -->

View File

@@ -18,7 +18,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.0</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -63,6 +65,12 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- dependencies are needed for the client being generated -->

View File

@@ -12,7 +12,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
@@ -31,4 +33,10 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -12,7 +12,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
@@ -30,4 +32,10 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -4,7 +4,9 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-maven-plugin</artifactId>

View File

@@ -245,7 +245,7 @@ public class CodeGenMojo extends AbstractMojo {
* To treat a document strictly against the spec.
*/
@Parameter(name = "strictSpec", property = "openapi.generator.maven.plugin.strictSpec", required = false)
private Boolean strictSpecBehavior;
private Boolean strictSpec;
/**
* To generate alias (array, map) as model
@@ -471,8 +471,8 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setValidateSpec(!skipValidateSpec);
}
if (strictSpecBehavior != null) {
configurator.setStrictSpecBehavior(strictSpecBehavior);
if (strictSpec != null) {
configurator.setStrictSpecBehavior(strictSpec);
}
if (logToStderr != null) {

View File

@@ -4,9 +4,12 @@ WORKDIR /generator
COPY target/openapi-generator-online.jar /generator/openapi-generator-online.jar
ENV GENERATOR_HOST=http://localhost
# GENERATOR_HOST can be used to determine the target location of a download link.
# The default value asumes binding to host via: docker -p 8080:8080 image_name
# Generally, this "just works" without GENERATOR_HOST, and this is provided only as
# a workaround if all else fails.
ENV GENERATOR_HOST=""
EXPOSE 8080
CMD ["java", "-jar", "/generator/openapi-generator-online.jar"]
CMD ["java", "-jar", "/generator/openapi-generator-online.jar" ]

View File

@@ -1,15 +1,57 @@
# OpenAPI generated server
Spring Boot Server
A Spring Boot Server application which hosts a client/server generator API.
## Overview
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub or one of 100+ client packages.
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)
Start your server as a simple java application
## Building
Change default port value in application.properties
Refer to [root README](../../README.md) for build directions.
## Running
### Via command line
Running is as simple as:
```
java -jar ./target/openapi-generator-online.jar
```
This exposes the API on local port 8080.
Springfox supports configuration of the "host" value in the output OpenAPI document by setting the `Host` HTTP header in the request.
To set this explicitly, pass the system property `springfox.documentation.swagger.v2.host` with the desired host. For example:
```
java -Dspringfox.documentation.swagger.v2.host=example.com:8888 -jar ./target/openapi-generator-online.jar
```
### Via Docker
After building from source, change to this module directory (`cd modules/openapi-generator-online`) and build the docker image:
```
docker build -t openapitools/openapi-generator-online:latest .
```
Now, run the docker image:
```
docker run -d -p 8888:8080 openapitools/openapi-generator-online
```
The `GENERATOR_HOST` variable is used here to ensure download links generated by the API refer to the proper API location.
## Environment
`GENERATOR_HOST` can be set to force the scheme/host/port used for download link generation. In most cases, this environment variable is not
necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback.

View File

@@ -3,7 +3,9 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-online</artifactId>
@@ -31,6 +33,14 @@
<build>
<finalName>openapi-generator-online</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@@ -67,11 +77,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>

View File

@@ -27,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
public class HomeController {
@RequestMapping(value = "/")
public String index() {
return "redirect:swagger-ui.html";
return "redirect:index.html";
}
}

View File

@@ -29,7 +29,11 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Properties;
@Configuration
@@ -37,13 +41,24 @@ import java.io.InputStream;
public class OpenAPIDocumentationConfig {
ApiInfo apiInfo() {
final Properties properties = new Properties();
try (InputStream stream = this.getClass().getResourceAsStream("/version.properties")) {
if (stream != null) {
properties.load(stream);
}
} catch (IOException ex) {
// ignore
}
String version = properties.getProperty("version", "unknown");
return new ApiInfoBuilder()
.title("OpenAPI Generator Online")
.description("This is an online openapi generator server. You can find out more at https://github.com/OpenAPITools/openapi-generator.")
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.termsOfServiceUrl("")
.version("3.0.0")
.version(version)
.contact(new Contact("","", ""))
.build();
}

View File

@@ -2,3 +2,4 @@ springfox.documentation.swagger.v2.path=/api-docs
server.port=8080
spring.jackson.date-format=org.openapitools.codegen.online.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/

View File

@@ -0,0 +1,17 @@
<!doctype html> <!-- Important: must specify -->
<html>
<head>
<meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 charecters -->
<script src="rapidoc-min.js"></script>
</head>
<body>
<rapi-doc spec-url="api-docs"
theme="dark">
<img
slot="logo"
src="logo.png"
style="margin:0 -0.3em 0 0.8em;"
/>
</rapi-doc>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
version = ${project.version}

View File

@@ -3,7 +3,9 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.1</version>
<!-- RELEASE_VERSION -->
<version>4.0.3-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -313,7 +315,7 @@
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-core</artifactId>
<version>4.0.1</version>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
<repositories>

View File

@@ -69,6 +69,9 @@ public class CodegenConstants {
public static final String WITH_GO_CODEGEN_COMMENT = "withGoCodegenComment";
public static final String WITH_GO_CODEGEN_COMMENT_DESC = "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs";
public static final String IS_GO_SUBMODULE = "isGoSubmodule";
public static final String IS_GO_SUBMODULE_DESC = "whether the generated Go module is a submodule";
public static final String GROUP_ID = "groupId";
public static final String GROUP_ID_DESC = "groupId in generated pom.xml";
@@ -303,4 +306,6 @@ public class CodegenConstants {
public static final String SNAPSHOT_VERSION = "snapshotVersion";
public static final String SNAPSHOT_VERSION_DESC = "Uses a SNAPSHOT version.";
public static final String EXCEPTION_ON_FAILURE = "returnExceptionOnFailure";
public static final String EXCEPTION_ON_FAILURE_DESC = "Throw an exception on non success response codes";
}

View File

@@ -38,7 +38,7 @@ public class CodegenSecurity {
// Oauth specific
public String flow, authorizationUrl, tokenUrl;
public List<Map<String, Object>> scopes;
public Boolean isCode, isPassword, isApplication, isImplicit;
public Boolean isCode, isPassword, isApplication, isImplicit, hasScopes;
@Override
public String toString() {

View File

@@ -810,7 +810,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the snake-cased variable name
*/
public String toApiVarName(String name) {
return snakeCase(name);
return lowerCamelCase(name);
}
/**
@@ -1475,7 +1475,7 @@ public class DefaultCodegen implements CodegenConfig {
* @param schema
* @return type
*/
private static String getPrimitiveType(Schema schema) {
private String getPrimitiveType(Schema schema) {
if (schema == null) {
throw new RuntimeException("schema cannot be null in getPrimitiveType");
} else if (ModelUtils.isStringSchema(schema) && "number".equals(schema.getFormat())) {
@@ -1519,6 +1519,13 @@ public class DefaultCodegen implements CodegenConfig {
} else if (ModelUtils.isURISchema(schema)) {
return "URI";
} else if (ModelUtils.isStringSchema(schema)) {
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.
return schema.getFormat();
}
return "string";
} else if (ModelUtils.isFreeFormObject(schema)) {
return "object";
@@ -1533,13 +1540,13 @@ public class DefaultCodegen implements CodegenConfig {
}
/**
* Return the snake-case of the string
* Return the lowerCamelCase of the string
*
* @param name string to be snake-cased
* @return snake-cased string
* @param name string to be lowerCamelCased
* @return lowerCamelCase string
*/
@SuppressWarnings("static-method")
public String snakeCase(String name) {
public String lowerCamelCase(String name) {
return (name.length() > 0) ? (Character.toLowerCase(name.charAt(0)) + name.substring(1)) : "";
}
@@ -1756,10 +1763,10 @@ public class DefaultCodegen implements CodegenConfig {
m.interfaces.add(modelName);
addImport(m, modelName);
if (allDefinitions != null && refSchema != null) {
if (allParents.contains(modelName) && supportsMultipleInheritance) {
if (allParents.contains(ref) && supportsMultipleInheritance) {
// multiple inheritance
addProperties(allProperties, allRequired, refSchema);
} else if (parentName != null && parentName.equals(modelName) && supportsInheritance) {
} else if (parentName != null && parentName.equals(ref) && supportsInheritance) {
// single inheritance
addProperties(allProperties, allRequired, refSchema);
} else {
@@ -1860,8 +1867,10 @@ public class DefaultCodegen implements CodegenConfig {
discriminator.setMapping(schema.getDiscriminator().getMapping());
if (schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) {
for (Entry<String, String> e : schema.getDiscriminator().getMapping().entrySet()) {
String name = toModelName(ModelUtils.getSimpleRef(e.getValue())); // e.g e.getValue => #/components/schemas/Dog
discriminator.getMappedModels().add(new MappedModel(e.getKey(), name));
String nameOrRef = e.getValue();
String name = nameOrRef.indexOf('/') >= 0 ? ModelUtils.getSimpleRef(nameOrRef) : nameOrRef;
String modelName = toModelName(name);
discriminator.getMappedModels().add(new MappedModel(e.getKey(), modelName));
}
} else {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
@@ -2210,6 +2219,7 @@ public class DefaultCodegen implements CodegenConfig {
// property.baseType = getSimpleRef(p.get$ref());
//}
// --END of revision
property.isModel = ModelUtils.isModel(p);
setNonArrayMapProperty(property, type);
}
@@ -3035,6 +3045,9 @@ public class DefaultCodegen implements CodegenConfig {
} else {
codegenParameter.dataType = codegenProperty.dataType;
}
if (ModelUtils.isObjectSchema(parameterSchema)) {
codegenProperty.complexType = codegenParameter.dataType;
}
codegenParameter.dataFormat = codegenProperty.dataFormat;
codegenParameter.required = codegenProperty.required;
@@ -3221,6 +3234,10 @@ public class DefaultCodegen implements CodegenConfig {
* @return data type
*/
protected String getParameterDataType(Parameter parameter, Schema schema) {
if (parameter.get$ref() != null) {
String refName = ModelUtils.getSimpleRef(parameter.get$ref());
return toModelName(refName);
}
return null;
}
@@ -3660,7 +3677,7 @@ public class DefaultCodegen implements CodegenConfig {
* @param schemas The complete set of model definitions (schemas).
* @return A mapping from model name to type alias
*/
static Map<String, String> getAllAliases(Map<String, Schema> schemas) {
Map<String, String> getAllAliases(Map<String, Schema> schemas) {
if (schemas == null || schemas.isEmpty()) {
return new HashMap<>();
}
@@ -4652,9 +4669,17 @@ public class DefaultCodegen implements CodegenConfig {
schema.setAdditionalProperties(inner);
}
CodegenProperty codegenProperty = fromProperty("property", schema);
// only support 1-dimension map only
imports.add(codegenProperty.baseType);
CodegenProperty innerCp = codegenProperty;
while (innerCp != null) {
if (innerCp.complexType != null) {
imports.add(innerCp.complexType);
}
innerCp = innerCp.items;
}
if (StringUtils.isEmpty(bodyParameterName)) {
codegenParameter.baseName = "request_body";
} else {
@@ -4707,7 +4732,7 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.items = codegenProperty.items;
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
codegenParameter.dataType = getTypeDeclaration(arraySchema);
codegenParameter.baseType = getSchemaType(arraySchema);
codegenParameter.baseType = getSchemaType(inner);
codegenParameter.isContainer = Boolean.TRUE;
codegenParameter.isListContainer = Boolean.TRUE;

View File

@@ -562,6 +562,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
operation.put("classVarName", config.toApiVarName(tag));
operation.put("importPath", config.toApiImport(tag));
operation.put("classFilename", config.toApiFilename(tag));
operation.put("strictSpecBehavior", config.isStrictSpecBehavior());
if (allModels == null || allModels.isEmpty()) {
operation.put("hasModel", false);
@@ -1051,6 +1052,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
if (securities != null && securities.isEmpty()) {
continue;
}
Map<String, SecurityScheme> authMethods = getAuthMethods(securities, securitySchemes);
if (authMethods == null || authMethods.isEmpty()) {
authMethods = getAuthMethods(globalSecurities, securitySchemes);
@@ -1058,6 +1060,39 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
if (authMethods != null && !authMethods.isEmpty()) {
codegenOperation.authMethods = config.fromSecurity(authMethods);
List<Map<String, Object>> scopes = new ArrayList<Map<String, Object>>();
if (codegenOperation.authMethods != null){
for (CodegenSecurity security : codegenOperation.authMethods){
if (security != null && security.isBasicBearer != null && security.isBasicBearer &&
securities != null){
for (SecurityRequirement req : securities){
if (req == null) continue;
for (String key : req.keySet()){
if (security.name != null && key.equals(security.name)){
int count = 0;
for (String sc : req.get(key)){
Map<String, Object> scope = new HashMap<String, Object>();
scope.put("scope", sc);
scope.put("description", "");
count++;
if (req.get(key) != null && count < req.get(key).size()){
scope.put("hasMore", "true");
} else {
scope.put("hasMore", null);
}
scopes.add(scope);
}
//end this inner for
break;
}
}
}
security.hasScopes = scopes.size() > 0;
security.scopes = scopes;
}
}
}
codegenOperation.hasAuthMethods = true;
}

View File

@@ -361,10 +361,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
iterator.remove();
}
// this will only import "fmt" if there are items in pathParams
// this will only import "fmt" and "strings" if there are items in pathParams
for (CodegenOperation operation : operations) {
if (operation.pathParams != null && operation.pathParams.size() > 0) {
imports.add(createMapping("import", "fmt"));
imports.add(createMapping("import", "strings"));
break; //just need to import once
}
}

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