Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

themisir
Copy link

@themisir themisir commented May 11, 2021

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

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    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.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request. - @kuhnroyal

Continue looping consumes while any known media type is found
@kuhnroyal
Copy link
Contributor

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.

@themisir themisir changed the title [BUG][dart-dio-next] Add if check before breaking loop WIP: [BUG][dart-dio-next] Add if check before breaking loop May 11, 2021
@themisir themisir changed the title WIP: [BUG][dart-dio-next] Add if check before breaking loop 🚧 WIP: [BUG][dart-dio-next] Add if check before breaking loop May 11, 2021
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'
@themisir
Copy link
Author

themisir commented May 12, 2021

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.

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.

@themisir themisir changed the title 🚧 WIP: [BUG][dart-dio-next] Add if check before breaking loop [BUG][dart-dio-next] Add if check before breaking loop May 12, 2021
@themisir
Copy link
Author

@kuhnroyal can you please review the changes?

@kuhnroyal
Copy link
Contributor

This looks pretty good, I have just fixed some CI problems on master, can you please rebase and see if it goes green.

@themisir
Copy link
Author

can you please rebase and see if it goes green.

I rebased, but checks still fails.

@kuhnroyal
Copy link
Contributor

I think this can be closed and is superseded by #9517

@themisir
Copy link
Author

I think this can be closed and is superseded by #9517

Sure.

@themisir themisir closed this May 20, 2021
@kuhnroyal
Copy link
Contributor

Thank you for your input on this!

@themisir themisir changed the title [BUG][dart-dio-next] Add if check before breaking loop [BUG][dart-dio-next] Fixes content-type prioritization May 20, 2021
kuhnroyal added a commit to kuhnroyal/openapi-generator that referenced this pull request May 21, 2021
* 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
wing328 pushed a commit that referenced this pull request May 24, 2021
* [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
premiumitsolution pushed a commit to premiumitsolution/openapi-generator that referenced this pull request May 26, 2021
* [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants