"External Documentation Object" implemented (according to spec)

Depends on https://github.com/wordnik/swagger-core/pull/716
This commit is contained in:
Martin Ehrnhoefer 2014-10-08 12:09:08 +02:00
parent 77053fa855
commit 436d2530e4
4 changed files with 9 additions and 5 deletions

View File

@ -12,4 +12,5 @@ public class CodegenModel {
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>(); public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars, hasMoreModels; public Boolean hasVars, emptyVars, hasMoreModels;
public ExternalDocs externalDocs;
} }

View File

@ -1,13 +1,12 @@
package com.wordnik.swagger.codegen; package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*; import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*; import java.util.*;
public class CodegenOperation { public class CodegenOperation {
public Boolean hasParams, returnTypeIsPrimitive, returnSimpleType; public Boolean hasParams, returnTypeIsPrimitive, returnSimpleType;
public String path, operationId, returnType, httpMethod, returnBaseType, public String path, operationId, returnType, httpMethod, returnBaseType,
returnContainer, summary, notes, baseName, defaultResponse; returnContainer, summary, notes, baseName, defaultResponse;
public List<Map<String, String>> consumes, produces; public List<Map<String, String>> consumes, produces;
@ -23,6 +22,7 @@ public class CodegenOperation {
public Set<String> imports = new HashSet<String>(); public Set<String> imports = new HashSet<String>();
public List<Map<String, String>> examples; public List<Map<String, String>> examples;
public ExternalDocs externalDocs;
// legacy support // legacy support
public String nickname; public String nickname;

View File

@ -325,6 +325,7 @@ public class DefaultCodegen {
m.classname = toModelName(name); m.classname = toModelName(name);
m.classVarName = toVarName(name); m.classVarName = toVarName(name);
m.modelJson = Json.pretty(model); m.modelJson = Json.pretty(model);
m.externalDocs = model.getExternalDocs();
int count = 0; int count = 0;
if(model instanceof ArrayModel) { if(model instanceof ArrayModel) {
ArrayModel am = (ArrayModel) model; ArrayModel am = (ArrayModel) model;
@ -775,7 +776,7 @@ public class DefaultCodegen {
if(op.allParams.size() > 0) if(op.allParams.size() > 0)
op.hasParams = true; op.hasParams = true;
op.externalDocs = operation.getExternalDocs();
return op; return op;
} }

View File

@ -136,7 +136,9 @@ public class DefaultGenerator implements Generator {
bundle.put("models", allModels); bundle.put("models", allModels);
bundle.put("apiFolder", config.apiPackage().replaceAll("\\.", "/")); bundle.put("apiFolder", config.apiPackage().replaceAll("\\.", "/"));
bundle.put("modelPackage", config.modelPackage()); bundle.put("modelPackage", config.modelPackage());
if (swagger.getExternalDocs() != null) {
bundle.put("externalDocs", swagger.getExternalDocs());
}
for(int i = 0; i < allModels.size() - 1; i++) { for(int i = 0; i < allModels.size() - 1; i++) {
HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i); HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i);
CodegenModel m = cm.get("model"); CodegenModel m = cm.get("model");
@ -331,7 +333,7 @@ public class DefaultGenerator implements Generator {
if(m != null && !config.defaultIncludes().contains(m)) { if(m != null && !config.defaultIncludes().contains(m)) {
im.put("import", m); im.put("import", m);
imports.add(im); imports.add(im);
} }
} }
objs.put("imports", imports); objs.put("imports", imports);