Added support for vendor extensions on model and property

This commit is contained in:
Patrick Culligan 2015-12-26 17:29:56 -06:00
parent 89daeb3bf8
commit ef1222f2bf
3 changed files with 11 additions and 5 deletions

View File

@ -2,10 +2,7 @@ package io.swagger.codegen;
import io.swagger.models.ExternalDocs;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
public class CodegenModel {
public String parent;
@ -21,4 +18,6 @@ public class CodegenModel {
public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum;
public ExternalDocs externalDocs;
public Map<String, Object> vendorExtensions;
}

View File

@ -38,6 +38,7 @@ public class CodegenProperty {
public List<String> _enum;
public Map<String, Object> allowableValues;
public CodegenProperty items;
public Map<String, Object> vendorExtensions;
@Override
public boolean equals(Object obj) {
@ -138,6 +139,9 @@ public class CodegenProperty {
if (this.allowableValues != other.allowableValues && (this.allowableValues == null || !this.allowableValues.equals(other.allowableValues))) {
return false;
}
if (this.vendorExtensions != other.vendorExtensions && (this.vendorExtensions == null || !this.vendorExtensions.equals(other.vendorExtensions))) {
return false;
}
return true;
}
}

View File

@ -762,6 +762,9 @@ public class DefaultCodegen {
m.classVarName = toVarName(name);
m.modelJson = Json.pretty(model);
m.externalDocs = model.getExternalDocs();
m.vendorExtensions = model.getVendorExtensions();
if (model instanceof ArrayModel) {
ArrayModel am = (ArrayModel) model;
ArrayProperty arrayProperty = new ArrayProperty(am.getItems());
@ -880,9 +883,9 @@ public class DefaultCodegen {
property.example = p.getExample();
property.defaultValue = toDefaultValue(p);
property.defaultValueWithParam = toDefaultValueWithParam(name, p);
property.jsonSchema = Json.pretty(p);
property.isReadOnly = p.getReadOnly();
property.vendorExtensions = p.getVendorExtensions();
String type = getSwaggerType(p);
if (p instanceof AbstractNumericProperty) {