Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix invalid spring properties prefix #3501

Merged
merged 8 commits into from
Aug 2, 2019
Merged

Fix invalid spring properties prefix #3501

merged 8 commits into from
Aug 2, 2019

Conversation

MelleD
Copy link
Contributor

@MelleD MelleD commented Jul 30, 2019

fixes #3381

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 . Default: master.
  • @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04)
    --

Description of the PR

Fix invalid spring properties prefix

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

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

please fix these lines, too:

{{=<% %>=}}@Value("${<%title%>.security.<%name%>.username:}")<%={{ }}=%>
private String {{{name}}}Username;
{{=<% %>=}}@Value("${<%title%>.security.<%name%>.password:}")<%={{ }}=%>
private String {{{name}}}Password;

{{=<% %>=}}@Value("${<%title%>.security.<%name%>.key:}")<%={{ }}=%>
private String {{{name}}}Key;

@MelleD
Copy link
Contributor Author

MelleD commented Jul 31, 2019

@macjohnny Will this work?

 {{=<% %>=}}@Value("${{{#lambda.lowercase}}<%title%>{{/lambda.lowercase}}.security.<%name%>.username:}")<%={{ }}=%>
  private String {{{name}}}Username;

@macjohnny
Copy link
Member

Will this work?

I guess it wont, because the {{=<% %>=}} indicates erb style tags, see http://mustache.github.io/mustache.5.html

maybe this should be converted to normal mustache tags, and escape the { and }

@MelleD
Copy link
Contributor Author

MelleD commented Jul 31, 2019

Ok got it. Yes it would be better to escape the {, but there is no default way to escape braces.

It think a variable is a good solution:

 public char openbrace= `{`;
 public char closebrace= `{`;

Then i could use:

@Value("${{openBrace}}{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username:{{closebrace}}")

Do you have a proposal,where i should add the openbrace variable?

@macjohnny
Copy link
Member

macjohnny commented Jul 31, 2019

how about

 @Value("${{=<% %>=}}{<%={{ }}=%>{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{name}}.key:{{=<% %>=}}}<%={{ }}=%>")
 private String {{{name}}}Key; 

@MelleD
Copy link
Contributor Author

MelleD commented Jul 31, 2019

This will work, but is not really readable.
That's why I like the workaround with the variable. It's readable and easy to understand.

@macjohnny
Copy link
Member

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

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

LGTM

@macjohnny macjohnny merged commit ba63aa5 into OpenAPITools:master Aug 2, 2019
@MelleD MelleD deleted the fix/3381-invalid-properties-name branch August 5, 2019 08:59
@wing328 wing328 changed the title Add lowercase lamda Fix invalid spring properties prefix Aug 9, 2019
@wing328 wing328 added this to the 4.1.0 milestone Aug 9, 2019
@wing328
Copy link
Member

wing328 commented Aug 10, 2019

@sirwayne thanks for the PR, which has been included in the 4.1.0 release: https://twitter.com/oas_generator/status/1160000504455319553

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [SPRING-CLOUD] Invalid generated ConfigurationProperties annotation
4 participants