added vendor extensions on parameters per #1173

This commit is contained in:
Tony Tam 2015-09-01 23:04:33 -07:00
parent b099d1e7a2
commit 5940f46f56
3 changed files with 102 additions and 2 deletions

View File

@ -13,6 +13,8 @@ public class CodegenParameter {
public boolean isEnum;
public List<String> _enum;
public Map<String, Object> allowableValues;
public Map<String, Object> vendorExtensions;
/**
* Determines whether this parameter is mandatory. If the parameter is in "path",
@ -50,6 +52,7 @@ public class CodegenParameter {
if (this.allowableValues != null) {
output.allowableValues = new HashMap<String, Object>(this.allowableValues);
}
output.vendorExtensions = this.vendorExtensions;
return output;
}

View File

@ -674,7 +674,102 @@ public class DefaultCodegen {
property.allowableValues = allowableValues;
}
}
if(p instanceof IntegerProperty) {
IntegerProperty sp = (IntegerProperty) p;
if(sp.getEnum() != null) {
List<Integer> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for(Integer i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}
}
if(p instanceof LongProperty) {
LongProperty sp = (LongProperty) p;
if(sp.getEnum() != null) {
List<Long> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for(Long i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}
}
if(p instanceof DoubleProperty) {
DoubleProperty sp = (DoubleProperty) p;
if(sp.getEnum() != null) {
List<Double> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for(Double i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}
}
if(p instanceof FloatProperty) {
FloatProperty sp = (FloatProperty) p;
if(sp.getEnum() != null) {
List<Float> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for(Float i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}
}
if(p instanceof DateProperty) {
DateProperty sp = (DateProperty) p;
if(sp.getEnum() != null) {
List<String> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for(String i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}
}
if(p instanceof DateTimeProperty) {
DateTimeProperty sp = (DateTimeProperty) p;
if(sp.getEnum() != null) {
List<String> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for(String i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}
}
property.datatype = getTypeDeclaration(p);
// this can cause issues for clients which don't support enums
@ -1033,6 +1128,8 @@ public class DefaultCodegen {
p.defaultValue = ((FormParameter) param).getDefaultValue();
}
p.vendorExtensions = param.getVendorExtensions();
if (param instanceof SerializableParameter) {
SerializableParameter qp = (SerializableParameter) param;
Property property = null;

View File

@ -502,10 +502,10 @@
</repository>
</repositories>
<properties>
<swagger-parser-version>1.0.10</swagger-parser-version>
<swagger-parser-version>1.0.11-SNAPSHOT</swagger-parser-version>
<scala-version>2.11.1</scala-version>
<felix-version>2.3.4</felix-version>
<swagger-core-version>1.5.3</swagger-core-version>
<swagger-core-version>1.5.4-SNAPSHOT</swagger-core-version>
<scala-test-version>2.1.4</scala-test-version>
<commons-io-version>2.3</commons-io-version>
<commons-cli-version>1.2</commons-cli-version>