Skip to content

[bug][dart][dart-dio] Improve parameterToString handling - #8372

Merged
wing328 merged 4 commits into
OpenAPITools:masterfrom
kuhnroyal:dart-dio/param-to-string
Mar 2, 2021
Merged

[bug][dart][dart-dio] Improve parameterToString handling#8372
wing328 merged 4 commits into
OpenAPITools:masterfrom
kuhnroyal:dart-dio/param-to-string

Conversation

@kuhnroyal

@kuhnroyal kuhnroyal commented Jan 7, 2021

Copy link
Copy Markdown
Contributor
  • handle all primitives correctly
  • use specific serializer for non-primitives

Related to #8271

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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. 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
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@auto-labeler

auto-labeler Bot commented Jan 7, 2021

Copy link
Copy Markdown

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@kuhnroyal
kuhnroyal force-pushed the dart-dio/param-to-string branch from 02a2e6e to 246d98c Compare February 16, 2021 21:21
* add tests
* not sure this is complete but it is better than before and can serve as a baseline with the test cases
@kuhnroyal
kuhnroyal force-pushed the dart-dio/param-to-string branch from 246d98c to 364d587 Compare February 25, 2021 12:52
@kuhnroyal

Copy link
Copy Markdown
Contributor Author

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

_bodyData = {{#isMultipart}}FormData.fromMap({{/isMultipart}}<String, dynamic>{
{{#formParams}}
{{^required}}{{^nullable}}if ({{{paramName}}} != null) {{/nullable}}{{/required}}r'{{{baseName}}}': {{#isFile}}MultipartFile.fromBytes({{{paramName}}}, filename: r'{{{baseName}}}'){{/isFile}}{{^isFile}}parameterToString(_serializers, {{{paramName}}}){{/isFile}},
{{^required}}{{^nullable}}if ({{{paramName}}} != null) {{/nullable}}{{/required}}r'{{{baseName}}}': {{#isFile}}MultipartFile.fromBytes({{{paramName}}}, filename: r'{{{baseName}}}'){{/isFile}}{{^isFile}}encodeFormParameter(_serializers, {{{paramName}}}, const FullType({{^isContainer}}{{{baseType}}}{{/isContainer}}{{#isContainer}}Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]{{/isContainer}})){{/isFile}},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you sacrifice formatting of generated code to make this easier to read? It's a question, not a request.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ask myself this a lot but useful diffing of the generated code kinda seems important.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you commit your autogenerated code to codebase? I'm used to generating it to untracked directories and generating everything in build pipelines. I do it in Java, TS and Dart.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do commit it for libraries but not for Flutter apps.
But what I actually mean are the changes in the generated example code in the PRs in this repository.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the diff for the API files in this PR, they are pretty good to read.

@wing328 wing328 added this to the 5.1.0 milestone Mar 2, 2021
@wing328
wing328 merged commit 2ed702b into OpenAPITools:master Mar 2, 2021
@kuhnroyal
kuhnroyal deleted the dart-dio/param-to-string branch March 2, 2021 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants