Fix Uuid parse (#6382)

* Fix Uuid parse

* Add isString = true when property is Uuid

This will not break previous code

* Update conversionBegin.mustache

* Update conversionEnd.mustache
This commit is contained in:
Daniel Ochoa Rodríguez 2017-09-03 17:10:25 +02:00 committed by wing328
parent a1c1a82725
commit cfa2074802
12 changed files with 28 additions and 17 deletions

View File

@ -14,7 +14,7 @@ public class CodegenParameter {
public String example; // example value (x-example)
public String jsonSchema;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid;
public boolean isListContainer, isMapContainer;
public boolean isFile, notFile;
public boolean isEnum;
@ -140,6 +140,7 @@ public class CodegenParameter {
output.isBoolean = this.isBoolean;
output.isDate = this.isDate;
output.isDateTime = this.isDateTime;
output.isUuid = this.isUuid;
output.isListContainer = this.isListContainer;
output.isMapContainer = this.isMapContainer;

View File

@ -39,7 +39,7 @@ public class CodegenProperty implements Cloneable {
public boolean hasMore, required, secondaryParam;
public boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
public boolean isPrimitiveType, isContainer, isNotContainer;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid;
public boolean isListContainer, isMapContainer;
public boolean isEnum;
public boolean isReadOnly = false;
@ -285,6 +285,9 @@ public class CodegenProperty implements Cloneable {
if (this.isDateTime != other.isDateTime) {
return false;
}
if (this.isUuid != other.isUuid) {
return false;
}
if (this.isBinary != other.isBinary) {
return false;
}

View File

@ -11,7 +11,7 @@ public class CodegenResponse {
public List<Map<String, Object>> examples;
public String dataType, baseType, containerType;
public boolean hasHeaders;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBoolean, isDate, isDateTime;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBoolean, isDate, isDateTime, isUuid;
public boolean isDefault;
public boolean simpleType;
public boolean primitiveType;

View File

@ -1707,6 +1707,7 @@ public class DefaultCodegen {
}
if (p instanceof UUIDProperty) {
property.isString = true;
property.isUuid = true;
}
if (p instanceof ByteArrayProperty) {
property.isByteArray = true;
@ -2399,6 +2400,8 @@ public class DefaultCodegen {
r.isDate = true;
} else if (Boolean.TRUE.equals(cm.isDateTime)) {
r.isDateTime = true;
} else if (Boolean.TRUE.equals(cm.isUuid)) {
r.isUuid = true;
} else {
LOGGER.debug("Property type is not primitive: " + cm.datatype);
}
@ -2724,6 +2727,8 @@ public class DefaultCodegen {
p.example = "2013-10-20";
} else if (Boolean.TRUE.equals(p.isDateTime)) {
p.example = "2013-10-20T19:20:30+01:00";
} else if (Boolean.TRUE.equals(p.isUuid)) {
p.example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
} else if (Boolean.TRUE.equals(p.isFile)) {
p.example = "/path/to/file.txt";
}
@ -3573,6 +3578,8 @@ public class DefaultCodegen {
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isFile)) {
parameter.isFile = true;
} else if (Boolean.TRUE.equals(property.isUuid)) {
parameter.isUuid = true;
// file is *not* a primitive type
//parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isDate)) {

View File

@ -1 +1 @@
{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isDateTime}}OffsetDateTime.parse({{/isDateTime}}
{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isUuid}}UUID.fromString({{/isUuid}}{{#isDateTime}}OffsetDateTime.parse({{/isDateTime}}

View File

@ -1 +1 @@
{{#isBoolean}}){{/isBoolean}}{{#isInteger}}){{/isInteger}}{{#isDouble}}){{/isDouble}}{{#isLong}}){{/isLong}}{{#isFloat}}){{/isFloat}}{{#isDateTime}}){{/isDateTime}}
{{#isBoolean}}){{/isBoolean}}{{#isInteger}}){{/isInteger}}{{#isDouble}}){{/isDouble}}{{#isLong}}){{/isLong}}{{#isFloat}}){{/isFloat}}{{#isUuid}}){{/isUuid}}{{#isDateTime}}){{/isDateTime}}

View File

@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
},
"collectionFormat" : "csv"
} ],

View File

@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
},
"collectionFormat" : "csv"
} ],

View File

@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
},
"collectionFormat" : "csv"
} ],

View File

@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
},
"collectionFormat" : "csv"
} ],

View File

@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
},
"collectionFormat" : "csv"
} ],

View File

@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
},
"collectionFormat" : "csv"
} ],