-
Notifications
You must be signed in to change notification settings - Fork 6k
Do not apply content-type header if no request body #6648
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
Conversation
| } | ||
| //only add content-Type if its no a GET-Method | ||
| if(path.getGet() != null || ! operation.equals(path.getGet())){ | ||
| if (hasBodyParameters){ |
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.
@bmordue shall we keep the logic path.getGet() != null || ! operation.equals(path.getGet()) ?
For POST using HTTP form (not JSON/XML string), we also need the content-type right?
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.
Thanks, I've made sure the default content-type for form data gets applied too.
I don't think the original logic was correct: any path that includes a GET operation would have a default content-type applied, which doesn't seem right. I've added some tests that demonstrate this (ac79987).
|
Please run |
|
Apologies for my slow reply, I've been travelling. I ran the update script and committed the changes. |
|
@wing328 Is it normal that this generator use "gson" ? AFAIK, most if not all generator here use jackson? |
|
cc @davidgri for review as well since the previous if-condition has been revised. |
|
@JFCote Java Feign client uses jackson: |
| private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); | ||
| private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); | ||
|
|
||
| public static GsonBuilder createGson() { |
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.
@wing328 I'm talking about this. You can see use of Gson in other modifier files too.
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.
The retrofit generator does use gson. I guess this change is due to regenerating all the Java samples.
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.
ok no problem then. :)
|
If no further question or feedback on this, I'll merge it on coming Monday/Tuesday. |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.Description of the PR
The intent is to avoid adding a Content-Type header on requests made by a generated Java-feign client if the request body is empty. This is to fix #6647
contentTypefor requests that have no body params specified.@Headersannotation for "Content-Type" ifcontentTypeis not set.