Skip to content

[dart][dart-dio] Improve form param handling, respect required flag#8369

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
kuhnroyal:dart-dio/form-param-improvements
Jan 22, 2021
Merged

[dart][dart-dio] Improve form param handling, respect required flag#8369
wing328 merged 2 commits intoOpenAPITools:masterfrom
kuhnroyal:dart-dio/form-param-improvements

Conversation

@kuhnroyal
Copy link
Copy Markdown
Contributor

  • simplify template
  • respect required flag (only null check when not required)
  • minor formatting

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.

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

* simplify template
* respect required flag (only null check when not rquired)
* minor formatting
@kuhnroyal kuhnroyal force-pushed the dart-dio/form-param-improvements branch from da76a07 to dcaea95 Compare January 7, 2021 14:58
formData['name'] = parameterToString(_serializers, name);
formData['status'] = parameterToString(_serializers, status);
final formData = <String, dynamic>{
if (name != null) r'name': parameterToString(_serializers, name),
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.

I would put null-check inside parameterToString to remove repeating code, what's the effect of formData['name'] = null ?

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.

There is one but it defaults to ''. I am unsure what the consequences are if I remove this.

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.

Also the null-check is only done when the param is not required.

];

var serializedBody = body;
final serializedBody = body;
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.

is this copy even needed?

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.

We expect the serializedBody below.

Comment thread modules/openapi-generator/src/main/resources/dart-dio/api.mustache Outdated
@wing328 wing328 merged commit 90ed129 into OpenAPITools:master Jan 22, 2021
@kuhnroyal kuhnroyal deleted the dart-dio/form-param-improvements branch January 25, 2021 11:39
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.

4 participants