forked from loafle/openapi-generator-original
Issue #1146: do not escape newlines in generated javadocs.
For this, we add a property `unescapedDescription` to CodegenModel + CodegenProperty, and use them for the Javadoc generation, while the annotation uses the escaped `description`.
This commit is contained in:
parent
28579cee03
commit
be84f03d14
@ -10,9 +10,10 @@ import java.util.Set;
|
|||||||
public class CodegenModel {
|
public class CodegenModel {
|
||||||
public String parent;
|
public String parent;
|
||||||
public String name, classname, description, classVarName, modelJson;
|
public String name, classname, description, classVarName, modelJson;
|
||||||
|
public String unescapedDescription;
|
||||||
public String defaultValue;
|
public String defaultValue;
|
||||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
||||||
public Set<String> imports = new HashSet<String>();
|
public Set<String> imports = new HashSet<String>();
|
||||||
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums;
|
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums;
|
||||||
public ExternalDocs externalDocs;
|
public ExternalDocs externalDocs;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ public class CodegenProperty {
|
|||||||
public String baseName, complexType, getter, setter, description, datatype, datatypeWithEnum,
|
public String baseName, complexType, getter, setter, description, datatype, datatypeWithEnum,
|
||||||
name, min, max, defaultValue, baseType, containerType;
|
name, min, max, defaultValue, baseType, containerType;
|
||||||
|
|
||||||
|
public String unescapedDescription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* maxLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1
|
* maxLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1
|
||||||
*/
|
*/
|
||||||
|
@ -533,6 +533,7 @@ public class DefaultCodegen {
|
|||||||
m.name = name;
|
m.name = name;
|
||||||
}
|
}
|
||||||
m.description = escapeText(model.getDescription());
|
m.description = escapeText(model.getDescription());
|
||||||
|
m.unescapedDescription = model.getDescription();
|
||||||
m.classname = toModelName(name);
|
m.classname = toModelName(name);
|
||||||
m.classVarName = toVarName(name);
|
m.classVarName = toVarName(name);
|
||||||
m.modelJson = Json.pretty(model);
|
m.modelJson = Json.pretty(model);
|
||||||
@ -629,6 +630,7 @@ public class DefaultCodegen {
|
|||||||
property.name = toVarName(name);
|
property.name = toVarName(name);
|
||||||
property.baseName = name;
|
property.baseName = name;
|
||||||
property.description = escapeText(p.getDescription());
|
property.description = escapeText(p.getDescription());
|
||||||
|
property.unescapedDescription = p.getDescription();
|
||||||
property.getter = "get" + getterAndSetterCapitalize(name);
|
property.getter = "get" + getterAndSetterCapitalize(name);
|
||||||
property.setter = "set" + getterAndSetterCapitalize(name);
|
property.setter = "set" + getterAndSetterCapitalize(name);
|
||||||
property.example = p.getExample();
|
property.example = p.getExample();
|
||||||
|
@ -7,10 +7,10 @@ import io.swagger.annotations.*;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
{{#models}}
|
{{#models}}
|
||||||
|
|
||||||
{{#model}}{{#description}}
|
{{#model}}{{#unescapedDescription}}
|
||||||
/**
|
/**
|
||||||
* {{description}}
|
* {{unescapedDescription}}
|
||||||
**/{{/description}}
|
**/{{/unescapedDescription}}
|
||||||
@ApiModel(description = "{{{description}}}")
|
@ApiModel(description = "{{{description}}}")
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||||
@ -22,8 +22,8 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
|||||||
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
/**{{#description}}
|
/**{{#unescapedDescription}}
|
||||||
* {{{description}}}{{/description}}{{#minimum}}
|
* {{{unescapedDescription}}}{{/unescapedDescription}}{{#minimum}}
|
||||||
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||||
* maximum: {{maximum}}{{/maximum}}
|
* maximum: {{maximum}}{{/maximum}}
|
||||||
**/
|
**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user