Open dougheitkamp opened 5 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Hello, just wanted to follow up on this issue - We experienced the same problem with our python client. it sets Application/json as the default header for all requests, including ones that doesn't have a body (GET and DELETE etc) which causes our server to reject the requests due to validation errors.
Update: This problem exists in the Java generated code as well. This isn't a Python-only issue.
Is this problem going on? It's a problem that Application/json set in the header
This has been fixed in python-experimental. One can see two content-types defined for the request body here: https://github.com/OpenAPITools/openapi-generator/blob/master/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api_endpoints/inline_composition.py#L331 And then the developer must input their used content_type and it will be used when serializing the data in the request body here: https://github.com/OpenAPITools/openapi-generator/blob/master/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api_endpoints/inline_composition.py#L529
I am removing the [Python] tag from this issue because we have the above python-experimental
generator which support this use case
Description
We have a REST endpoint where users can upload files of various content types. The user supplies the content type in the header. This supplied header value is not being passed correctly through the generated code (opting to set it to application/json instead).
openapi-generator version
java -jar openapi-generator-cli.jar version 4.0.1
We are creating Python clients with an advanced form of the following spec (which demonstrates the issue):
OpenAPI declaration file content or url
Open API spec (json):
Command line used for generation
java -jar openapi-generator-cli.jar generate -i content-type-bug.json -g python -o client\object --package-name content_type_bug
Steps to reproduce
The generated code creates the following (snippit) in default_api.py, which shows that the Content-Type header is set correctly but then (almost immediately) overwritten by the result of self.api_client.select_header_content_type().
Suggest a fix
The call to self.api_client.select_header_content_type() should only be made if the Content-Type header hasn't already been set.