mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-25 02:00:53 +00:00
This changes `@JsonProperty({{name}})` to `@JsonProperty({{baseName}})` in model.mustache for JavaInflector, JavaJaxRS and JavaSpringMVC. In pull request #535 this was already done for the plain Java files (which get used on client side). This replaces the sanitized names in the generated code by the original property names from the swagger document.
53 lines
1.6 KiB
Plaintext
53 lines
1.6 KiB
Plaintext
package {{package}};
|
|
|
|
{{#imports}}import {{import}};
|
|
{{/imports}}
|
|
|
|
import io.swagger.annotations.*;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
{{#models}}
|
|
|
|
{{#model}}{{#unescapedDescription}}
|
|
/**
|
|
* {{unescapedDescription}}
|
|
**/{{/unescapedDescription}}
|
|
@ApiModel(description = "{{{description}}}")
|
|
{{>generatedAnnotation}}
|
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
|
{{#vars}}{{#isEnum}}
|
|
public enum {{datatypeWithEnum}} {
|
|
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
|
|
};
|
|
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
|
|
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
|
|
|
{{#vars}}
|
|
/**{{#unescapedDescription}}
|
|
* {{{unescapedDescription}}}{{/unescapedDescription}}{{#minimum}}
|
|
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
|
* maximum: {{maximum}}{{/maximum}}
|
|
**/
|
|
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
|
@JsonProperty("{{baseName}}")
|
|
public {{{datatypeWithEnum}}} {{getter}}() {
|
|
return {{name}};
|
|
}
|
|
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
|
this.{{name}} = {{name}};
|
|
}
|
|
|
|
{{/vars}}
|
|
|
|
@Override
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("class {{classname}} {\n");
|
|
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
|
|
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
|
|
{{/vars}}sb.append("}\n");
|
|
return sb.toString();
|
|
}
|
|
}
|
|
{{/model}}
|
|
{{/models}}
|