Merge pull request #2082 from jhitchcock/feature/vendorExtensionsRoot

Add VendorExtensions to root swagger
This commit is contained in:
wing328 2016-02-15 10:41:17 +08:00
commit f79ec39d8d
3 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,8 @@ public interface CodegenConfig {
String getHelp(); String getHelp();
Map<String, Object> additionalProperties(); Map<String, Object> additionalProperties();
Map<String, Object> vendorExtensions();
String testPackage(); String testPackage();

View File

@ -71,6 +71,7 @@ public class DefaultCodegen {
protected String templateDir; protected String templateDir;
protected String embeddedTemplateDir; protected String embeddedTemplateDir;
protected Map<String, Object> additionalProperties = new HashMap<String, Object>(); protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>();
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>(); protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
protected List<CliOption> cliOptions = new ArrayList<CliOption>(); protected List<CliOption> cliOptions = new ArrayList<CliOption>();
protected boolean skipOverwrite; protected boolean skipOverwrite;
@ -247,6 +248,10 @@ public class DefaultCodegen {
return additionalProperties; return additionalProperties;
} }
public Map<String, Object> vendorExtensions() {
return vendorExtensions;
}
public List<SupportingFile> supportingFiles() { public List<SupportingFile> supportingFiles() {
return supportingFiles; return supportingFiles;
} }

View File

@ -133,6 +133,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
config.additionalProperties().put("termsOfService", info.getTermsOfService()); config.additionalProperties().put("termsOfService", info.getTermsOfService());
} }
} }
if(swagger.getVendorExtensions() != null) {
config.vendorExtensions().putAll(swagger.getVendorExtensions());
}
StringBuilder hostBuilder = new StringBuilder(); StringBuilder hostBuilder = new StringBuilder();
String scheme; String scheme;
@ -273,6 +277,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
operation.put("classname", config.toApiName(tag)); operation.put("classname", config.toApiName(tag));
operation.put("classVarName", config.toApiVarName(tag)); operation.put("classVarName", config.toApiVarName(tag));
operation.put("importPath", config.toApiImport(tag)); operation.put("importPath", config.toApiImport(tag));
if(!config.vendorExtensions().isEmpty()) {
operation.put("vendorExtensions", config.vendorExtensions());
}
// Pass sortParamsByRequiredFlag through to the Mustache template... // Pass sortParamsByRequiredFlag through to the Mustache template...
boolean sortParamsByRequiredFlag = true; boolean sortParamsByRequiredFlag = true;