Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for x-codegen-ignore and x-import-mapping extensions #8478

Merged
merged 2 commits into from
Jul 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,11 @@ private Model getParent(Model model) {
Map<String, Model> modelMap = new HashMap<String, Model>();
modelMap.put(name, model);
Map<String, Object> models = processModels(config, modelMap, definitions);
models.put("classname", config.toModelName(name));
models.putAll(config.additionalProperties());
allProcessedModels.put(name, models);
if (models != null) {
models.put("classname", config.toModelName(name));
models.putAll(config.additionalProperties());
allProcessedModels.put(name, models);
}
} catch (Exception e) {
String message = "Could not process model '" + name + "'" + ". Please make sure that your schema is correct!";
LOGGER.error(message, e);
Expand Down Expand Up @@ -1016,6 +1018,16 @@ private Map<String, Object> processModels(CodegenConfig config, Map<String, Mode
Set<String> allImports = new LinkedHashSet<String>();
for (String key : definitions.keySet()) {
Model mm = definitions.get(key);
if(mm.getVendorExtensions() != null && mm.getVendorExtensions().containsKey("x-codegen-ignore")) {
// skip this model
LOGGER.debug("skipping model " + key);
return null;
}
else if(mm.getVendorExtensions() != null && mm.getVendorExtensions().containsKey("x-codegen-import-mapping")) {
String codegenImport = mm.getVendorExtensions().get("x-codegen-import-mapping").toString();
config.importMapping().put(key, codegenImport);
allImports.add(codegenImport);
}
CodegenModel cm = config.fromModel(key, mm, allDefinitions);
Map<String, Object> mo = new HashMap<String, Object>();
mo.put("model", cm);
Expand Down