* [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>
* [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>
* 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>
* [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
* [dart][dart-dio] Add support for query collection parameter format
* add support for collectionFormat in query parameters and www-url-encoded content
* add tests
* remove empty query parameter maps from generated code
* closes#6681
* closes#9522
* closes#8271 (the last remaining parts)
* Fix formatting
* remove deprecated author field from all pubspec templates
* improve dart-dio-next readme/markdown documentation
* add a lot of dart-doc to model and API classes
* [dart][dart-dio] Improve support for file uploads
* add support for filenames in multipart requests by using `MultipartFile` from dio directly
* add support for binary/file body data
* fixes#6671
* fixes#9079
* Add and fix tests
* Only use MultipartFile for body/multipart parameters
* Fix test
* Actually fix tests
* [dart] Improve content-type handling
* fixes#9334
* superseeds #9454
* use `prioritizedContentTypes` in the same way `JavaClientCodegen` does
* move `application/json` to the front if it exists
* don't do anything if it is multi-part or url-encoded as for this the first content-type already needs to match
* log warning if an unsupported content-type is first after prioritizing
* remove some unused code blocks from dio generators
* Only use first prioritized content-type in dio generators
* don't default to any content-type in dio-next, dio defaults itself to JSON
* [dart] Move Dart samples from CircleCI to Github actions
* Fix format failing with latest Dart version
* Workflow naming
* Split dart samples depending on version
* use fixed version to prevent flaky builds
* Change branch pattern for release branches
* Fix go-echo-server sample not running in CircleCI
* remove wrong argument
* [dart] Fix petstore sample tests & Multipart not working
* follow up to #9392
* `MultipartRequest(null, null)` is no longer valid after `http` package upgrade
* fix petstore sample project not compiling
* disable live petstore tests
* use template to strip out unused code blocks
* Fix#8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true
* Fix#8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true
* Fix#8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true
* Revert "Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true"
This reverts commit 56e2b1fb
* Revert "Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true"
This reverts commit 335c304d
* Fix#8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true
* Fix#8027 - import the auto generated supporting JSON class only when discriminator is needed
* Fix#8027 - import the auto generated supporting JSON class only when discriminator is needed
* Fix#8027 - import the auto generated supporting JSON class only when discriminator is needed
* [Java] [Native] Add response body to exception message
* [Java] [Native] Use default base URI if baseUri param is null
* [Java] [Native] Use default base URI if baseUri param is null
* Don't include read-only properties in Python examples.
When using a schema with read-only fields as API inputs, Python
generates examples for those: this excludes them.
* Fix tests
* fix by mapping outside of class
* tests
* regeneration and tests
* server
* INDENT
* a
* enable mapping
* Revert "server"
This reverts commit 6fc9712fb550d258d0332df243ea5080565c6770.
* Samples regenerated
Co-authored-by: Justin Black <justin.a.black@gmail.com>
* [dart] Improve types & imports
* don't use importMapping as it is intended for something different that is not possible in dart
* introduce imports map for dart specific features
* always import `dart:core`
* get rid of additionalReservedWords
* fix `--type-mappings` not working
* use required type mappings in samples
* no longer define additional reserved words as it is impossible to list all anyways, they can now be configured via type-mapping parameter
* simplify dio imports
* Don't use guava for map instantiation
* Update docs