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

Upgrade Dart2 template to advertised best-practices, plenty of additions too. #7585

Merged
merged 23 commits into from
Oct 10, 2020
Merged

Upgrade Dart2 template to advertised best-practices, plenty of additions too. #7585

merged 23 commits into from
Oct 10, 2020

Conversation

noordawod
Copy link
Contributor

This upgrades the Dart2 template to advertised best-practices by the Dart team and most importantly, use {{{ }}} to reference variables instead of {{ }} since the latter is for escaping values. It happened to me that occasionally the generated code would include " and &#XX; escape characters for some reason or another.

Few additions were added too:

  • Allow users to decide whether an invalid enum throws an error or not -- handy since in the old case, when an API changes, outdated apps would crash.
  • Added growable to most calls that returns a List. Defaults to not allow growing a returned list.
  • Uses functional calls where possible (=>).
  • Uses final variables where possible.
  • Uses singleton instances for type transformers, lazily-instantiated.
  • Added comments where needed.

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
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @athornz (2019/12) @amondnet (2019/12) @wing328

@agilob
Copy link
Contributor

agilob commented Oct 3, 2020

To summarize my comments above, dart-lang says to prefer single quotes https://github.com/dart-lang/pedantic/#stricter-than-effective-dart.

@noordawod
Copy link
Contributor Author

Thanks @agilob for the review.
I have answered your question regarding the use of double-quotes. If you're not convinced, I can roll back to using single quotes, no problem at all.
The rest of the notes you've raised, I answered or dealt with.

What do you think?

@noordawod
Copy link
Contributor Author

@agilob

Running ./bin/generate-samples.sh and ./bin/utils/ensure-up-to-date causes many files unrelated to Dart2 to change. Kind of a mess to prepare a pr for a specific generator/template and include other files too. This is partly why the CI is failing.

Am I doing something wrong?

docs/generators/dart-dio.md Outdated Show resolved Hide resolved
docs/generators/dart-dio.md Outdated Show resolved Hide resolved
@agilob
Copy link
Contributor

agilob commented Oct 4, 2020

@agilob

Running ./bin/generate-samples.sh and ./bin/utils/ensure-up-to-date causes many files unrelated to Dart2 to change. Kind of a mess to prepare a pr for a specific generator/template and include other files too. This is partly why the CI is failing.

Am I doing something wrong?

  1. Make sure you're using latest java package too, I often make the mistake and forget to recompile maven project! mvn clean package -DskipTests=true && ./bin/generate-samples.sh

  2. ./bin/generate-samples.sh accepts input like bin/configs/dart-petstore_client_lib.yaml

mvn clean package -DskipTests=true && ./bin/generate-samples.sh bin/configs/dart-petstore_client_lib.yaml
mvn clean package -DskipTests=true && ./bin/generate-samples.sh bin/configs/dart-openapi.yaml this one is removed in my dart1 removal PR!

you don't need to run all configs, just select the ones your changes affect

@agilob
Copy link
Contributor

agilob commented Oct 4, 2020

Calm down with changes now, this is massive PR ;)

@noordawod
Copy link
Contributor Author

/me Calming down...

@wing328
Copy link
Member

wing328 commented Oct 5, 2020

@noordawod thanks for the PR. Can you please resolve the merge conflicts when you've time?

@noordawod
Copy link
Contributor Author

@wing328 @agilob

What you guys think about the pr? Any other comments?

@wing328 wing328 added this to the 5.0.0 milestone Oct 10, 2020
@wing328
Copy link
Member

wing328 commented Oct 10, 2020

@noordawod let's go ahead with this PR. Thanks for the contribution.

@wing328 wing328 merged commit 2984497 into OpenAPITools:master Oct 10, 2020
@noordawod
Copy link
Contributor Author

It's been a pleasure guys, thank you for merging it!

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.

None yet

4 participants