-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] remove default content-type in the request #10782
Conversation
modules/openapi-generator/src/main/resources/python-legacy/api.mustache
Outdated
Show resolved
Hide resolved
Can you add a test that checks that 1 or two content types are set when they are included in the spec? |
Sure. Let me add some tests. I think we cannot let the user to specific content type right now. It defaults to use the first one. Maybe we can create another issue for this? |
@spacether openapi-generator/samples/client/petstore/python/tests/test_api_client.py Lines 104 to 123 in 3f3f837
|
This PR and #10686 (review) are both seeking to solve the same problem |
@@ -552,7 +552,7 @@ class ApiClient(object): | |||
:return: Content-Type (e.g. application/json). | |||
""" | |||
if not content_types: | |||
return 'application/json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am concerned that this could be a breaking change for servers/client that depended upon this functionality.
How about adding a generator argument useJsonAsDefaultContentType and default it to True.
With that we could put your PR in a patch release.
If you want to default it to False, then this will need to be released as a minor release because it would be a breaking change with a fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am concerned that this could be a breaking change for servers/client that depended upon this functionality.
How about adding a generator argument useJsonAsDefaultContentType and default it to True.
We've done something similar in other generators (e.g. Ruby) to remove such default behaviour (which was added before I worked on this project). No complains so far.
Thank you for adding those tests |
@kevchentw can you please resolve the merge conflicts when you've time and then PM me via Slack? https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g |
013f0c5
to
90927af
Compare
Before this fix, the content-type of the request defaults to "application/json".
With this fix, we no longer set such default.
fix #8116, relate to #10769
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(5.3.0),6.0.x
cc @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @arun-nalla (2019/11) @spacether (2019/11)