Fix for Issue #2146 "NPE in JavascriptClientCodegen if definition name does not start with an upper case character"

This commit is contained in:
demonfiddler
2016-04-01 10:45:09 +01:00
parent 023a941a15
commit 7dfddd449d
3 changed files with 18 additions and 12 deletions

View File

@@ -130,10 +130,10 @@ public class DefaultCodegen {
@SuppressWarnings({ "static-method", "unchecked" })
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
if (supportsInheritance) {
// Index all CodegenModels by name.
// Index all CodegenModels by model name.
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
for (Entry<String, Object> entry : objs.entrySet()) {
String modelName = entry.getKey();
String modelName = toModelName(entry.getKey());
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
for (Map<String, Object> mo : models) {
@@ -1013,7 +1013,7 @@ public class DefaultCodegen {
m.interfaces.add(interfaceRef);
addImport(m, interfaceRef);
if (allDefinitions != null) {
final Model interfaceModel = allDefinitions.get(interfaceRef);
final Model interfaceModel = allDefinitions.get(_interface.getSimpleRef());
if (supportsInheritance) {
addProperties(allProperties, allRequired, interfaceModel, allDefinitions);
} else {
@@ -1070,7 +1070,7 @@ public class DefaultCodegen {
required.addAll(mi.getRequired());
}
} else if (model instanceof RefModel) {
String interfaceRef = toModelName(((RefModel) model).getSimpleRef());
String interfaceRef = ((RefModel) model).getSimpleRef();
Model interfaceModel = allDefinitions.get(interfaceRef);
addProperties(properties, required, interfaceModel, allDefinitions);
} else if (model instanceof ComposedModel) {

View File

@@ -298,6 +298,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return "_" + name;
}
/**
* Concatenates an array of path segments into a path string.
* @param segments The path segments to concatenate. A segment may contain either of the file separator characters '\' or '/'.
* A segment is ignored if it is <code>null</code>, empty or &quot;.&quot;.
* @return A path string using the correct platform-specific file separator character.
*/
private String createPath(String... segments) {
StringBuilder buf = new StringBuilder();
for (String segment : segments) {
@@ -704,8 +710,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions);
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) {
final Model parentModel = allDefinitions.get(toModelName(codegenModel.parent));
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions);
codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
}
if (model instanceof ArrayModel) {