Skip to content

Conversation

@jmini
Copy link
Contributor

@jmini jmini commented Mar 16, 2018

Existing templates (here or in the swagger-codegen repository) are using these values:

{{modelPackage}}
{{apiPackage}}
{{invokerPackage}}
{{#sortParamsByRequiredFlag}}..{{/sortParamsByRequiredFlag}}
{{#hideGenerationTimestamp}}..{{/hideGenerationTimestamp}}

They need to be available in the additionalProperties map in order to be consumed from the mustache templates.

In addition, setting the value should be possible using setters. This is usefull when the generators are used directly (no maven plugin or no cli integration). Setter for hideGenerationTimestamp has been added.

invokerPackage is present only in AbstractJavaCodegen. Its value is derived from apiPackage or modelPackage. Current behavior needs to be preserved this is why some regression tests were implemented first in 7ad6ca2.

@webron webron requested a review from HugoMario March 16, 2018 23:54
@jmini jmini changed the title Allow some values to be use them in templates Allow some values to be use in templates Mar 18, 2018
@jmini jmini mentioned this pull request Mar 25, 2018
this.setModelPackage((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE));
} else {
// not set, use to be passed to template
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this could cause an error or something similar, but i'm wondering if you'd need to set modelPackage in additionalProperties if its value is null or empty.

@jmini
Copy link
Contributor Author

jmini commented Mar 28, 2018

Thank you for your feedback. I have added a is null or empty check.

To stay consistent, I updated all code location where the same pattern is used.

@HugoMario HugoMario merged commit 9094847 into swagger-api:master Mar 28, 2018
@HugoMario
Copy link
Contributor

awesome, thanks !

@HugoMario
Copy link
Contributor

@jmini
i will need to revert these PR, since is causing problem to php client generator, and i think it'll be present to next languages generators to add.

The best approach here is add those changes in the specific language overriding methods in DefaultCodegenConfig class, instead changing it.

I understand is more work, i can help you with that if you're agree.

@HugoMario
Copy link
Contributor

basically i will only rever this commit and tweaks test related.

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.

2 participants