[Typescript] support schemaMapping (#12803)

Co-authored-by: hansnuttin <hans.nuttin@aca-it.be>
This commit is contained in:
Hans Nuttin 2022-07-11 19:06:57 +02:00 committed by GitHub
parent 244a459836
commit 073a800464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -430,11 +430,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
public String getTypeDeclaration(Schema p) { public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) { if (ModelUtils.isArraySchema(p)) {
Schema<?> items = getSchemaItems((ArraySchema) p); Schema<?> items = getSchemaItems((ArraySchema) p);
return getSchemaType(p) + "<" + getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, items)) + ">"; return getSchemaType(p) + "<" + getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, items, schemaMapping)) + ">";
} else if (ModelUtils.isMapSchema(p)) { } else if (ModelUtils.isMapSchema(p)) {
Schema<?> inner = getSchemaAdditionalProperties(p); Schema<?> inner = getSchemaAdditionalProperties(p);
String nullSafeSuffix = getNullSafeAdditionalProps() ? " | undefined" : ""; String nullSafeSuffix = getNullSafeAdditionalProps() ? " | undefined" : "";
return "{ [key: string]: " + getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, inner)) + nullSafeSuffix + "; }"; return "{ [key: string]: " + getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, inner, schemaMapping)) + nullSafeSuffix + "; }";
} else if (ModelUtils.isFileSchema(p)) { } else if (ModelUtils.isFileSchema(p)) {
return "any"; return "any";
} else if (ModelUtils.isBinarySchema(p)) { } else if (ModelUtils.isBinarySchema(p)) {