Skip to content

Commit

Permalink
fix models.'x' | 'x' & null<string, number> bug
Browse files Browse the repository at this point in the history
  • Loading branch information
杨乾军 authored and yangqianjun committed Nov 2, 2020
1 parent 27f0e1f commit 43c7104
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,9 @@ public int compare(CodegenParameter one, CodegenParameter another) {
}
op.hasRequiredParams = op.requiredParams.size() > 0;

// only body
op.hasOnlyBodyParams = op.bodyParams.size() > 0 && op.pathParams.size() == 0 && op.queryParams.size() == 0 && op.headerParams.size() == 0 && op.formParams.size() == 0;

// set Restful Flag
op.isRestfulShow = op.isRestfulShow();
op.isRestfulIndex = op.isRestfulIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value";
private static final String UNDEFINED_VALUE = "undefined";

protected String modelPropertyNaming= "camelCase";
protected String modelPropertyNaming= "original";
protected Boolean supportsES6 = true;
protected HashSet<String> languageGenericTypes;

Expand Down Expand Up @@ -73,6 +73,8 @@ public AbstractTypeScriptClientCodegen() {
));

instantiationTypes.put("array", "Array");
// fix null<x, y> bug
instantiationTypes.put("map", "Map");

typeMapping = new HashMap<String, String>();
typeMapping.put("Array", "Array");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ private String addModelPrefix(String swaggerType) {
}

if (!isLanguagePrimitive(type) && !isLanguageGenericType(type)) {
type = "models." + swaggerType;
// fix bug
if (swaggerType.matches("^[a-zA-Z_$]\\S*$")) {
type = "models." + swaggerType;
} else {
type = swaggerType;
}
}
return type;
}
Expand Down

0 comments on commit 43c7104

Please sign in to comment.