11973 Commits

Author SHA1 Message Date
John Boyes
7084a79ede
[BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests (#9852)
* [BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests

The Python generator no longer sets a default `Content-Type` of
`application/json` for `GET`, `HEAD` and `DELETE` requests.

Having the `Content-Type` set for these requests was causing issues with
other tools which insist that GET, HEAD and DELETE requests do not have
a Content-Type (as per the OpenAPI 3 specification).

An example of the problem that this commit fixes is when using
[Prism][1] as a [validation proxy][2].

[Prism rejects any GET request that has a Content-Type][3].

Here is [an example of the problem manifesting itself][4].

To validate the fix in this commit:

1. Start with any OpenAPI3 spec e.g. the Petstore example at
https://editor.swagger.io/
2. Generate Python client code for the spec
3. Look at the generated `rest.py` e.g. in the [standard sample in this
repo][5] and see that the `Content-Type` defaults to `application/json`
for all HTTP methods (including `GET`, `HEAD` and `DELETE`), rather than
there being no `Content-Type` for `GET`, `HEAD` and `DELETE`.

Fixes #9831

[1]: https://github.com/stoplightio/prism
[2]: https://meta.stoplight.io/docs/prism/docs/guides/03-validation-proxy.md
[3]: https://github.com/stoplightio/prism/issues/1408#issuecomment-690948020
[4]: https://github.com/agilepathway/gauge-openapi-example/pull/28/checks?check_run_id=2888606052#step:13:18
[5]: 969cea8ce1/samples/openapi3/client/petstore/python/petstore_api/rest.py (L141)

* update samples

* Fix Python DELETE bug introduced in earlier commit

The earlier commit 9dfe1f6 introduced a bug for `DELETE` requests on the
standard Python generator.  This commit fixes that bug and also includes
the updated samples.

Co-authored-by: William Cheng <wing328hk@gmail.com>
2021-07-07 11:04:26 +08:00
William Cheng
046780657c
fix regex in erlang, update samples (#9892) 2021-07-06 11:10:08 +08:00
Łukasz Leszczuk
efe0e1d7a0
Fix cancellation token usage for async calls in csharp-netcore. (#9841) 2021-07-05 13:11:45 +08:00
William Cheng
eb2e56dbb1 better code indentation 2021-07-05 09:30:51 +08:00
Katsuya Oda
a835f6ec0e
fix: missing vendor extensions in inlined objects #8064 (#9810) 2021-07-05 09:16:35 +08:00
Jens Fischer
870c1e1894
[Java] [Native] Unify exception messages for async, add the status code (#9825)
* [Java] [Native] Unify exception messages for async, add the status code

The template has two methods for creating API exceptions, and the enhancements from #9169 didn't make it to the async version.

- unify the signatures of the two methods (name, arguments)
- make sure the sync version is not generated with asyncNative
- extract the formatting logic into a common formatExceptionMessage() method
- add the status code to the exception message as well, not just the body
- shortened "call received non-success response" to a more concise "call failed with"

* Treat an empty body the same as a null body

Co-authored-by: Jens Fischer <jens.fischer@vier.ai>
2021-07-05 08:57:40 +08:00
William Cheng
a5c98dd416
better null check to surpress sonarcloud warning (#9888) 2021-07-04 15:16:19 +08:00
cal
d2e79be728
[cleanup] erefactor/AutoRefactor - TestNG asserts (#9861)
AutoRefactor cleanup 'TestNGAssert' applied by erefactor:

Refactors to a proper use of TestNG assertions.

For AutoRefactor see https://github.com/JnRouvignac/AutoRefactor
For erefactor see https://github.com/cal101/erefactor
2021-07-04 14:49:47 +08:00
cal
611a3effa6
[cleanup] erefactor/AutoRefactor - Log parameters rather than log message (#9859)
AutoRefactor cleanup 'LogParametersRatherThanLogMessage' applied by erefactor:

Replaces a string concatenation as parameter of a logger method by a
string template followed by objects.

For AutoRefactor see https://github.com/JnRouvignac/AutoRefactor
For erefactor see https://github.com/cal101/erefactor
2021-07-04 14:47:52 +08:00
cal
54814caeb1
[cleanup] erefactor/EclipseJdt - Add missing @Override annotation - include interface implementations (#9860)
EclipseJdt cleanup 'AddMissingOverrideAnnotation' applied by erefactor.

For EclipseJdt see https://www.eclipse.org/eclipse/news/4.20/jdt.php
For erefactor see https://github.com/cal101/erefactor
2021-07-04 14:44:57 +08:00
Bastien Gérard
510e64fa43
Fix minor typo in @cached_property docstring (#9886) 2021-07-04 12:29:55 +08:00
Matthias Ernst
17b6379df5
[Kotlin Multiplatform] Update and fixes for Kotlin 1.5.10 and Kotlinx.serialization 1.2.1 (#9755)
* Update Kotlin Multiplatform with Kotlin 1.5.10, Ktor 1.6.0 and Kotlinx.serialization 1.2.1
* remove @Serializable from interfaces
* Using 'String(CharArray): String' is an error. Use CharArray.concatToString() instead
* Fix, RequestConfig needs a type to infer type variable T

Fixes from @DevSrSouzaern
* Fix `private` keyword not being handle as a reservedWords
* Fix enum serialization generation
* Migrate gradle build to Kotlin DSL

* update samples and documentation

* PR Review changes
* sample update
* revert non multiplatform kotlinx_serialization removal
* default Json{} in ApiClient
* revert accidental version push for jvm client
* Match ktor and Kotlinx Serialization version in documentation and build.gradle.kts

* remove const from JSON_DEFAULT

* Update AbstractKotlinCodegen.java

Co-authored-by: Gabriel Souza <devsrsouza@gmail.com>
Co-authored-by: ern <ern@ti8m.ch>
2021-07-03 23:33:39 +08:00
SimeonGerginov
3663831b4d
[REQ][PowerShell] Improve generated PowerShell examples (#9836)
* Implement new PowerShell example structure

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Modify documentation template to work with the new PowerShell example format

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Update PowerShell Generator documentation with the new properties

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Update PowerShell samples with the new PowerShell example format

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Fix issues with array of models as parameters

Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com>

* Change string value generation to include the prefix 'My'

Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com>

* Remove multiple new lines and trim leading and trailing spaces in PowerShell example

Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com>
2021-07-03 22:27:06 +08:00
Marc de Jonge
bba23272ff
#9848 Add support for generating a Set for a list with uniqueItems set to true (#9849) 2021-07-01 17:56:28 +08:00
Adriaan Duz
147367e559
[Kotlin][Bug] Added open, external and internal as reserved keywords for kotlin (#9842)
* Added open, external and internal as reserved keywords for kotlin

* ./bin/generate-samples.sh
./bin/utils/export_docs_generators.sh
with only kotlin
2021-07-01 17:54:04 +08:00
Bernhard Danecker
f0cbfbc820
Updated openapi-generator-gradle-plugin/README.adoc to latest plugin version (#9874)
Updated docs to reference latest gradle plugin version with important support for gradle 7
2021-07-01 17:48:28 +08:00
Ghufran Zahidi
90233d6653
conditional serialization add only those property which user wants to… (#9807)
* conditional serialization add only those property which user wants to configure.

* fixed the samples

* fixed the sample String to string issue.

* fixed the sample String to string issue.

* updated the sample

* Added unit test for conditional serialization

* update samples

* remove trailing spaces, update samples

* remove files

* add back files

* build the project in the ci

Co-authored-by: William Cheng <wing328hk@gmail.com>
2021-06-29 20:28:47 +08:00
Florian Verger
b9b539459a
Typescript angular discriminator mapping (#8929)
* remove trailing spaces

* add support of discriminator mapping for typecript-angular generator

* PR comment
2021-06-29 13:01:58 +02:00
Michał J. Gajda
1cd1001e34
Fix returning NoContent. (#9830) 2021-06-26 18:20:59 +08:00
Gabriel Rohden
44c1fee3e2
[dart] fix some compilation issues and added casts for analyzer implicit-casts flag (#8244)
* fix: missing dart casts and analyzer issues

* chore: regenerate dart template files

* refactor: remove unneeded implicit-casts:false and regenerate sources

* chore: regenerate templates after merge

* chore: regenerate dart pet store codes
2021-06-24 10:24:28 +08:00
bflamand
48e05ce162
[Typescript Fetch] New optional mode with redux saga & immutablejs (saga & records) (#8578)
* first commit: add cli option for saga and records. Added dummy sagas.mustache test file.

* More progress with default values. First prototype for isEntity and isUniqueId.

* record generation complete

* record generation complete

* progress with saga generation

* progress with saga generation

* first fully working saga generation

* merge with latest master

* removed unneeded "items" properties.

* moved global CodegenModel modifications into subclass ExtendedCodegenModel used exclusively by TypescriptFetchClient. Adding missing samples files.

* moved global CodegenOperation modifications into subclass ExtendedCodegenOperation used exclusively by TypescriptFetchClient.

* moved global CodegenProperty modifications into subclass ExtendedCodegenProperty used exclusively by TypescriptFetchClient.

* moved global CodegenParameter modifications into subclass ExtendedCodegenParameter used exclusively by TypescriptFetchClient.

* added the missing "allSagas" export.

* renamed & reworked "meta data response" flags to a more useful general concept of "operation return passthrough"

* added vendor flag keepAsJSObject as escape hatch to support circular dependencies in models and other special cases. Also fixed issues with default values for some records properties.

* added autodetection for passthrough to simplify standardised specs.

* fix small issue with passthrough void

* fix small issues with passthrough void and missing passthrough imports in some cases. Fix issues with enum default values.

* fix small issues with passthrough void and missing passthrough imports in some cases. Fix issues with enum default values.

* Added "reservedRecordField" feature to support remapping fields names that cannot be used in Records. Added missing export to record: toApi().

* added uniqueId inference. Fix small generation when uniqueId property is an array.

* removed feature "reservedRecordField" and replaced it with existing built-in "reserved words" feature. Fix minor issues with typings in generated files.

* Changed api recType names to make them less likely to cause name conflicts. Added generated ApiEntities (record, reducer & selector) files.

* Moved location of ApiEntities related files and fix issues with exports.

* - merge latest master
- renamed fake test apis to better fit the "pet theme"
- added mode for "SourceOnlyLibrary" (same as used in codegen typescript jquery)

* - missing ganarate sampless

* - Modified way to export apiEntitiesSelectpr to reduce typescript analysis time for consuming project. Removed tab characters in mustache files. Reformat code for TypeScriptFetchClientCodegen to try to remove false positive for tabs vs spaces.

* - added markErrorsAsHandled property to api sagas. Increased typescript version to address some typing errors on library build.

* - fix bug in saga interfaces. Upgraded to typescript "strict" mode to ensure proper typechecking info is generated.

* - added optional id for apiEntity selectors. Added toInlined() support to convert an entity to an inlined model recursively.

* - minor tweak for apiEntitySelector to accept null id

* - minor tweak for apiEntitySelector

* - runned ensure up to date.

* Revert "- runned ensure up to date."

This reverts commit ea9b4aed

* - runned ensure up to date.

* - runned ensure up to date.

Co-authored-by: Bruno Flamand <bflamand@stingray.com>
2021-06-24 00:07:17 +08:00
Kevyn Liebersbach
77f84ec811
Limit depth of example code generation in RClientCodegen (#9822) 2021-06-23 11:29:48 +08:00
Kuzma
969cea8ce1
[Typescript] Fix oneOf (#9628)
* on of

* fix map

* samples

* file to any

* samples

* add unit tests

* clear code
2021-06-21 23:42:47 +02:00
Max Goltzsche
2e85ccdec8
[go-server] fix addResponseHeaders tpl option typo (#9814)
According to the [documentation](https://openapi-generator.tech/docs/generators/go-server) the go-server generator should support an `addResponseHeaders` option but a template uses an `addResponseHeader` option in some places which this PR fixes.

Closes #9795

Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
2021-06-21 11:46:51 +08:00
Mehmet YUCE
ccd031a3da
Continuing from #1317 and its PRs for pistache server string enum code generation (#9786)
* Continuing from #1317 and its PRs for pistache server string enum code generation;
* A class that has an `anyOf` specification, in cpp side will have no members: in stead it should have a member having the type `classname_anyOf`
* Thus, Its `==` operator is not present or wrongly filled
* An string enum, should have a better usage, hence the `setEnumValue`
* this PR, is a brigde between `stringenumclassname_anyOf` and `stringenumclassname`
* `anyOf` specification is not just about `Enums`, so a better handling is needed from mustache templates, hence new template model parameter `isStringEnumContainer`

* PR fix: muttleyxd: `double semicolon`

* PR fix: wing328: `I think std::string is C++ only. What about adding x-is-string-enum-container instead in the postProcessModel operation in the C++ pistache server generator?`

* PR fix: wing328: `I think std::string is C++ only...` after fix get latest codes and then generate samples

Co-authored-by: Mehmet Fatih <mfyuce@netas.com.tr>
2021-06-20 22:13:38 +08:00
Sascha Peilicke
463d905664
Kotlin-Server: Optional metrics and upgrade to Ktor 1.5.4 (#9358)
Use Gradle 6.9 and Kotlin 1.4.32. Generate Paths for other HTTP verbs
(#828) and fix imports (#5640). Use 'object' when no parameters are
used. Introduce 'featureMetrics' to control metrics plugin usage. Remove
HOCON configuration parsing. This is provided by
`Application.environment.config already` and removes a dependency.

Resolves #9087, resolves #828, resolves #5640
Relates-To #5346
2021-06-20 22:03:44 +08:00
Prajon Shakya
015886fded
[csharp][netcore] Update type "String" to "string" for consistent type (#9713)
* Updated 'String' to 'string' for consistent use of keyword

* Build project and update samples for csharp-netcore
2021-06-19 12:42:33 +08:00
William Cheng
c5405aa59a
[Go-client] Fix inability to download files (#9812)
* Revert a change to the Go Client code that broke
the ability to download files. This reverts the change
from 14d41310b9

* Missed import for "io/ioutil"

* update samples

Co-authored-by: icubbon <icubbon@gmail.com>
2021-06-19 11:23:05 +08:00
Yoshiyuki Kurauchi
513e242a3e
Return empty binary for 304 (#9800) 2021-06-19 10:50:28 +08:00
Sebastian Weddmark Olsson
73350073b2
[erlang-server] spec fixes (#9784) 2021-06-19 10:44:31 +08:00
William Cheng
d13685a3ad
More updates for isBoolean (#9802)
* more updates for isBoolean

* update samples
2021-06-19 10:44:00 +08:00
Minjae Kim
41afcd0f86
Handle boolean enum correctly in typescript-axios (#9025)
can't use enum because of TS18033
2021-06-18 16:34:38 +08:00
Hippolyte HENRY
7389446354
Add imports for inner items of arrays/maps in composed schemas (#9268)
* Add imports for inner items of arrays/maps in composedSchemas

* Add test case for typescript-angular

* tests

* tests

* disable generate alias

* Create different config
2021-06-18 16:08:03 +08:00
Guillaume TOURBIER
95a11a7f5d
[Java][WebClient] add ResponseEntity return for webclient (#9327)
* feat: add ResponseEntity return for webclient

fix: #5599

* refactor: merge functions

simplification to avoir duplicated code
2021-06-18 16:03:38 +08:00
Sandeep jindal
c7038d1b57
[scala][client] invoker package enhancement (#9381)
* updated invoker

remove unwanted set the invoker

fixed the ordering of supported files

added sample generated files

regenerated samples

added docs

* sample files

Co-authored-by: sjindal <sandeep.jindal@agoda.com>
2021-06-18 15:53:25 +08:00
Daniel Krebs
2e65e6f62d
[python][client] allow passing floats for _request_timeout (#9532)
* [python][client] allow passing floats for _request_timeout

While several method docstrings suggested that you could pass floats for
_request_timeout and the underlying urllib3.Timeout can deal with them,
the code only allowed integer values so far when passed as a single
number.

* [python][samples] update with fix for _request_timeout type
2021-06-18 15:09:55 +08:00
shartte
8a31064028
[Java] Remove JAX-RS dependency from generated java-native client. (#8320) (#9585) 2021-06-18 15:05:55 +08:00
Tobias Tiemerding
75fc1383bc
Fix typo (Unsuported -> Unsupported) (#9790) 2021-06-17 13:44:12 +08:00
Albert
55600256b2
[rust-client]: fix reqwest not support client::options (#9745)
* fix: https://github.com/OpenAPITools/openapi-generator/issues/9743

* update samples
2021-06-17 01:17:50 +08:00
Bruno Coelho
687692cedc
update AnyCodable and gitignore (#9777) 2021-06-17 00:37:23 +08:00
Ween Jiann
77e1ca56cf
[go-server] Add go-chi generator to go-server via a router property (#9748)
* Add go-chi generator to go-server

* Add go-chi configs

* Add go-chi generated output

* Updated docs

* Add some javadocs

* Fix import issue

* Regen files
2021-06-16 16:53:20 +08:00
Celebrate-future
8af147b3ea
Update pom.mustache (#9768)
* Update pom.mustache

* Update pom.mustache
2021-06-16 15:59:09 +08:00
Christian Schuster
5bbdc62ada
create explicit copy of system properties (#7601) (#9653) 2021-06-15 21:27:13 +08:00
Julian G
3fcbf17536
[C++][Pistache] Fix compile break, error handling (#9742)
* fix compilation break with validate function

* fix error handling in handleParsingException
bug caused all errors to be regarded as an internal server error

* generate samples
2021-06-15 14:42:29 +08:00
randomswdev
3edeaeea07
Fix single inheritance code generation for goserver (#8356)
Co-authored-by: Bernardo Pastorelli <13519917+randomswdev@users.noreply.github.com>
2021-06-14 18:56:02 +08:00
parpa
376e4192e1
Update routers.mustache (#9662)
Add PATCH suppord.
2021-06-14 18:48:55 +08:00
Christoph Ludwig
f3e3a724fb
Fix python-fastapi free-form objects mapping and forward ref type hints (#9723)
* map free-form objects to Dict[str, Any]

* support Forward Type References

Forward type references will be supported by default from Python 3.10 on only. Until then (and starting with Python 3.7), we can opt in by a __future__ import, cf. https://docs.python.org/3.9/whatsnew/3.7.html?highlight=forward#pep-563-postponed-evaluation-of-annotations

* re-created pet-store sample

* bump required Python version to 3.7 for generated FastAPI projects

* make pydantic modell classes process forward type references
2021-06-14 18:05:36 +08:00
William Cheng
874d7d4f97
skip oauth files in java feign (#9760) 2021-06-14 18:04:34 +08:00
Profpatsch
cdb92086db
[haskell][server]: Set "AnyType" to Aeson.Value (#9733)
* [haskell][server]: Set "AnyType" to `Aeson.Value`

`AnyType` would not be translated to the json value type.
This fixes that.

* [haskell][server] Fix haddock error in `API.hs`

Haddock (the Haskell documentation generator) would choke on the
misplaced docstring. The heading has to appear inside the list.
2021-06-14 17:00:11 +08:00
Ivan
856eca4ee6
Hide buildOauthRequestInterceptor under isOAuth section (#9147) (#9736) 2021-06-14 15:39:55 +08:00