mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #3260 from gokl/format-field
Issue 3257: Add format field to CodegenParameter and CodegenProperty.…
This commit is contained in:
commit
021f554a6b
@ -9,7 +9,7 @@ public class CodegenParameter {
|
||||
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||
isCookieParam, isBodyParam, hasMore, isContainer,
|
||||
secondaryParam, isCollectionFormatMulti, isPrimitiveType;
|
||||
public String baseName, paramName, dataType, datatypeWithEnum, collectionFormat, description, unescapedDescription, baseType, defaultValue;
|
||||
public String baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue;
|
||||
public String example; // example value (x-example)
|
||||
public String jsonSchema;
|
||||
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
||||
@ -85,6 +85,7 @@ public class CodegenParameter {
|
||||
output.paramName = this.paramName;
|
||||
output.dataType = this.dataType;
|
||||
output.datatypeWithEnum = this.datatypeWithEnum;
|
||||
output.dataFormat = this.dataFormat;
|
||||
output.collectionFormat = this.collectionFormat;
|
||||
output.isCollectionFormatMulti = this.isCollectionFormatMulti;
|
||||
output.description = this.description;
|
||||
@ -181,6 +182,8 @@ public class CodegenParameter {
|
||||
return false;
|
||||
if (datatypeWithEnum != null ? !datatypeWithEnum.equals(that.datatypeWithEnum) : that.datatypeWithEnum != null)
|
||||
return false;
|
||||
if (dataFormat != null ? !dataFormat.equals(that.dataFormat) : that.dataFormat != null)
|
||||
return false;
|
||||
if (collectionFormat != null ? !collectionFormat.equals(that.collectionFormat) : that.collectionFormat != null)
|
||||
return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||
@ -276,6 +279,7 @@ public class CodegenParameter {
|
||||
result = 31 * result + (paramName != null ? paramName.hashCode() : 0);
|
||||
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
|
||||
result = 31 * result + (datatypeWithEnum != null ? datatypeWithEnum.hashCode() : 0);
|
||||
result = 31 * result + (dataFormat != null ? dataFormat.hashCode() : 0);
|
||||
result = 31 * result + (collectionFormat != null ? collectionFormat.hashCode() : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0);
|
||||
|
@ -6,7 +6,7 @@ import java.util.Objects;
|
||||
|
||||
public class CodegenProperty implements Cloneable {
|
||||
public String baseName, complexType, getter, setter, description, datatype, datatypeWithEnum,
|
||||
name, min, max, defaultValue, defaultValueWithParam, baseType, containerType;
|
||||
dataFormat, name, min, max, defaultValue, defaultValueWithParam, baseType, containerType;
|
||||
|
||||
public String unescapedDescription;
|
||||
|
||||
@ -66,6 +66,7 @@ public class CodegenProperty implements Cloneable {
|
||||
result = prime * result + ((containerType == null) ? 0 : containerType.hashCode());
|
||||
result = prime * result + ((datatype == null) ? 0 : datatype.hashCode());
|
||||
result = prime * result + ((datatypeWithEnum == null) ? 0 : datatypeWithEnum.hashCode());
|
||||
result = prime * result + ((dataFormat == null) ? 0 : dataFormat.hashCode());
|
||||
result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
|
||||
result = prime * result + ((defaultValueWithParam == null) ? 0 : defaultValueWithParam.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
@ -143,6 +144,9 @@ public class CodegenProperty implements Cloneable {
|
||||
if ((this.datatypeWithEnum == null) ? (other.datatypeWithEnum != null) : !this.datatypeWithEnum.equals(other.datatypeWithEnum)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.dataFormat == null) ? (other.dataFormat != null) : !this.dataFormat.equals(other.dataFormat)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1543,6 +1543,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
property.datatype = getTypeDeclaration(p);
|
||||
property.dataFormat = p.getFormat();
|
||||
|
||||
// this can cause issues for clients which don't support enums
|
||||
if (property.isEnum) {
|
||||
@ -2143,6 +2144,7 @@ public class DefaultCodegen {
|
||||
setParameterBooleanFlagWithCodegenProperty(p, cp);
|
||||
|
||||
p.dataType = cp.datatype;
|
||||
p.dataFormat = cp.dataFormat;
|
||||
if(cp.isEnum) {
|
||||
p.datatypeWithEnum = cp.datatypeWithEnum;
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{{#isFormParam}}<div class="param">{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}</div>
|
||||
|
||||
<div class="param-desc"><span class="param-type">Form Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}}{{/defaultValue}}</div>{{/isFormParam}}
|
||||
<div class="param-desc"><span class="param-type">Form Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}</div>{{/isFormParam}}
|
@ -1,3 +1,3 @@
|
||||
{{#isHeaderParam}}<div class="param">{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}</div>
|
||||
|
||||
<div class="param-desc"><span class="param-type">Header Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}}{{/defaultValue}}</div>{{/isHeaderParam}}
|
||||
<div class="param-desc"><span class="param-type">Header Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}</div>{{/isHeaderParam}}
|
@ -164,7 +164,7 @@
|
||||
<div class="model">
|
||||
<h3 class="field-label"><a name="{{name}}">{{name}}</a> <a class="up" href="#__Models">Up</a></h3>
|
||||
<div class="field-items">
|
||||
{{#vars}}<div class="param">{{name}} {{^required}}(optional){{/required}}</div><div class="param-desc"><span class="param-type">{{^isPrimitiveType}}<a href="#{{complexType}}">{{datatype}}</a>{{/isPrimitiveType}}</span> {{description}}</div>
|
||||
{{#vars}}<div class="param">{{name}} {{^required}}(optional){{/required}}</div><div class="param-desc"><span class="param-type">{{^isPrimitiveType}}<a href="#{{complexType}}">{{datatype}}</a>{{/isPrimitiveType}}</span> {{description}} {{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}</div>
|
||||
{{#isEnum}}
|
||||
<div class="param-enum-header">Enum:</div>
|
||||
{{#_enum}}<div class="param-enum">{{this}}</div>{{/_enum}}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{{#isPathParam}}<div class="param">{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}</div>
|
||||
|
||||
<div class="param-desc"><span class="param-type">Path Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}}{{/defaultValue}}</div>{{/isPathParam}}
|
||||
<div class="param-desc"><span class="param-type">Path Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}</div>{{/isPathParam}}
|
@ -1,3 +1,3 @@
|
||||
{{#isQueryParam}}<div class="param">{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}</div>
|
||||
|
||||
<div class="param-desc"><span class="param-type">Query Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}}{{/defaultValue}}</div>{{/isQueryParam}}
|
||||
<div class="param-desc"><span class="param-type">Query Parameter</span> — {{description}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}</div>{{/isQueryParam}}
|
Loading…
Reference in New Issue
Block a user