add multipleOf to CodegenProperty (#2192) (#5009)

This commit is contained in:
Liv Fischer 2020-01-16 10:27:49 +01:00 committed by William Cheng
parent 3218587d2f
commit b94fe7a40f
2 changed files with 15 additions and 1 deletions

View File

@ -49,6 +49,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public String jsonSchema; public String jsonSchema;
public String minimum; public String minimum;
public String maximum; public String maximum;
public Number multipleOf;
public boolean exclusiveMinimum; public boolean exclusiveMinimum;
public boolean exclusiveMaximum; public boolean exclusiveMaximum;
public boolean hasMore; public boolean hasMore;
@ -513,6 +514,14 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.maxProperties = maxProperties; this.maxProperties = maxProperties;
} }
public Number getMultipleOf() {
return multipleOf;
}
public void setMultipleOf(Number multipleOf) {
this.multipleOf = multipleOf;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{"); final StringBuilder sb = new StringBuilder("CodegenProperty{");
@ -591,6 +600,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
sb.append(", maxProperties=").append(maxProperties); sb.append(", maxProperties=").append(maxProperties);
sb.append(", minProperties=").append(minProperties); sb.append(", minProperties=").append(minProperties);
sb.append(", uniqueItems=").append(uniqueItems); sb.append(", uniqueItems=").append(uniqueItems);
sb.append(", multipleOf=").append(multipleOf);
sb.append(", isXmlAttribute=").append(isXmlAttribute); sb.append(", isXmlAttribute=").append(isXmlAttribute);
sb.append(", xmlPrefix='").append(xmlPrefix).append('\''); sb.append(", xmlPrefix='").append(xmlPrefix).append('\'');
sb.append(", xmlName='").append(xmlName).append('\''); sb.append(", xmlName='").append(xmlName).append('\'');
@ -681,7 +691,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
Objects.equals(minItems, that.minItems) && Objects.equals(minItems, that.minItems) &&
Objects.equals(xmlPrefix, that.xmlPrefix) && Objects.equals(xmlPrefix, that.xmlPrefix) &&
Objects.equals(xmlName, that.xmlName) && Objects.equals(xmlName, that.xmlName) &&
Objects.equals(xmlNamespace, that.xmlNamespace); Objects.equals(xmlNamespace, that.xmlNamespace) &&
Objects.equals(multipleOf, that.multipleOf);
} }
@Override @Override

View File

@ -2358,6 +2358,9 @@ public class DefaultCodegen implements CodegenConfig {
if (p.getExclusiveMaximum() != null) { if (p.getExclusiveMaximum() != null) {
property.exclusiveMaximum = p.getExclusiveMaximum(); property.exclusiveMaximum = p.getExclusiveMaximum();
} }
if (p.getMultipleOf() != null) {
property.multipleOf = p.getMultipleOf();
}
// check if any validation rule defined // check if any validation rule defined
// exclusive* are noop without corresponding min/max // exclusive* are noop without corresponding min/max