-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[BUG][dart-dio-next] Fixes content-type prioritization #9454
Conversation
Continue looping consumes while any known media type is found
Did you regenerate the samples? If so, this would mean we don't have this case in the samples or we use it differently in the templates. |
Generator now picks first matching supported ("application/json", "application/x-www-form-urlencoded", "multipart/form-data") content type, if none available, it uses first mediaType or default value which is 'application/json'
I just did, but maybe the samples might not contain my case. UPDATE: I've checked with our private openapi schema which had the issue mentioned in #9334 and it worked. |
@kuhnroyal can you please review the changes? |
This looks pretty good, I have just fixed some CI problems on master, can you please rebase and see if it goes green. |
I rebased, but checks still fails. |
I think this can be closed and is superseded by #9517 |
Sure. |
Thank you for your input on this! |
* fixes OpenAPITools#9334 * superseeds OpenAPITools#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
* [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] Improve content-type handling * fixes OpenAPITools#9334 * superseeds OpenAPITools#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
This PR ensures that generator first looks if consumer contains any of the supported media types ("application/json", "application/x-www-form-urlencoded", "multipart/form-data").
If it does generator sets first one to 'x-content-type' parameter. Otherwise 'x-content-type' parameter value will be either the first consumer's media type (same behavior as previously generator but the whole thing is happening on generator side instead of doing
[ ... ].first
) or default value which is "application/json" (also same as old behavior).Fixes #9334. Please check the issue for more details.
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.1.x
,6.0.x