Skip to content

Feature/mustache lambda tests#3447

Merged
jimschubert merged 3 commits intoOpenAPITools:masterfrom
MichalFoksa:feature/mustache-lambda-tests
Aug 11, 2019
Merged

Feature/mustache lambda tests#3447
jimschubert merged 3 commits intoOpenAPITools:masterfrom
MichalFoksa:feature/mustache-lambda-tests

Conversation

@MichalFoksa
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Follow up PR to #3368.

  1. In registering common Mustache lambdas, do not fallback to _lambda key when lambda is already take in additionalProperties. It is possible only if lambda key was taken by DefaultCodegen itself.
  2. Unit tests of common Mustache lambdas.

Copy link
Member

Choose a reason for hiding this comment

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

Has the detailed message moved elsewhere? If not, we should keep the link to templating docs.

Copy link
Contributor Author

@MichalFoksa MichalFoksa Jul 24, 2019

Choose a reason for hiding this comment

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

Hi @jimschubert

I am sorry, I do not understand the question.
Condition if (additionalProperties.containsKey("lambda")) should never evaluate to true and if then only because something has changed in DefautlCodegen and that will be caught at first instantiation of DefautlCodegen - in unit tests.

I think the construct bellow made sense when it was in a generator derived from DefaultCodegen, but not now.

 if (additionalProperties.containsKey("lambda")) {
            LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'. " +
                    "You'll likely need to use a custom template, " +
                    "see https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md. ");
            additionalProperties.put("_lambda", lambdas);
        } else {
            additionalProperties.put("lambda", lambdas);
        }

Makes sense?

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks for the clarification. I incorrectly remembered your earlier change being in DefaultGenerator, and missed that it's actually called in this class constructor.

@MichalFoksa
Copy link
Contributor Author

Re-based PR to current master.

@jimschubert jimschubert merged commit 42d6420 into OpenAPITools:master Aug 11, 2019
@jimschubert
Copy link
Member

Sorry for the delay. Thanks for writing these tests and for updating the branch!

@MichalFoksa
Copy link
Contributor Author

@jimschubert No problem, You have been working on 4.1.0.

BTW: Congrats on the release. Now I can replace custom build generator with the 4.1.0 release in all of my repos. I really appreciate it,

Michal

@MichalFoksa MichalFoksa deleted the feature/mustache-lambda-tests branch August 12, 2019 05:07
@wing328 wing328 added this to the 4.1.1 milestone Aug 26, 2019
@wing328
Copy link
Member

wing328 commented Aug 26, 2019

@MichalFoksa thanks for the PR, which has been included in the v4.1.1 release: https://twitter.com/oas_generator/status/1165944867391860737

@MichalFoksa
Copy link
Contributor Author

😄 you are welcome. Congrats to release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments