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

[dart] Improve content-type handling #9517

Merged
merged 2 commits into from May 24, 2021

Conversation

kuhnroyal
Copy link
Contributor

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.

CC @swipesight (2018/09) @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12)

@kuhnroyal
Copy link
Contributor Author

@themisir Do you mind testing this for your use-case?

@themisir
Copy link

@themisir Do you mind testing this for your use-case?

Do I have a chance to test this without having to clone & re-building the project?

@kuhnroyal
Copy link
Contributor Author

@themisir Do you mind testing this for your use-case?

Do I have a chance to test this without having to clone & re-building the project?

I don't think so, can't find the artifacts anywhere.

@themisir
Copy link

themisir commented May 18, 2021

@themisir Do you mind testing this for your use-case?

Yes it works.

But why don't you directly generating code as contentType: 'value' instead of contentType: ['value'].first? If in the end, only the first value will be used on runtime, so what's the point of writing like [...].first? Maybe I'm missing something.

@kuhnroyal
Copy link
Contributor Author

@themisir Do you mind testing this for your use-case?

Yes it works.

But why don't you directly generating code as contentType: 'value' instead of contentType: ['value'].first? If in the end, only the first value will be used on runtime, so what's the point of writing like [...].first? Maybe I'm missing something.

I am not sure this is possible in the template but I will check. In any case, they are now correctly ordered in a way that works.

@themisir
Copy link

I am not sure this is possible in the template but I will check

In my implementation, I introduced a vendorExtensions called x-content-type for that purpose.

But yeah, they are correctly ordered now.

@kuhnroyal
Copy link
Contributor Author

@themisir I changed this to use only the first content-type.

* 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
* don't default to any content-type in dio-next, dio defaults itself to JSON
@wing328 wing328 merged commit 48924eb into OpenAPITools:master May 24, 2021
@kuhnroyal kuhnroyal deleted the dart/content-types branch May 25, 2021 08:26
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
@wing328 wing328 added this to the 5.2.0 milestone Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants