Compare commits

..

93 Commits

Author SHA1 Message Date
William Cheng
be68142c8b better format in build.gradle (kotlin) 2025-11-26 17:26:16 +08:00
Konstantin Ignatyev
b9d4b56d1c added ability to publish kotlin-client to maven local repo (#22438)
* this allows pushing client jar to local maven repository gradle -i clean jar publishToMavenLocal;  also generates jar with sources;

* this allows pushing client jar to local maven repository gradle -i clean jar publishToMavenLocal;  also generates jar with sources;
2025-11-26 16:59:41 +08:00
Julian Vennen
ea62c676c9 [php][php-nextgen] Cleanup api authentication code when using api keys in cookies or supporting multiple authentication methods (#22433) 2025-11-26 14:36:16 +08:00
dependabot[bot]
6be8fb3047 Bump actions/setup-dotnet from 5.0.0 to 5.0.1 (#22437)
Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/actions/setup-dotnet/releases)
- [Commits](https://github.com/actions/setup-dotnet/compare/v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: actions/setup-dotnet
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-26 13:54:45 +08:00
David Gamero
6e0fe098f1 [typescript] replace headers with same case-insensitive key to match http spec (#22393)
* replace headers with same caseinsensitive key to match http spec

* regenerate samples

* regenerate samples

* enable test for header case-insensitive replacement

* reduce redundant test comments
2025-11-25 10:58:22 +01:00
dschodits-secunet
41024dc23b [JAVA](native-client) Add support for UnaryInterceptors (#22381)
* added UnaryInterceptor functionality

* set useUnaryInterceptor default to false

* added generated files

* updated generated files to new default value

* fixed asyncResponseInterceptor and indentations

* fixed newlines and generate comments on config

* updated comment in async response interceptor

* reverting docstring

* adjusting newlines
2025-11-25 13:54:29 +08:00
Devon
9116411dac [cpp-rest] Fixes segfault for nullable strings (#22405) 2025-11-25 13:37:05 +08:00
William Cheng
1c447a1605 update swagger parser to 2.1.36 (#22429)
* update swagger parser to 2.1.36

* comment out test
2025-11-25 13:21:36 +08:00
Devon
4a7e0c9bdc [nim] Nim Generator Fixes (#22385)
* Nim Generator Fixes

* remove test that is tested via yaml anyway

* Only include required parameters or non-empty optional parameters in URLs, support oneOf/anyOf via nim object variants, optional field support

* snapshot

* docs gen

* Improved handling of enums
2025-11-23 17:19:16 +08:00
Ruben Hönle
65f99ebb21 fix(enums): add character handling for euro symbol (#22414)
relates to #22413
2025-11-23 17:08:11 +08:00
William Cheng
5d12e71b40 [typescript-rxjs] Feat: Add @deprecated JSDoc tag to API operations (#22419)
* feat(typescript-rxjs): Add @deprecated tag to generated API operations

This commit introduces the JSDoc @deprecated tag to API operations in the typescript-rxjs generator when the operation is marked as deprecated in the OpenAPI specification.

This ensures that IDEs (like VS Code or WebStorm) correctly flag the method as deprecated, providing better developer experience and warning consumers about upcoming removals or changes.

* minor updates

---------

Co-authored-by: Dirk Niemeier <dirk.niemeier@cgi.com>
2025-11-23 16:15:43 +08:00
Cas van Dinter
5711f391e9 build(pom): update swagger-parser to 2.1.35 (#22410) 2025-11-23 15:24:11 +08:00
Josh Wulf
ddfcc95b61 fix: use httpx in generated configuration.py (#22418)
* fix: use httpx in generated configuration.py

* fix: add enum_values for httpx

* chore: update petstore samples
2025-11-23 15:11:48 +08:00
Ary Obenholzner
c5e0d0840b [typescript-nestjs-server] Fix #21842 by updating api.module.mustache (#22403) 2025-11-23 00:16:34 +08:00
Brendan Burns
8a4246cbaf Add support for custom tls server names. (#22372)
* Add support for custom tls server names.

* Update samples

* Fix missing declaration.
2025-11-20 10:36:11 +08:00
William Cheng
a1b962d0b6 minor change to code format in package.json (ts nestjs server) (#22397) 2025-11-20 10:35:29 +08:00
dependabot[bot]
3b4494d751 Bump glob and @nestjs/cli (#22396)
Bumps [glob](https://github.com/isaacs/node-glob) to 12.0.0 and updates ancestor dependency [@nestjs/cli](https://github.com/nestjs/nest-cli). These dependencies need to be updated together.


Updates `glob` from 11.0.1 to 12.0.0
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v11.0.1...v12.0.0)

Updates `@nestjs/cli` from 11.0.7 to 11.0.12
- [Release notes](https://github.com/nestjs/nest-cli/releases)
- [Changelog](https://github.com/nestjs/nest-cli/blob/master/.release-it.json)
- [Commits](https://github.com/nestjs/nest-cli/compare/11.0.7...11.0.12)

---
updated-dependencies:
- dependency-name: glob
  dependency-version: 12.0.0
  dependency-type: indirect
- dependency-name: "@nestjs/cli"
  dependency-version: 11.0.12
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-20 10:11:24 +08:00
William Cheng
2c4c24728f update ruby samples 2025-11-20 10:04:12 +08:00
Devon
5ad2f84650 [Ruby] Fixes anyOf Support in Responses (#22392)
* [Ruby] Fixes anyOf Support in Responses

* re-gen samples

* Revert "re-gen samples"

This reverts commit 1b4d85d359.
2025-11-20 09:59:43 +08:00
William Cheng
74be550d94 update go-gin crypto to newer version (#22395) 2025-11-20 09:44:53 +08:00
William Cheng
554e10dc34 Fix siblings of $ref using allOf in openapi normalizer (#22364)
* fix ref sibiling using allOf in normalizer

* update samples
2025-11-19 20:35:07 +08:00
William Cheng
6699ecd9d2 update jersey3 to newer version (#22388) 2025-11-19 19:19:54 +08:00
Xi Lu
9655c22ff6 [Protobuf] Add isEnumSchema check in generateNestedSchema (#22384)
Co-authored-by: xil <xil@uber.com>
2025-11-19 17:46:43 +08:00
William Cheng
6210db308e fix website to use load instead of safeLoad (#22386) 2025-11-19 16:53:26 +08:00
Daniil Iastremskii
e86daf9059 Add support for oneOf with discriminator when using kotlinx.serialization (#22373)
* Generate wrappers for oneOf with discriminator when using kotlinx.serialization

* Add spec with oneOf using discriminator

* Add config to generate samples

* Generate samples

* Update samples

* Change naming of wrapper classes

* Fix empty model test

* Update GH workflow with new samples
2025-11-19 02:55:37 +08:00
Jachym Metlicka
c52cc1f275 [kotlin-spring][server] Feat: Make it possible to include "HttpServletRequest" or "ServerWebExchange" as a method parameter in controller interfaces and/or implementations (#22263)
* modify templates to enable possibility to add reactive or blocking request context

* add logic to enable additional property

* regenerate files

* regenerate documentation

* revert unrelated formatting changes

* revert commented out code

* add tests

* refactor test to DRY them a bit

* move tests around

* increase tests coverage

* fix for delegate

* fix for delegate - and refactor tests

* fix tests

* refactor tests

* add tests for delegate

* add kotlin project compile check test for include-http-request-context

* fix

* fix

* fix output folder naming. Add the sample to github action config file.

* add missing interfaces to fix compilation

* regenerate samples

* fix also api_test.mustache to enable testing

* add tests for generated tests
2025-11-19 00:29:07 +08:00
dsteeley
2c7efda060 Update rust-server swagger dependency to 7.0 (#22365) 2025-11-17 18:59:28 +08:00
dependabot[bot]
107d72c5f5 Bump js-yaml from 3.14.1 to 4.1.1 in /website (#22363)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.14.1 to 4.1.1.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.14.1...4.1.1)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.1.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-17 13:48:21 +08:00
Levi Lutz
a52e902cb5 [RUST] Fix #22356 / Introduce useSerdePathToError option to improve JSON error messages (#22357)
* Add CLI option

* Add dep to generated Cargo.toml

* Add new `Error::SerdePathToError` error type

* Add `serde_path_to_error` invocation to API layer

* Add sample for serde-path-to-error

* Add arg & docstring to cliOptions as well

* Fix sample
2025-11-16 22:13:55 +08:00
ddl-rliu
547eee1970 [BUG] Fix #22351 by updating exceptions.mustache to log both the response data and response body, when applicable (#22352)
* Update exceptions.mustache

* Add autogen files
2025-11-16 22:06:23 +08:00
Jachym Metlicka
c1c74c0ec8 [kotlin-spring][server] Feat: Add Spring Declarative HTTP Interface support for easy client instantiation (#22302)
* add required template files and logic in generator

* add possibility to choose between coroutines and reactor style reactive for spring declarative http client

* remove Flow as array-type input param for declarative http interface

* better name for switches

* revert change

* fix implementation and add tests

* revert unrelated formatting changes

* add compile check for generated code to  github action config file

* fix output folder for config files

* commit generated files

* commit generated docs files

* fix compile test output folder names

* fix sample generation

* fix compile to jdk 17+

* force test rerun

* remove misleading warning

* remove extraneous mustache files. Rebuild samples

* restoring incorrectly deleted output files
2025-11-16 21:54:19 +08:00
William Cheng
7690545276 add sample to test useGzipFeature in java native (#22361) 2025-11-16 21:52:17 +08:00
Ilya Nemtsev
ecb1e9e2cb [JAVA][NATIVE] Add gzip capability (#22358)
* add gzip capability

* fixed test

* added docstring

* regenerated samples
2025-11-16 21:23:08 +08:00
Daniil Iastremskii
039de98d4f Fix generation of an empty data class when using kotlinx.serialization (#22350)
* Fix generation of an empty data class

* Add a test

* Delete polymorphicJacksonSerialization artifacts on exit
2025-11-16 18:59:21 +08:00
William Cheng
6892768009 [typescript-axios] add support for accept headers (#22318)
* cherry pick the change from 22299

* fix accept headers
2025-11-15 14:40:58 +08:00
dsteeley
fd72d4d521 Merge branch 'allow-trait-mocking' into 'rust-openapi' (#22332)
allow trait mocking

See merge request tools.core/swagger-codegen!379

Co-authored-by: Richard Whitehouse <richard.whitehouse@metaswitch.com>
2025-11-13 13:45:30 +08:00
dsteeley
1e3f6d0ed9 Refresh rust-server Cargo.toml wiht updated dependencies and move jsonwebtoken to dev-deps (#22338) 2025-11-12 19:18:14 +08:00
William Cheng
886e4a6dd0 [kotlin] Test array integer (enum) with kotlin client generator (#22336)
* add tests for array of enum

* update
2025-11-12 16:39:01 +08:00
William Cheng
57d304f3f6 add tests for deprecated enum class (#22335) 2025-11-12 16:09:42 +08:00
William Cheng
59f7d09c2e [java][jersey2][jersey3] Cleanup samples (#22328)
* clean up java jersey3 smaples

* clean up jersey3 samples

* update tests
2025-11-12 15:40:19 +08:00
Christopher Molin
ec8ca20dec [Java] Support Deprecation of Generated enum-classes (#22312)
* [Java] Annotate Deprecated `enum`-classes with `@Deprecated`

* Update Generated 'samples'-files

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

* Update `modelEnum.mustache` According to Review Comment

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

* Update Generated 'sample'-files

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

* Update Java Native `modelEnum.mustache` File

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

* Update Java JaxRS `modelEnum.mustache` File

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

* Update Java Okhttp-gson `modelEnum.mustache` File

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

* Update Java Micronaut `modelEnum.mustache` File

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

* Update Java Helidon `modelEnum.mustache` File

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>

---------

Signed-off-by: Chrimle <28791817+Chrimle@users.noreply.github.com>
2025-11-12 15:33:28 +08:00
Olek Janiszewski
2ab5365fb2 Fix kotlin codegen for enum with int items (#22324) 2025-11-11 22:18:43 +08:00
dsteeley
2326eef7cf Fixups for rust-server hyper1 support (#22321) 2025-11-11 18:27:11 +08:00
Julian Vennen
d318752478 [php][php-nextgen] fix return type if empty and non-empty responses are mixed (#22322) 2025-11-10 22:06:21 +08:00
Julian Vennen
86ff873a03 [php][php-nextgen] fix array enum query parameters (#22320) 2025-11-10 19:14:41 +08:00
rignicat
28e2254e7a [JAXRS] Partial revert changing path generation if interface, fixes #22279 (#22316)
* Partial revert changing path generation if interface

This reverts commit 65703ff320.

* update samples and docs
2025-11-10 16:54:06 +08:00
William Cheng
69da1ea470 Add new JAX-RS samples to Github workflow (#22314)
* add new jaxrs samples to github workflow

* trigger ci
2025-11-10 15:07:40 +08:00
Raoul de Haard
b1f2a67bc3 [JAVA jaxrs-spec gen] add option for generating swagger V3 annotations (#22300)
* feat: add support for Swagger v3 annotations to jaxrs-spec

* test added unittest for jaxrs-spec with swagger3Annotations

* test added integrationtest for jaxrs-spec with swagger3Annotations

* test added integrationtest for jaxrs-spec with swaggerV2Annotations

* documentation update for new option useSwaggerV3Annotations in the jaxrs-spec.md

* test added integrationtest for jaxrs-spec with swaggerV3Annotations icm use JakartaEE

* update documentation by executing:  ./bin/utils/export_docs_generators.sh

* ran on wsl: ./bin/generate-samples.sh ./bin/configs/*.yaml
2025-11-10 14:50:10 +08:00
BiekerUdan
48648a4051 fix(c): Remove duplicate code generation for UUID path parameters (#22285)
* fix(c): Remove duplicate code generation for UUID path parameters

The C generator was generating duplicate path parameter handling code
when a parameter had format: uuid. This occurred because UUID parameters
have both isString=true and isUuid=true flags set, causing both the
{{#isString}} and {{#isUuid}} template blocks to execute.

The duplicate {{#isUuid}} block has been removed since it generated
identical code to the {{#isString}} block. This makes UUID parameters
consistent with email parameters, which already work this way
(isEmail=true and isString=true, but only use the {{#isString}} block).

The generated code now compiles successfully without duplicate variable
declarations.

* test(c): Add UUID path parameter test case to petstore

Adds endpoint with UUID path parameter to verify C generator produces compilable code without duplicate variable declarations.

* chore(samples): Regenerate all C samples with template fix

Regenerated all C sample variants to include the UUID path parameter example.
2025-11-10 14:36:58 +08:00
William Cheng
a6c753ea69 php template minor refactoring (#22310) 2025-11-09 17:22:18 +08:00
William Cheng
81285b75e4 add exts alias to simply the templates (rust-server) (#22309) 2025-11-09 15:42:14 +08:00
William Cheng
c596bb7d8a add check for optionl to show null in doc (php) (#22307) 2025-11-08 23:12:27 +08:00
Enric Pou
ce338a4a23 Added UUID support in python docs (#22301) 2025-11-08 22:29:12 +08:00
Achton Smidt Winther
fb444bf15e [php] Fix PHP generator validation for nullable required properties (#22292)
* [php] Fix null+required properties to accept null values in generated models. Also fix PHP annotations related to same.

* [php] Update samples.
2025-11-08 22:28:37 +08:00
macmanad
a144678459 [csharp][generichost] Fix format string parameter (#22282) (#22283)
* [csharp][generichost] Fix format string parameter (#22282)

* Update samples
2025-11-08 21:54:42 +08:00
William Cheng
95b9438fd9 add tests for api key name in ccp rest sdk (#22306) 2025-11-08 21:38:06 +08:00
Devon
7beb8a6102 [cpp-rest] Fixing Incorrect Header Name Used (#22298) 2025-11-08 21:19:07 +08:00
Devon
2107686d3d [Rust Reqwest] Fixes Enums in Query Parameters via Causing Compilation Failure (#22281)
* [Rust Reqwest] Fixes Enums in Query Parameters via  Causing Compilation Failure

* regen
2025-11-08 20:56:07 +08:00
Mattias Sehlstedt
7486f12e62 Correct unsafe pistache documentation link (#22296)
* Replace outdated/incorrect documentation link with correct https version

* Generate samples
2025-11-08 15:04:52 +08:00
Enric Pou
600c051fa5 Dart Dio: fix typo in markdown files (#22293) 2025-11-08 15:04:06 +08:00
Enric Pou
f37b8cce58 Add UUID examples and documentation (#22303) 2025-11-08 14:56:46 +08:00
William Cheng
64c8711356 [python] Fix pyproject (poetry 2.x) for httpx (#22289)
* fix poetry 2 httpx dependencies

* use poetry 2 for tests
2025-11-06 14:09:54 +08:00
Michael Munch
65359d8050 [Java] Use new location for hibernate validator (#22287)
* Use new location for hibernate validator
org.hibernate:hibernate-validator -> org.hibernate.validator:hibernate-validator

* Update samples

* Update samples

---------

Co-authored-by: Michael Munch <mmu@bankdata.dk>
2025-11-06 01:42:18 +08:00
Linh Tran Tuan
7ce0096e73 [Rust-Axum] Fix Regex (#22277) 2025-11-04 13:35:51 +08:00
Aman Rao
0ae50f5a10 Fixes #22146. Fixed the code to call the correct method to prevent duplication of Prefix added to the model when using --model-name-prefix (#22188)
* Fixes #22146

* Added handling for when super.getSchemaType method
returns null
2025-11-03 15:26:22 +08:00
William Cheng
3347204425 [java][microprofile] Using incorrect @Multipart instead of @FormParam (#22266)
* fix: #10618 Using incorrect @Multipart instead of @FormParam in microprofile java client

[BUG][JAVA] Using incorrect @Multipart instead of @FormParam when generated Microprofile java client #10618
https://github.com/OpenAPITools/openapi-generator/issues/10618

* fix: #10618 put updated samples under sourcecontrol

* fix: #10618 delete configoption disableMultipart for microprofile

* fix: #10618 put updated samples after cleanup of "disableMultipart"

* fix: #10618 make samples compile and switch jandex-maven-plugin

* fix: #10618 sync my fork with upstream & clean pom

* fix: #10618 regenerate samples

* fix: #10618 microprofile-rest-client-with-useSingleRequestParameter

* update

* update

---------

Co-authored-by: Riedlinger, Jochen (IT 480) <jochen.riedlinger@l-bank.de>
Co-authored-by: Jochen Riedlinger <j_ri@gmx.de>
Co-authored-by: Jochen Riedlinger <14962274+jochenr@users.noreply.github.com>
2025-11-02 16:56:10 +08:00
Lars van Leeuwen
93d7821281 Patch dependencies (#22262) 2025-10-31 22:08:58 +08:00
William Cheng
1e614d4b96 update samples 2025-10-31 16:07:52 +08:00
Marcel Jacek
66b742038a fix(java): default values from allOfs are not correctly definied (#22200)
* fix: extend check for default values of integer and number schema

* add testcases to openapi specs

* generate java clients with the updated fix
2025-10-31 15:58:20 +08:00
William Cheng
9b8ab659ac update undertow to newer version (#22259) 2025-10-31 13:27:43 +08:00
William Cheng
f9d2b8b579 Prepare v7.18.0 release (#22250)
* Revert "v7.17.0 release (#22248)"

This reverts commit 0120486e62.

* prepare v7.18.0 release

* update samples

* update doc
2025-10-30 01:25:35 +08:00
William Cheng
0120486e62 v7.17.0 release (#22248) 2025-10-30 00:18:40 +08:00
Ivan ROGER
44075c9edf Fix explode query params for typescript-fetch (#22246)
Fixes: #10438
2025-10-29 16:28:00 +01:00
William Cheng
3d4f29eac7 [PYTHON-FASTAPI] update starlette to newer version 0.49.1 (#22243)
* update starlette to newer version 0.49.1

* update fastapi to newer version
2025-10-29 15:18:27 +08:00
William Cheng
351b601368 openapi-normalizer: Add REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT normalize option (#22236)
* fix bug 21680: Introduce REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT normalize option

* Advise to use REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT

* update doc

---------

Co-authored-by: Guillaume ALAMOME <guillaume.alamome@gmail.com>
2025-10-28 13:54:49 +08:00
Jason Frey
2c248e6c93 [ruby] Introduce ApiModelBase (#22052)
The Ruby code that is generated copies numerous methods into every
model. This creates bloat both in file size and run-time memory usage.
This commit introduces a base class for all models to store common
methods. This commit's focus is only on static methods that do not
change between models.
2025-10-28 12:42:51 +08:00
Eddie Sholl
68b0dfe6d1 Expose mtls certificate config params in python and php configuration templates (#22229)
* Expose mtls config params in python template

* Expose certFile and keyFile configuration items to support mtls in php generated client

* Regenerate of examples
2025-10-28 12:33:05 +08:00
Leon Linhart
31e462dc3e Make Gradle properties non-nullable (#22050)
They were never really intended to support null values, so this is kind of a bug. However, this is technically also breaking for users that set these properties to `null` explicitly (instead of leaving them unset).
2025-10-27 15:18:08 +08:00
Elliott Kember
74488fa3c3 Update modelOneOf.mustache (#22220)
Adds booleans to modelOneOf
2025-10-27 15:15:57 +08:00
William Cheng
8c54f18f7c remove BACKTICK_PLAN.md 2025-10-27 14:56:13 +08:00
Anshul Singhvi
57d12811ef [Julia] Fix docstring parameter formatting with backticks (#22190)
* [Julia] Fix docstring parameter formatting with backticks

Wrap parameter names in backticks in generated Julia client docstrings
to prevent markdown from misinterpreting underscores as italic formatting.

This fixes an issue where parameter names like `pet_id`, `api_key`, and
`additional_metadata` would render incorrectly in documentation, with
underscores being treated as markdown italic markers instead of literal
characters.

Related issue: JuliaComputing/OpenAPI.jl#72

* Also wrap data types and return types in backticks

* Regenerate Julia client samples with backticked docstrings

* [Julia] Add backticks to all markdown documentation templates

Extend backtick formatting to markdown documentation templates for
both Julia client and server generators. This ensures consistent
markdown rendering of identifiers with underscores.

Changes:
- julia-client/api_doc.mustache: Add backticks to function signatures,
  parameter names, types, and return types in markdown API docs
- julia-server/api_doc.mustache: Same changes for server API docs
- julia-client/model_doc.mustache: Add backticks to property names and
  types in markdown model documentation
- julia-server/model_doc.mustache: Same changes for server model docs

All generated markdown files now properly display identifiers like
`pet_id`, `Custom_Type`, `update_pet_with_form` with literal
underscores instead of broken italic formatting.

Related to JuliaComputing/OpenAPI.jl#72
2025-10-27 14:55:35 +08:00
lbilger
676efae183 [Java] Add import for java.util.Arrays if there is a set property in a model. Arrays.asList is used when initializing the property if it has a default value. (#22207) 2025-10-27 14:55:10 +08:00
Rens Groothuijsen
a4d05b38f5 [go] Correctly set default array value on query parameters (#22060) 2025-10-27 10:30:08 +08:00
Mattias Sehlstedt
75ae04ecfd Fix so that the x-field-extra-annotation properly split any array items (#22226)
* Fix so that the x-field-extra-annotation properly split any array items

* Add a unit test to show that the annotations are generated as expected
2025-10-27 09:56:38 +08:00
rignicat
808d106e0c [jaxrs] Support jackson option (true by default) (#22169)
* allow configuring jackson, remove jackson import if disabled

* do not generate root resource or application file if generating interface

* change template files to remove jackson if disabled

* updated samples and docs as required by PR checklist
2025-10-27 09:56:07 +08:00
William Cheng
9d810e0fbb update jackson databind nullable to v0.2.8 (#22230) 2025-10-27 00:35:51 +08:00
Kevin Liddle
91a499b8c6 [rust-axum] Fix polymorphic type discriminators (#22222)
* [rust-axum] Make discriminator field name camelCase

* [rust-axum] Give polymorphic enum values a serde alias using the mapping keys if available

* update samples

* update test file checksum
2025-10-25 22:43:56 +08:00
dependabot[bot]
eda2e67b94 Bump actions/download-artifact from 5 to 6 (#22225)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  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>
2025-10-25 17:31:18 +08:00
Rens Groothuijsen
8643bc1d66 [python-fastapi] Remove additional slashes in query regex (#22223) 2025-10-25 17:16:17 +08:00
dependabot[bot]
2b22d172da Bump actions/upload-artifact from 4 to 5 (#22224)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  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>
2025-10-25 17:14:59 +08:00
William Cheng
d605afeef5 update vertx-web to 4.x 2025-10-23 10:32:20 +08:00
William Cheng
6eff628139 update logback to newer versions (#22204) 2025-10-22 18:51:38 +08:00
William Cheng
1d071288f8 use path from spec in ts angular documentation (#22194) 2025-10-21 15:40:48 +08:00
9603 changed files with 86120 additions and 32037 deletions

View File

@@ -62,7 +62,7 @@ jobs:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: Upload Maven build artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
if: matrix.java == '11' && matrix.os == 'ubuntu-latest'
with:
name: artifact
@@ -98,7 +98,7 @@ jobs:
maven-version: 3.8.8
cache: gradle
- name: Download build artifact
uses: actions/download-artifact@v5
uses: actions/download-artifact@v6
with:
name: artifact
- name: Run Ensures Script

View File

@@ -42,7 +42,7 @@ jobs:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- run: ls -la modules/openapi-generator-cli/target
- name: Upload openapi-generator-cli.jar artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target/openapi-generator-cli.jar
@@ -81,7 +81,7 @@ jobs:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: Publish unit test reports
if: ${{ always() }}
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
@@ -99,7 +99,7 @@ jobs:
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v5
uses: actions/download-artifact@v6
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target
@@ -138,7 +138,7 @@ jobs:
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v5
uses: actions/download-artifact@v6
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target

View File

@@ -26,7 +26,7 @@ jobs:
- samples/server/petstore/aspnet/fastendpoints-useValidators
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@@ -26,7 +26,7 @@ jobs:
- samples/client/petstore/csharp/restsharp/standard2.0/Petstore/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '7.0.x'
- name: Build

View File

@@ -28,7 +28,7 @@ jobs:
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: 3.1.*
- name: Build

View File

@@ -25,7 +25,7 @@ jobs:
- samples/server/petstore/aspnetcore-6.0-useSwashBuckle
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '6.0.x'
- name: Build

View File

@@ -43,7 +43,7 @@ jobs:
- samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '7.0.x'
- name: Build

View File

@@ -19,7 +19,7 @@ jobs:
- samples/client/echo_api/csharp/restsharp/net8/EchoApi
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '8.0.x'
- name: Run echo server

View File

@@ -19,7 +19,7 @@ jobs:
- samples/client/petstore/csharp/restsharp/net8/useVirtualForHooks/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@@ -26,7 +26,7 @@ jobs:
- samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@@ -34,7 +34,7 @@ jobs:
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@@ -48,7 +48,7 @@ jobs:
#- samples/client/petstore/csharp/unityWebRequest/net9/Petstore
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: '9.0.101'
- name: Build

View File

@@ -61,6 +61,7 @@ jobs:
- samples/client/petstore/java/native
- samples/client/petstore/java/native-async
- samples/client/petstore/java/native-jakarta
- samples/client/petstore/java/native-useGzipFeature
- samples/client/petstore/java/retrofit2
- samples/client/petstore/java/retrofit2rx2
- samples/client/petstore/java/retrofit2rx3

View File

@@ -34,6 +34,9 @@ jobs:
- samples/server/petstore/jaxrs-cxf-cdi
- samples/server/petstore/jaxrs-cxf-non-spring-app
- samples/server/petstore/jaxrs-spec-microprofile-openapi-annotations
- samples/server/petstore/jaxrs-spec-swagger-annotations
- samples/server/petstore/jaxrs-spec-swagger-v3-annotations-jakarta
- samples/server/petstore/jaxrs-spec-swagger-v3-annotations
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5

View File

@@ -44,6 +44,7 @@ jobs:
- samples/client/petstore/kotlin-threetenbp
- samples/client/petstore/kotlin-kotlinx-datetime
- samples/client/petstore/kotlin-uppercase-enum
- samples/client/petstore/kotlin-array-integer-enum
- samples/client/petstore/kotlin-default-values-jvm-okhttp4
- samples/client/petstore/kotlin-default-values-jvm-retrofit2
- samples/client/petstore/kotlin-default-values-jvm-volley
@@ -71,6 +72,7 @@ jobs:
- samples/client/others/kotlin-jvm-okhttp-path-comments
- samples/client/others/kotlin-integer-enum
- samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization
- samples/client/others/kotlin-oneOf-discriminator-kotlinx-serialization
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5

View File

@@ -8,6 +8,7 @@ on:
- 'samples/server/petstore/kotlin-server-modelMutable/**'
- 'samples/server/petstore/kotlin-springboot-*/**'
- 'samples/server/petstore/kotlin-server-required-and-nullable-properties/**'
- 'samples/server/petstore/kotlin-spring-declarative*/**'
# comment out due to gradle build failure
# - samples/server/petstore/kotlin-spring-default/**
pull_request:
@@ -17,6 +18,7 @@ on:
- 'samples/server/petstore/kotlin-server-modelMutable/**'
- 'samples/server/petstore/kotlin-springboot-*/**'
- 'samples/server/petstore/kotlin-server-required-and-nullable-properties/**'
- 'samples/server/petstore/kotlin-spring-declarative*/**'
# comment out due to gradle build failure
# - samples/server/petstore/kotlin-spring-default/**
@@ -44,6 +46,10 @@ jobs:
- samples/server/petstore/kotlin-server/ktor
- samples/server/petstore/kotlin-server/ktor2
- samples/server/petstore/kotlin-misk
- samples/server/petstore/kotlin-spring-declarative-interface
- samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines
- samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped
- samples/server/petstore/kotlin-spring-declarative-interface-wrapped
# comment out due to gradle build failure
# - samples/server/petstore/kotlin-spring-default/
steps:

View File

@@ -39,6 +39,7 @@ jobs:
- samples/server/petstore/kotlin-springboot-source-swagger2
- samples/server/petstore/kotlin-springboot-springfox
- samples/server/petstore/kotlin-springboot-x-kotlin-implements
- samples/server/petstore/kotlin-springboot-include-http-request-context-delegate
- samples/server/petstore/kotlin-server/ktor
- samples/server/petstore/kotlin-server/ktor2
- samples/server/petstore/kotlin-server/jaxrs-spec

View File

@@ -15,7 +15,7 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.17.0`):
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.18.0`):
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Bitrise](https://img.shields.io/bitrise/4a2b10a819d12b67/master?label=bitrise%3A%20Swift+4,5&token=859FMDR8QHwabCzwvZK6vQ)](https://app.bitrise.io/app/4a2b10a819d12b67)
@@ -148,8 +148,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 7.17.0 (upcoming minor release) [SNAPSHOT](https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-to-test-with-the-latest-master-of-openapi-generator) | 24.10.2025 | Minor release with breaking changes (with fallback) |
| [7.16.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.16.0) (latest stable release) | 28.09.2025 | Minor release with breaking changes (with fallback) |
| 7.18.0 (upcoming minor release) [SNAPSHOT](https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-to-test-with-the-latest-master-of-openapi-generator) | 10.12.2025 | Minor release with breaking changes (with fallback) |
| [7.17.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.17.0) (latest stable release) | 29.10.2025 | 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) |
@@ -212,16 +212,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.16.0/openapi-generator-cli-7.16.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.0.jar`
For **Mac/Linux** users:
```sh
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.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.16.0/openapi-generator-cli-7.16.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.0.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@@ -456,7 +456,7 @@ openapi-generator-cli version
To use a specific version of "openapi-generator-cli"
```sh
openapi-generator-cli version-manager set 7.16.0
openapi-generator-cli version-manager set 7.17.0
```
Or install it as dev-dependency:
@@ -480,7 +480,7 @@ pip install openapi-generator-cli
To install a specific version
```
pip install openapi-generator-cli==7.16.0
pip install openapi-generator-cli==7.17.0
```
You can also install with [jdk4py](https://github.com/activeviam/jdk4py) instead of java binary. (python>=3.10 is required)
@@ -506,7 +506,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php -o c:\temp\php_api_client`)
<!-- RELEASE_VERSION -->
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar)
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.0.jar)
<!-- /RELEASE_VERSION -->
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
@@ -1182,6 +1182,7 @@ Here is a list of template creators:
* Scala Finch: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Scala Lagom: @gmkumar2005
* Scala Play: @adigerber
* TypeScript NestJS: @aryobenholzner
* Documentation
* AsciiDoc: @man-at-home
* HTML Doc 2: @jhitchcock

View File

@@ -0,0 +1,9 @@
generatorName: java
outputDir: samples/client/petstore/java/native-useGzipFeature
library: native
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-addpet-only.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: petstore-native-useGzipFeature
hideGenerationTimestamp: "true"
useJakartaEe: "true"

View File

@@ -0,0 +1,11 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec-swagger-annotations
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
artifactId: jaxrs-spec-petstore-server
serializableModel: "true"
hideGenerationTimestamp: "true"
implicitHeadersRegex: (api_key|enum_header_string)
generateBuilders: "true"
useSwaggerAnnotations: "true"

View File

@@ -0,0 +1,12 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec-swagger-v3-annotations-jakarta
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
artifactId: jaxrs-spec-petstore-server-jakarta-swagger-v3
serializableModel: "true"
hideGenerationTimestamp: "true"
implicitHeadersRegex: (api_key|enum_header_string)
generateBuilders: "true"
useSwaggerV3Annotations: "true"
useJakartaEe: "true"

View File

@@ -0,0 +1,11 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec-swagger-v3-annotations
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
artifactId: jaxrs-spec-petstore-server
serializableModel: "true"
hideGenerationTimestamp: "true"
implicitHeadersRegex: (api_key|enum_header_string)
generateBuilders: "true"
useSwaggerV3Annotations: "true"

View File

@@ -0,0 +1,8 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-array-integer-enum
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/issue15204-int-array-enum.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-array-integer-enum
serializableModel: "true"
dateLibrary: java8

View File

@@ -0,0 +1,12 @@
generatorName: kotlin
outputDir: samples/client/others/kotlin-oneOf-discriminator-kotlinx-serialization
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/polymorphism-oneof-discriminator.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-oneOf-discriminator
serializableModel: "false"
dateLibrary: java8
library: jvm-retrofit2
enumUnknownDefaultCase: true
serializationLibrary: kotlinx_serialization
generateOneOfAnyOfWrappers: true

View File

@@ -0,0 +1,17 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-springboot-include-http-request-context-delegate
library: spring-boot
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-x-kotlin-implements.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
additionalProperties:
documentationProvider: none
annotationLibrary: swagger1
useSwaggerUI: false
serviceImplementation: false
skipDefaultInterface: true
interfaceOnly: false
serializableModel: true
beanValidations: true
includeHttpRequestContext: true
reactive: true
delegatePattern: true

View File

@@ -5,10 +5,11 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
additionalProperties:
documentationProvider: none
annotationLibrary: none
useSwaggerUI: "false"
serviceImplementation: "false"
skipDefaultInterface: "true"
interfaceOnly: "true"
serializableModel: "true"
beanValidations: "true"
annotationLibrary: swagger1
useSwaggerUI: false
serviceImplementation: false
skipDefaultInterface: true
interfaceOnly: true
serializableModel: true
beanValidations: true
includeHttpRequestContext: true

View File

@@ -0,0 +1,16 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines
library: spring-declarative-http-interface
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
additionalProperties:
documentationProvider: springDoc
annotationLibrary: swagger2
useSwaggerUI: "false"
serializableModel: "true"
beanValidations: "true"
interfaceOnly: true
reactive: true
declarativeInterfaceWrapResponses: false
useFlowForArrayReturnType: false
declarativeInterfaceReactiveMode: "coroutines"

View File

@@ -0,0 +1,16 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped
library: spring-declarative-http-interface
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
additionalProperties:
documentationProvider: springDoc
annotationLibrary: swagger2
useSwaggerUI: "false"
serializableModel: "true"
beanValidations: "true"
interfaceOnly: true
reactive: true
declarativeInterfaceWrapResponses: true
useFlowForArrayReturnType: false
declarativeInterfaceReactiveMode: "reactor"

View File

@@ -0,0 +1,15 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-spring-declarative-interface-wrapped
library: spring-declarative-http-interface
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
additionalProperties:
documentationProvider: springDoc
annotationLibrary: swagger2
useSwaggerUI: "false"
serializableModel: "true"
beanValidations: "true"
interfaceOnly: true
reactive: false
declarativeInterfaceWrapResponses: true
useFlowForArrayReturnType: false

View File

@@ -0,0 +1,15 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-spring-declarative-interface
library: spring-declarative-http-interface
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
additionalProperties:
documentationProvider: springDoc
annotationLibrary: swagger2
useSwaggerUI: "false"
serializableModel: "true"
beanValidations: "true"
interfaceOnly: true
reactive: false
declarativeInterfaceWrapResponses: true
useFlowForArrayReturnType: false

View File

@@ -6,7 +6,7 @@ library: httpx
additionalProperties:
packageName: petstore_api
mapNumberTo: float
poetry1: true
poetry1: false
nameMappings:
_type: underscore_type
type_: type_with_underscore

View File

@@ -0,0 +1,8 @@
generatorName: rust
outputDir: samples/client/others/rust/reqwest/enum-query-params
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/enum-query-params.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: true
packageName: enum-query-params-reqwest

View File

@@ -0,0 +1,10 @@
generatorName: rust
outputDir: samples/client/petstore/rust/reqwest/petstore-serde-path-to-error
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
packageName: petstore-reqwest-serde-path-to-error
useSerdePathToError: true
enumNameMappings:
delivered: shipped

View File

@@ -31,10 +31,10 @@
sha256: 24c6a39a9d7327d397dc038c368a19c84f14ed96a69fe28d53719b3eaf0a725c
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/api/PetApiTest.java"
sha256: 5e9f471d34310f94895751bb96cc79583376f043593c3a387c82077c70f8102f
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/MammalTest.java"
sha256: 67a9e63e13ebddac21cb236aa015edce30f5d3bd8d6adcf50044cad00d48c45e
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/ZebraTest.java"
sha256: 15eeb6d8a9a79d0f1930b861540d9c5780d6c49ea4fdb68269ac3e7ec481e142
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/MammalTest.java"
sha256: a09c120b694788b12f8d73cc0dd307e509ee1744b2ff45c5711b1186c419f915
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/ZebraTest.java"
sha256: 15e509d8cb8e9b050c6418cfbf8a5dced9acc97cf29e5727da9f907c52d11f1e
- filename: "samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/api/PetApiTest.java"
sha256: d8f7fff724f81e666daf115cc25f8347e1fda4e861aa30df0dae3fa50c91404c
- filename: "samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/api/PetApiTest.java"
@@ -59,6 +59,6 @@
sha256: 45cdaba3d2adc212cd4f0184ad475419a95e2326254c2ef84175e210c922b2f3
# rust axum test files
- filename: "samples/server/petstore/rust-axum/output/rust-axum-oneof/tests/oneof_with_discriminator.rs"
sha256: 2d4f5a069fdcb3057bb078d5e75b3de63cd477b97725e457079df24bd2c30600
sha256: b2093528aac971193f2863a70f46eea45cf8bda79120b133a614599e80d8b46d
- filename: "samples/server/petstore/rust-axum/output/openapi-v3/tests/oneof_untagged.rs"
sha256: 1d3fb01f65e98290b1d3eece28014c7d3e3f2fdf18e7110249d3c591cc4642ab

View File

@@ -644,6 +644,13 @@ Example:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/required-properties.yaml -o /tmp/java-okhttp/ --openapi-normalizer NORMALIZER_CLASS=org.openapitools.codegen.OpenAPINormalizerTest$RemoveRequiredNormalizer
```
- `REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT`: When set to true, remove the "properties" of a schema with type other than "object".
Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/required-properties.yaml -o /tmp/java-okhttp/ --openapi-normalizer REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT=true
```
- `FILTER`
The `FILTER` parameter allows selective inclusion of API operations based on specific criteria. It applies the `x-internal: true` property to operations that do **not** match the specified values, preventing them from being generated. Multiple filters can be separated by a semicolon.

View File

@@ -105,6 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false|
|useSealedOneOfInterfaces|Generate the oneOf interfaces as sealed interfaces. Only supported for WebClient and RestClient.| |false|
|useSingleRequestParameter|Setting this property to &quot;true&quot; will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY native, jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to &quot;static&quot; does the same as &quot;true&quot;, but also makes the generated arguments class static with single parameter instantiation.| |false|
|useUnaryInterceptor|If true it will generate ResponseInterceptors using a UnaryOperator. This can be usefull for manipulating the request before it gets passed, for example doing your own decryption| |false|
|webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false|
|withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|

View File

@@ -105,6 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false|
|useSealedOneOfInterfaces|Generate the oneOf interfaces as sealed interfaces. Only supported for WebClient and RestClient.| |false|
|useSingleRequestParameter|Setting this property to &quot;true&quot; will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY native, jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to &quot;static&quot; does the same as &quot;true&quot;, but also makes the generated arguments class static with single parameter instantiation.| |false|
|useUnaryInterceptor|If true it will generate ResponseInterceptors using a UnaryOperator. This can be usefull for manipulating the request before it gets passed, for example doing your own decryption| |false|
|webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false|
|withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|

View File

@@ -84,6 +84,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|useSwaggerV3Annotations|Whether to generate Swagger v3 (OpenAPI v3) annotations.| |false|
|useTags|use tags for creating interface and controller classnames| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|

View File

@@ -85,6 +85,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|useSwaggerV3Annotations|Whether to generate Swagger v3 (OpenAPI v3) annotations.| |false|
|useTags|use tags for creating interface and controller classnames| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|

View File

@@ -27,14 +27,17 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|beanQualifiers|Whether to add fully-qualifier class names as bean qualifiers in @Component and @RestController annotations. May be used to prevent bean names clash if multiple generated libraries (contexts) added to single project.| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
|declarativeInterfaceReactiveMode|What type of reactive style to use in Spring Http declarative interface|<dl><dt>**coroutines**</dt><dd>Use kotlin-idiomatic 'suspend' functions</dd><dt>**reactor**</dt><dd>Use reactor return wrappers 'Mono' and 'Flux'</dd></dl>|coroutines|
|declarativeInterfaceWrapResponses|Whether (when false) to return actual type (e.g. List&lt;Fruit&gt;) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity&lt;List&lt;Fruit&gt;&gt;)| |false|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|documentationProvider|Select the OpenAPI documentation provider.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springfox**</dt><dd>Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x. Deprecated (for removal); use springdoc instead.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|springdoc|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
|exceptionHandler|generate default global exception handlers (not compatible with reactive. enabling reactive will disable exceptionHandler )| |true|
|gradleBuildFile|generate a gradle build file using the Kotlin DSL| |true|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|includeHttpRequestContext|Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods.| |false|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd></dl>|spring-boot|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-declarative-http-interface**</dt><dd>Spring Declarative Interface client</dd></dl>|spring-boot|
|modelMutable|Create mutable models| |false|
|modelPackage|model package for generated code| |org.openapitools.model|
|packageName|Generated artifact package name.| |org.openapitools|

View File

@@ -226,8 +226,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
|allOf|✗|OAS2,OAS3
|anyOf||OAS3
|oneOf||OAS3
|anyOf||OAS3
|oneOf||OAS3
|not|✗|OAS3
### Security Feature

View File

@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>UUID</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid||
|Uuid||
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3

View File

@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>UUID</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid||
|Uuid||
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3

View File

@@ -50,6 +50,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>UUID</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
@@ -150,7 +151,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid||
|Uuid||
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3

View File

@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>UUID</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid||
|Uuid||
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3

View File

@@ -53,6 +53,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>UUID</li>
<li>bool</li>
<li>bytearray</li>
<li>bytes</li>
@@ -155,7 +156,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid||
|Uuid||
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3

View File

@@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option| |false|
|topLevelApiClient|Creates a top level `Api` trait and `ApiClient` struct that contain all Apis. This option is for 'reqwest-trait' library only| |false|
|useBonBuilder|Use the bon crate for building parameter types. This option is for the 'reqwest-trait' library only| |false|
|useSerdePathToError|If set, use the serde_path_to_error library to enhance serde error messages. This option is for 'reqwest' and 'reqwest-trait' library only| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|withAWSV4Signature|whether to include AWS v4 signature support| |false|

View File

@@ -22,7 +22,7 @@ npm install @openapitools/openapi-generator-cli -g
To install a specific version of the tool, pass the version during installation:
<!-- RELEASE_VERSION -->
```bash
openapi-generator-cli version-manager set 7.16.0
openapi-generator-cli version-manager set 7.17.0
```
<!-- /RELEASE_VERSION -->
To install the tool as a dev dependency in your current project:
@@ -119,18 +119,18 @@ docker run --rm \
<!-- 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.16.0/openapi-generator-cli-7.16.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.0.jar`
For **Mac/Linux** users:
```bash
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.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.
```powershell
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.0.jar
```
<!-- /RELEASE_VERSION -->

View File

@@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.16.0</version>
<version>7.17.0</version>
<executions>
<execution>
<goals>

View File

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

View File

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

View File

@@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
[source,group]
----
plugins {
id "org.openapi.generator" version "7.16.0"
id "org.openapi.generator" version "7.17.0"
}
----
@@ -113,7 +113,7 @@ buildscript {
// url "https://plugins.gradle.org/m2/"
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:7.16.0"
classpath "org.openapitools:openapi-generator-gradle-plugin:7.17.0"
}
}
@@ -759,7 +759,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath('org.openapitools:openapi-generator-gradle-plugin:7.16.0') {
classpath('org.openapitools:openapi-generator-gradle-plugin:7.17.0') {
exclude group: 'com.google.guava'
}
}

View File

@@ -1,5 +1,5 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.17.0-SNAPSHOT
openApiGeneratorVersion=7.18.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.17.0-SNAPSHOT</version>
<version>7.18.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@@ -19,5 +19,5 @@ gradle generateGoWithInvalidSpec # expected outcome: BUILD FAILED
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
```bash
gradle -PopenApiGeneratorVersion=7.16.0 openApiValidate
gradle -PopenApiGeneratorVersion=7.17.0 openApiValidate
```

View File

@@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.17.0-SNAPSHOT
openApiGeneratorVersion=7.18.0-SNAPSHOT
# /RELEASE_VERSION

View File

@@ -81,12 +81,12 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
/**
* The template directory holding a custom template.
*/
val templateDir = project.objects.property<String?>()
val templateDir = project.objects.property<String>()
/**
* The template location (which may be a directory or a classpath location) holding custom templates.
*/
val templateResourcePath = project.objects.property<String?>()
val templateResourcePath = project.objects.property<String>()
/**
* Adds authorization headers when fetching the OpenAPI definitions remotely.
@@ -109,7 +109,7 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
/**
* Specifies if the existing files should be overwritten during the generation.
*/
val skipOverwrite = project.objects.property<Boolean?>()
val skipOverwrite = project.objects.property<Boolean>()
/**
* Package for generated classes (where supported)
@@ -244,32 +244,32 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
/**
* Reference the library template (sub-template) of a generator.
*/
val library = project.objects.property<String?>()
val library = project.objects.property<String>()
/**
* Git host, e.g. gitlab.com.
*/
val gitHost = project.objects.property<String?>()
val gitHost = project.objects.property<String>()
/**
* Git user ID, e.g. openapitools.
*/
val gitUserId = project.objects.property<String?>()
val gitUserId = project.objects.property<String>()
/**
* Git repo ID, e.g. openapi-generator.
*/
val gitRepoId = project.objects.property<String?>()
val gitRepoId = project.objects.property<String>()
/**
* Release note, default to 'Minor update'.
*/
val releaseNote = project.objects.property<String?>()
val releaseNote = project.objects.property<String>()
/**
* HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}/{language}'
*/
val httpUserAgent = project.objects.property<String?>()
val httpUserAgent = project.objects.property<String>()
/**
* Specifies how a reserved name should be escaped to. Otherwise, the default _<name> is used.
@@ -279,17 +279,17 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
/**
* Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
*/
val ignoreFileOverride = project.objects.property<String?>()
val ignoreFileOverride = project.objects.property<String>()
/**
* Remove prefix of operationId, e.g. config_getId => getId
*/
val removeOperationIdPrefix = project.objects.property<Boolean?>()
val removeOperationIdPrefix = project.objects.property<Boolean>()
/**
* Skip examples defined in the operation
*/
val skipOperationExample = project.objects.property<Boolean?>()
val skipOperationExample = project.objects.property<Boolean>()
/**
* Defines which API-related files should be generated. This allows you to create a subset of generated files (or none at all).
@@ -394,7 +394,7 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
/**
* Templating engine: "mustache" (default) or "handlebars" (beta)
*/
val engine = project.objects.property<String?>()
val engine = project.objects.property<String>()
/**
* Defines whether the output dir should be cleaned up before generating the output.

View File

@@ -55,7 +55,6 @@ import org.openapitools.codegen.config.MergedSpecBuilder
*
* @author Jim Schubert
*/
@Suppress("UnstableApiUsage")
@CacheableTask
open class GenerateTask @Inject constructor(private val objectFactory: ObjectFactory) : DefaultTask() {
@@ -154,14 +153,14 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
@get:Optional
@get:InputDirectory
@get:PathSensitive(PathSensitivity.RELATIVE)
val templateDir = project.objects.property<String?>()
val templateDir = project.objects.property<String>()
/**
* Resource path containing template files.
*/
@get:Optional
@get:Input
val templateResourcePath = project.objects.property<String?>()
val templateResourcePath = project.objects.property<String>()
/**
* Adds authorization headers when fetching the OpenAPI definitions remotely.
@@ -193,7 +192,7 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
*/
@get:Optional
@get:Input
val skipOverwrite = project.objects.property<Boolean?>()
val skipOverwrite = project.objects.property<Boolean>()
/**
* Package for generated classes (where supported)
@@ -384,42 +383,42 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
*/
@get:Optional
@get:Input
val library = project.objects.property<String?>()
val library = project.objects.property<String>()
/**
* Git host, e.g. gitlab.com.
*/
@get:Optional
@get:Input
val gitHost = project.objects.property<String?>()
val gitHost = project.objects.property<String>()
/**
* Git user ID, e.g. openapitools.
*/
@get:Optional
@get:Input
val gitUserId = project.objects.property<String?>()
val gitUserId = project.objects.property<String>()
/**
* Git repo ID, e.g. openapi-generator.
*/
@get:Optional
@get:Input
val gitRepoId = project.objects.property<String?>()
val gitRepoId = project.objects.property<String>()
/**
* Release note, default to 'Minor update'.
*/
@get:Optional
@get:Input
val releaseNote = project.objects.property<String?>()
val releaseNote = project.objects.property<String>()
/**
* HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}/{language}'
*/
@get:Optional
@get:Input
val httpUserAgent = project.objects.property<String?>()
val httpUserAgent = project.objects.property<String>()
/**
* Specifies how a reserved name should be escaped to.
@@ -434,21 +433,21 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
@get:Optional
@get:InputFile
@get:PathSensitive(PathSensitivity.RELATIVE)
val ignoreFileOverride = project.objects.property<String?>()
val ignoreFileOverride = project.objects.property<String>()
/**
* Remove prefix of operationId, e.g. config_getId => getId
*/
@get:Optional
@get:Input
val removeOperationIdPrefix = project.objects.property<Boolean?>()
val removeOperationIdPrefix = project.objects.property<Boolean>()
/**
* Remove examples defined in the operation
*/
@get:Optional
@get:Input
val skipOperationExample = project.objects.property<Boolean?>()
val skipOperationExample = project.objects.property<Boolean>()
/**
* Defines which API-related files should be generated. This allows you to create a subset of generated files (or none at all).
@@ -581,7 +580,7 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
*/
@get:Optional
@get:Input
val engine = project.objects.property<String?>()
val engine = project.objects.property<String>()
/**
* Defines whether the output dir should be cleaned up before generating the output.
@@ -598,19 +597,11 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
@get:Input
val dryRun = project.objects.property<Boolean>()
private fun <T : Any?> Property<T>.ifNotEmpty(block: Property<T>.(T) -> Unit) {
private fun <T> Property<T>.ifNotEmpty(block: Property<T>.(T) -> Unit) {
if (isPresent) {
val item: T? = get()
if (item != null) {
when (get()) {
is String -> if ((get() as String).isNotEmpty()) {
block(get())
}
is String? -> if (true == (get() as String?)?.isNotEmpty()) {
block(get())
}
else -> block(get())
}
when (val value = get()) {
is String -> if (value.isNotEmpty()) block(value)
else -> block(value)
}
}
}
@@ -725,7 +716,7 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
}
skipOverwrite.ifNotEmpty { value ->
configurator.setSkipOverwrite(value ?: false)
configurator.setSkipOverwrite(value)
}
generatorName.ifNotEmpty { value ->
@@ -820,11 +811,11 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
}
removeOperationIdPrefix.ifNotEmpty { value ->
configurator.setRemoveOperationIdPrefix(value!!)
configurator.setRemoveOperationIdPrefix(value)
}
skipOperationExample.ifNotEmpty { value ->
configurator.setSkipOperationExample(value!!)
configurator.setSkipOperationExample(value)
}
logToStderr.ifNotEmpty { value ->

View File

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

View File

@@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.17.0-SNAPSHOT</version>
<version>7.18.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.17.0-SNAPSHOT</version>
<version>7.18.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.17.0-SNAPSHOT</version>
<version>7.18.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.17.0-SNAPSHOT</version>
<version>7.18.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.17.0-SNAPSHOT</version>
<version>7.18.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.17.0-SNAPSHOT</version>
<version>7.18.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.17.0-SNAPSHOT</version>
<version>7.18.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

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

View File

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

View File

@@ -265,6 +265,15 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
private Map<String, CodegenProperty> requiredVarsMap;
private String ref;
/**
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
*
* @return vendor extensions
*/
public Map<String, Object> getExts() {
return vendorExtensions;
}
@Override
public CodegenProperty getContains() {
return contains;
@@ -365,7 +374,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
return discriminator == null ? null : discriminator.getPropertyName();
}
@Override
public String getPattern() {
return pattern;

View File

@@ -79,6 +79,15 @@ public class CodegenOperation {
return params != null && !params.isEmpty();
}
/**
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
*
* @return vendor extensions
*/
public Map<String, Object> getExts() {
return vendorExtensions;
}
/**
* Check if there's at least one parameter
*

View File

@@ -534,6 +534,15 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
return sb.toString();
}
/**
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
*
* @return vendor extensions
*/
public Map<String, Object> getExts() {
return vendorExtensions;
}
// use schema.getContains or content.mediaType.schema.getContains instead of this
@Override
public CodegenProperty getContains() {

View File

@@ -436,6 +436,15 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
return !getRequired() || isNullable;
}
/**
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
*
* @return vendor extensions
*/
public Map<String, Object> getExts() {
return vendorExtensions;
}
@Override
public CodegenProperty getItems() {
return items;

View File

@@ -206,6 +206,15 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
}
/**
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
*
* @return vendor extensions
*/
public Map<String, Object> getExts() {
return vendorExtensions;
}
// use content.mediaType.schema.getContains instead of this
@Override
public CodegenProperty getContains() {

View File

@@ -38,4 +38,13 @@ public class CodegenServer {
sb.append('}');
return sb.toString();
}
/**
* An alias for vendor extensions, e.g. one can use {{exts.x-something}} for cleaner template
*
* @return vendor extensions
*/
public Map<String, Object> getExts() {
return vendorExtensions;
}
}

View File

@@ -1843,6 +1843,7 @@ public class DefaultCodegen implements CodegenConfig {
protected void initializeSpecialCharacterMapping() {
// Initialize special characters
specialCharReplacements.put("$", "Dollar");
specialCharReplacements.put("", "Euro");
specialCharReplacements.put("^", "Caret");
specialCharReplacements.put("|", "Pipe");
specialCharReplacements.put("=", "Equal");

View File

@@ -353,22 +353,20 @@ public class InlineModelResolver {
}
}
}
} else {
if (schema.getProperties() != null) {
// If non-object type is specified but also properties
LOGGER.warn("Illegal schema found with non-object type ({}) combined with properties. Properties automatically removed.", schema.getType());
schema.setProperties(null);
return;
}
if (schema.getAdditionalProperties() != null) {
// If non-object type is specified but also additionalProperties
LOGGER.error("Illegal schema found with non-object type ({}) combined with additionalProperties. AdditionalProperties automatically removed.", schema.getType());
schema.setAdditionalProperties(null);
return;
}
} else if (schema.getProperties() != null) {
// If non-object type is specified but also properties
LOGGER.error("Illegal schema found with non-object type combined with properties," +
" no properties should be defined:" +
" consider using --openapi-normalizer REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT=true\n " +
schema.toString());
return;
} else if (schema.getAdditionalProperties() != null) {
// If non-object type is specified but also additionalProperties
LOGGER.error("Illegal schema found with non-object type combined with" +
" additionalProperties, no additionalProperties should be defined:\n " +
schema.toString());
return;
}
// Check array items
if (ModelUtils.isArraySchema(schema)) {
Schema items = ModelUtils.getSchemaItems(schema);

View File

@@ -124,6 +124,9 @@ public class OpenAPINormalizer {
// the allOf contains a new schema containing the properties in the top level
final String REFACTOR_ALLOF_WITH_PROPERTIES_ONLY = "REFACTOR_ALLOF_WITH_PROPERTIES_ONLY";
// when set to true, remove the "properties" of a schema with type other than "object"
final String REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT = "REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT";
// when set to true, normalize OpenAPI 3.1 spec to make it work with the generator
final String NORMALIZE_31SPEC = "NORMALIZE_31SPEC";
@@ -206,6 +209,7 @@ public class OpenAPINormalizer {
ruleNames.add(SET_CONTAINER_TO_NULLABLE);
ruleNames.add(SET_PRIMITIVE_TYPES_TO_NULLABLE);
ruleNames.add(SIMPLIFY_ONEOF_ANYOF_ENUM);
ruleNames.add(REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT);
// rules that are default to true
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
@@ -692,6 +696,11 @@ public class OpenAPINormalizer {
* @return Schema
*/
public Schema normalizeSchema(Schema schema, Set<Schema> visitedSchemas) {
// normalize reference schema
if (StringUtils.isNotEmpty(schema.get$ref())) {
normalizeReferenceSchema(schema);
}
if (skipNormalization(schema, visitedSchemas)) {
return schema;
}
@@ -702,6 +711,8 @@ public class OpenAPINormalizer {
markSchemaAsVisited(schema, visitedSchemas);
processNormalizeOtherThanObjectWithProperties(schema);
if (ModelUtils.isArraySchema(schema)) { // array
Schema result = normalizeArraySchema(schema);
normalizeSchema(result.getItems(), visitedSchemas);
@@ -757,6 +768,30 @@ public class OpenAPINormalizer {
return schema;
}
/**
* Normalize reference schema with allOf to support sibling properties
*
* @param schema Schema
*/
protected void normalizeReferenceSchema(Schema schema) {
if (schema.getTitle() != null || schema.getDescription() != null
|| schema.getNullable() != null || schema.getDefault() != null || schema.getDeprecated() != null
|| schema.getMaximum() != null || schema.getMinimum() != null
|| schema.getExclusiveMaximum() != null || schema.getExclusiveMinimum() != null
|| schema.getMaxItems() != null || schema.getMinItems() != null
|| schema.getMaxProperties() != null || schema.getMinProperties() != null
|| schema.getMaxLength() != null || schema.getMinLength() != null
|| schema.getWriteOnly() != null || schema.getReadOnly() != null
|| schema.getExample() != null || (schema.getExamples() != null && !schema.getExamples().isEmpty())
|| schema.getMultipleOf() != null || schema.getPattern() != null
|| (schema.getExtensions() != null && !schema.getExtensions().isEmpty())
) {
// create allOf with a $ref schema
schema.addAllOfItem(new Schema<>().$ref(schema.get$ref()));
// clear $ref in original schema
schema.set$ref(null);
}
}
/**
* Check if normalization is needed.
@@ -1961,6 +1996,23 @@ public class OpenAPINormalizer {
private boolean hasMethod(String method) {
return methodFilters.contains(method);
}
}
/**
* When set to true, remove "properties" attribute on schema other than "object"
* since it should be ignored and may result in odd generated code
*
* @param schema Schema
* @return Schema
*/
protected void processNormalizeOtherThanObjectWithProperties(Schema schema) {
if (getRule(REMOVE_PROPERTIES_FROM_TYPE_OTHER_THAN_OBJECT)) {
// Check object models / any type models / composed models for properties,
// if the schema has a type defined that is not "object" it should not define
// any properties
if (schema.getType() != null && !"object".equals(schema.getType())) {
schema.setProperties(null);
}
}
}
}

View File

@@ -1359,20 +1359,20 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return String.format(Locale.ROOT, "new %s<>()",
instantiationTypes().getOrDefault("map", "HashMap"));
} else if (ModelUtils.isIntegerSchema(schema)) {
} else if (ModelUtils.isIntegerSchema(schema) || cp.isInteger || cp.isLong) {
if (schema.getDefault() != null) {
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(schema.getFormat())) {
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(schema.getFormat()) || cp.isLong) {
return schema.getDefault().toString() + "l";
} else {
return schema.getDefault().toString();
}
}
return null;
} else if (ModelUtils.isNumberSchema(schema)) {
} else if (ModelUtils.isNumberSchema(schema) || cp.isFloat || cp.isDouble) {
if (schema.getDefault() != null) {
if (SchemaTypeUtil.FLOAT_FORMAT.equals(schema.getFormat())) {
if (SchemaTypeUtil.FLOAT_FORMAT.equals(schema.getFormat()) || cp.isFloat) {
return schema.getDefault().toString() + "f";
} else if (SchemaTypeUtil.DOUBLE_FORMAT.equals(schema.getFormat())) {
} else if (SchemaTypeUtil.DOUBLE_FORMAT.equals(schema.getFormat()) || cp.isDouble) {
return schema.getDefault().toString() + "d";
} else {
return "new BigDecimal(\"" + schema.getDefault().toString() + "\")";
@@ -1891,6 +1891,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
model.imports.add("Arrays");
} else if ("set".equals(property.containerType)) {
model.imports.add("LinkedHashSet");
model.imports.add("Arrays");
if ((!openApiNullable || !property.isNullable) && jackson) { // cannot be wrapped to nullable
model.imports.add("JsonDeserialize");
property.vendorExtensions.put("x-setter-extra-annotation", "@JsonDeserialize(as = LinkedHashSet.class)");

View File

@@ -119,6 +119,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
convertPropertyToStringAndWriteBack(CodegenConstants.IMPL_FOLDER, this::setImplFolder);
convertPropertyToBooleanAndWriteBack(USE_BEANVALIDATION, this::setUseBeanValidation);
convertPropertyToBooleanAndWriteBack(USE_TAGS, this::setUseTags);
convertPropertyToBooleanAndWriteBack(JACKSON, this::setJackson);
}
@Override

View File

@@ -20,6 +20,7 @@ package org.openapitools.codegen.languages;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import lombok.Getter;
@@ -35,6 +36,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Pattern;
@@ -1172,4 +1176,15 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
}
}
protected static abstract class CustomLambda implements Mustache.Lambda {
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
final StringWriter tempWriter = new StringWriter();
frag.execute(tempWriter);
out.write(formatFragment(tempWriter.toString()));
}
public abstract String formatFragment(String fragment);
}
}

View File

@@ -25,6 +25,7 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.meta.features.DataTypeFeature;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
@@ -71,7 +72,9 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
SecurityFeature.BearerToken,
SecurityFeature.ApiKey,
SecurityFeature.OAuth2_Implicit
)));
)).includeDataTypeFeatures(
DataTypeFeature.Uuid
));
// from https://docs.python.org/3/reference/lexical_analysis.html#keywords
setReservedWordsLowerCase(
@@ -108,6 +111,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
// TODO file and binary is mapped as `file`
languageSpecificPrimitives.add("file");
languageSpecificPrimitives.add("bytes");
languageSpecificPrimitives.add("UUID");
typeMapping.clear();
typeMapping.put("integer", "int");
@@ -129,8 +133,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
// mapped to String as a workaround
typeMapping.put("binary", "str");
typeMapping.put("ByteArray", "str");
// map uuid to string for the time being
typeMapping.put("UUID", "str");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "str");
typeMapping.put("null", "none_type");
@@ -571,7 +574,12 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
type = p.dataType;
}
if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
if (Boolean.TRUE.equals(p.isUuid)) {
if (example == null) {
example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
}
example = "UUID('" + escapeTextInSingleQuotes(example) + "')";
} else if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
if (example == null) {
example = p.paramName + "_example";
}
@@ -671,7 +679,13 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
return getSchemaType(p) + "[str, " + getCollectionItemTypeDeclaration(inner) + "]";
}
String openAPIType = getSchemaType(p);
String openAPIType = super.getSchemaType(p);
if (openAPIType == null) {
LOGGER.error("OpenAPI Type for {} is null. Default to UNKNOWN_OPENAPI_TYPE instead.", p.getName());
openAPIType = "UNKNOWN_OPENAPI_TYPE";
}
if (typeMapping.containsKey(openAPIType)) {
return typeMapping.get(openAPIType);
}

View File

@@ -17,6 +17,7 @@
package org.openapitools.codegen.languages;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.collect.Iterables;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.Schema;
@@ -440,6 +441,17 @@ public class GoClientCodegen extends AbstractGoCodegen {
return null;
}
if (ModelUtils.isArraySchema(p)) {
StringJoiner joinedDefaultValues = new StringJoiner(", ");
Object defaultValues = p.getDefault();
if (defaultValues instanceof ArrayNode) {
for (var value : (ArrayNode) defaultValues) {
joinedDefaultValues.add(value.toString());
}
return "{" + joinedDefaultValues + "}";
}
}
return super.toDefaultValue(p);
}

View File

@@ -105,6 +105,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String FAIL_ON_UNKNOWN_PROPERTIES = "failOnUnknownProperties";
public static final String SUPPORT_VERTX_FUTURE = "supportVertxFuture";
public static final String USE_SEALED_ONE_OF_INTERFACES = "useSealedOneOfInterfaces";
public static final String USE_UNARY_INTERCEPTOR = "useUnaryInterceptor";
// Internal configurations
public static final String SINGLE_REQUEST_PARAMETER = "singleRequestParameter";
@@ -149,6 +150,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
@Getter @Setter protected boolean failOnUnknownProperties = false;
@Setter protected boolean supportVertxFuture = false;
@Setter protected boolean useSealedOneOfInterfaces = false;
@Setter protected boolean useUnaryInterceptor = false;
protected String authFolder;
/**
* Serialization library.
@@ -260,6 +262,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(FAIL_ON_UNKNOWN_PROPERTIES, "Fail Jackson de-serialization on unknown properties", this.failOnUnknownProperties));
cliOptions.add(CliOption.newBoolean(SUPPORT_VERTX_FUTURE, "Also generate api methods that return a vertx Future instead of taking a callback. Only `vertx` supports this option. Requires vertx 4 or greater.", this.supportVertxFuture));
cliOptions.add(CliOption.newBoolean(USE_SEALED_ONE_OF_INTERFACES, "Generate the oneOf interfaces as sealed interfaces. Only supported for WebClient and RestClient.", this.useSealedOneOfInterfaces));
cliOptions.add(CliOption.newBoolean(USE_UNARY_INTERCEPTOR, "If true it will generate ResponseInterceptors using a UnaryOperator. This can be usefull for manipulating the request before it gets passed, for example doing your own decryption", this.useUnaryInterceptor));
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.17.1");
supportedLibraries.put(JERSEY3, "HTTP client: Jersey client 3.1.1. JSON processing: Jackson 2.17.1");
@@ -376,6 +379,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
convertPropertyToStringAndWriteBack(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, this::setUseSingleRequestParameter);
convertPropertyToBooleanAndWriteBack(USE_SEALED_ONE_OF_INTERFACES, this::setUseSealedOneOfInterfaces);
convertPropertyToBooleanAndWriteBack(USE_UNARY_INTERCEPTOR, this::setUseUnaryInterceptor);
writePropertyBack(SINGLE_REQUEST_PARAMETER, getSingleRequestParameter());
writePropertyBack(STATIC_REQUEST, getStaticRequest());

View File

@@ -42,6 +42,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
public static final String GENERATE_POM = "generatePom";
public static final String USE_SWAGGER_ANNOTATIONS = "useSwaggerAnnotations";
public static final String USE_MICROPROFILE_OPENAPI_ANNOTATIONS = "useMicroProfileOpenAPIAnnotations";
public static final String USE_SWAGGER_V3_ANNOTATIONS = "useSwaggerV3Annotations";
public static final String USE_MUTINY = "useMutiny";
public static final String OPEN_API_SPEC_FILE_LOCATION = "openApiSpecFileLocation";
public static final String GENERATE_JSON_CREATOR = "generateJsonCreator";
@@ -57,6 +58,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
private boolean returnJbossResponse = false;
private boolean generatePom = true;
private boolean useSwaggerAnnotations = true;
private boolean useSwaggerV3Annotations = false;
private boolean useMicroProfileOpenAPIAnnotations = false;
private boolean useMutiny = false;
@@ -133,6 +135,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
cliOptions.add(CliOption.newBoolean(RETURN_RESPONSE, "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.").defaultValue(String.valueOf(returnResponse)));
cliOptions.add(CliOption.newBoolean(RETURN_JBOSS_RESPONSE, "Whether generate API interface should return `org.jboss.resteasy.reactive.RestResponse` instead of a deserialized entity. This flag cannot be combined with `returnResponse` flag. It requires the flag `interfaceOnly` and `useJakartaEE` set to true, because `org.jboss.resteasy.reactive.RestResponse` was introduced in Quarkus 2.x").defaultValue(String.valueOf(returnJbossResponse)));
cliOptions.add(CliOption.newBoolean(USE_SWAGGER_ANNOTATIONS, "Whether to generate Swagger annotations.", useSwaggerAnnotations));
cliOptions.add(CliOption.newBoolean(USE_SWAGGER_V3_ANNOTATIONS, "Whether to generate Swagger v3 (OpenAPI v3) annotations.", useSwaggerV3Annotations));
cliOptions.add(CliOption.newBoolean(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, "Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.", useMicroProfileOpenAPIAnnotations));
cliOptions.add(CliOption.newString(OPEN_API_SPEC_FILE_LOCATION, "Location where the file containing the spec will be generated in the output folder. No file generated when set to null or empty string."));
cliOptions.add(CliOption.newBoolean(SUPPORT_ASYNC, "Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).", supportAsync));
@@ -149,14 +152,28 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
convertPropertyToBooleanAndWriteBack(RETURN_JBOSS_RESPONSE, value -> returnJbossResponse = value);
convertPropertyToBooleanAndWriteBack(SUPPORT_ASYNC, this::setSupportAsync);
if (QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || OPEN_LIBERTY_LIBRARY.equals(library) || KUMULUZEE_LIBRARY.equals(library)) {
// disable Swagger v2 annotations in library modes; MicroProfile or Swagger v3 may be used instead
useSwaggerAnnotations = false;
} else {
convertPropertyToBooleanAndWriteBack(USE_SWAGGER_ANNOTATIONS, value -> useSwaggerAnnotations = value);
}
// Swagger v3 can be used regardless of library
convertPropertyToBooleanAndWriteBack(USE_SWAGGER_V3_ANNOTATIONS, value -> useSwaggerV3Annotations = value);
// prefer v3 when requested
if (useSwaggerV3Annotations) {
useSwaggerAnnotations = false;
}
if (KUMULUZEE_LIBRARY.equals(library)) {
super.setSourceFolder("src/main/java");
}
if (useSwaggerAnnotations && useSwaggerV3Annotations) {
throw new IllegalArgumentException("Flags 'useSwaggerAnnotations' (v2) and 'useSwaggerV3Annotations' (v3) are mutually exclusive. Please enable only one.");
}
if (useSwaggerV3Annotations && useMicroProfileOpenAPIAnnotations) {
throw new IllegalArgumentException("Flags 'useSwaggerV3Annotations' and 'useMicroProfileOpenAPIAnnotations' are mutually exclusive. Please enable only one.");
}
if (QUARKUS_LIBRARY.equals(library)) {
convertPropertyToBooleanAndWriteBack(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, value -> useMicroProfileOpenAPIAnnotations = value);
}
@@ -184,22 +201,30 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
super.processOpts();
// expose flags to templates
additionalProperties.put(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);
additionalProperties.put(USE_SWAGGER_V3_ANNOTATIONS, useSwaggerV3Annotations);
additionalProperties.put(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, useMicroProfileOpenAPIAnnotations);
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("RestResourceRoot.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestResourceRoot.java")
.doNotOverwrite());
if (!interfaceOnly) {
supportingFiles.add(new SupportingFile("RestResourceRoot.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestResourceRoot.java")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("RestApplication.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")
.doNotOverwrite());
}
if (generatePom) {
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
}
supportingFiles.add(new SupportingFile("RestApplication.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")
.doNotOverwrite());
if (StringUtils.isNotEmpty(openApiSpecFileLocation)) {
int index = openApiSpecFileLocation.lastIndexOf('/');
String fileFolder;
@@ -276,6 +301,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
if (!jackson) {
codegenModel.imports.remove("JsonValue");
codegenModel.imports.remove("JsonProperty");
codegenModel.imports.remove("JsonTypeName");
}
return codegenModel;
}

View File

@@ -22,7 +22,6 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
@@ -40,10 +39,8 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.samskivert.mustache.Mustache;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
@@ -60,14 +57,7 @@ import org.openapitools.codegen.meta.features.ParameterFeature;
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.meta.features.WireFormatFeature;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.templating.mustache.ReplaceAllLambda;
import org.openapitools.codegen.utils.ProcessUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Collections.sort;
@@ -569,6 +559,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
// as the parser interrupts that as a start of a multiline comment.
// We replace paths like `/v1/foo/*` with `/v1/foo/<*>` to avoid this
additionalProperties.put("sanitizePathComment", new ReplaceAllLambda("\\/\\*", "/<*>"));
additionalProperties.put("fnToOneOfWrapperName", new ToOneOfWrapperName());
}
private void processDateLibrary() {
@@ -974,11 +965,21 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
if (discriminator == null) {
continue;
}
// When using generateOneOfAnyOfWrappers and encountering oneOf, we keep discriminator properties,
// because single entity can be referenced in multiple "parent" entities,
// so discriminator for one might not be discriminator for another.
boolean shouldKeepDiscriminatorField = generateOneOfAnyOfWrappers && cm.oneOf != null && !cm.oneOf.isEmpty();
if (shouldKeepDiscriminatorField) {
continue;
}
// Remove discriminator property from the base class, it is not needed in the generated code
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name.equals(discriminator.getPropertyName())));
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
// Add the mapping name to additionalProperties.disciminatorValue
// Add the mapping name to additionalProperties.discriminatorValue
// The mapping name is used to define SerializedName, which in result makes derived classes
// found by kotlinx-serialization during deserialization
CodegenProperty additionalProperties = mappedModel.getModel().getAdditionalProperties();
@@ -989,8 +990,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
additionalProperties.discriminatorValue = mappedModel.getMappingName();
// Remove the discriminator property from the derived class, it is not needed in the generated code
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name.equals(discriminator.getPropertyName())));
}
// If model has no properties after removing discriminator, mark it as empty
// so it generates as a class instead of an empty data class
if (mappedModel.getModel().vars.isEmpty() && !mappedModel.getModel().isEnum && !mappedModel.getModel().isAlias) {
mappedModel.getModel().setHasVars(false);
}
}
}
}
}
@@ -1135,6 +1141,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
param.defaultValue = type + "." + param.enumDefaultValue;
}
private class ToOneOfWrapperName extends CustomLambda {
@Override
public String formatFragment(String fragment) {
return toModelName(StringUtils.lowerCase(fragment)) + "Wrapper";
}
}
@Override
public void postProcess() {
System.out.println("################################################################################");

View File

@@ -70,6 +70,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public static final String BASE_PACKAGE = "basePackage";
public static final String SPRING_BOOT = "spring-boot";
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
public static final String SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY = "spring-declarative-http-interface";
public static final String EXCEPTION_HANDLER = "exceptionHandler";
public static final String GRADLE_BUILD_FILE = "gradleBuildFile";
public static final String SERVICE_INTERFACE = "serviceInterface";
@@ -84,13 +85,30 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public static final String DELEGATE_PATTERN = "delegatePattern";
public static final String USE_TAGS = "useTags";
public static final String BEAN_QUALIFIERS = "beanQualifiers";
public static final String DECLARATIVE_INTERFACE_WRAP_RESPONSES = "declarativeInterfaceWrapResponses";
public static final String DECLARATIVE_INTERFACE_REACTIVE_MODE = "declarativeInterfaceReactiveMode";
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
public static final String INCLUDE_HTTP_REQUEST_CONTEXT = "includeHttpRequestContext";
public static final String USE_FLOW_FOR_ARRAY_RETURN_TYPE = "useFlowForArrayReturnType";
public static final String REQUEST_MAPPING_OPTION = "requestMappingMode";
public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
public static final String USE_REQUEST_MAPPING_ON_INTERFACE = "useRequestMappingOnInterface";
@Getter
public enum DeclarativeInterfaceReactiveMode {
coroutines("Use kotlin-idiomatic 'suspend' functions", "reactiveModeCoroutines"),
reactor("Use reactor return wrappers 'Mono' and 'Flux'", "reactiveModeReactor");
private final String description;
private final String additionalPropertyName;
DeclarativeInterfaceReactiveMode(String description, String additionalPropertyName) {
this.description = description;
this.additionalPropertyName = additionalPropertyName;
}
}
public enum RequestMappingMode {
api_interface("Generate the @RequestMapping annotation on the generated Api Interface."),
controller("Generate the @RequestMapping annotation on the generated Api Controller Implementation."),
@@ -127,6 +145,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
@Setter private boolean serviceImplementation = false;
@Getter @Setter
private boolean reactive = false;
@Setter private boolean includeHttpRequestContext = false;
@Getter @Setter
private boolean useFlowForArrayReturnType = true;
@Setter private boolean interfaceOnly = false;
@@ -135,6 +154,8 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
@Setter private boolean delegatePattern = false;
@Setter protected boolean useTags = false;
@Setter private boolean beanQualifiers = false;
@Setter private DeclarativeInterfaceReactiveMode declarativeInterfaceReactiveMode = DeclarativeInterfaceReactiveMode.coroutines;
@Setter private boolean declarativeInterfaceWrapResponses = false;
@Getter @Setter
protected boolean useSpringBoot3 = false;
@@ -220,9 +241,15 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
" (contexts) added to single project.", beanQualifiers);
addSwitch(USE_SPRING_BOOT3, "Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.", useSpringBoot3);
addSwitch(USE_FLOW_FOR_ARRAY_RETURN_TYPE, "Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.", useFlowForArrayReturnType);
addSwitch(INCLUDE_HTTP_REQUEST_CONTEXT, "Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods.", includeHttpRequestContext);
addSwitch(DECLARATIVE_INTERFACE_WRAP_RESPONSES,
"Whether (when false) to return actual type (e.g. List<Fruit>) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>)",
declarativeInterfaceWrapResponses);
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
"Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
supportedLibraries.put(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY,
"Spring Declarative Interface client");
setLibrary(SPRING_BOOT);
CliOption cliOpt = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC);
@@ -238,6 +265,14 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
}
cliOptions.add(requestMappingOpt);
CliOption declarativeInterfaceReactiveModeOpt = new CliOption(DECLARATIVE_INTERFACE_REACTIVE_MODE,
"What type of reactive style to use in Spring Http declarative interface")
.defaultValue(declarativeInterfaceReactiveMode.name());
for (DeclarativeInterfaceReactiveMode mode : DeclarativeInterfaceReactiveMode.values()) {
declarativeInterfaceReactiveModeOpt.addEnum(mode.name(), mode.getDescription());
}
cliOptions.add(declarativeInterfaceReactiveModeOpt);
if (null != defaultDocumentationProvider()) {
CliOption documentationProviderCliOption = new CliOption(DOCUMENTATION_PROVIDER,
"Select the OpenAPI documentation provider.")
@@ -518,6 +553,41 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
this.setUseFlowForArrayReturnType(convertPropertyToBoolean(USE_FLOW_FOR_ARRAY_RETURN_TYPE));
}
}
if (library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY)) {
this.setReactive(convertPropertyToBoolean(REACTIVE));
if (additionalProperties.containsKey(USE_FLOW_FOR_ARRAY_RETURN_TYPE)) {
this.setUseFlowForArrayReturnType(convertPropertyToBoolean(USE_FLOW_FOR_ARRAY_RETURN_TYPE));
}
if (this.isUseFlowForArrayReturnType()) {
{
throw new IllegalArgumentException("Additional property '" + USE_FLOW_FOR_ARRAY_RETURN_TYPE + "' must be set to 'false' as it is not supported by Spring declarative HTTP interface");
}
}
if (additionalProperties.containsKey(DECLARATIVE_INTERFACE_REACTIVE_MODE)) {
try {
DeclarativeInterfaceReactiveMode optValue = DeclarativeInterfaceReactiveMode.valueOf(
String.valueOf(additionalProperties.get(DECLARATIVE_INTERFACE_REACTIVE_MODE)));
setDeclarativeInterfaceReactiveMode(optValue);
writePropertyBack(optValue.getAdditionalPropertyName(), true);
additionalProperties.remove(DECLARATIVE_INTERFACE_REACTIVE_MODE);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"Invalid value for additional property '" + DECLARATIVE_INTERFACE_REACTIVE_MODE + "'. Supported values are " + Arrays.toString(DeclarativeInterfaceReactiveMode.values()) + "."
);
}
}
}
}
if (SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY.equals(library)) {
this.setUseSpringBoot3(true);
this.setInterfaceOnly(true);
this.setUseFeignClient(false);
this.setSkipDefaultInterface(true);
writePropertyBack(USE_SPRING_BOOT3, useSpringBoot3);
writePropertyBack(INTERFACE_ONLY, interfaceOnly);
writePropertyBack(USE_FEIGN_CLIENT, useFeignClient);
writePropertyBack(SKIP_DEFAULT_INTERFACE, skipDefaultInterface);
}
writePropertyBack(REACTIVE, reactive);
writePropertyBack(EXCEPTION_HANDLER, exceptionHandler);
@@ -564,6 +634,9 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
if (additionalProperties.containsKey(USE_SPRING_BOOT3)) {
this.setUseSpringBoot3(convertPropertyToBoolean(USE_SPRING_BOOT3));
}
if (additionalProperties.containsKey(INCLUDE_HTTP_REQUEST_CONTEXT)) {
this.setIncludeHttpRequestContext(convertPropertyToBoolean(INCLUDE_HTTP_REQUEST_CONTEXT));
}
if (isUseSpringBoot3()) {
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
throw new IllegalArgumentException(DocumentationProvider.SPRINGFOX.getPropertyName() + " is not supported with Spring Boot > 3.x");
@@ -606,7 +679,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
if (this.exceptionHandler && !library.equals(SPRING_CLOUD_LIBRARY)) {
if (this.exceptionHandler && !(library.equals(SPRING_CLOUD_LIBRARY) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY))) {
supportingFiles.add(new SupportingFile("exceptions.mustache",
sanitizeDirectory(sourceFolder + File.separator + apiPackage), "Exceptions.kt"));
}
@@ -699,8 +772,29 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
apiTestTemplateFiles.clear();
}
if (library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY)) {
LOGGER.info("Setup code generator for Kotlin Spring Declarative Http interface");
if (!reactive && !library.equals(SPRING_CLOUD_LIBRARY)) {
supportingFiles.add(new SupportingFile("pom-sb3.mustache", "pom.xml"));
if (this.gradleBuildFile) {
supportingFiles.add(new SupportingFile("buildGradle-sb3-Kts.mustache", "build.gradle.kts"));
supportingFiles.add(new SupportingFile("settingsGradle.mustache", "settings.gradle"));
String gradleWrapperPackage = "gradle.wrapper";
supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache",
gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.properties"));
supportingFiles.add(new SupportingFile("gradle-wrapper.jar",
gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.jar"));
}
apiTemplateFiles.put("apiInterface.mustache", "Client.kt");
apiTestTemplateFiles.clear();
}
if (!reactive && !(library.equals(SPRING_CLOUD_LIBRARY) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY))) {
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
supportingFiles.add(new SupportingFile("springfoxDocumentationConfig.mustache",
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),

View File

@@ -34,6 +34,8 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@@ -77,6 +79,10 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
.excludeSchemaSupportFeatures(
SchemaSupportFeature.Polymorphism
)
.includeSchemaSupportFeatures(
SchemaSupportFeature.oneOf,
SchemaSupportFeature.anyOf
)
.excludeParameterFeatures(
ParameterFeature.Cookie
)
@@ -167,11 +173,203 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("DateTime", "string");
typeMapping.put("password", "string");
typeMapping.put("file", "string");
typeMapping.put("object", "JsonNode");
typeMapping.put("AnyType", "JsonNode");
}
@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> allModels) {
allModels = super.postProcessAllModels(allModels);
// First pass: identify all models that have fields with custom JSON names
Set<String> modelsWithCustomJson = new HashSet<>();
for (Map.Entry<String, ModelsMap> entry : allModels.entrySet()) {
ModelsMap modelsMap = entry.getValue();
for (ModelMap mo : modelsMap.getModels()) {
CodegenModel cm = mo.getModel();
// Check if this model has fields with custom JSON names
for (CodegenProperty var : cm.vars) {
if (var.vendorExtensions.containsKey("x-json-name")) {
modelsWithCustomJson.add(cm.classname);
break;
}
}
}
}
// Second pass: cascade custom JSON handling to parent models and mark array fields
// We need multiple passes to handle transitive dependencies
boolean changed = true;
while (changed) {
changed = false;
for (Map.Entry<String, ModelsMap> entry : allModels.entrySet()) {
ModelsMap modelsMap = entry.getValue();
for (ModelMap mo : modelsMap.getModels()) {
CodegenModel cm = mo.getModel();
// Check if any field's type needs custom JSON and mark array fields appropriately
for (CodegenProperty var : cm.vars) {
String fieldType = var.complexType != null ? var.complexType : var.baseType;
// Handle arrays - check if the inner type has custom JSON
if (var.isArray && var.items != null) {
String innerType = var.items.complexType != null ? var.items.complexType : var.items.baseType;
if (innerType != null && modelsWithCustomJson.contains(innerType)) {
// Mark this array field as containing types with custom JSON
var.vendorExtensions.put("x-is-array-with-custom-json", "true");
var.vendorExtensions.put("x-array-inner-type", innerType);
}
fieldType = innerType;
}
// Cascade custom JSON to parent model if not already marked
if (fieldType != null && modelsWithCustomJson.contains(fieldType)) {
if (!cm.vendorExtensions.containsKey("x-has-custom-json-names")) {
cm.vendorExtensions.put("x-has-custom-json-names", true);
modelsWithCustomJson.add(cm.classname);
changed = true;
}
}
}
}
}
}
return allModels;
}
/**
* Strips surrounding quotes from integer enum values.
* The base OpenAPI Generator stores all enum values as quoted strings (e.g., "0", "1", "2")
* regardless of the enum's actual type. For Nim integer enums, we need the raw numbers
* without quotes so they serialize correctly: %(0) instead of %("0")
*/
private void stripQuotesFromIntegerEnumValues(Map<String, Object> allowableValues) {
if (allowableValues == null || !allowableValues.containsKey("enumVars")) {
return;
}
@SuppressWarnings("unchecked")
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) allowableValues.get("enumVars");
for (Map<String, Object> enumVar : enumVars) {
Object value = enumVar.get("value");
if (value instanceof String) {
String strValue = (String) value;
// Remove surrounding quotes if present
if (strValue.startsWith("\"") && strValue.endsWith("\"")) {
enumVar.put("value", strValue.substring(1, strValue.length() - 1));
}
}
}
}
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
return postProcessModelsEnum(objs);
objs = postProcessModelsEnum(objs);
for (ModelMap mo : objs.getModels()) {
CodegenModel cm = mo.getModel();
if (cm.isEnum && cm.allowableValues != null && cm.allowableValues.containsKey("enumVars")) {
cm.vendorExtensions.put("x-is-top-level-enum", true);
// For integer enums, strip quotes from enum values
if (cm.vendorExtensions.containsKey("x-is-integer-enum")) {
stripQuotesFromIntegerEnumValues(cm.allowableValues);
}
}
// Check if any fields need custom JSON name mapping
boolean hasCustomJsonNames = false;
// Fix dataType fields that contain underscored type names
// This handles cases like Table[string, Record_string__foo__value]
// Also wrap optional fields in Option[T]
for (CodegenProperty var : cm.vars) {
if (var.dataType != null && var.dataType.contains("Record_")) {
var.dataType = fixRecordTypeReferences(var.dataType);
}
if (var.datatypeWithEnum != null && var.datatypeWithEnum.contains("Record_")) {
var.datatypeWithEnum = fixRecordTypeReferences(var.datatypeWithEnum);
}
// Check if the field name was changed from the original (baseName)
// This happens for fields like "_id" which are renamed to "id"
// But we need to exclude cases where the name is just escaped with backticks
// (e.g., "from" becomes "`from`" because it's a reserved word)
if (var.baseName != null && !var.baseName.equals(var.name)) {
// Check if this is just a reserved word escaping (name is `baseName`)
String escapedName = "`" + var.baseName + "`";
if (!var.name.equals(escapedName)) {
// This is a real rename, not just escaping
var.vendorExtensions.put("x-json-name", var.baseName);
hasCustomJsonNames = true;
}
}
// Wrap optional (non-required) or nullable fields in Option[T]
// For non-enum fields only (enums are handled specially in the template)
if ((!var.required || var.isNullable) && !var.isReadOnly && !var.isEnum) {
String baseType = var.dataType;
if (baseType != null && !baseType.startsWith("Option[")) {
var.dataType = "Option[" + baseType + "]";
if (var.datatypeWithEnum != null) {
var.datatypeWithEnum = "Option[" + var.datatypeWithEnum + "]";
}
}
}
// For enum fields, set x-is-optional if they are not required
if (var.isEnum && (!var.required || var.isNullable)) {
var.vendorExtensions.put("x-is-optional", true);
}
// Always set x-is-optional based on the final dataType (for non-enum fields)
// This ensures consistency between type declaration and JSON handling
if (!var.isEnum && var.dataType != null && var.dataType.startsWith("Option[")) {
var.vendorExtensions.put("x-is-optional", true);
}
}
// Mark the model as needing custom JSON deserialization if any fields have custom names
if (hasCustomJsonNames) {
cm.vendorExtensions.put("x-has-custom-json-names", true);
}
}
return objs;
}
/**
* Fix underscored Record type references in dataType strings.
* Converts Record_string__foo___value to RecordStringFooValue.
*/
private String fixRecordTypeReferences(String typeString) {
if (typeString == null || !typeString.contains("Record_")) {
return typeString;
}
// Pattern to match Record_string_... type names with underscores
// These are embedded in strings like: Table[string, Record_string__foo__value]
String result = typeString;
// Match Record_ followed by any characters until end or comma/bracket
Pattern pattern = Pattern.compile("Record_[a-z_]+");
Matcher matcher = pattern.matcher(result);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
String matched = matcher.group();
// Camelize the matched Record type name
String camelized = camelize(matched);
matcher.appendReplacement(sb, camelized);
}
matcher.appendTail(sb);
return sb.toString();
}
@Override
@@ -192,6 +390,8 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
apiPackage = File.separator + packageName + File.separator + "apis";
modelPackage = File.separator + packageName + File.separator + "models";
supportingFiles.add(new SupportingFile("lib.mustache", "", packageName + ".nim"));
supportingFiles.add(new SupportingFile("model_any_type.mustache", packageName + File.separator + "models", "model_any_type.nim"));
supportingFiles.add(new SupportingFile("model_object.mustache", packageName + File.separator + "models", "model_object.nim"));
}
@Override
@@ -215,11 +415,13 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toModelImport(String name) {
name = normalizeSchemaName(name);
name = name.replaceAll("-", "_");
if (importMapping.containsKey(name)) {
return "model_" + StringUtils.underscore(importMapping.get(name));
return sanitizeNimIdentifier("model_" + StringUtils.underscore(importMapping.get(name)));
} else {
return "model_" + StringUtils.underscore(name);
return sanitizeNimIdentifier("model_" + StringUtils.underscore(name));
}
}
@@ -227,22 +429,153 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
public String toApiImport(String name) {
name = name.replaceAll("-", "_");
if (importMapping.containsKey(name)) {
return "api_" + StringUtils.underscore(importMapping.get(name));
return sanitizeNimIdentifier("api_" + StringUtils.underscore(importMapping.get(name)));
} else {
return "api_" + StringUtils.underscore(name);
return sanitizeNimIdentifier("api_" + StringUtils.underscore(name));
}
}
/**
* Normalize schema names to ensure consistency across filename, import, and type name generation.
* This is called early in the pipeline so downstream methods work with consistent names.
*/
private String normalizeSchemaName(String name) {
if (name == null) {
return null;
}
// Remove underscores around and before digits (HTTP status codes, version numbers, etc.)
// e.g., "GetComments_200_response" -> "GetComments200response"
// e.g., "Config_anyOf_1" -> "ConfiganyOf1"
// This ensures consistent handling whether the name comes with or without underscores
name = name.replaceAll("_(\\d+)_", "$1"); // Underscores on both sides
name = name.replaceAll("_(\\d+)$", "$1"); // Trailing underscore before digits
return name;
}
@Override
public CodegenModel fromModel(String name, Schema schema) {
// Normalize the schema name before any processing
name = normalizeSchemaName(name);
CodegenModel mdl = super.fromModel(name, schema);
// Detect integer enums - check both the schema type and the dataType
if (mdl.isEnum) {
String schemaType = schema != null ? schema.getType() : null;
if ("integer".equals(schemaType) || "int".equals(mdl.dataType) || "int64".equals(mdl.dataType)) {
mdl.vendorExtensions.put("x-is-integer-enum", true);
}
}
// Handle oneOf/anyOf schemas to use Nim object variants
if (mdl.getComposedSchemas() != null) {
if (mdl.getComposedSchemas().getOneOf() != null && !mdl.getComposedSchemas().getOneOf().isEmpty()) {
mdl.vendorExtensions.put("x-is-one-of", true);
processComposedSchemaVariants(mdl, mdl.getComposedSchemas().getOneOf(), schema);
} else if (mdl.getComposedSchemas().getAnyOf() != null && !mdl.getComposedSchemas().getAnyOf().isEmpty()) {
mdl.vendorExtensions.put("x-is-any-of", true);
processComposedSchemaVariants(mdl, mdl.getComposedSchemas().getAnyOf(), schema);
}
}
return mdl;
}
/**
* Process oneOf/anyOf schemas to generate proper variant names for Nim object variants.
*/
private void processComposedSchemaVariants(CodegenModel mdl, List<CodegenProperty> variants, Schema schema) {
List<CodegenProperty> newVariants = new ArrayList<>();
List<Schema> schemas = ModelUtils.getInterfaces(schema);
if (variants.size() != schemas.size()) {
LOGGER.warn("Variant size does not match schema interfaces size for model " + mdl.name);
return;
}
for (int i = 0; i < variants.size(); i++) {
CodegenProperty variant = variants.get(i);
Schema variantSchema = schemas.get(i);
// Create a clone to avoid modifying the original
CodegenProperty newVariant = variant.clone();
// Sanitize baseName to remove underscores and properly format for Nim
if (newVariant.baseName != null) {
// Remove trailing underscores and convert to proper format
String sanitizedBase = newVariant.baseName.replaceAll("_+$", ""); // Remove trailing underscores
if (sanitizedBase.length() > 0 && Character.isUpperCase(sanitizedBase.charAt(0))) {
newVariant.baseName = toModelName(sanitizedBase);
} else {
newVariant.baseName = sanitizeNimIdentifier(sanitizedBase);
}
}
// Sanitize dataType to remove underscores and properly format for Nim
// For model types (not primitives), use toModelName to get the proper type name
if (newVariant.dataType != null) {
// Check if this is a model type (starts with uppercase) vs primitive
if (newVariant.dataType.length() > 0 && Character.isUpperCase(newVariant.dataType.charAt(0))) {
// This is likely a model type, use toModelName to properly format it
newVariant.dataType = toModelName(newVariant.dataType);
} else {
// Primitive type, just sanitize
newVariant.dataType = sanitizeNimIdentifier(newVariant.dataType);
}
}
if (newVariant.datatypeWithEnum != null) {
if (newVariant.datatypeWithEnum.length() > 0 && Character.isUpperCase(newVariant.datatypeWithEnum.charAt(0))) {
newVariant.datatypeWithEnum = toModelName(newVariant.datatypeWithEnum);
} else {
newVariant.datatypeWithEnum = sanitizeNimIdentifier(newVariant.datatypeWithEnum);
}
}
// Set variant name based on schema reference or type
if (variantSchema.get$ref() != null && !variantSchema.get$ref().isEmpty()) {
String refName = ModelUtils.getSimpleRef(variantSchema.get$ref());
if (refName != null) {
newVariant.setName(toModelName(refName));
newVariant.setBaseName(refName);
}
} else if (variantSchema.getType() != null) {
// For primitive types or inline schemas
String typeName = variantSchema.getType();
if (variantSchema.getTitle() != null && !variantSchema.getTitle().isEmpty()) {
typeName = variantSchema.getTitle();
}
newVariant.setName(camelize(typeName));
newVariant.setBaseName(typeName);
}
newVariants.add(newVariant);
}
// Replace the original variants with the processed ones
if (mdl.getComposedSchemas().getOneOf() != null) {
mdl.getComposedSchemas().setOneOf(newVariants);
} else if (mdl.getComposedSchemas().getAnyOf() != null) {
mdl.getComposedSchemas().setAnyOf(newVariants);
}
}
@Override
public String toModelName(String name) {
// Name should be normalized by fromModel, but normalize again for safety
name = normalizeSchemaName(name);
return camelize(sanitizeName(name));
}
@Override
public String toModelFilename(String name) {
name = normalizeSchemaName(name);
name = name.replaceAll("-", "_");
return "model_" + StringUtils.underscore(name);
return sanitizeNimIdentifier("model_" + StringUtils.underscore(name));
}
@Override
public String toApiFilename(String name) {
name = name.replaceAll("-", "_");
return "api_" + StringUtils.underscore(name);
return sanitizeNimIdentifier("api_" + StringUtils.underscore(name));
}
@Override
@@ -262,6 +595,12 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
List<CodegenOperation> operations = objectMap.getOperation();
for (CodegenOperation operation : operations) {
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
// Set custom flag for DELETE operations with body to use different template logic
// Nim's httpClient.delete() doesn't support a body parameter
if ("delete".equals(operation.httpMethod) && operation.getHasBodyParam()) {
operation.vendorExtensions.put("x-nim-delete-with-body", true);
}
}
return objs;
@@ -360,6 +699,24 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
return identifier.matches("^(?:[A-Z]|[a-z]|[\\x80-\\xff])(_?(?:[A-Z]|[a-z]|[\\x80-\\xff]|[0-9]))*$");
}
/**
* Sanitize a Nim identifier by removing trailing underscores and collapsing multiple underscores.
* Nim does not allow identifiers to end with underscores.
*
* @param name the identifier to sanitize
* @return the sanitized identifier
*/
private String sanitizeNimIdentifier(String name) {
if (name == null || name.isEmpty()) {
return name;
}
// Remove trailing underscores (Nim identifiers cannot end with underscore)
name = name.replaceAll("_+$", "");
// Collapse multiple consecutive underscores to single underscore
name = name.replaceAll("_+", "_");
return name;
}
@Override
public String toEnumVarName(String name, String datatype) {
name = name.replace(" ", "_");

View File

@@ -188,6 +188,7 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
for (CodegenOperation operation : operations.getOperation()) {
Set<String> phpReturnTypeOptions = new LinkedHashSet<>();
Set<String> docReturnTypeOptions = new LinkedHashSet<>();
boolean hasEmptyResponse = false;
for (CodegenResponse response : operation.responses) {
if (response.dataType != null) {
@@ -200,6 +201,8 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
phpReturnTypeOptions.add(returnType);
docReturnTypeOptions.add(response.dataType);
} else {
hasEmptyResponse = true;
}
}
@@ -208,9 +211,16 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
operation.vendorExtensions.putIfAbsent("x-php-return-type", "void");
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", "void");
} else {
String phpReturnType = String.join("|", phpReturnTypeOptions);
String docReturnType = String.join("|", docReturnTypeOptions);
if (hasEmptyResponse) {
phpReturnType = "?" + phpReturnType;
docReturnType = docReturnType + "|null";
}
operation.vendorExtensions.putIfAbsent("x-php-return-type-is-void", false);
operation.vendorExtensions.putIfAbsent("x-php-return-type", String.join("|", phpReturnTypeOptions));
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", String.join("|", docReturnTypeOptions));
operation.vendorExtensions.putIfAbsent("x-php-return-type", phpReturnType);
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", docReturnType);
}
for (CodegenParameter param : operation.allParams) {

View File

@@ -385,7 +385,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
if(ModelUtils.isArraySchema(schema)) {
Schema itemsSchema = ModelUtils.getSchemaItems(schema);
itemsSchema = ModelUtils.getReferencedSchema(openAPI, itemsSchema);
if(ModelUtils.isModel(itemsSchema)) {
if(ModelUtils.isModel(itemsSchema) || (itemsSchema != null && ModelUtils.isEnumSchema(itemsSchema))) {
String newSchemaName = ModelUtils.getSimpleRef(ModelUtils.getSchemaItems(schema).get$ref()) + ARRAY_SUFFIX;
return addSchemas(schema, newSchemaName, visitedSchemas);
}else if (ModelUtils.isPrimitiveType(itemsSchema)){
@@ -400,7 +400,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
} else if(ModelUtils.isMapSchema(schema)) {
Schema mapValueSchema = ModelUtils.getAdditionalProperties(schema);
mapValueSchema = ModelUtils.getReferencedSchema(openAPI, mapValueSchema);
if(ModelUtils.isModel(mapValueSchema) ) {
if(ModelUtils.isModel(mapValueSchema) || (mapValueSchema != null && ModelUtils.isEnumSchema(mapValueSchema))) {
String newSchemaName = ModelUtils.getSimpleRef(ModelUtils.getAdditionalProperties(schema).get$ref()) + MAP_SUFFIX;
return addSchemas(schema, newSchemaName, visitedSchemas);
}else if (ModelUtils.isPrimitiveType(mapValueSchema)){
@@ -1116,7 +1116,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
} else {
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
if(additionalProperties == null) {
return;
return;
} else if (additionalProperties.getTitle() != null) {
addtionalPropertiesName = additionalProperties.getTitle();
} else if (additionalProperties.get$ref() != null) {
@@ -1124,8 +1124,8 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
addtionalPropertiesName = toVarName(toModelName(ref));
}
}
properties.put(addtionalPropertiesName, schema);
properties.put(addtionalPropertiesName, schema);
}
}
}

View File

@@ -271,6 +271,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
supportingFiles.add(new SupportingFile("gem.mustache", libFolder, gemName + ".rb"));
String gemFolder = libFolder + File.separator + gemName;
supportingFiles.add(new SupportingFile("api_error.mustache", gemFolder, "api_error.rb"));
supportingFiles.add(new SupportingFile("api_model_base.mustache", gemFolder, "api_model_base.rb"));
supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));

View File

@@ -648,7 +648,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
}
private void postProcessPolymorphism(final List<ModelMap> allModels) {
final HashMap<String, List<String>> discriminatorsForModel = new HashMap<>();
final HashMap<String, List<CodegenDiscriminator>> discriminatorsForModel = new HashMap<>();
for (final ModelMap mo : allModels) {
final CodegenModel cm = mo.getModel();
@@ -656,15 +656,17 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
final CodegenComposedSchemas cs = cm.getComposedSchemas();
if (cs != null) {
final List<CodegenProperty> csOneOf = cs.getOneOf();
CodegenDiscriminator discriminator = cm.getDiscriminator();
if (csOneOf != null) {
processPolymorphismDataType(csOneOf);
processPolymorphismDataType(csOneOf, discriminator);
cs.setOneOf(csOneOf);
cm.setComposedSchemas(cs);
}
final List<CodegenProperty> csAnyOf = cs.getAnyOf();
if (csAnyOf != null) {
processPolymorphismDataType(csAnyOf);
processPolymorphismDataType(csAnyOf, discriminator);
cs.setAnyOf(csAnyOf);
cm.setComposedSchemas(cs);
}
@@ -672,14 +674,14 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
if (cm.discriminator != null) {
for (final String model : cm.oneOf) {
final List<String> discriminators = discriminatorsForModel.getOrDefault(model, new ArrayList<>());
discriminators.add(cm.discriminator.getPropertyName());
final List<CodegenDiscriminator> discriminators = discriminatorsForModel.getOrDefault(model, new ArrayList<>());
discriminators.add(cm.discriminator);
discriminatorsForModel.put(model, discriminators);
}
for (final String model : cm.anyOf) {
final List<String> discriminators = discriminatorsForModel.getOrDefault(model, new ArrayList<>());
discriminators.add(cm.discriminator.getPropertyName());
final List<CodegenDiscriminator> discriminators = discriminatorsForModel.getOrDefault(model, new ArrayList<>());
discriminators.add(cm.discriminator);
discriminatorsForModel.put(model, discriminators);
}
}
@@ -689,11 +691,11 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
for (ModelMap mo : allModels) {
final CodegenModel cm = mo.getModel();
final List<String> discriminators = discriminatorsForModel.get(cm.getSchemaName());
final List<CodegenDiscriminator> discriminators = discriminatorsForModel.get(cm.getSchemaName());
if (discriminators != null) {
// If the discriminator field is not a defined attribute in the variant structure, create it.
if (!discriminating(discriminators, cm)) {
final String discriminator = discriminators.get(0);
final CodegenDiscriminator discriminator = discriminators.get(0);
CodegenProperty property = new CodegenProperty();
@@ -710,17 +712,18 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
property.isDiscriminator = true;
// Attributes based on the discriminator value
property.baseName = discriminator;
property.name = discriminator;
property.nameInCamelCase = camelize(discriminator);
property.baseName = discriminator.getPropertyBaseName();
property.name = discriminator.getPropertyName();
property.nameInCamelCase = camelize(discriminator.getPropertyName());
property.nameInPascalCase = property.nameInCamelCase.substring(0, 1).toUpperCase(Locale.ROOT) + property.nameInCamelCase.substring(1);
property.nameInSnakeCase = underscore(discriminator).toUpperCase(Locale.ROOT);
property.nameInSnakeCase = underscore(discriminator.getPropertyName()).toUpperCase(Locale.ROOT);
property.getter = String.format(Locale.ROOT, "get%s", property.nameInPascalCase);
property.setter = String.format(Locale.ROOT, "set%s", property.nameInPascalCase);
property.defaultValueWithParam = String.format(Locale.ROOT, " = data.%s;", property.name);
// Attributes based on the model name
property.defaultValue = String.format(Locale.ROOT, "r#\"%s\"#.to_string()", cm.getSchemaName());
property.discriminatorValue = getDiscriminatorValue(cm.getClassname(), discriminator);
property.jsonSchema = String.format(Locale.ROOT, "{ \"default\":\"%s\"; \"type\":\"string\" }", cm.getSchemaName());
cm.vars.add(property);
@@ -743,14 +746,27 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
}
}
private static boolean discriminating(final List<String> discriminatorsForModel, final CodegenModel cm) {
private static String getDiscriminatorValue(String modelName, CodegenDiscriminator discriminator) {
if (discriminator == null || discriminator.getMappedModels() == null) {
return modelName;
}
return discriminator
.getMappedModels()
.stream()
.filter(m -> m.getModelName().equals(modelName) && m.getMappingName() != null)
.map(CodegenDiscriminator.MappedModel::getMappingName)
.findFirst()
.orElse(modelName);
}
private static boolean discriminating(final List<CodegenDiscriminator> discriminatorsForModel, final CodegenModel cm) {
resetDiscriminatorProperty(cm);
// Discriminator will be presented as enum tag -> One and only one tag is allowed
int countString = 0;
int countNonString = 0;
for (final CodegenProperty var : cm.vars) {
if (discriminatorsForModel.stream().anyMatch(discriminator -> var.baseName.equals(discriminator) || var.name.equals(discriminator))) {
if (discriminatorsForModel.stream().anyMatch(discriminator -> var.baseName.equals(discriminator.getPropertyBaseName()) || var.name.equals(discriminator.getPropertyName()))) {
if (var.isString) {
var.isDiscriminator = true;
++countString;
@@ -773,7 +789,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
}
}
private static void processPolymorphismDataType(final List<CodegenProperty> cp) {
private static void processPolymorphismDataType(final List<CodegenProperty> cp, CodegenDiscriminator discriminator) {
final HashSet<String> dedupDataTypeWithEnum = new HashSet<>();
final HashMap<String, Integer> dedupDataType = new HashMap<>();
@@ -783,6 +799,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
// Mainly needed for primitive types.
model.datatypeWithEnum = camelize(model.dataType.replaceAll("(?:\\w+::)+(\\w+)", "$1")
.replace("<", "Of").replace(">", "")).replace(" ", "").replace(",", "");
model.discriminatorValue = getDiscriminatorValue(model.datatypeWithEnum, discriminator);
if (!dedupDataTypeWithEnum.add(model.datatypeWithEnum)) {
model.datatypeWithEnum += ++idx;
}

View File

@@ -52,6 +52,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
@Setter(AccessLevel.PRIVATE) private boolean useSingleRequestParameter = false;
@Setter(AccessLevel.PRIVATE) private boolean supportAsync = true;
@Setter(AccessLevel.PRIVATE) private boolean supportMiddleware = false;
@Setter(AccessLevel.PRIVATE) private boolean useSerdePathToError = false;
@Setter(AccessLevel.PRIVATE) private boolean supportTokenSource = false;
private boolean supportMultipleResponses = false;
private boolean withAWSV4Signature = false;
@@ -70,6 +71,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
public static final String REQWEST_TRAIT_LIBRARY_ATTR = "reqwestTrait";
public static final String SUPPORT_ASYNC = "supportAsync";
public static final String SUPPORT_MIDDLEWARE = "supportMiddleware";
public static final String USE_SERDE_PATH_TO_ERROR = "useSerdePathToError";
public static final String SUPPORT_TOKEN_SOURCE = "supportTokenSource";
public static final String SUPPORT_MULTIPLE_RESPONSES = "supportMultipleResponses";
public static final String PREFER_UNSIGNED_INT = "preferUnsignedInt";
@@ -210,6 +212,8 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
.defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(SUPPORT_MIDDLEWARE, "If set, add support for reqwest-middleware. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(USE_SERDE_PATH_TO_ERROR, "If set, use the serde_path_to_error library to enhance serde error messages. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
@@ -410,6 +414,11 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
}
writePropertyBack(SUPPORT_MIDDLEWARE, getSupportMiddleware());
if (additionalProperties.containsKey(USE_SERDE_PATH_TO_ERROR)) {
this.setUseSerdePathToError(convertPropertyToBoolean(USE_SERDE_PATH_TO_ERROR));
}
writePropertyBack(USE_SERDE_PATH_TO_ERROR, getUseSerdePathToError());
if (additionalProperties.containsKey(SUPPORT_TOKEN_SOURCE)) {
this.setSupportTokenSource(convertPropertyToBoolean(SUPPORT_TOKEN_SOURCE));
}
@@ -527,6 +536,10 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
return supportMiddleware;
}
private boolean getUseSerdePathToError() {
return useSerdePathToError;
}
private boolean getSupportTokenSource() {
return supportTokenSource;
}

View File

@@ -370,6 +370,16 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
return sanitizeIdentifier(operationId, CasingType.CAMEL_CASE, "call", "method", true);
}
@Override
public String toParamName(String name) {
// rust-server doesn't support r# in param name.
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
return sanitizeIdentifier(name, CasingType.SNAKE_CASE, "param", "parameter", false);
}
@Override
public String toEnumValue(String value, String datatype) {
// rust-server templates expect value to be in quotes
@@ -860,6 +870,16 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
op.vendorExtensions.put("x-has-request-body", true);
}
if (op.allParams.stream()
.anyMatch(p -> p.isArray && !p.isPrimitiveType)) {
op.vendorExtensions.put("x-has-borrowed-params", Boolean.TRUE);
for (CodegenParameter param : op.allParams) {
if (param.isArray) {
param.vendorExtensions.put("x-param-needs-lifetime", Boolean.TRUE);
}
}
}
// The CLI generates a structopt structure for each operation. This can only have a single
// use of a short option, which comes from the parameter name, so we need to police
// against duplicates
@@ -1229,6 +1249,9 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
&& (mdl.dataType.startsWith("swagger::OneOf") || mdl.dataType.startsWith("swagger::AnyOf"))) {
toStringSupport = false;
partialOrdSupport = false;
} else if (mdl.dataType != null && mdl.dataType.equals("serde_json::Value")) {
// Value doesn't implement PartialOrd
partialOrdSupport = false;
} else if (mdl.getAdditionalPropertiesType() != null) {
toStringSupport = false;
} else if (model instanceof ComposedSchema) {
@@ -1545,7 +1568,18 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
}
} else {
param.vendorExtensions.put("x-format-string", "{:?}");
if (param.example != null) {
// Check if this is a model-type enum (allowableValues with values list)
if (param.allowableValues != null && param.allowableValues.containsKey("values")) {
List<?> values = (List<?>) param.allowableValues.get("values");
if (!values.isEmpty()) {
// Use the first enum value as the example.
String firstEnumValue = values.get(0).toString();
String enumVariant = toEnumVarName(firstEnumValue, param.dataType);
example = param.dataType + "::" + enumVariant;
} else if (param.example != null) {
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
}
} else if (param.example != null) {
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
}
}

View File

@@ -1229,6 +1229,9 @@ public class RustServerCodegenDeprecated extends AbstractRustCodegen implements
&& (mdl.dataType.startsWith("swagger::OneOf") || mdl.dataType.startsWith("swagger::AnyOf"))) {
toStringSupport = false;
partialOrdSupport = false;
} else if (mdl.dataType != null && mdl.dataType.equals("serde_json::Value")) {
// Value doesn't implement PartialOrd
partialOrdSupport = false;
} else if (mdl.getAdditionalPropertiesType() != null) {
toStringSupport = false;
} else if (model instanceof ComposedSchema) {
@@ -1546,7 +1549,18 @@ public class RustServerCodegenDeprecated extends AbstractRustCodegen implements
}
else {
param.vendorExtensions.put("x-format-string", "{:?}");
if (param.example != null) {
// Check if this is a model-type enum (allowableValues with values list)
if (param.allowableValues != null && param.allowableValues.containsKey("values")) {
List<?> values = (List<?>) param.allowableValues.get("values");
if (!values.isEmpty()) {
// Use the first enum value as the example.
String firstEnumValue = values.get(0).toString();
String enumVariant = toEnumVarName(firstEnumValue, param.dataType);
example = param.dataType + "::" + enumVariant;
} else if (param.example != null) {
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
}
} else if (param.example != null) {
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
}
}

View File

@@ -461,6 +461,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
}
}
// backup path in extensions
op.vendorExtensions.put("x-path-from-spec", op.path);
// Overwrite path to TypeScript template string, after applying everything we just did.
op.path = pathBuffer.toString();
}

View File

@@ -188,15 +188,6 @@ end:
localVarPath = strReplace(localVarPath, localVarToReplace_{{paramName}}, {{^isEnum}}{{paramName}}{{/isEnum}}{{#isEnum}}{{{operationId}}}_{{enumName}}_ToString({{paramName}}){{/isEnum}});
{{/isString}}
{{#isUuid}}
if({{paramName}} == NULL) {
goto end;
}
char* localVarToReplace_{{paramName}} = malloc(sizeOfPathParams_{{paramName}});
sprintf(localVarToReplace_{{paramName}}, "{%s}", "{{baseName}}");
localVarPath = strReplace(localVarPath, localVarToReplace_{{paramName}}, {{paramName}});
{{/isUuid}}
{{/pathParams}}

View File

@@ -117,7 +117,7 @@ ext {
jackson_version = "2.19.2"
jackson_databind_version = "2.19.2"
{{#openApiNullable}}
jackson_databind_nullable_version = "0.2.7"
jackson_databind_nullable_version = "0.2.8"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
{{#useBeanValidation}}

View File

@@ -117,7 +117,7 @@ ext {
jackson_version = "2.19.2"
jackson_databind_version = "2.19.2"
{{#openApiNullable}}
jackson_databind_nullable_version = "0.2.7"
jackson_databind_nullable_version = "0.2.8"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
httpclient_version = "5.1.3"

View File

@@ -354,7 +354,7 @@
<jackson-version>2.19.2</jackson-version>
<jackson-databind-version>2.19.2</jackson-databind-version>
{{#openApiNullable}}
<jackson-databind-nullable-version>0.2.7</jackson-databind-nullable-version>
<jackson-databind-nullable-version>0.2.8</jackson-databind-nullable-version>
{{/openApiNullable}}
{{#useJakartaEe}}
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>

View File

@@ -107,7 +107,7 @@ ext {
jackson_databind_version = "2.19.2"
{{/jackson}}
{{#openApiNullable}}
jackson_databind_nullable_version = "0.2.7"
jackson_databind_nullable_version = "0.2.8"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
feign_version = "13.5"

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