Compare commits

..

99 Commits

Author SHA1 Message Date
William Cheng
56eb5a63bf set useJakartaEe to true by default 2024-04-03 16:24:18 +08:00
William Cheng
2934f5ac51 add logic to simplify any type represented with oneof/anyof (#18268) 2024-04-02 15:08:20 +08:00
dependabot[bot]
2ce71512d0 Bump julia-actions/setup-julia from 1 to 2 (#18270)
Bumps [julia-actions/setup-julia](https://github.com/julia-actions/setup-julia) from 1 to 2.
- [Release notes](https://github.com/julia-actions/setup-julia/releases)
- [Commits](https://github.com/julia-actions/setup-julia/compare/v1...v2)

---
updated-dependencies:
- dependency-name: julia-actions/setup-julia
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-02 08:52:03 +08:00
William Cheng
927768757b Add designli to bronze sponsor (#18269)
* add designli to bronze sponsor

* update link to jpg
2024-04-01 15:46:04 +08:00
devhl-labs
858499ffdd [csharp][generichost] Form models (#18264)
* rename a bin artifact

* add support for form models

* revert sample changes

* revert sample changes

* build samples

* build samples
2024-04-01 13:12:03 +08:00
William Cheng
4719d9e55f update spring-context to newer version (#18266) 2024-04-01 11:56:58 +08:00
William Cheng
2d7f0496ec add rule to set primitive types to nullable (#18258) 2024-04-01 11:54:21 +08:00
devhl-labs
2fac8e34db [csharp][generichost] Updated UseSourceGeneration (#18265)
* updated UseSourceGeneration

* updated UseSourceGeneration

* updated UseSourceGeneration
2024-04-01 11:49:13 +08:00
martin-mfg
1704ae1194 fix issue 17999 (#18259) 2024-03-31 22:47:19 +08:00
devhl-labs
370eca2889 [csharp] Update dependencies (#18263)
* version bump

* updated a workflow
2024-03-31 11:27:57 +08:00
devhl-labs
d0f8468651 [csharp] Rename samples (#18260)
* renamed OpenAPIClient-httpclient to Petstore

* updated bin artifacts

* renamed OpenAPIClientCoreAndNet47 to MultipleFrameworks

* updated bin artifacts

* renamed OpenAPIClient-net47 to Petstore

* renamed OpenAPIClient-net48 to Petstore

* updated bin artifacts

* renamed OpenAPIClient-restsharp-name-parameter-mappings to ParameterMappings

* updated bin artifacts

* renamed OpenAPIClientCore to Petstore

* updated bin artifacts

* renamed OpenAPIClient-net7.0-useDateTimeForDate to UseDateTimeForDate

* updated bin artifacts

* renamed OpenAPIClient-net5.0 to EnumMappings

* updated bin artifacts

* renamed OpenAPIClient-ConditionalSerialization to ConditionalSerialization

* updated bin artifacts

* renamed OpenAPIClient to Petstore

* updated bin artifacts

* renamed OpenAPIClient-unityWebRequest to Petstore

* updated bin artifacts

* updated appveyor

* updated bin artifacts

* updated bin artifacts

* comenting out a sample project with no csproj file

* updated bin artifacts
2024-03-31 10:36:42 +08:00
devhl-labs
6252dac28e [csharp][generichost] Ensure samples are running (#18257)
* ensure samples are running

* ensure samples are running

* ensure samples are running

* ensure samples are running

* ensure samples are running

* ensure samples are running

* revert testing changes

* sorted the array entries
2024-03-30 21:14:51 +08:00
B4ckslash
807aa5d3ae [Java][jersey2] Fix generated client code for oneOf models if datatype includes arrays (#18042)
* Add java-jersey2 sample with mixed oneOf

* [java][jersey2]Fix client generation if oneOf contains an array type

Changes:
* Change jersey2/oneof_model template to use composed schema data
* Change adding of imports in AbstractJavaCodegen to use composed schema data
* Add escapedDataType property to CodegenProperty so that the data type
  may be part of identifiers (e.g. in getters)
* Update samples

* Add sample for multiple array in oneOf

* Fix generation of constructors with same erasures

* Update samples again

* Version bump

* Add new sample folders to CI

* Make primitive handling more explicit

* Replace escapedDataType property with Mustache lambda

* Update samples with new primitive handling and sanitization lambda
2024-03-30 21:08:41 +08:00
timo-a
f73db59b0e Migrate generated tests for java resttemplate generator updateFeature/resttemplate junit5 (#18222)
* update(resttemplate): migrate java resttemplate templates to junit 5

* update(java defaults): migrate java defaults as well because resttemplate uses model_tests from default

* update(samples, java): update samples as described in the contribution guidelines

* fix tests: try double quotes

* fix tests: remaining double quotes

* update(samples): regenerate resttemplate

* update(samples): regenerate resttemplate-jakarta

* update(samples): regenerate resttemplate-swagger1

* update(samples): regenerate resttemplate-swagger2

* update(samples): regenerate resttemplate-withXml

* update(samples again): ./bin/generate-samples.sh ./bin/configs/*.yaml
2024-03-30 21:06:05 +08:00
Yohei Kitamura
34ebc1c644 [ruby] Use Marcel to detect content-type in form-data file upload using faraday (#18243) 2024-03-29 21:58:08 +08:00
martin-mfg
de680de60e fix issue 17895 (#18248) 2024-03-29 21:57:13 +08:00
William Cheng
e78aeb6bc7 Better support for $ref to schema's properties (#18233)
* use once

* add support for reference to schema properties
2024-03-27 11:46:00 +08:00
Dennis Melzer
309918d03e Fix compile error in client properties configuration (#18232)
* Fix config

* Add tests

* Remove unused import

* Sort imports

* Add new workflow
2024-03-26 22:02:19 +08:00
Harry Devane
6690b9f87d Update okhttp3 to 4.12.0 (#18235) 2024-03-26 21:44:43 +08:00
dependabot[bot]
ee69a7983a Bump express from 4.18.2 to 4.19.2 in /website (#18228)
Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-26 10:21:02 +08:00
devhl-labs
204407daf0 Rename samples (#18223)
* moved OpenAPIClient-generichost-net6.0

* moved OpenAPIClient-generichost-netcore-latest-allOf

* moved OpenAPIClient-generichost-netcore-latest-anyOf

* moved OpenAPIClient-generichost-netcore-latest-oneOf

* moved OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration

* moved OpenAPIClient-generichost-net6.0-nrt

* moved OpenAPIClient-generichost-net7.0-useDateTimeForDate

* moved OpenAPIClient-generichost-manual-tests

* moved OpenAPIClient-generichost-netstandard2.0

* moved OpenAPIClient-generichost-net6.0

* deleted abandoned files

* updated bin artifacts

* build samples

* updated workflow

* fix manual tests
2024-03-26 10:19:05 +08:00
devhl-labs
d1860b95cf [csharp] Move samples (#18217)
* moved manual tests

* moved allOf

* moved anyOf

* moved oneOf

* moved OpenAPIClient-generichost-net6.0

* moved OpenAPIClient-generichost-net6.0-nrt

* moved OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration

* moved OpenAPIClient-generichost-net7.0-useDateTimeForDate

* moved OpenAPIClient-generichost-netstandard2.0

* moved OpenAPIClient

* moved OpenAPIClient-ConditionalSerialization

* moved OpenAPIClient-httpclient

* moved OpenAPIClient-net5.0

* moved OpenAPIClient-net7.0-useDateTimeForDate

* moved OpenAPIClient-net47

* moved OpenAPIClient-net48

* moved OpenAPIClient-restsharp-name-parameter-mappings

* moved OpenAPIClient-unityWebRequest

* moved OpenAPIClientCore

* moved OpenAPIClientCoreAndNet47

* renamed standard2 to standard2.0

* renamed standard2 to standard2.0

* fixed workflows

* renamed workflows

* updated bin artifacts

* updated bin artifacts

* pinned the samples to their version

* renamed bin artifacts

* update bin artifact

* update bin artifact

* update bin artifact

* updated appveyor

* reverting changes bc git does not show the rename

* commiting all but the file rename for these two files
2024-03-25 09:14:34 +08:00
William Cheng
e0b059bcde update samples 2024-03-24 18:14:15 +08:00
William Cheng
6746be9a50 fix allOf handling in 3.1 spec 2024-03-24 18:07:01 +08:00
William Cheng
d88023f833 fix ref to request bodies in form content type (#18216) 2024-03-24 11:38:21 +08:00
Nick Cooper
8acf9b779d Specify named param for field defaults in Python Pydantic V1 generator (#18187)
* Use named parameter

* Regenerate samples
2024-03-24 11:36:15 +08:00
ふぁ
9acd620bbb [Python] Add test object serialization for multipart requests (#18156)
* [Python] add test object serialization for multipart requests #18140

* [python] update samples

* [python] update samples
2024-03-24 09:37:44 +08:00
William Cheng
e17777044e Use systemPropertyVariables in pom.xml (#18213)
* use system property variables in pom.xml

* update
2024-03-23 21:45:29 +08:00
Maroš Varchola
f258ce2cf5 #18031 Fix: added middleware adding for authorization methods [php-slim4] (#18103)
* fix: added middleware adding for authorization methods, added unauthorized handler to authorization abstract, fixes #18031

* feat: updated generated sample for php-slim4

* fix: small fix for running error handlers and environment setting fix

* feat: removed unused dependency in abstract authenticator, php-slim4
2024-03-23 21:41:16 +08:00
ふぁ
5e9546451c [Python] Add echo_api test object serialization for multipart requests (#18176)
* [python] echo add test object serialization for multipart requests

* [echo api] update samples

* [echo api] update samples
2024-03-23 21:40:10 +08:00
William Cheng
420e49f258 better type check for additoinal properties before casting (#18212) 2024-03-23 21:21:31 +08:00
William Cheng
4ca8f9c384 Update kotlin client dependencies to newer versions (#18211)
* update kotlin client dependencies to newer versoins

* update
2024-03-23 21:21:20 +08:00
Njeri Gachoka
aedf571811 Handle both types of additional properties when getting type declaration (#18201) 2024-03-23 17:42:22 +08:00
William Cheng
8288b6fb15 fix #18184, check nullable in 3.1 spec (#18189) 2024-03-23 17:15:27 +08:00
William Cheng
a26c87e7a9 [Kotlin][jvm-retrofit2] fix missing import for models in query parameters (#18143)
* add new kotlin client samples

* update workflow

* update samples

* update

* add kotlin echo api client

* update

* update

* fix model import
2024-03-23 15:38:49 +08:00
Thom
2916be0fb5 fix[kotlin]: only use data class when it has constructor vars (#18202)
Co-authored-by: Thom van Kalkeren <thom.vankalkeren@ns.nl>
2024-03-23 15:38:03 +08:00
devhl-labs
716a82f8bb minor spacing change (#18210) 2024-03-23 13:01:58 +08:00
William Cheng
84b3cd9962 allow customer version to be overwritten in additional properties (#18170) 2024-03-22 15:22:24 +08:00
dependabot[bot]
19898646a8 Bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /website (#18200)
Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4.
- [Release notes](https://github.com/webpack/webpack-dev-middleware/releases)
- [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-middleware/compare/v5.3.3...v5.3.4)

---
updated-dependencies:
- dependency-name: webpack-dev-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-22 15:17:16 +08:00
Matteo Baccan
7565e365f8 Update pom.mustache (#18195)
* Update pom.mustache

* Updated pom.xml of samples
2024-03-22 15:05:32 +08:00
shirin175
1bfe800b9f typescript-fetch: Move parenthesis to correct place (#18075)
A misplaced parenthesis let to a syntax error when generating the code for a nullable set in the FromJSONTyped function. By moving the parenthesis to the correct place the syntax error was resolved.
2024-03-21 18:45:50 +08:00
Flemming Nørnberg Larsen
a4508f6817 #18058 Fix the Java generator to generate valid @RequestMappings where the produce field takes list of string parameters instead of a single comma-separated string (#18092)
* #18058 Fix AbstractJavaCodegen.getAccepts() so it returns a String array instead of a comma-separated string, and fixed api.mustache so the @RequestMapping annotation generated produces for x-accepts as a parameter list instead of a (single) string.

* #18058 Updated test case to accept a string array instead of a comma-separated list.

* #18058 Reverted changes on imported compared to the main branch.

* #18058 getAccepts() is now hybrid, and can return both a single String or a String[].

* #18058 Rolled back the hybrid getAccepts(), so it only returns a String array.

* #18058 Updated mustache files to cope with vendorExtensions.x-accepts being a string array instead of a comma-separated string.

* #18058 Generated new sample files with by running `./bin/generate-samples.sh ./bin/configs/*.yaml`

* #18058 Optimization of getAccepts()

* #18058 Regenerated scripts that got broken after resolving conflicts on GitHub

* #18058 Fixed introduced issue with api.mustache causing a redundant accept with @HttpExchange with the PetApi.java, StoreApi.java, and UserApi.java.
2024-03-21 17:53:18 +08:00
Sondre Eikanger Kvalø
c7e9bd2f29 [Kotlin][Server] Skip new post processing routine for kotlin server jaxrs (#18180)
* Skip post processing when generating JAXRS spec with Kotlin
This feature was previously added to work with the javalin5 library

* Add sample that proves what we expect after fixing this

* Update sample

* Added new samples to samples workflow

* Revert from jdk17 pipeline
2024-03-21 15:55:28 +08:00
ふぁ
e39b99051c [python] add test Missing the important statement for Datetime in Python binding generation (#18175)
* [python] add test on datetime response import

* [python] update sample

* [python] update sample
2024-03-21 15:40:33 +08:00
William Cheng
894848e550 update links to blog posts (#18174)
* update links to blog posts

* update doc
2024-03-21 15:36:52 +08:00
Maroš Varchola
9c26ad4745 fix: when instantiation type is not defined for language, return type itself for parent (#18164) 2024-03-21 08:06:11 +01:00
Jonas Emmert
bcd0bc5de8 [R][Client] fix brackets for httr2 file_params (#18142)
* fix brackets for httr2 file_params

* added additional braces to baseName of httr2 file_params
2024-03-21 11:43:50 +08:00
Daniel Wischolek
bf2a251dd6 scala-sttp4: fix for missing EnumNameSerializer for inner enum definitions (#18145) (#18160) 2024-03-21 11:43:15 +08:00
William Cheng
7aeb952565 update samples 2024-03-21 11:42:51 +08:00
Zishun (Zack) WEI
43ca5fcac9 Fix issue 18088: Missing the important statement for Datetime in Python binding generation (#18173)
* fix issue 18088

* update samples
2024-03-21 11:39:19 +08:00
William Cheng
0b94817f58 skip check for possible model type in abstract C# (#18171) 2024-03-21 11:38:40 +08:00
Matteo Baccan
fe9ba01bf8 Upgrade github action (#18181) 2024-03-21 11:31:05 +08:00
Jonas Emmert
2600eb92dc [R][Client] allow to initialize enum classes without parameters (#18183)
* allow empty initialization of enum classes

* regenerate samples
2024-03-21 11:21:41 +08:00
Sondre Eikanger Kvalø
ed8b7ec7f6 Should parse boolean value for useJavaEE as this is done elsewhere (#18182)
For consistency across generators we should allow specifying the value of the useJavaEE in the same way as for instance in the jaxrs-spec (Java)
2024-03-21 11:21:12 +08:00
Giovanni Cimolin da Silva
6a1791c8c3 fix: Don't spread strings, instead "||" them together (#18185) 2024-03-20 18:30:09 +01:00
Artur Zdolinski
c15e267e22 Fix problem in sanitize_for_serialization for Python (pydantic type SecretStr ) BUG#16086 (2nd pull) (#18023)
* fix-for-bug-16086

* add to_dict alternative

* fix assertEqual

* remove extra blank line + test_model Argument SecretStr set

* update samples / remove extra blank line

* restore sanitize test for serialization with different data types

* remove empty line in api_client.mustache

* remove 2nd empty line in api_client.mustache
2024-03-20 19:14:43 +08:00
Axident
e2df0d6154 #18095 | Prevent generating "pattern" and "size" to special formats of string type (#18135) 2024-03-20 14:07:29 +08:00
William Cheng
971c3a6059 Insert missing quote in clientPropertiesConfiguration.mustache for the Spring generator (#18172)
* #18090 Insert missing quote: `{{{tokenUrl}}}"` -> `"{{{tokenUrl}}}"`

* #18058 Added test unit

* #18058 Stop unit test from generating unnecessary APIs

* fix test

---------

Co-authored-by: Flemming Nørnberg Larsen <f.larsen@elsevier.com>
2024-03-20 14:06:16 +08:00
William Cheng
09af44eca3 [java] update jakarta.validation-api to 3.0.2 (#18124)
* fix: jersey3 library

fix issue that library failed in case pattern matching was used in
the api.

* add tests, update version

* update

* fix tag

* fix, update samples

* update build

* more update

* update workflow

* test useJakarta

---------

Co-authored-by: holomekc <30546982+holomekc@users.noreply.github.com>
2024-03-20 12:55:19 +08:00
condorcorde
de081e4edf Fix proxy type (#18166)
* Update configuration.mustache

Fix check of proxy type

* Changing sample source files
2024-03-20 12:53:58 +08:00
William Cheng
1108ce5808 update samples for cpp-ue4 petstore 2024-03-20 11:33:43 +08:00
Samuel Kahn
783119b687 [cpp-ue4] Handled nullable by setting the required tag, effectively making nullables optionals (even if they may be required in the spec). This is because there is no such concept as a value being nullable in C++, and this generator deals with values, not pointers. (#18168)
Co-authored-by: Samuel Kahn <samuel@darewise.com>
2024-03-20 11:26:54 +08:00
Giovanni Cimolin da Silva
93b76dde37 fix: Fix schema generation for oneOf when using TS-FETCH client (#18154)
* fix: Fix schema generation for `oneOf` when using TS-FETCH client

This fixes the following errors:
* Spread types may only be created from object types (on `FromJSONTyped` functions).
* Module '"./BlankEnum"' has no exported member 'instanceOfBlankEnum' (enum templaces don't export function used by other API client files).

* chore: Regenerate samples
2024-03-19 11:48:21 +01:00
William Cheng
191dc1a6ba Override escape reserved word in abstract rust (#17440)
* override escape reserved word in abstract rust

* add tests for ref, improve verion lambda

* add files
2024-03-19 18:33:29 +08:00
Poolmann
b7ea139f77 [Python] Fix object serialization for multipart requests (#18140)
* Fix multipart object serialization

* Update samples
2024-03-19 18:31:08 +08:00
Beppe Catanese
e58f19c735 [POSTMAN] Process request with array of string (#18159)
* Process JSON array

* Update test file

* Regenerate samples

* Add CI test
2024-03-19 18:29:48 +08:00
adrianhelvikspond
815205250a Fix: Incorrect serialisation of maps and sets in typescript-axios (#17790) 2024-03-19 08:21:39 +01:00
Jonas Emmert
5f49a04190 allow api response to be NULL and regenerate samples (#18141) 2024-03-19 10:03:17 +08:00
William Cheng
ddb5ab4078 Add name in various cases in property, parameter names (#18139)
* create nameInPascalCase

* add back name in camel case

* update abstract cpp codegen

* update erlang templates, update samples

* update tests

* add param names in various cases

* clean up

* fix
2024-03-19 09:27:02 +08:00
William Cheng
3155a70c3f [Refactor] create a static function to build map of codegen model (#18138)
* refactor to build map of codegen model

* update
2024-03-19 09:15:33 +08:00
Ross Bender
b59957a095 Java API invocation flexibility (#18078)
* add direct invocation methods for java (httpclient)

* add direct invocation methods for java (resttemplate)

* handle methods only if endpoints exist for api client

* preserve previous newline to minimize changes

* update httpclient/resttemplate samples

* add common methods in base class

* regenerate samples with base class
2024-03-18 21:51:32 +08:00
devhl-labs
da1187fc8d [csharp] Fixes incorrect property name (#18136)
* moved camel case lambda

* renamed camel case lambda

* reverted unintended change

* fixed wrong property names

* restored accidental file deletion

* build samples
2024-03-18 13:02:26 +08:00
William Cheng
669651fcb2 trigger workflow when theres change to postman.json (#18129) 2024-03-18 13:01:15 +08:00
devhl-labs
96fad5eb2c [csharp] Fix getModelFromParameter (#18137)
* fix getModelFromParameter

* minor fix
2024-03-18 12:54:49 +08:00
devhl-labs
12849cccbe Camel case lambda does too much (#18131)
* moved camel case lambda

* renamed camel case lambda

* reverted unintended change
2024-03-17 16:42:11 +08:00
William Cheng
c5ab78575a Add rule to set container (array, set, map) to true (#18128)
* add rule to set containter to null

* update doc
2024-03-17 16:37:46 +08:00
Tomohiko Ozawa
0b4cf0a027 [typescript-fetch] Omit readOnly properties from request models (#18065)
* omit readOnly properties on requests

* update the sample
2024-03-16 09:27:39 +01:00
dvacca-onfido
ae9598dcfc fix(typescript-axios): Serialize boolean to string in form-data file upload (#18084) 2024-03-16 09:20:48 +01:00
William Cheng
d1ccabbe7e update file header 2024-03-16 15:34:52 +08:00
ふぁ
3137b3da77 [python-pydantic-v1] Fix unnamed dicts with additional properties (#18112)
* [python-pydantic-v1] pick #16779

* [python] update sample
2024-03-16 15:26:06 +08:00
Daniel Karlsson
fbe81f0735 Add new uncamelize lambda (#18109)
Co-authored-by: Daniel Karlsson <daniel.karlsson@cinnober.com>
2024-03-16 15:23:10 +08:00
William Cheng
41dbe51575 update protobuf to newer version (go gin) (#18123) 2024-03-16 14:59:47 +08:00
dependabot[bot]
58bdef48c7 Bump follow-redirects from 1.15.4 to 1.15.6 in /website (#18116)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.4 to 1.15.6.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.4...v1.15.6)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-16 14:36:24 +08:00
Petar Karadzhov
4f4237393f [dart] fix: Bearer and Basic auth interceptors case-insensitive scheme comparison (17073) (#17074)
* [dart] fix: Bearer and Basic auth interceptors case-insensitive scheme comparison

* Update samples
2024-03-16 10:49:43 +08:00
Jérôme Prinet
3bd8974583 Ignore _merged_spec.yaml when computing build cache key (#18105) 2024-03-15 19:43:29 +08:00
Beppe Catanese
cb75fa0d9e [POSTMAN] Genarate Postman requests from inline examples (#18086)
* Process inline examples (if available)

* Test generation with inline examples

* Update samples

* Move test to CI testing suite
2024-03-14 21:03:31 +08:00
Dennis Melzer
5ed2283e01 Fix model generation of array with items unique = true (#18104)
* Fix optional empty collection as default

* Fix test

* Fix test

* Fix default value collection handling
2024-03-14 20:51:11 +08:00
Dennis Melzer
96bf7ac915 Fix default empty collections when collection is optional (#18080)
* Fix optional empty collection as default

* Fix test

* Fix test
2024-03-14 20:28:27 +08:00
Jonas Emmert
6075b8a8f1 [R][Client] Fix api response, JSON for maps and let httr2 api client handle empty response bodies (#18049)
* changed files from rebuilding project and updating samples

* change default value of from_encoding to empty string

- from_encoding = NULL is invalid and produces an error, as only strings are allowed, see https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/iconv
- defaulting to an empty string fixes this issue

* fix map being surrounded by quotes in json

* allow httr2 client to deal with empty response body

* changed files from rebuilding project and updating samples

* added PetMap schema for test of correct map serialization in toJSONString and regenerated samples
2024-03-13 15:30:58 +08:00
javiarellanoo
7e8de912a7 Update ExampleGenerator.java (#18003)
Renamed the DATE_FORMAT field in order to follow convention
2024-03-13 15:02:08 +08:00
Daniel Seiler
9824b004f0 Update 2018-12-24-new-website.md (#18085)
https://docusaurus.io/en returns 404
2024-03-13 13:26:54 +08:00
dependabot[bot]
e41dc1e81b Bump swift-actions/setup-swift from 1 to 2 (#18087)
Bumps [swift-actions/setup-swift](https://github.com/swift-actions/setup-swift) from 1 to 2.
- [Release notes](https://github.com/swift-actions/setup-swift/releases)
- [Commits](https://github.com/swift-actions/setup-swift/compare/v1...v2)

---
updated-dependencies:
- dependency-name: swift-actions/setup-swift
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-13 13:21:50 +08:00
ふぁ
1586c698c9 [python] Fix multipart requests with type file fails with binary data (#18079)
* [python] fix Multipart requests with type file fails with binary data #18073

* [python] update sample
2024-03-12 19:24:55 +08:00
Timo von Holtz
5975e6c5b0 Haskell: JSON Query parameters (#18047)
* Allow json encoded query paramters

* Also fix haskell-http-client

* Regenerate haskell samples
2024-03-12 15:35:18 +08:00
denisbog
6251aa17ef [RUST-AXUM] fix generator not handling application/x-www-form-urlencoded request content (#18061)
* fix OpenAPITools/openapi-generator#18060

* isolate the option as separate flag

* apply modification suggested by @wing328

* remove added newlines
2024-03-12 15:17:30 +08:00
ふぁ
678db1e4af [python] json like str response (#18069)
* [python] json like str response

* [python] fix response deserialize

* [python] update sample

* [python] fix echo_api test quotes
2024-03-11 20:27:26 +08:00
BaptisteSaves
82fcf28a2b Remove pydantic warnings when using model_dump by fixing one_of_schemas type (#17941) 2024-03-11 20:26:46 +08:00
William Cheng
7f1e79f7d2 [C] Optimize memory usage when printing JSON (#18072)
* cJSON generate unformatted json to save memory during large objects handling

* update sample

* add option to use cjson print unforamtted in client

* remove unused test template files

* add new samples

* update workflow

* update doc

* fix model filename

* fix inclulde

---------

Co-authored-by: Hemant Zope <42613258+zhemant@users.noreply.github.com>
Co-authored-by: Hemant Zope <hemantzope2008@gmail.com>
2024-03-11 16:18:08 +08:00
William Cheng
4ff7e0ec3f Prepare 7.5.0 snapshot (#18068)
* Revert "7.4.0 release"

This reverts commit eda0493484.

* prepare 7.5.0 snapshot version

* update samples

* update doc
2024-03-11 11:10:52 +08:00
13471 changed files with 295583 additions and 179416 deletions

View File

@@ -4,14 +4,23 @@ on:
push:
paths:
- 'samples/client/petstore/c/**'
- 'samples/client/petstore/c-useJsonUnformatted/**'
pull_request:
paths:
- 'samples/client/petstore/c/**'
- 'samples/client/petstore/c-useJsonUnformatted/**'
jobs:
build:
name: Build c libcurl client
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
- 'samples/client/petstore/c/'
- 'samples/client/petstore/c-useJsonUnformatted/'
steps:
- uses: actions/checkout@v4
- name: Prepare
@@ -19,7 +28,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y libssl-dev libcurl4-openssl-dev
- name: Build
working-directory: "samples/client/petstore/c"
working-directory: ${{ matrix.sample }}
run: |
mkdir build
cd build

View File

@@ -3,22 +3,16 @@ name: Samples C# .Net Standard Client
on:
push:
paths:
# build C# API client (netstandard)
- samples/client/petstore/csharp/OpenAPIClient/**
- samples/client/petstore/csharp/*netstandard*/**
# build C# API client (netstandard with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
# build C# API client (netstandard httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
- samples/client/petstore/csharp/generichost/standard2.0/**
- samples/client/petstore/csharp/httpclient/standard2.0/**
- samples/client/petstore/csharp/restsharp/standard2.0/**
- samples/client/petstore/csharp/unityWebRequest/standard2.0/**
pull_request:
paths:
# build C# API client (netstandard)
- samples/client/petstore/csharp/OpenAPIClient/**
- samples/client/petstore/csharp/*netstandard*/**
# build C# API client (netstandard with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
# build C# API client (netstandard httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
- samples/client/petstore/csharp/generichost/standard2.0/**
- samples/client/petstore/csharp/httpclient/standard2.0/**
- samples/client/petstore/csharp/restsharp/standard2.0/**
- samples/client/petstore/csharp/unityWebRequest/standard2.0/**
jobs:
build:
name: Build .Net projects
@@ -27,13 +21,11 @@ jobs:
fail-fast: false
matrix:
sample:
# build C# API client (netstandard)
- samples/client/petstore/csharp/OpenAPIClient/
- samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/
# build C# API client (netstandard with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/
# build C# API client (netstandard httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/
- samples/client/petstore/csharp/generichost/standard2.0/Petstore/
- samples/client/petstore/csharp/httpclient/standard2.0/Petstore/
- samples/client/petstore/csharp/restsharp/standard2.0/Petstore/
- samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -3,16 +3,16 @@ name: Samples C# .Net 8 Clients
on:
push:
paths:
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**
- samples/client/petstore/csharp/*net6.0*/**
- samples/client/petstore/csharp/*net7.0*/**
- samples/client/petstore/csharp/OpenAPIClient-*latest*/**
- samples/client/petstore/csharp/generichost/net8/**
- samples/client/petstore/csharp/httpclient/net8/**
- samples/client/petstore/csharp/restsharp/net8/**
- samples/client/petstore/csharp/unityWebRequest/net8/**
pull_request:
paths:
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**
- samples/client/petstore/csharp/*net6.0*/**
- samples/client/petstore/csharp/*net7.0*/**
- samples/client/petstore/csharp/OpenAPIClient-*latest*/**
- samples/client/petstore/csharp/generichost/net8/**
- samples/client/petstore/csharp/httpclient/net8/**
- samples/client/petstore/csharp/restsharp/net8/**
- samples/client/petstore/csharp/unityWebRequest/net8/**
jobs:
build:
name: Build .Net projects
@@ -21,16 +21,16 @@ jobs:
fail-fast: false
matrix:
sample:
# clients
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt
- samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
- samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
- samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
- samples/client/petstore/csharp/generichost/net8/AllOf
- samples/client/petstore/csharp/generichost/net8/AnyOf
- samples/client/petstore/csharp/generichost/net8/FormModels
- samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests
- samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests
- samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
- samples/client/petstore/csharp/generichost/net8/OneOf
- samples/client/petstore/csharp/generichost/net8/Petstore
- samples/client/petstore/csharp/generichost/net8/SourceGeneration
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -3,28 +3,10 @@ name: Samples C# .Net 6 Client
on:
push:
paths:
# build C# API client (httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
# build C# API client (.net framework 4.7)
- samples/client/petstore/csharp/OpenAPIClient-net47/**
# build C# API client (.net framework 4.8)
- samples/client/petstore/csharp/OpenAPIClient-net48/**
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/**
# build C# API client (multiple frameworks)
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
- samples/client/petstore/csharp/restsharp/net6/**
pull_request:
paths:
# build C# API client (httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
# build C# API client (.net framework 4.7)
- samples/client/petstore/csharp/OpenAPIClient-net47/**
# build C# API client (.net framework 4.8)
- samples/client/petstore/csharp/OpenAPIClient-net48/**
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/**
# build C# API client (multiple frameworks)
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
- samples/client/petstore/csharp/restsharp/net6/**
jobs:
build:
name: Build .Net clients
@@ -33,16 +15,7 @@ jobs:
fail-fast: false
matrix:
sample:
# build C# API client (httpclient)
- samples/client/petstore/csharp/OpenAPIClient-httpclient/
# build C# API client (.net framework 4.7)
- samples/client/petstore/csharp/OpenAPIClient-net47/
# build C# API client (.net framework 4.8)
- samples/client/petstore/csharp/OpenAPIClient-net48/
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings/
# build C# API client (multiple frameworks)
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/
- samples/client/petstore/csharp/restsharp/net6/ParameterMappings/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4.0.0

View File

@@ -13,6 +13,8 @@ on:
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
- samples/client/others/java/jersey2-oneOf-Mixed/**
pull_request:
paths:
- 'samples/client/petstore/java/**'
@@ -25,6 +27,8 @@ on:
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
- samples/client/others/java/jersey2-oneOf-Mixed/**
jobs:
build:
name: Build Java Client JDK11
@@ -71,6 +75,8 @@ jobs:
- samples/client/others/java/okhttp-gson-oneOf/
- samples/client/others/java/resttemplate-useAbstractionForFiles/
- samples/client/others/java/webclient-useAbstractionForFiles/
- samples/client/others/java/jersey2-oneOf-duplicates/
- samples/client/others/java/jersey2-oneOf-Mixed/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4

View File

@@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: 1.8
arch: x64

View File

@@ -25,6 +25,7 @@ jobs:
- samples/client/petstore/kotlin
- samples/client/petstore/kotlin-gson
- samples/client/petstore/kotlin-jackson
- samples/client/petstore/kotlin-model-prefix-type-mappings
# needs Android configured
#- samples/client/petstore/kotlin-json-request-string
- samples/client/petstore/kotlin-jvm-okhttp4-coroutines

View File

@@ -19,6 +19,7 @@ jobs:
sample:
# clients
- samples/client/echo_api/kotlin-jvm-spring-3-restclient
- samples/client/echo_api/kotlin-model-prefix-type-mappings
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4

View File

@@ -5,12 +5,14 @@ on:
branches:
- samples/server/others/kotlin-server/jaxrs-spec/**
- 'samples/server/petstore/kotlin*/**'
- 'samples/server/others/kotlin-server/jaxrs-spec-array-response/**'
# comment out due to gradle build failure
#- samples/server/petstore/kotlin-spring-default/**
pull_request:
paths:
- samples/server/others/kotlin-server/jaxrs-spec/**
- 'samples/server/petstore/kotlin*/**'
- 'samples/server/others/kotlin-server/jaxrs-spec-array-response/**'
# comment out due to gradle build failure
# - samples/server/petstore/kotlin-spring-default/**
@@ -40,6 +42,7 @@ jobs:
- samples/server/petstore/kotlin-server-modelMutable
- samples/server/petstore/kotlin-server/javalin
- samples/server/others/kotlin-server/jaxrs-spec
- samples/server/others/kotlin-server/jaxrs-spec-array-response
# comment out due to gradle build failure
#- samples/server/petstore/kotlin-spring-default
# no build.gradle file

View File

@@ -4,6 +4,7 @@ on:
pull_request:
paths:
- samples/schema/postman-collection/python/**
- samples/schema/postman-collection/postman.json
- .github/workflows/samples-postman.yaml
jobs:
build:

View File

@@ -34,6 +34,7 @@ jobs:
- samples/openapi3/client/petstore/spring-cloud-async
- samples/openapi3/client/petstore/spring-cloud-spring-pageable
- samples/client/petstore/spring-cloud-tags
- samples/client/petstore/spring-cloud-auth
- samples/client/petstore/spring-cloud-deprecated
# servers
- samples/server/petstore/springboot

View File

@@ -41,7 +41,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v1
- uses: swift-actions/setup-swift@v2
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
swift-version: '5'

View File

@@ -13,7 +13,7 @@ if [ "$NODE_INDEX" = "1" ]; then
echo "Running node $NODE_INDEX ..."
java -version
sudo apt-get -y install cpanminus libmagic-dev
sudo apt-get -y install cpanminus
(cd samples/client/petstore/perl && /bin/bash ./test.bash)
(cd samples/client/petstore/ruby && mvn integration-test)
@@ -112,5 +112,3 @@ else
(cd samples/client/petstore/java/apache-httpclient && mvn integration-test)
fi

View File

@@ -15,7 +15,7 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.4.0`):
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.5.0`):
[![Build Status](https://api.travis-ci.com/OpenAPITools/openapi-generator.svg?branch=master&status=passed)](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/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)
@@ -68,6 +68,7 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
[<img src="https://openapi-generator.tech/img/companies/ssstwitter.png" width="128" height="128">](https://ssstwitter.com/?utm_source=github&utm_medium=referral&utm_campaign=sponsor)
[<img src="https://openapi-generator.tech/img/companies/svix.png" width="128" height="128">](https://www.svix.com/?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
[<img src="https://openapi-generator.tech/img/companies/litslink.png" width="128" height="128">](https://litslink.com/services/artificial-intelligence?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
[<img src="https://openapi-generator.tech/img/companies/designli.jpg" width="128" height="128">](https://designli.co?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS, Checkly for sponsoring the API monitoring and Gradle for sponsoring Develocity
@@ -125,8 +126,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 7.4.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.4.0-SNAPSHOT/) | 08.03.2024 | Minor release with breaking changes (with fallback) |
| [7.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.3.0) (latest stable release) | 08.02.2024 | Minor release with breaking changes (with fallback) |
| 7.5.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.5.0-SNAPSHOT/) | 12.04.2024 | Minor release with breaking changes (with fallback) |
| [7.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.4.0) (latest stable release) | 11.03.2024 | Minor release with breaking changes (with fallback) |
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 11.05.2023 | Minor release with breaking changes (with fallback) |
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | Minor release with breaking changes (with fallback) |
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
@@ -189,16 +190,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.3.0/openapi-generator-cli-7.3.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar`
For **Mac/Linux** users:
```sh
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.3.0/openapi-generator-cli-7.3.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar -O openapi-generator-cli.jar
```
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.3.0/openapi-generator-cli-7.3.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@@ -904,6 +905,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2022-04-06 - [Effective Software Development using OpenAPI Generator](https://apexlabs.ai/post/openapi-generator) by Ajil Oommen (Senior Flutter Developer)
- 2022-05-13 - [A Path From an API To Client Libraries](https://www.youtube.com/watch?v=XC8oVn_efTw) by [Filip Srnec](https://www.devoxx.co.uk/talk/?id=11211) at Infobip
- 2022-06-01 - [API First, using OpenAPI and Spring Boot](https://medium.com/xgeeks/api-first-using-openapi-and-spring-boot-2602c04bb0d3) by [Micael Estrázulas Vianna](https://estrazulas.medium.com/)
- 2022-06-10 - [Autogenerating Clients with FastAPI and Github Actions](https://www.propelauth.com/post/autogenerating-clients-with-fastapi-and-github-actions) by [Andrew Israel](https://www.propelauth.com/author/andrew)
- 2022-06-12 - [Mustache templates with OpenAPI specs](https://medium.com/geekculture/mustache-templates-with-openapi-specs-f24711c67dec) by [Beppe Catanese](https://github.com/gcatanese)
- 2022-07-01 - [Generate API contract using OpenAPI Generator Maven plugin](https://huongdanjava.com/generate-api-contract-using-openapi-generator-maven-plugin.html) by [Khanh Nguyen](https://huongdanjava.com/)
- 2022-07-22 - [使用OpenAPI Generator Maven plugin开发api优先的java客户端和服务端代码](https://blog.roccoshi.top/2022/java/openapi-generator%E7%9A%84%E4%BD%BF%E7%94%A8/) by [Lincest](https://github.com/Lincest)
@@ -927,6 +929,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2023-06-28 - [Generate API contract using OpenAPI Generator Maven plugin](https://huongdanjava.com/generate-api-contract-using-openapi-generator-maven-plugin.html) by [Khanh Nguyen](https://huongdanjava.com/)
- 2023-06-30 - [Generate Client SDKs with OpenApi Generator in Springboot](https://medium.com/@ramavathvinayak/generate-client-sdks-with-openapi-generator-in-springboot-f9f012e73c0b) by [Vinayak Ramavath](https://medium.com/@ramavathvinayak)
- 2023-12-10 - [UnityでOpenAPI Generatorを使う](https://www.youtube.com/watch?v=CbNwKVV5LRM) by [Soup Tori](https://www.youtube.com/@souptori8417)
- 2024-03-04 - [Generating TypeScript Types with OpenAPI for REST API Consumption](https://www.pullrequest.com/blog/generating-typescript-types-with-openapi-for-rest-api-consumption/) by [PullRequest](https://www.pullrequest.com/)
- 2024-03-07 - [Fully typed Web Apps with OpenAPI (Part 1)](https://medium.com/@gfox1984/fully-typed-web-apps-with-openapi-part-1-595d55766670) by [Guillaume Renard](https://medium.com/@gfox1984)
## [6 - About Us](#table-of-contents)
@@ -1114,8 +1118,9 @@ Here is a list of template creators:
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
* Ktorm: @Luiz-Monad
* MySQL: [@ybelenko](https://github.com/ybelenko)
* Postman Collection: @gcatanese
* Protocol Buffer: @wing328
* WSDL @adessoDpd
* WSDL: @adessoDpd
:heart: = Link to support the contributor directly

View File

@@ -43,23 +43,29 @@ build_script:
#- dotnet build samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\Org.OpenAPITools.sln
test_script:
# test c# API client (multiple frameworks)
- dotnet test samples\client\petstore\csharp\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (httpclient)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-httpclient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (generichost)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-generichost-netstandard2.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test c# API client (netcore)
- dotnet test samples\client\petstore\csharp\OpenAPIClientCore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
#- dotnet test samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net framework 4.7)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net framework 4.8)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net 5.0)
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API Client using conditional-serialization
- dotnet test samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\AllOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\AnyOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\FormModels\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualSourceGenerationTests\ManualTests.Latest.UseSourceGeneration\ManualTests.Latest.UseSourceGeneration.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\ManualPetstoreTests\OpenAPIClient-generichost-manual-tests\OpenAPIClient-generichost-manual-tests.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\NullReferenceTypes\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\OneOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\SourceGeneration\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\net8\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\httpclient\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\MultipleFrameworks\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net4.8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net6\ParameterMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\EnumMappings\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\net7\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\restsharp\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
### TODO: Execute all generators via powershell or other
# generate all petstore clients

View File

@@ -0,0 +1,9 @@
generatorName: c
outputDir: samples/client/petstore/c-useJsonUnformatted
inputSpec: modules/openapi-generator/src/test/resources/2_0/c/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/C-libcurl
additionalProperties:
useJsonUnformatted: true
modelNameMappings:
another_model: MappedModel
another_property: mappedProperty

View File

@@ -1,12 +0,0 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true

View File

@@ -1,12 +0,0 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true

View File

@@ -1,13 +0,0 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
useSourceGeneration: true
packageName: UseSourceGeneration
equatable: true

View File

@@ -1,12 +0,0 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true

View File

@@ -1,12 +0,0 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true

View File

@@ -1,12 +0,0 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: false
equatable: true

View File

@@ -1,9 +0,0 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}'
useDateTimeForDate: true

View File

@@ -0,0 +1,13 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/AllOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -0,0 +1,13 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/AnyOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -0,0 +1,16 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/FormModels
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: false
equatable: true
targetFramework: net8.0
skipFormModel: false
inlineSchemaOptions:
RESOLVE_INLINE_ENUMS: true

View File

@@ -0,0 +1,13 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/SourceGeneration
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
useSourceGeneration: true
equatable: true
targetFramework: net8.0

View File

@@ -0,0 +1,13 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -0,0 +1,13 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/OneOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: true
equatable: true
targetFramework: net8.0

View File

@@ -0,0 +1,10 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}'
useDateTimeForDate: true
targetFramework: net8.0

View File

@@ -0,0 +1,13 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
nullableReferenceTypes: false
equatable: true
targetFramework: net8.0

View File

@@ -1,6 +1,6 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0
outputDir: samples/client/petstore/csharp/generichost/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
library: generichost
templateDir: modules/openapi-generator/src/main/resources/csharp

View File

@@ -1,6 +1,6 @@
# for .net standard httpclient
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-httpclient
outputDir: samples/client/petstore/csharp/httpclient/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
library: httpclient

View File

@@ -1,5 +1,5 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClientCoreAndNet47
outputDir: samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-net47
outputDir: samples/client/petstore/csharp/restsharp/net4.7/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-net48
outputDir: samples/client/petstore/csharp/restsharp/net4.8/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,5 +1,5 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-restsharp-name-parameter-mappings
outputDir: samples/client/petstore/csharp/restsharp/net6/ParameterMappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/name-parameter-mappings.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
nameMappings:

View File

@@ -1,5 +1,5 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClientCore
outputDir: samples/client/petstore/csharp/restsharp/net7/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
outputDir: samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-net5.0
outputDir: samples/client/petstore/csharp/restsharp/net7/EnumMappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net standard
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient
outputDir: samples/client/petstore/csharp/restsharp/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:

View File

@@ -1,6 +1,6 @@
# for .net Unity
generatorName: csharp
outputDir: samples/client/petstore/csharp/OpenAPIClient-unityWebRequest
outputDir: samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
library: unityWebRequest

View File

@@ -1,6 +1,6 @@
generatorName: haskell-http-client
outputDir: samples/client/petstore/haskell-http-client
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/haskell-http-client/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/haskell-http-client
additionalProperties:
queryExtraUnreserved: ''

View File

@@ -0,0 +1,7 @@
generatorName: java
outputDir: samples/client/others/java/jersey2-oneOf-duplicates
library: jersey2
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_duplicateArray.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: "true"

View File

@@ -0,0 +1,7 @@
generatorName: java
outputDir: samples/client/others/java/jersey2-oneOf-Mixed
library: jersey2
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_primitiveAndArray.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: "true"

View File

@@ -4,6 +4,7 @@ library: jersey3
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
useBeanValidation: true
artifactId: petstore-jersey3
hideGenerationTimestamp: true
serverPort: "8082"

View File

@@ -8,3 +8,4 @@ additionalProperties:
hideGenerationTimestamp: "true"
disallowAdditionalPropertiesIfNotPresent: false
useSingleRequestParameter: true
useBeanValidation: true

View File

@@ -10,3 +10,4 @@ additionalProperties:
playVersion: play26
artifactId: petstore-java-client-retrofit2-play26
hideGenerationTimestamp: "true"
useJakartaEe: "true"

View File

@@ -0,0 +1,15 @@
generatorName: kotlin
outputDir: samples/client/echo_api/kotlin-model-prefix-type-mappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
typeMappings:
java.io.File: RequestBody
modelNamePrefix: Api
additionalProperties:
artifactId: kotlin-client-prefix-mapping
useCoroutines: true
library: jvm-retrofit2
enumPropertyNaming: UPPERCASE
serializationLibrary: gson
openapiNormalizer:
SIMPLIFY_ONEOF_ANYOF=false

View File

@@ -0,0 +1,15 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-model-prefix-type-mappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
typeMappings:
java.io.File: RequestBody
modelNamePrefix: Api
additionalProperties:
artifactId: kotlin-client-prefix-mapping
useCoroutines: true
library: jvm-retrofit2
enumPropertyNaming: UPPERCASE
serializationLibrary: gson
openapiNormalizer:
SIMPLIFY_ONEOF_ANYOF=false

View File

@@ -0,0 +1,8 @@
generatorName: kotlin-server
outputDir: samples/server/others/kotlin-server/jaxrs-spec-array-response
library: jaxrs-spec
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/issue18177-array.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-server
additionalProperties:
interfaceOnly: "true"
useJakartaEe: true

View File

@@ -0,0 +1,9 @@
generatorName: spring
outputDir: samples/client/petstore/spring-cloud-auth
library: spring-cloud
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-auth.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
documentationProvider: none
artifactId: petstore-spring-cloud-auth
hideGenerationTimestamp: "true"

View File

@@ -1,10 +1,10 @@
---
# csharp test files and image for upload
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
sha256: e323c7e646a0ceb6d1d8f34f287175ac666fdbbe057791b45d138de3d9582666
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
sha256: 7dad88554fe630d25c787cae05305d302d5e34ca810aee4fa23f20055f9188e1
- filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
- filename: "samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools.Test/linux-logo.png"
sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
# java okhttp gson test files
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java"

View File

@@ -598,3 +598,17 @@ Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java-okhttp/ --openapi-normalizer FILTER="operationId:addPet|getPetById"
```
- `SET_CONTAINER_TO_NULLABLE`: When set to `array|set|map` (or just `array`) for example, it will set `nullable` in array, set and map to true.
Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_CONTAINER_TO_NULLABLE="array|map"
```
- `SET_PRIMITIVE_TYPES_TO_NULLABLE`: When set to `string|integer|number|boolean` (or just `string`) for example, it will set the type to `nullable` (nullable: true)
Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_PRIMITIVE_TYPES_TO_NULLABLE="integer|number"
```

View File

@@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|useJsonUnformatted|Use cJSON_PrintUnformatted instead of cJSON_Print when creating the JSON string.| |false|
## IMPORT MAPPING

View File

@@ -51,6 +51,9 @@ To push the auto-generated SDK to GitHub, we provide `git_push.sh` to streamline
cd /var/tmp/perl/petstore
/bin/sh ./git_push.sh
```
To use openapi-generator as part of Github workflows, the blog post ["Autogenerating Clients with FastAPI and Github Actions"](https://www.propelauth.com/post/autogenerating-clients-with-fastapi-and-github-actions) by Andrew Israel is a good starting point.
### CI/CD
Some generators also generate CI/CD configuration files (.travis.yml) so that the output will be ready to be tested by the CI (e.g. Travis)

View File

@@ -822,6 +822,7 @@ Many generators (*those extending DefaultCodegen*) come with a small set of lamb
- `uppercase` - Converts all of the characters in this fragment to upper case using the rules of the `ROOT` locale.
- `titlecase` - Converts text in a fragment to title case. For example `once upon a time` to `Once Upon A Time`.
- `camelcase` - Converts text in a fragment to camelCase. For example `Input-text` to `inputText`.
- `uncamelize` - Converts text in a fragment from camelCase or PascalCase to a string of words separated by whitespaces. For example `inputText` to `Input Text`.
- `indented` - Prepends 4 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_8` - Prepends 8 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_12` - Prepends 12 spaces indention from second line of a fragment on. First line will be indented by Mustache.

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.4.0
openApiGeneratorVersion=7.5.0-SNAPSHOT
# /RELEASE_VERSION

View File

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

View File

@@ -15,7 +15,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.4.0</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@@ -19,7 +19,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.4.0</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>

View File

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

View File

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

View File

@@ -20,7 +20,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.4.0</version>
<version>7.5.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

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

View File

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

View File

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

View File

@@ -350,6 +350,8 @@ public interface CodegenConfig {
*/
String generatorLanguageVersion();
boolean isTypeErasedGenerics();
List<VendorExtension> getSupportedVendorExtensions();
boolean getUseInlineModelResolver();

View File

@@ -39,6 +39,9 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumDefaultValue, enumName, style;
public String nameInLowerCase; // property name in lower case
public String nameInCamelCase; // property name in camel case (e.g. modifiedDate)
public String nameInPascalCase; // property name in pascal case (e.g. ModifiedDate)
public String nameInSnakeCase; // property name in upper snake case
public String example; // example value (x-example)
public Map<String, Example> examples;
public String jsonSchema;
@@ -184,6 +187,11 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
output.additionalProperties = this.additionalProperties;
output.isNull = this.isNull;
output.isVoid = this.isVoid;
output.nameInPascalCase = this.nameInPascalCase;
output.nameInCamelCase = this.nameInCamelCase;
output.nameInLowerCase = this.nameInLowerCase;
output.nameInSnakeCase = this.nameInSnakeCase;
output.setAdditionalPropertiesIsAnyType(this.getAdditionalPropertiesIsAnyType());
output.setHasVars(this.hasVars);
output.setHasRequired(this.hasRequired);
@@ -265,7 +273,22 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
@Override
public int hashCode() {
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, containerType, containerTypeMapped, defaultValue, enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, isVoid, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content, requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties);
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam,
isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName,
paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description,
unescapedDescription, baseType, containerType, containerTypeMapped, defaultValue,
enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples,
jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal,
isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword,
isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues,
items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation,
getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(),
getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(),
getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull,isVoid,
additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger,
hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, schema, content,
requiredVarsMap, ref, uniqueItemsBoolean, schemaIsFromAdditionalProperties,
nameInPascalCase, nameInCamelCase, nameInLowerCase, nameInSnakeCase);
}
@Override

View File

@@ -182,8 +182,10 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
public boolean isInherited;
public String discriminatorValue;
public String nameInLowerCase; // property name in lower case
public String nameInCamelCase; // property name in camel case
public String nameInCamelCase; // property name in camel case (e.g. modifiedDate)
public String nameInPascalCase; // property name in pascal case (e.g. ModifiedDate)
public String nameInSnakeCase; // property name in upper snake case
// enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
public String enumName;
@@ -697,6 +699,14 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.nameInCamelCase = nameInCamelCase;
}
public String getNameInPascalCase() {
return nameInPascalCase;
}
public void setNameInPascalCase(String nameInPascalCase) {
this.nameInPascalCase = nameInPascalCase;
}
public String getNameInSnakeCase() {
return nameInSnakeCase;
}
@@ -1129,6 +1139,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isEnum = isEnum;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{");
@@ -1213,6 +1224,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
sb.append(", isInherited=").append(isInherited);
sb.append(", discriminatorValue='").append(discriminatorValue).append('\'');
sb.append(", nameInCamelCase='").append(nameInCamelCase).append('\'');
sb.append(", nameInPascalCase='").append(nameInPascalCase).append('\'');
sb.append(", nameInSnakeCase='").append(nameInSnakeCase).append('\'');
sb.append(", enumName='").append(enumName).append('\'');
sb.append(", maxItems=").append(maxItems);
@@ -1352,6 +1364,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
Objects.equals(vendorExtensions, that.vendorExtensions) &&
Objects.equals(discriminatorValue, that.discriminatorValue) &&
Objects.equals(nameInCamelCase, that.nameInCamelCase) &&
Objects.equals(nameInPascalCase, that.nameInPascalCase) &&
Objects.equals(nameInSnakeCase, that.nameInSnakeCase) &&
Objects.equals(enumName, that.enumName) &&
Objects.equals(maxItems, that.maxItems) &&
@@ -1376,7 +1389,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
isArray, isMap, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, isOverridden, _enum,
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInPascalCase, nameInCamelCase,
nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
xmlNamespace, isXmlWrapped, isNull, isVoid, additionalPropertiesIsAnyType, hasVars, hasRequired,
hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes, requiredVarsMap,

View File

@@ -43,6 +43,8 @@ public class CodegenSecurity {
// Oauth specific
public String flow, authorizationUrl, tokenUrl, refreshUrl;
public List<Map<String, Object>> scopes;
public Boolean hasScopes;
public Boolean isCode, isPassword, isApplication, isImplicit;
// OpenId specific
public String openIdConnectUrl;

View File

@@ -52,6 +52,7 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.examples.ExampleGenerator;
import org.openapitools.codegen.languages.PhpNextgenClientCodegen;
import org.openapitools.codegen.languages.RustAxumServerCodegen;
import org.openapitools.codegen.languages.RustServerCodegen;
import org.openapitools.codegen.meta.FeatureSet;
import org.openapitools.codegen.meta.GeneratorMetadata;
@@ -64,6 +65,7 @@ import org.openapitools.codegen.model.WebhooksMap;
import org.openapitools.codegen.serializer.SerializerUtils;
import org.openapitools.codegen.templating.MustacheEngineAdapter;
import org.openapitools.codegen.templating.mustache.*;
import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.OneOfImplementorAdditionalData;
import org.slf4j.Logger;
@@ -81,6 +83,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.CodegenConstants.UNSUPPORTED_V310_SPEC_MSG;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.*;
@@ -462,8 +465,9 @@ public class DefaultCodegen implements CodegenConfig {
.put("snakecase", new SnakecaseLambda())
.put("titlecase", new TitlecaseLambda())
.put("kebabcase", new KebabCaseLambda())
.put("camelcase", new CamelCaseLambda(true).generator(this))
.put("pascalcase", new CamelCaseLambda(false).generator(this))
.put("camelcase", new CamelCaseAndSanitizeLambda(true).generator(this))
.put("pascalcase", new CamelCaseAndSanitizeLambda(false).generator(this))
.put("uncamelize", new UncamelizeLambda())
.put("forwardslash", new ForwardSlashLambda())
.put("backslash", new BackSlashLambda())
.put("doublequote", new DoubleQuoteLambda())
@@ -2055,7 +2059,11 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isMapSchema(schema)) {
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
String inner = getSchemaType(additionalProperties);
return instantiationTypes.get("map") + "<String, " + inner + ">";
String mapInstantion = instantiationTypes.get("map");
if (mapInstantion != null) {
return mapInstantion + "<String, " + inner + ">";
}
return inner;
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String inner = getSchemaType(getSchemaItems(arraySchema));
@@ -2456,6 +2464,14 @@ public class DefaultCodegen implements CodegenConfig {
protected String getSingleSchemaType(Schema schema) {
Schema unaliasSchema = unaliasSchema(schema);
if (ModelUtils.isRefToSchemaWithProperties(unaliasSchema.get$ref())) {
// ref to schema's properties, e.g. #/components/schemas/Pet/properties/category
Schema refSchema = ModelUtils.getReferencedSchema(openAPI, unaliasSchema);
if (refSchema != null) {
return getSingleSchemaType(refSchema);
}
}
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
// get the schema/model name from $ref
String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
@@ -2942,7 +2958,7 @@ public class DefaultCodegen implements CodegenConfig {
newProperties.forEach((key, value) ->
existingProperties.put(
key,
AnnotationsUtils.clone(value, specVersionGreaterThanOrEqualTo310(openAPI))
ModelUtils.cloneSchema(value, specVersionGreaterThanOrEqualTo310(openAPI))
));
if (null != existingType && null != newType && null != newType.getEnum() && !newType.getEnum().isEmpty()) {
for (Object e : newType.getEnum()) {
@@ -3346,7 +3362,7 @@ public class DefaultCodegen implements CodegenConfig {
String modelName = ModelUtils.getSimpleRef(((Schema) oneOf).get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) oneOf, discPropName, visitedSchemas);
if (thisCp == null) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName);
}
@@ -3355,7 +3371,7 @@ public class DefaultCodegen implements CodegenConfig {
continue;
}
if (cp != thisCp) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the OneOf schema '{}' has a different {} definition than the prior OneOf schema's. Make sure the {} type and required values are the same",
composedSchemaName, discPropName, modelName, discPropName, discPropName);
}
@@ -3369,7 +3385,7 @@ public class DefaultCodegen implements CodegenConfig {
String modelName = ModelUtils.getSimpleRef(((Schema) anyOf).get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, (Schema) anyOf, discPropName, visitedSchemas);
if (thisCp == null) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName);
}
@@ -3378,7 +3394,7 @@ public class DefaultCodegen implements CodegenConfig {
continue;
}
if (cp != thisCp) {
LOGGER.warn(
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the AnyOf schema '{}' has a different {} definition than the prior AnyOf schema's. Make sure the {} type and required values are the same",
composedSchemaName, discPropName, modelName, discPropName, discPropName);
}
@@ -3446,7 +3462,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if (discriminatorsPropNames.size() > 1) {
LOGGER.warn("The oneOf schemas have conflicting discriminator property names. " +
once(LOGGER).warn("The oneOf schemas have conflicting discriminator property names. " +
"oneOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
}
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getOneOf().size() && discriminatorsPropNames.size() == 1) {
@@ -3475,7 +3491,7 @@ public class DefaultCodegen implements CodegenConfig {
}
}
if (discriminatorsPropNames.size() > 1) {
LOGGER.warn("The anyOf schemas have conflicting discriminator property names. " +
once(LOGGER).warn("The anyOf schemas have conflicting discriminator property names. " +
"anyOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
}
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getAnyOf().size() && discriminatorsPropNames.size() == 1) {
@@ -3524,7 +3540,7 @@ public class DefaultCodegen implements CodegenConfig {
// schemas also has inline composed schemas
// Note: if it is only inline one level, then the inline model resolver will move it into its own
// schema and make it a $ref schema in the oneOf/anyOf location
LOGGER.warn(
once(LOGGER).warn(
"Invalid inline schema defined in oneOf/anyOf in '{}'. Per the OpenApi spec, for this case when a composed schema defines a discriminator, the oneOf/anyOf schemas must use $ref. Change this inline definition to a $ref definition",
composedSchemaName);
}
@@ -3546,14 +3562,14 @@ public class DefaultCodegen implements CodegenConfig {
msgSuffix += spacer + "invalid optional definition of " + discPropName + ", include it in required";
}
}
LOGGER.warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
once(LOGGER).warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
composedSchemaName, discPropName, modelName, msgSuffix);
}
MappedModel mm = new MappedModel(modelName, toModelName(modelName));
descendentSchemas.add(mm);
Schema cs = ModelUtils.getSchema(openAPI, modelName);
if (cs == null) { // cannot lookup the model based on the name
LOGGER.error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
once(LOGGER).error("Failed to lookup the schema '{}' when processing oneOf/anyOf. Please check to ensure it's defined properly.", modelName);
} else {
Map<String, Object> vendorExtensions = cs.getExtensions();
if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) {
@@ -3666,7 +3682,7 @@ public class DefaultCodegen implements CodegenConfig {
if (e.getValue().indexOf('/') >= 0) {
name = ModelUtils.getSimpleRef(e.getValue());
if (ModelUtils.getSchema(openAPI, name) == null) {
LOGGER.error("Failed to lookup the schema '{}' when processing the discriminator mapping of oneOf/anyOf. Please check to ensure it's defined properly.", name);
once(LOGGER).error("Failed to lookup the schema '{}' when processing the discriminator mapping of oneOf/anyOf. Please check to ensure it's defined properly.", name);
}
} else {
name = e.getValue();
@@ -3975,6 +3991,13 @@ public class DefaultCodegen implements CodegenConfig {
return cpc;
}
// if it's ref to schema's properties, get the actual schema defined in the properties
Schema refToPropertiesSchema = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, p.get$ref());
if (refToPropertiesSchema != null) {
p = refToPropertiesSchema;
return fromProperty(name, refToPropertiesSchema, required, schemaIsFromAdditionalProperties);
}
Schema original = null;
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level
if (ModelUtils.isAllOf(p) && p.getAllOf().size() == 1) {
@@ -4010,8 +4033,9 @@ public class DefaultCodegen implements CodegenConfig {
} else {
property.openApiType = p.getType();
}
property.nameInCamelCase = camelize(property.name);
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
property.nameInPascalCase = camelize(property.name);
property.nameInCamelCase = camelize(property.name, LOWERCASE_FIRST_LETTER);
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInPascalCase);
property.description = escapeText(p.getDescription());
property.unescapedDescription = p.getDescription();
property.title = p.getTitle();
@@ -4723,13 +4747,13 @@ public class DefaultCodegen implements CodegenConfig {
List<CodegenParameter> notNullableParams = new ArrayList<>();
CodegenParameter bodyParam = null;
RequestBody requestBody = operation.getRequestBody();
RequestBody requestBody = ModelUtils.getReferencedRequestBody(this.openAPI, operation.getRequestBody());
if (requestBody != null) {
String contentType = getContentType(requestBody);
if (contentType != null) {
contentType = contentType.toLowerCase(Locale.ROOT);
}
if (contentType != null &&
if (!(this instanceof RustAxumServerCodegen) && contentType != null &&
(contentType.startsWith("application/x-www-form-urlencoded") ||
contentType.startsWith("multipart"))) {
// process form parameters
@@ -4747,8 +4771,6 @@ public class DefaultCodegen implements CodegenConfig {
}
} else {
// process body parameter
requestBody = ModelUtils.getReferencedRequestBody(this.openAPI, requestBody);
String bodyParameterName = "";
if (op.vendorExtensions != null && op.vendorExtensions.containsKey("x-codegen-request-body-name")) {
bodyParameterName = (String) op.vendorExtensions.get("x-codegen-request-body-name");
@@ -5456,6 +5478,11 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.isCollectionFormatMulti = true;
}
codegenParameter.paramName = toParamName(parameter.getName());
codegenParameter.nameInCamelCase = camelize(codegenParameter.paramName, LOWERCASE_FIRST_LETTER);
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
// import
if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);
@@ -6768,6 +6795,7 @@ public class DefaultCodegen implements CodegenConfig {
enumVar.put("name", finalEnumName);
enumVar.put("value", toEnumValue(String.valueOf(value), dataType));
enumVar.put("isString", isDataTypeString(dataType));
// TODO: add isNumeric
enumVars.add(enumVar);
}
@@ -6790,6 +6818,7 @@ public class DefaultCodegen implements CodegenConfig {
enumVar.put("name", toEnumVarName(enumName, dataType));
enumVar.put("value", toEnumValue(enumValue, dataType));
enumVar.put("isString", isDataTypeString(dataType));
// TODO: add isNumeric
enumVars.add(enumVar);
}
@@ -6928,6 +6957,7 @@ public class DefaultCodegen implements CodegenConfig {
scopes.add(scope);
}
codegenSecurity.scopes = scopes;
codegenSecurity.hasScopes = true;
}
}
@@ -7183,6 +7213,11 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.dataType = codegenProperty.dataType;
codegenParameter.baseName = codegenProperty.baseName;
codegenParameter.paramName = toParamName(codegenParameter.baseName);
codegenParameter.nameInCamelCase = camelize(codegenParameter.paramName, LOWERCASE_FIRST_LETTER);
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
codegenParameter.dataFormat = codegenProperty.dataFormat;
// non-array/map
updateCodegenPropertyEnum(codegenProperty);
@@ -7567,6 +7602,11 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.baseName = bodyParameterName;
}
codegenParameter.paramName = toArrayModelParamName(codegenParameter.baseName);
codegenParameter.nameInCamelCase = camelize(codegenParameter.paramName, LOWERCASE_FIRST_LETTER);
codegenParameter.nameInPascalCase = camelize(codegenParameter.paramName);
codegenParameter.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codegenParameter.nameInPascalCase);
codegenParameter.nameInLowerCase = codegenParameter.paramName.toLowerCase(Locale.ROOT);
codegenParameter.items = codegenProperty.items;
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
codegenParameter.dataType = getTypeDeclaration(arraySchema);
@@ -8399,12 +8439,17 @@ public class DefaultCodegen implements CodegenConfig {
xOf.add(cp);
i += 1;
if (dataTypeSet.contains(cp.dataType)) {
if (dataTypeSet.contains(cp.dataType)
|| (isTypeErasedGenerics() && dataTypeSet.contains(cp.baseType))) {
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
// in other sub-schemas of allOf/anyOf/oneOf
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type", true);
} else {
dataTypeSet.add(cp.dataType);
if(isTypeErasedGenerics()) {
dataTypeSet.add(cp.baseType);
} else {
dataTypeSet.add(cp.dataType);
}
}
}
return xOf;
@@ -8441,11 +8486,16 @@ public class DefaultCodegen implements CodegenConfig {
return openapiGeneratorIgnoreList;
}
@Override
public boolean isTypeErasedGenerics() {
return false;
}
/*
A function to convert yaml or json ingested strings like property names
And convert special characters like newline, tab, carriage return
Into strings that can be rendered in the language that the generator will output to
*/
A function to convert yaml or json ingested strings like property names
And convert special characters like newline, tab, carriage return
Into strings that can be rendered in the language that the generator will output to
*/
protected String handleSpecialCharacters(String name) { return name; }
/**

View File

@@ -292,7 +292,9 @@ public class DefaultGenerator implements Generator {
// set OpenAPI to make these available to all methods
config.setOpenAPI(openAPI);
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
if (!config.additionalProperties().containsKey("generatorVersion")) {
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
}
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
config.additionalProperties().put("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
config.additionalProperties().put("generatorClass", config.getClass().getName());

View File

@@ -38,6 +38,8 @@ public class OpenAPINormalizer {
private Map<String, String> inputRules = new HashMap<>();
private Map<String, Boolean> rules = new HashMap<>();
private TreeSet<String> anyTypeTreeSet = new TreeSet<>();
final Logger LOGGER = LoggerFactory.getLogger(OpenAPINormalizer.class);
Set<String> ruleNames = new TreeSet<>();
@@ -101,10 +103,25 @@ public class OpenAPINormalizer {
final String X_INTERNAL = "x-internal";
boolean removeXInternal;
// when set (e.g. operationId:getPetById, addPet), filter out (or remove) everything else
// when set (e.g. operationId:getPetById|addPet), filter out (or remove) everything else
final String FILTER = "FILTER";
HashSet<String> operationIdFilters = new HashSet<>();
// when set (e.g. operationId:getPetById|addPet), filter out (or remove) everything else
final String SET_CONTAINER_TO_NULLABLE = "SET_CONTAINER_TO_NULLABLE";
HashSet<String> setContainerToNullable = new HashSet<>();
boolean updateArrayToNullable;
boolean updateSetToNullable;
boolean updateMapToNullable;
// when set (e.g. operationId:getPetById|addPet), filter out (or remove) everything else
final String SET_PRIMITIVE_TYPES_TO_NULLABLE = "SET_PRIMITIVE_TYPES_TO_NULLABLE";
HashSet<String> setPrimitiveTypesToNullable = new HashSet<>();
boolean updateStringToNullable;
boolean updateIntegerToNullable;
boolean updateNumberToNullable;
boolean updateBooleanToNullable;
// ============= end of rules =============
/**
@@ -136,12 +153,23 @@ public class OpenAPINormalizer {
ruleNames.add(NORMALIZE_31SPEC);
ruleNames.add(REMOVE_X_INTERNAL);
ruleNames.add(FILTER);
ruleNames.add(SET_CONTAINER_TO_NULLABLE);
ruleNames.add(SET_PRIMITIVE_TYPES_TO_NULLABLE);
// rules that are default to true
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
processRules(inputRules);
// represent any type in tree set
anyTypeTreeSet.add("string");
anyTypeTreeSet.add("number");
anyTypeTreeSet.add("integer");
anyTypeTreeSet.add("boolean");
anyTypeTreeSet.add("object");
anyTypeTreeSet.add("array");
}
/**
@@ -199,6 +227,43 @@ public class OpenAPINormalizer {
}
}
}
if (inputRules.get(SET_CONTAINER_TO_NULLABLE) != null) {
rules.put(SET_CONTAINER_TO_NULLABLE, true);
setContainerToNullable = new HashSet<>(Arrays.asList(inputRules.get(SET_CONTAINER_TO_NULLABLE).split("[|]")));
if (setContainerToNullable.contains("array")) {
updateArrayToNullable = true;
}
if (setContainerToNullable.contains("set")) {
updateSetToNullable = true;
}
if (setContainerToNullable.contains("map")) {
updateMapToNullable = true;
}
if (!updateArrayToNullable && !updateSetToNullable && !updateMapToNullable) {
LOGGER.error("SET_CONTAINER_TO_NULLABLE rule must be in the form of `array|set|map`, e.g. `set`, `array|map`: {}", inputRules.get(SET_CONTAINER_TO_NULLABLE));
}
}
if (inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE) != null) {
rules.put(SET_PRIMITIVE_TYPES_TO_NULLABLE, true);
setPrimitiveTypesToNullable = new HashSet<>(Arrays.asList(inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE).split("[|]")));
if (setPrimitiveTypesToNullable.contains("string")) {
updateStringToNullable = true;
}
if (setPrimitiveTypesToNullable.contains("integer")) {
updateIntegerToNullable = true;
}
if (setPrimitiveTypesToNullable.contains("number")) {
updateNumberToNullable = true;
}
if (setPrimitiveTypesToNullable.contains("boolean")) {
updateBooleanToNullable = true;
}
if (!updateStringToNullable && !updateIntegerToNullable && !updateNumberToNullable && !updateBooleanToNullable) {
LOGGER.error("SET_PRIMITIVE_TYPES_TO_NULLABLE rule must be in the form of `string|integer|number|boolean`, e.g. `string`, `integer|number`: {}", inputRules.get(SET_PRIMITIVE_TYPES_TO_NULLABLE));
}
}
}
/**
@@ -445,8 +510,10 @@ public class OpenAPINormalizer {
}
if (schema instanceof ArraySchema) { // array
normalizeArraySchema(schema);
normalizeSchema(schema.getItems(), visitedSchemas);
} else if (schema.getAdditionalProperties() instanceof Schema) { // map
normalizeMapSchema(schema);
normalizeSchema((Schema) schema.getAdditionalProperties(), visitedSchemas);
} else if (ModelUtils.isOneOf(schema)) { // oneOf
return normalizeOneOf(schema, visitedSchemas);
@@ -498,16 +565,27 @@ public class OpenAPINormalizer {
return schema;
}
private Schema normalizeArraySchema(Schema schema) {
return processSetArraytoNullable(schema);
}
private Schema normalizeMapSchema(Schema schema) {
return processSetMapToNullable(schema);
}
private Schema normalizeSimpleSchema(Schema schema, Set<Schema> visitedSchemas) {
return processNormalize31Spec(schema, visitedSchemas);
Schema result = processNormalize31Spec(schema, visitedSchemas);
return processSetPrimitiveTypesToNullable(result);
}
private void normalizeBooleanSchema(Schema schema, Set<Schema> visitedSchemas) {
processSimplifyBooleanEnum(schema);
processSetPrimitiveTypesToNullable(schema);
}
private void normalizeIntegerSchema(Schema schema, Set<Schema> visitedSchemas) {
processAddUnsignedToIntegerWithInvalidMaxValue(schema);
processSetPrimitiveTypesToNullable(schema);
}
private void normalizeProperties(Map<String, Schema> properties, Set<Schema> visitedSchemas) {
@@ -818,8 +896,14 @@ public class OpenAPINormalizer {
}
}
if (!(schema instanceof JsonSchema) && (schema.getType() == null || schema.getType().equals("null")) && schema.get$ref() == null) {
return true;
if (schema instanceof JsonSchema) { // 3.1 spec
if (Boolean.TRUE.equals(schema.getNullable())) {
return true;
}
} else { // 3.0.x or 2.x spec
if ((schema.getType() == null || schema.getType().equals("null")) && schema.get$ref() == null) {
return true;
}
}
// convert referenced enum of null only to `nullable:true`
@@ -848,6 +932,27 @@ public class OpenAPINormalizer {
List<Schema> oneOfSchemas = schema.getOneOf();
if (oneOfSchemas != null) {
// simplify any type with 6 sub-schemas (string, integer, etc) in oneOf
if (oneOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: oneOfSchemas) {
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
Schema anyType = new Schema();
anyType.setDescription(schema.getDescription());
anyType.setNullable(schema.getNullable());
anyType.setExtensions(schema.getExtensions());
anyType.setTitle(schema.getTitle());
anyType.setExample(schema.getExample());
anyType.setExamples(schema.getExamples());
anyType.setDefault(schema.getDefault());
anyType.setDeprecated(schema.getDeprecated());
return anyType;
}
}
if (oneOfSchemas.removeIf(oneOf -> isNullTypeSchema(oneOf))) {
schema.setNullable(true);
@@ -864,6 +969,80 @@ public class OpenAPINormalizer {
return schema;
}
/**
* Set nullable to true in array/set if needed.
*
* @param schema Schema
* @return Schema
*/
private Schema processSetArraytoNullable(Schema schema) {
if (!getRule(SET_CONTAINER_TO_NULLABLE)) {
return schema;
}
if (Boolean.TRUE.equals(schema.getUniqueItems())) { // a set
if (updateSetToNullable) {
return setNullable(schema);
}
} else { // array
if (updateArrayToNullable) {
return setNullable(schema);
}
}
return schema;
}
/**
* Set nullable to true in primitive types (e.g. string) if needed.
*
* @param schema Schema
* @return Schema
*/
private Schema processSetPrimitiveTypesToNullable(Schema schema) {
if (!getRule(SET_PRIMITIVE_TYPES_TO_NULLABLE)) {
return schema;
}
if (updateStringToNullable && "string".equals(schema.getType())) {
return setNullable(schema);
} else if (updateIntegerToNullable && "integer".equals(schema.getType())) {
return setNullable(schema);
} else if (updateNumberToNullable && "number".equals(schema.getType())) {
return setNullable(schema);
} else if (updateBooleanToNullable && "boolean".equals(schema.getType())) {
return setNullable(schema);
}
return schema;
}
private Schema setNullable(Schema schema) {
if (schema.getNullable() != null || (schema.getExtensions() != null && schema.getExtensions().containsKey("x-nullable"))) {
// already set, don't overwrite
return schema;
}
schema.setNullable(true);
return schema;
}
/**
* Set nullable to true in map if needed.
*
* @param schema Schema
* @return Schema
*/
private Schema processSetMapToNullable(Schema schema) {
if (!getRule(SET_CONTAINER_TO_NULLABLE)) {
return schema;
}
if (updateMapToNullable) {
return setNullable(schema);
}
return schema;
}
/**
* If the schema is anyOf and the sub-schemas is null, set `nullable: true` instead.
* If there's only one sub-schema, simply return the sub-schema directly.
@@ -878,6 +1057,27 @@ public class OpenAPINormalizer {
List<Schema> anyOfSchemas = schema.getAnyOf();
if (anyOfSchemas != null) {
// simplify any type with 6 sub-schemas (string, integer, etc) in anyOf
if (anyOfSchemas.size() == 6) {
TreeSet<String> ts = new TreeSet<>();
for (Schema s: anyOfSchemas) {
ts.add(s.getType());
}
if (ts.equals(anyTypeTreeSet)) {
Schema anyType = new Schema();
anyType.setDescription(schema.getDescription());
anyType.setNullable(schema.getNullable());
anyType.setExtensions(schema.getExtensions());
anyType.setTitle(schema.getTitle());
anyType.setExample(schema.getExample());
anyType.setExamples(schema.getExamples());
anyType.setDefault(schema.getDefault());
anyType.setDeprecated(schema.getDeprecated());
return anyType;
}
}
if (anyOfSchemas.removeIf(anyOf -> isNullTypeSchema(anyOf))) {
schema.setNullable(true);
}
@@ -1036,6 +1236,7 @@ public class OpenAPINormalizer {
as.setMaxItems(schema.getMaxItems());
as.setExtensions(schema.getExtensions());
as.setXml(schema.getXml());
as.setUniqueItems(schema.getUniqueItems());
if (schema.getItems() != null) {
// `items` is also a json schema
if (StringUtils.isNotEmpty(schema.getItems().get$ref())) {

View File

@@ -37,7 +37,7 @@ public class ExampleGenerator {
private static final String MIME_TYPE_JSON = "application/json";
private static final String MIME_TYPE_XML = "application/xml";
protected final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
protected final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
private static final String EXAMPLE = "example";
private static final String CONTENT_TYPE = "contentType";
@@ -57,7 +57,7 @@ public class ExampleGenerator {
this.openAPI = openAPI;
// use a fixed seed to make the "random" numbers reproducible.
this.random = new Random("ExampleGenerator".hashCode());
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}
public List<Map<String, String>> generateFromResponseSchema(String statusCode, Schema responseSchema, Set<String> producesInfo) {
@@ -238,7 +238,7 @@ public class ExampleGenerator {
// When a property is of type Date, we want to ensure that we're returning a formatted Date.
// And not returning the Date object directly.
if (property.getExample() instanceof Date) {
return DATE_FORMAT.format(property.getExample());
return dateFormat.format(property.getExample());
}
return property.getExample();
} else if (ModelUtils.isBooleanSchema(property)) {

View File

@@ -469,9 +469,9 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
CodegenProperty property = super.fromProperty(name, p, required);
if (property != null) {
String nameInCamelCase = property.nameInCamelCase;
nameInCamelCase = sanitizeName(nameInCamelCase);
property.nameInCamelCase = nameInCamelCase;
String nameInPascalCase = property.nameInPascalCase;
nameInPascalCase = sanitizeName(nameInPascalCase);
property.nameInPascalCase = nameInPascalCase;
}
return property;
}
@@ -650,10 +650,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
}
}
}
for (CodegenProperty header : rsp.headers) {
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
}
return op;
@@ -845,10 +841,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
}
}
}
for (CodegenProperty header : rsp.headers) {
header.nameInCamelCase = toModelName(header.baseName);
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
}
}
/*

View File

@@ -85,7 +85,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
protected String enumValueSuffix = "Enum";
protected String sourceFolder = "src";
protected String invalidNamePrefix = "var";
protected static final String invalidParameterNamePrefix = "var";
protected static final String invalidPropertyNamePrefix = "Var";
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.PascalCase;
// TODO: Add option for test folder output location. Nice to allow e.g. ./test instead of ./src.
@@ -441,7 +442,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
CopyLambda copyLambda = new CopyLambda();
return super.addMustacheLambdas()
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
.put("camelcase_sanitize_param", new CamelCaseAndSanitizeLambda().generator(this).escapeAsParamName(true))
.put("required", new RequiredParameterLambda())
.put("optional", new OptionalParameterLambda().generator(this))
.put("joinWithComma", new JoinWithCommaLambda())
@@ -461,7 +462,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
.put("pasteOnce", new PasteLambda(copyLambda, true, true, true, true))
.put("pasteLine", new PasteLambda(copyLambda, true, true, false, false))
.put("uniqueLines", new UniqueLambda("\n", false))
.put("unique", new UniqueLambda("\n", true));
.put("unique", new UniqueLambda("\n", true))
.put("camel_case", new CamelCaseLambda())
.put("escape_reserved_word", new EscapeKeywordLambda((val) -> this.escapeKeyword(val)));
}
@Override
@@ -664,18 +667,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
private String patchPropertyName(CodegenModel model, String value) {
// the casing will be wrong if we just set the name to escapeReservedWord
// if we try to fix it with camelize, underscores get stripped out
// so test if the name was escaped and then replace var with Var
String tmpPropertyName = escapeReservedWord(model, value);
if (!value.equals(tmpPropertyName) || value.startsWith(this.invalidNamePrefix)) {
value = tmpPropertyName;
String firstCharacter = value.substring(0, 1);
value = value.substring(1);
value = firstCharacter.toUpperCase(Locale.ROOT) + value;
String name = escapeReservedWord(model, value);
if (name.startsWith(AbstractCSharpCodegen.invalidParameterNamePrefix)) {
name = AbstractCSharpCodegen.invalidPropertyNamePrefix + name.substring(AbstractCSharpCodegen.invalidParameterNamePrefix.length());
}
return value;
return name;
}
private void patchPropertyVendorExtensions(CodegenProperty property) {
@@ -700,7 +698,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
patchPropertyVendorExtensions(property);
String tmpPropertyName = escapeReservedWord(model, property.name);
property.name = patchPropertyName(model, property.name);
String[] nestedTypes = { "List", "Collection", "ICollection", "Dictionary" };
@@ -737,6 +734,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
});
}
String[] numericTypes = {"double", "double?", "decimal", "decimal", "float", "float?", "int", "int?", "long", "long?", "ulong", "ulong?"};
enumVars.forEach((enumVar) -> {
enumVar.put("isNumeric", Arrays.stream(numericTypes).anyMatch(dataType::equals));
});
return enumVars;
}
@@ -794,6 +796,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
additionalProperties.put("x-http-statuses-with-return", httpStatusesWithReturn);
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
if (objs != null) {
OperationMap operations = objs.getOperations();
if (operations != null) {
@@ -1044,57 +1048,57 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
for (CodegenParameter parameter : operation.allParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.bodyParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.cookieParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.formParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.headerParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.implicitHeadersParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.optionalParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.pathParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.queryParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.notNullableParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
for (CodegenParameter parameter : operation.requiredParams) {
CodegenModel model = getModelFromParameter(allModels, parameter);
CodegenModel model = getModelFromParameter(modelMaps, parameter);
patchParameter(model, parameter);
}
@@ -1121,10 +1125,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
/**
* Returns the model related to the given parameter
*/
private CodegenModel getModelFromParameter(List<ModelMap> allModels, CodegenParameter parameter) {
return parameter.isModel
? allModels.stream().map(m -> m.getModel()).filter(m -> m.getClassname().equals(parameter.dataType)).findFirst().orElse(null)
: null;
private CodegenModel getModelFromParameter(HashMap<String, CodegenModel> allModels, CodegenParameter parameter) {
return allModels.getOrDefault(parameter.dataType, null);
}
/**
@@ -1308,23 +1310,24 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
public String escapeReservedWord(CodegenModel model, String name) {
name = this.escapeReservedWord(name);
return name.equalsIgnoreCase(model.getClassname())
? this.invalidNamePrefix + camelize(name)
return name.equals(model.getClassname())
? AbstractCSharpCodegen.invalidParameterNamePrefix + camelize(name)
: name;
}
@Override
public String escapeReservedWord(String name) {
if (reservedWords().contains(name) ||
reservedWords().contains(name.toLowerCase(Locale.ROOT)) ||
reservedWords().contains(camelize(sanitizeName(name))) ||
isReservedWord(name) ||
if (isReservedWord(name) ||
name.matches("^\\d.*")) {
name = this.invalidNamePrefix + camelize(name);
name = AbstractCSharpCodegen.invalidParameterNamePrefix + camelize(name);
}
return name;
}
public String escapeKeyword(String value) {
return isReservedWord(value) ? "@" + value : value;
}
/**
* Return the example value of the property
*

View File

@@ -280,7 +280,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
@Override
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
CodegenProperty property = super.fromProperty(name, p, required);
String nameInCamelCase = property.nameInCamelCase;
String nameInCamelCase = property.nameInPascalCase;
if (nameInCamelCase.length() > 1) {
nameInCamelCase = sanitizeName(Character.toLowerCase(nameInCamelCase.charAt(0)) + nameInCamelCase.substring(1));
} else {

View File

@@ -313,7 +313,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
@Override
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
return super.addMustacheLambdas()
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true));
.put("camelcase_param", new CamelCaseAndSanitizeLambda().generator(this).escapeAsParamName(true));
}
@Override

View File

@@ -277,8 +277,11 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
Schema inner = ap.getItems();
return "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = (Schema) p.getAdditionalProperties();
return getTypeDeclaration(inner);
Object ap = p.getAdditionalProperties();
// additionalProperties is either a Schema or a Boolean
if (ap instanceof Schema) {
return getTypeDeclaration((Schema) ap);
}
}
// Not using the supertype invocation, because we want to UpperCamelize

View File

@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
@@ -139,7 +140,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected boolean implicitHeaders = false;
protected String implicitHeadersRegex = null;
protected boolean camelCaseDollarSign = false;
protected boolean useJakartaEe = false;
protected boolean useJakartaEe = true;
protected boolean containerDefaultToNull = false;
private Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
@@ -666,6 +667,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.setContainerDefaultToNull(Boolean.parseBoolean(additionalProperties.get(CONTAINER_DEFAULT_TO_NULL).toString()));
}
additionalProperties.put(CONTAINER_DEFAULT_TO_NULL, containerDefaultToNull);
additionalProperties.put("sanitizeGeneric", (Mustache.Lambda) (fragment, writer) -> {
String content = fragment.execute();
for (final String s: List.of("<", ">", ",", " ")) {
content = content.replace(s, "");
}
writer.write(content);
});
}
@Override
@@ -1038,7 +1047,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
private String getStringBeanValidation(Schema<?> items) {
String validations = "";
if (ModelUtils.isByteArraySchema(items) || ModelUtils.isBinarySchema(items)) {
if (ModelUtils.shouldIgnoreBeanValidation(items)) {
return validations;
}
@@ -1103,13 +1112,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
*/
public String toArrayDefaultValue(CodegenProperty cp, Schema schema) {
if (schema.getDefault() != null) { // has default value
if (cp.isArray && !cp.getUniqueItems()) { // array
if (cp.isArray) {
List<String> _values = new ArrayList<>();
if (schema.getDefault() instanceof ArrayNode) { // array of default values
ArrayNode _default = (ArrayNode) schema.getDefault();
if (_default.isEmpty()) { // e.g. default: []
return "new ArrayList<>()";
return getDefaultCollectionType(schema);
}
List<String> final_values = _values;
@@ -1155,14 +1164,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
defaultValue = StringUtils.join(_values, ", ");
}
} else {
return "new ArrayList<>()";
return getDefaultCollectionType(schema);
}
return String.format(Locale.ROOT, "new ArrayList<>(Arrays.asList(%s))", defaultValue);
} else if (cp.isArray && cp.getUniqueItems()) { // set
// TODO
return null;
} else if (cp.isMap) { // map
return getDefaultCollectionType(schema, defaultValue);
}
if (cp.isMap) { // map
// TODO
return null;
} else {
@@ -1178,21 +1185,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
if (ModelUtils.isArraySchema(schema)) {
if (schema.getDefault() == null) {
// nullable, optional or containerDefaultToNull set to true
if (cp.isNullable || !cp.required || containerDefaultToNull) {
// nullable or containerDefaultToNull set to true
if (cp.isNullable || containerDefaultToNull) {
return null;
} else {
if (ModelUtils.isSet(schema)) {
return String.format(Locale.ROOT, "new %s<>()",
instantiationTypes().getOrDefault("set", "LinkedHashSet"));
} else {
return String.format(Locale.ROOT, "new %s<>()",
instantiationTypes().getOrDefault("array", "ArrayList"));
}
}
} else { // has default value
return toArrayDefaultValue(cp, schema);
return getDefaultCollectionType(schema);
}
return toArrayDefaultValue(cp, schema);
} else if (ModelUtils.isMapSchema(schema) && !(ModelUtils.isComposedSchema(schema))) {
if (schema.getProperties() != null && schema.getProperties().size() > 0) {
// object is complex object with free-form additional properties
@@ -1202,7 +1201,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return null;
}
if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
// nullable or containerDefaultToNull set to true
if (cp.isNullable || containerDefaultToNull) {
return null;
}
@@ -1290,6 +1290,24 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return super.toDefaultValue(schema);
}
private String getDefaultCollectionType(Schema schema) {
return getDefaultCollectionType(schema, null);
}
private String getDefaultCollectionType(Schema schema, String defaultValues) {
String arrayFormat = "new %s<>(Arrays.asList(%s))";
if(defaultValues == null || defaultValues.isEmpty()){
defaultValues = "";
arrayFormat = "new %s<>()";
}
if (ModelUtils.isSet(schema)) {
return String.format(Locale.ROOT, arrayFormat,
instantiationTypes().getOrDefault("set", "LinkedHashSet"),defaultValues);
}
return String.format(Locale.ROOT, arrayFormat, instantiationTypes().getOrDefault("array", "ArrayList"),defaultValues);
}
@Override
public String toDefaultParameterValue(final Schema<?> schema) {
Object defaultValue = schema.get$ref() != null ? ModelUtils.getReferencedSchema(openAPI, schema).getDefault() : schema.getDefault();
@@ -1583,15 +1601,29 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
// additional import for different cases
addAdditionalImports(codegenModel, codegenModel.oneOf);
addAdditionalImports(codegenModel, codegenModel.anyOf);
addAdditionalImports(codegenModel, codegenModel.getComposedSchemas());
return codegenModel;
}
private void addAdditionalImports(CodegenModel model, Set<String> dataTypeSet) {
for (String dataType : dataTypeSet) {
if (null != importMapping().get(dataType)) {
model.imports.add(dataType);
private void addAdditionalImports(CodegenModel model, CodegenComposedSchemas composedSchemas) {
if(composedSchemas == null) {
return;
}
final List<List<CodegenProperty>> propertyLists = Arrays.asList(
composedSchemas.getAnyOf(),
composedSchemas.getOneOf(),
composedSchemas.getAllOf());
for(final List<CodegenProperty> propertyList : propertyLists){
if(propertyList == null)
{
continue;
}
for (CodegenProperty cp : propertyList) {
final String dataType = cp.baseType;
if (null != importMapping().get(dataType)) {
model.imports.add(dataType);
}
}
}
}
@@ -1775,7 +1807,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
String contentType = consumes.isEmpty() ? defaultContentType : consumes.get(0);
operation.addExtension("x-content-type", contentType);
}
String accepts = getAccepts(openAPI, operation);
String[] accepts = getAccepts(openAPI, operation);
operation.addExtension("x-accepts", accepts);
}
}
@@ -1826,19 +1858,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
}
private static String getAccepts(OpenAPI openAPIArg, Operation operation) {
private static String[] getAccepts(OpenAPI openAPIArg, Operation operation) {
final Set<String> producesInfo = getProducesInfo(openAPIArg, operation);
if (producesInfo != null && !producesInfo.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (String produce : producesInfo) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(produce);
}
return sb.toString();
return producesInfo.toArray(new String[] {});
}
return "application/json"; // default media type
return new String[] { "application/json" }; // default media type
}
@Override
@@ -2505,4 +2530,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
imports.add(importsItem);
}
}
@Override
public boolean isTypeErasedGenerics() {
return true;
}
}

View File

@@ -21,7 +21,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import org.apache.commons.io.FilenameUtils;
@@ -30,7 +29,6 @@ import org.openapitools.codegen.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.templating.mustache.EscapeChar;
import org.openapitools.codegen.templating.mustache.JoinWithCommaLambda;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -524,7 +522,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
if (additionalProperties.containsKey(USE_JAKARTA_EE)) {
setUseJakartaEe(Boolean.TRUE.equals(additionalProperties.get(USE_JAKARTA_EE)));
setUseJakartaEe(Boolean.parseBoolean(additionalProperties.get(USE_JAKARTA_EE).toString()));
}
additionalProperties.put(USE_JAKARTA_EE, useJakartaEe);
@@ -648,7 +646,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toEnumName(CodegenProperty property) {
return property.nameInCamelCase;
return property.nameInPascalCase;
}
@Override

View File

@@ -1056,8 +1056,8 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
Set<String> exampleImports,
Set<String> postponedModelImports,
Set<String> postponedExampleImports,
PythonImports moduleImports,
String classname) {
PythonImports moduleImports = new PythonImports();
PydanticType pt = new PydanticType(
modelImports,
exampleImports,
@@ -1250,6 +1250,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
exampleImports,
postponedModelImports,
postponedExampleImports,
moduleImports,
null
);
}
@@ -2062,7 +2063,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
values.add((String) enumVar.get("value"));
}
}
return String.format(Locale.ROOT, "%sEnum", cp.nameInCamelCase);
return String.format(Locale.ROOT, "%sEnum", cp.nameInPascalCase);
} else*/
if (result == null) {
@@ -2171,7 +2172,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
// TODO process the first one only at the moment
if (cmt != null)
// TODO: don't loop back to the deprecated getPydanticType method
return getPydanticType(cmt.getSchema(), modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname);
return getPydanticType(cmt.getSchema(), modelImports, exampleImports, postponedModelImports, postponedExampleImports, moduleImports, classname);
}
throw new RuntimeException("Error! Failed to process getPydanticType when getting the content: " + cp);
} else {

View File

@@ -956,7 +956,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
}
if (!fields.isEmpty()) {
fields.add(0, fieldCustomization);
fields.add(0, "default=" + fieldCustomization);
pydanticImports.add("Field");
fieldCustomization = String.format(Locale.ROOT, "Field(%s)", StringUtils.join(fields, ", "));
}
@@ -1351,7 +1351,7 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
values.add((String) enumVar.get("value"));
}
}
return String.format(Locale.ROOT, "%sEnum", cp.nameInCamelCase);
return String.format(Locale.ROOT, "%sEnum", cp.nameInPascalCase);
} else*/
if (cp.isArray) {
String constraints = "";

View File

@@ -436,4 +436,12 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
public String addRegularExpressionDelimiter(String pattern) {
return pattern;
}
@Override
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "r#"+ name;
}
}

View File

@@ -39,6 +39,9 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(CLibcurlClientCodegen.class);
public static final String USE_JSON_UNFORMATTED = "useJsonUnformatted";
public static final String USE_JSON_UNFORMATTED_DESC = "Use cJSON_PrintUnformatted instead of cJSON_Print when creating the JSON string.";
public static final String PROJECT_NAME = "projectName";
protected String moduleName;
protected String projectName;
@@ -47,6 +50,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
protected String libFolder = "lib";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected boolean useJsonUnformatted = false;
protected static int emptyMethodNameCounter = 0;
@@ -306,6 +310,8 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).
defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(USE_JSON_UNFORMATTED, USE_JSON_UNFORMATTED_DESC).
defaultValue(Boolean.FALSE.toString()));
}
@Override
@@ -316,6 +322,15 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
LOGGER.info("Environment variable C_POST_PROCESS_FILE not defined so the C code may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To define it, try `export C_POST_PROCESS_FILE=\"/usr/local/bin/uncrustify --no-backup\" && export UNCRUSTIFY_CONFIG=/path/to/uncrustify-rules.cfg` (Linux/Mac). Note: replace /path/to with the location of uncrustify-rules.cfg");
}
if (additionalProperties.containsKey(USE_JSON_UNFORMATTED)) {
useJsonUnformatted = Boolean.parseBoolean(additionalProperties.get(USE_JSON_UNFORMATTED).toString());
}
if (useJsonUnformatted) {
additionalProperties.put("cJSONPrint", "cJSON_PrintUnformatted");
} else {
additionalProperties.put("cJSONPrint", "cJSON_Print");
}
// make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);

View File

@@ -171,9 +171,13 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
return "(s/coll-of " + getTypeDeclaration(inner) + ")";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = (Schema) p.getAdditionalProperties();
return "(s/map-of string? " + getTypeDeclaration(inner) + ")";
Object ap = p.getAdditionalProperties();
// additionalProperties is either a Schema or a Boolean
if (ap instanceof Schema) {
Schema inner = (Schema) ap;
return "(s/map-of string? " + getTypeDeclaration(inner) + ")";
}
return "(s/map-of string? s/any?)";
}
// If it's a type we defined, we want to append the spec suffix

View File

@@ -20,6 +20,10 @@ import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenResponse;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
@@ -246,6 +250,34 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
this.optionalProjectFileFlag = flag;
}
// override to post-process any model properties
@Override
@SuppressWarnings("unused")
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
// Nullable will be handled as optional
property.required = !property.notRequiredOrIsNullable();
}
// override to post-process any response
@Override
@SuppressWarnings("unused")
public void postProcessResponseWithProperty(CodegenResponse response, CodegenProperty property) {
super.postProcessResponseWithProperty(response, property);
// Nullable will be handled as optional
property.required = !property.notRequiredOrIsNullable();
}
// override to post-process any parameters
@Override
@SuppressWarnings("unused")
public void postProcessParameter(CodegenParameter parameter) {
super.postProcessParameter(parameter);
// Nullable will be handled as optional
parameter.required = !parameter.notRequiredOrIsNullable();
}
/**
* Configures the type of generator.
*

View File

@@ -599,14 +599,9 @@ public class CrystalClientCodegen extends DefaultCodegen {
return objs;
}
OperationMap operations = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, Integer> processedModelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operationList = operations.getOperation();
for (CodegenOperation op : operationList) {
for (CodegenParameter p : op.allParams) {

View File

@@ -453,7 +453,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
CodegenProperty prop = super.fromProperty(name, p, required);
String cc = camelize(prop.name, LOWERCASE_FIRST_LETTER);
if (isReservedWord(cc)) {
cc = escapeReservedWord(cc);
cc = escapeReservedWord(cc); // e.g. byte => byte_
}
prop.nameInCamelCase = cc;
return prop;
@@ -533,14 +533,9 @@ public class GoClientCodegen extends AbstractGoCodegen {
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
OperationMap operations = objs.getOperations();
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, CodegenModel> modelMaps = ModelMap.toCodegenModelMap(allModels);
HashMap<String, ArrayList<Integer>> processedModelMaps = new HashMap<>();
for (ModelMap modelMap : allModels) {
CodegenModel m = modelMap.getModel();
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operationList = operations.getOperation();
for (CodegenOperation op : operationList) {
for (CodegenParameter p : op.allParams) {

View File

@@ -132,9 +132,10 @@ public class GraphQLNodeJSExpressServerCodegen extends AbstractGraphQLCodegen im
// return "[" + getTypeDeclaration(inner) + "]";
return getTypeDeclaration(inner);
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = (Schema) p.getAdditionalProperties();
return getTypeDeclaration(inner);
Object ap = p.getAdditionalProperties();
if (ap instanceof Schema) {
return getTypeDeclaration((Schema) ap);
}
}
// IMPORTANT NOTE Not using the supertype invocation, because we want to UpperCamelize the type:

View File

@@ -745,10 +745,15 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
param.vendorExtensions.put(VENDOR_EXTENSION_X_IS_BODY_OR_FORM_PARAM, param.isBodyParam || param.isFormParam);
if (!StringUtils.isBlank(param.collectionFormat)) {
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
} else if (!param.isBodyParam && (param.isArray || param.dataType.startsWith("["))) { // param.isArray is sometimes false for list types
// defaulting due to https://github.com/wing328/openapi-generator/issues/72
param.collectionFormat = "csv";
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
} else if (!param.isBodyParam) {
if (param.isArray || param.dataType.startsWith("[")) { // param.isArray is sometimes false for list types
// defaulting due to https://github.com/wing328/openapi-generator/issues/72
param.collectionFormat = "csv";
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
}
}
if (param.isQueryParam && (isJsonMimeType(param.contentType) || ContainsJsonMimeType(param.contentType))) {
param.vendorExtensions.put(X_MEDIA_IS_JSON, "true");
}
if (!param.required) {
op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_OPTIONAL_PARAMS, true);

View File

@@ -514,6 +514,13 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// Query parameters appended to routes
for (CodegenParameter param : op.queryParams) {
String paramType = param.dataType;
if (param.contentType == "application/json") {
if (param.isArray) {
paramType = "[JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + "]";
} else {
paramType = "(JSONQueryParam " + paramType + ")";
}
}
if (param.isArray) {
if (StringUtils.isEmpty(param.collectionFormat)) {
param.collectionFormat = "csv";
@@ -549,6 +556,13 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
path.add("Header \"" + param.baseName + "\" " + param.dataType);
String paramType = param.dataType;
if (param.contentType == "application/json") {
if (param.isArray) {
paramType = "(JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + ")";
} else {
paramType = "(JSONQueryParam " + paramType + ")";
}
}
if (param.isArray) {
if (StringUtils.isEmpty(param.collectionFormat)) {
param.collectionFormat = "csv";

View File

@@ -569,6 +569,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
}
if (APACHE.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("BaseApi.mustache", invokerFolder, "BaseApi.java"));
}
if (FEIGN.equals(getLibrary())) {
if (getSerializationLibrary() == null) {
LOGGER.info("No serializationLibrary configured, using '{}' as fallback", SERIALIZATION_LIBRARY_JACKSON);

View File

@@ -953,6 +953,12 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
if (Boolean.TRUE.equals(param.isFile)) {
operations.put("x-kotlin-multipart-import", true);
}
if (param.isQueryParam && "form".equals(param.style) && param.isExplode && param.isModel) {
// query parameter (style: form, explode) referencing models need to import
// models defined in the properties of the models
operations.put("x-koltin-import-models", true);
}
}
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {

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