-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix isenum for referenced enums #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
{{>interfaceOptVar}} | ||
{{/optionalVars}} | ||
{{/discriminator}} | ||
{{#hasEnums}}{{#vars}}{{#isEnum}} | ||
{{#hasEnums}}{{#vars}}{{#isEnum}}{{#isPrimitiveType}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. I started looking at this a bit after our Slack conversation, but hadn't thought about how One issue with considering enums as primitive is that I'll have to think about this a little more and maybe discuss with the core team. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the kotlin test allowed me to notice that an inline enum is basically this in core:
But when you have a referenced enum (with my change), you get:
and that's it. So relying on |
||
/** | ||
* {{{description}}} | ||
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} | ||
|
@@ -30,5 +30,5 @@ | |
@JsonProperty({{{value}}}) {{{name}}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}} | ||
{{/enumVars}}{{/allowableValues}} | ||
} | ||
{{/isEnum}}{{/vars}}{{/hasEnums}} | ||
{{/isPrimitiveType}}{{/isEnum}}{{/vars}}{{/hasEnums}} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{{#useBeanValidation}}{{#required}} | ||
{{^isReadOnly}}@get:NotNull{{/isReadOnly}} {{/required}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swaggerAnnotations}} | ||
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}} | ||
@field:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isListContainer}}{{baseType}}<{{/isListContainer}}{{classname}}.{{nameInCamelCase}}{{#isListContainer}}>{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}{{/isReadOnly}} | ||
@field:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{^isPrimitiveType}}{{{dataType}}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isListContainer}}{{baseType}}<{{/isListContainer}}{{classname}}.{{nameInCamelCase}}{{#isListContainer}}>{{/isListContainer}}{{/isPrimitiveType}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}{{/isReadOnly}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have already occurred on line 519.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not what I witnessed: if the model itself is not an enum, but has variables that are enums, then kotlin generator need to have that import.
... Now that I reread, I see it's
hasEnums
so you should be right. Two possibilities: my code here changed nothing so I'll remove it, orhasEnum
wasfalse
and I need to check out why. I'll try to do that on monday and report backThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimschubert Just took a look at it again, line 519 adds
JsonProperty
if a model is not an enum, because it will have properties.My code replaces the previous line 521 that was adding
JsonValue
whenever a model has enums by a code that adds it only if one of the enum is embedded, as what was done previously by that generator. I did it to have the same result as master, although theJsonValue
import doesn't seem to be used at all...