From 5940f46f56df78227c330eb7d93d600bdcec9199 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Tue, 1 Sep 2015 23:04:33 -0700 Subject: [PATCH] added vendor extensions on parameters per #1173 --- .../io/swagger/codegen/CodegenParameter.java | 3 + .../io/swagger/codegen/DefaultCodegen.java | 97 +++++++++++++++++++ pom.xml | 4 +- 3 files changed, 102 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index 4447915de4d..e9383f48c6b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -13,6 +13,8 @@ public class CodegenParameter { public boolean isEnum; public List _enum; public Map allowableValues; + public Map 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(this.allowableValues); } + output.vendorExtensions = this.vendorExtensions; return output; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index b798fa9a4b1..99db99bd962 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -674,7 +674,102 @@ public class DefaultCodegen { property.allowableValues = allowableValues; } } + if(p instanceof IntegerProperty) { + IntegerProperty sp = (IntegerProperty) p; + if(sp.getEnum() != null) { + List _enum = sp.getEnum(); + property._enum = new ArrayList(); + for(Integer i : _enum) { + property._enum.add(i.toString()); + } + property.isEnum = true; + // legacy support + Map allowableValues = new HashMap(); + allowableValues.put("values", _enum); + property.allowableValues = allowableValues; + } + } + if(p instanceof LongProperty) { + LongProperty sp = (LongProperty) p; + if(sp.getEnum() != null) { + List _enum = sp.getEnum(); + property._enum = new ArrayList(); + for(Long i : _enum) { + property._enum.add(i.toString()); + } + property.isEnum = true; + + // legacy support + Map allowableValues = new HashMap(); + allowableValues.put("values", _enum); + property.allowableValues = allowableValues; + } + } + if(p instanceof DoubleProperty) { + DoubleProperty sp = (DoubleProperty) p; + if(sp.getEnum() != null) { + List _enum = sp.getEnum(); + property._enum = new ArrayList(); + for(Double i : _enum) { + property._enum.add(i.toString()); + } + property.isEnum = true; + + // legacy support + Map allowableValues = new HashMap(); + allowableValues.put("values", _enum); + property.allowableValues = allowableValues; + } + } + if(p instanceof FloatProperty) { + FloatProperty sp = (FloatProperty) p; + if(sp.getEnum() != null) { + List _enum = sp.getEnum(); + property._enum = new ArrayList(); + for(Float i : _enum) { + property._enum.add(i.toString()); + } + property.isEnum = true; + + // legacy support + Map allowableValues = new HashMap(); + allowableValues.put("values", _enum); + property.allowableValues = allowableValues; + } + } + if(p instanceof DateProperty) { + DateProperty sp = (DateProperty) p; + if(sp.getEnum() != null) { + List _enum = sp.getEnum(); + property._enum = new ArrayList(); + for(String i : _enum) { + property._enum.add(i.toString()); + } + property.isEnum = true; + + // legacy support + Map allowableValues = new HashMap(); + allowableValues.put("values", _enum); + property.allowableValues = allowableValues; + } + } + if(p instanceof DateTimeProperty) { + DateTimeProperty sp = (DateTimeProperty) p; + if(sp.getEnum() != null) { + List _enum = sp.getEnum(); + property._enum = new ArrayList(); + for(String i : _enum) { + property._enum.add(i.toString()); + } + property.isEnum = true; + + // legacy support + Map allowableValues = new HashMap(); + 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; diff --git a/pom.xml b/pom.xml index 4f0d717140a..e7a93c0e052 100644 --- a/pom.xml +++ b/pom.xml @@ -502,10 +502,10 @@ - 1.0.10 + 1.0.11-SNAPSHOT 2.11.1 2.3.4 - 1.5.3 + 1.5.4-SNAPSHOT 2.1.4 2.3 1.2