Skip to content

Commit

Permalink
swagger-api#10125 fix DefaultCodegen parsing to handle 'uniqueItems' …
Browse files Browse the repository at this point in the history
…flag
  • Loading branch information
akshpan committed Jun 7, 2020
1 parent 2b24149 commit 720d8aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class CodegenProperty implements Cloneable {
public String enumName;
public Integer maxItems;
public Integer minItems;
public boolean uniqueItems;

// XML
public boolean isXmlAttribute = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,7 @@ private CodegenProperty fromProperty(String name, Property p, Integer itemsDepth
ArrayProperty ap = (ArrayProperty) p;
property.maxItems = ap.getMaxItems();
property.minItems = ap.getMinItems();
property.uniqueItems = ap.getUniqueItems() == null ? false : ap.getUniqueItems();
String itemName = (String) p.getVendorExtensions().get("x-item-name");
if (itemName == null) {
itemName = property.name;
Expand Down Expand Up @@ -2732,6 +2733,7 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
p.isPrimitiveType = cp.isPrimitiveType;
p.isContainer = true;
p.isListContainer = true;
p.uniqueItems = impl.getUniqueItems() == null ? false : impl.getUniqueItems();

// set boolean flag (e.g. isString)
setParameterBooleanFlagWithCodegenProperty(p, cp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ isInteger set
isLong set
}}{{#isLong}}{{#minimum}} @Min({{minimum}}L){{/minimum}}{{#maximum}} @Max({{maximum}}L){{/maximum}}{{/isLong}}{{!
Not Integer, not Long => we have a decimal value!
}}{{^isInteger}}{{^isLong}}{{#minimum}} @DecimalMin("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}"){{/maximum}}{{/isLong}}{{/isInteger}}
}}{{^isInteger}}{{^isLong}}{{#minimum}} @DecimalMin("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}"){{/maximum}}{{/isLong}}{{/isInteger}}{{!
uniqueItems set
}}{{#uniqueItems}} @UniqueElements {{/uniqueItems}}

0 comments on commit 720d8aa

Please sign in to comment.