DefaultCodegen#procesOpts sets up quite a bit which may be expected by
users (template directory overrides, git user/repo, etc). The way the
dart-dio and dart-jaguar processOpts methods were written, these things
did not work. This makes it work.
cc all dart contributors for awareness:
Dart: @yissachar
Dart (refactor): @joernahrens
Dart 2: @swipesight
Dart (Jaguar): @jaumard
Dart (Dio): @athornz
To repro the bug, copy the dart README.mustache (for dart-dio or dart-jaguar) to some directory called template, make some changes to the README, for example add to the top:
We'd expect this README to be generated, but as of current master it is not. This was reported as a question by a member of the community in Slack. I thought it was going to be a quick assist, but turned out to be an issue. There's no associated GitHub issue, although I'd image this might resolve other issues with dart-dio and dart-jaguar because there's an attempted workaround in the extended DartClientCodegen which leads me to believe there was a known confusion with templateDir:
final Object isSupportDart2 = additionalProperties.get(SUPPORT_DART2); if (Boolean.FALSE.equals(isSupportDart2) || (isSupportDart2 instanceof String && !Boolean.parseBoolean((String) isSupportDart2))) { // dart 1.x LOGGER.info("Dart version: 1.x"); supportingFiles.add(new SupportingFile("analysis_options.mustache", "", ".analysis_options")); } else { // dart 2.x LOGGER.info("Dart version: 2.x"); // check to not overwrite a custom templateDir if (templateDir == null) { embeddedTemplateDir = templateDir = "dart2"; } }
I don't follow why the if final if condition in the above snippet exists. Maybe someone familiar with these generators could add more of a comment (why are we setting dirs here when they should be handled in constructor and super.processOpts?)
If contributing template-only or documentation-only changes which will change sample output, build the project before.
Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");
LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");