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

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

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

@ -134,6 +134,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
} }
} }
if(swagger.getVendorExtensions() != null) {
config.vendorExtensions().putAll(swagger.getVendorExtensions());
}
StringBuilder hostBuilder = new StringBuilder(); StringBuilder hostBuilder = new StringBuilder();
String scheme; String scheme;
if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) { if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
@ -274,6 +278,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
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;
if (this.config.additionalProperties().containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) { if (this.config.additionalProperties().containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) {