Fix parameter schema mapping (#12893)

* fix parameter schema mapping,refactor unaliasSchema

* minor code format change
This commit is contained in:
William Cheng 2022-07-17 12:43:00 +08:00 committed by GitHub
parent a9e63f4ce3
commit bdd54dacad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 112 additions and 111 deletions

View File

@ -313,7 +313,7 @@ public interface CodegenConfig {
void setRemoveEnumValuePrefix(boolean removeEnumValuePrefix); void setRemoveEnumValuePrefix(boolean removeEnumValuePrefix);
Schema unaliasSchema(Schema schema, Map<String, String> schemaMappings); Schema unaliasSchema(Schema schema);
String defaultTemplatingEngine(); String defaultTemplatingEngine();

View File

@ -2203,8 +2203,8 @@ public class DefaultCodegen implements CodegenConfig {
} }
@Override @Override
public Schema unaliasSchema(Schema schema, Map<String, String> schemaMappings) { public Schema unaliasSchema(Schema schema) {
return ModelUtils.unaliasSchema(this.openAPI, schema, schemaMappings); return ModelUtils.unaliasSchema(this.openAPI, schema, schemaMapping);
} }
/** /**
@ -2214,7 +2214,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return the string representation of the schema type. * @return the string representation of the schema type.
*/ */
protected String getSingleSchemaType(Schema schema) { protected String getSingleSchemaType(Schema schema) {
Schema unaliasSchema = unaliasSchema(schema, schemaMapping); Schema unaliasSchema = unaliasSchema(schema);
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
// get the schema/model name from $ref // get the schema/model name from $ref
@ -2546,7 +2546,7 @@ public class DefaultCodegen implements CodegenConfig {
m.interfaces = new ArrayList<>(); m.interfaces = new ArrayList<>();
for (Schema interfaceSchema : interfaces) { for (Schema interfaceSchema : interfaces) {
interfaceSchema = unaliasSchema(interfaceSchema, schemaMapping); interfaceSchema = unaliasSchema(interfaceSchema);
if (StringUtils.isBlank(interfaceSchema.get$ref())) { if (StringUtils.isBlank(interfaceSchema.get$ref())) {
// primitive type // primitive type
@ -2775,7 +2775,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
// unalias schema // unalias schema
schema = unaliasSchema(schema, schemaMapping); schema = unaliasSchema(schema);
if (schema == null) { if (schema == null) {
LOGGER.warn("Schema {} not found", name); LOGGER.warn("Schema {} not found", name);
return null; return null;
@ -3448,7 +3448,7 @@ public class DefaultCodegen implements CodegenConfig {
property.maxItems = p.getMaxProperties(); property.maxItems = p.getMaxProperties();
// handle inner property // handle inner property
Schema innerSchema = unaliasSchema(getAdditionalProperties(p), schemaMapping); Schema innerSchema = unaliasSchema(getAdditionalProperties(p));
if (innerSchema == null) { if (innerSchema == null) {
LOGGER.error("Undefined map inner type for `{}`. Default to String.", p.getName()); LOGGER.error("Undefined map inner type for `{}`. Default to String.", p.getName());
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type"); innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
@ -3565,7 +3565,7 @@ public class DefaultCodegen implements CodegenConfig {
return cpc; return cpc;
} }
// unalias schema // unalias schema
p = unaliasSchema(p, schemaMapping); p = unaliasSchema(p);
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY); CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
property.required = required; property.required = required;
@ -3734,7 +3734,7 @@ public class DefaultCodegen implements CodegenConfig {
itemName = property.name; itemName = property.name;
} }
ArraySchema arraySchema = (ArraySchema) p; ArraySchema arraySchema = (ArraySchema) p;
Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema), schemaMapping); Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema));
CodegenProperty cp = fromProperty(itemName, innerSchema, false); CodegenProperty cp = fromProperty(itemName, innerSchema, false);
updatePropertyForArray(property, cp); updatePropertyForArray(property, cp);
} else if (ModelUtils.isTypeObjectSchema(p)) { } else if (ModelUtils.isTypeObjectSchema(p)) {
@ -3980,7 +3980,7 @@ public class DefaultCodegen implements CodegenConfig {
CodegenOperation op, CodegenOperation op,
ApiResponse methodResponse, ApiResponse methodResponse,
Map<String, String> schemaMappings) { Map<String, String> schemaMappings) {
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse), schemaMapping); Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse));
if (responseSchema != null) { if (responseSchema != null) {
CodegenProperty cm = fromProperty("response", responseSchema, false); CodegenProperty cm = fromProperty("response", responseSchema, false);
@ -4420,7 +4420,7 @@ public class DefaultCodegen implements CodegenConfig {
Schema responseSchema; Schema responseSchema;
if (this.openAPI != null && this.openAPI.getComponents() != null) { if (this.openAPI != null && this.openAPI.getComponents() != null) {
responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(response), schemaMapping); responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(response));
} else { // no model/alias defined } else { // no model/alias defined
responseSchema = ModelUtils.getSchemaFromResponse(response); responseSchema = ModelUtils.getSchemaFromResponse(response);
} }
@ -4712,7 +4712,7 @@ public class DefaultCodegen implements CodegenConfig {
String parameterModelName = null; String parameterModelName = null;
if (parameter.getSchema() != null) { if (parameter.getSchema() != null) {
parameterSchema = parameter.getSchema(); parameterSchema = unaliasSchema(parameter.getSchema());
parameterModelName = getParameterDataType(parameter, parameterSchema); parameterModelName = getParameterDataType(parameter, parameterSchema);
CodegenProperty prop; CodegenProperty prop;
if (this instanceof RustServerCodegen) { if (this instanceof RustServerCodegen) {
@ -4759,7 +4759,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
// TODO need to reivew replacing empty map with schemaMapping instead // TODO need to reivew replacing empty map with schemaMapping instead
parameterSchema = unaliasSchema(parameterSchema, Collections.emptyMap()); parameterSchema = unaliasSchema(parameterSchema);
if (parameterSchema == null) { if (parameterSchema == null) {
LOGGER.warn("warning! Schema not found for parameter \" {} \"", parameter.getName()); LOGGER.warn("warning! Schema not found for parameter \" {} \"", parameter.getName());
finishUpdatingParameter(codegenParameter, parameter); finishUpdatingParameter(codegenParameter, parameter);
@ -4964,7 +4964,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return data type * @return data type
*/ */
protected String getParameterDataType(Parameter parameter, Schema schema) { protected String getParameterDataType(Parameter parameter, Schema schema) {
Schema unaliasSchema = ModelUtils.unaliasSchema(openAPI, schema); Schema unaliasSchema = unaliasSchema(schema);
if (unaliasSchema.get$ref() != null) { if (unaliasSchema.get$ref() != null) {
return toModelName(ModelUtils.getSimpleRef(unaliasSchema.get$ref())); return toModelName(ModelUtils.getSimpleRef(unaliasSchema.get$ref()));
} }
@ -5365,7 +5365,7 @@ public class DefaultCodegen implements CodegenConfig {
protected Map<String, Schema> unaliasPropertySchema(Map<String, Schema> properties) { protected Map<String, Schema> unaliasPropertySchema(Map<String, Schema> properties) {
if (properties != null) { if (properties != null) {
for (String key : properties.keySet()) { for (String key : properties.keySet()) {
properties.put(key, unaliasSchema(properties.get(key), schemaMapping())); properties.put(key, unaliasSchema(properties.get(key)));
} }
} }
@ -6491,7 +6491,7 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.debug("Debugging fromFormProperty {}: {}", name, propertySchema); LOGGER.debug("Debugging fromFormProperty {}: {}", name, propertySchema);
CodegenProperty codegenProperty = fromProperty(name, propertySchema, false); CodegenProperty codegenProperty = fromProperty(name, propertySchema, false);
Schema ps = unaliasSchema(propertySchema, schemaMapping); Schema ps = unaliasSchema(propertySchema);
ModelUtils.syncValidationProperties(ps, codegenParameter); ModelUtils.syncValidationProperties(ps, codegenParameter);
codegenParameter.setTypeProperties(ps); codegenParameter.setTypeProperties(ps);
codegenParameter.setComposedSchemas(getComposedSchemas(ps)); codegenParameter.setComposedSchemas(getComposedSchemas(ps));
@ -7002,7 +7002,7 @@ public class DefaultCodegen implements CodegenConfig {
name = ModelUtils.getSimpleRef(schema.get$ref()); name = ModelUtils.getSimpleRef(schema.get$ref());
} }
Schema unaliasedSchema = unaliasSchema(schema, schemaMapping); Schema unaliasedSchema = unaliasSchema(schema);
schema = ModelUtils.getReferencedSchema(this.openAPI, schema); schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter); ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter);

View File

@ -477,7 +477,7 @@ public class DefaultGenerator implements Generator {
// generators may choose to make models for use case 2 + 3 // generators may choose to make models for use case 2 + 3
Schema refSchema = new Schema(); Schema refSchema = new Schema();
refSchema.set$ref("#/components/schemas/" + name); refSchema.set$ref("#/components/schemas/" + name);
Schema unaliasedSchema = config.unaliasSchema(refSchema, config.schemaMapping()); Schema unaliasedSchema = config.unaliasSchema(refSchema);
if (unaliasedSchema.get$ref() == null) { if (unaliasedSchema.get$ref() == null) {
LOGGER.info("Model {} not generated since it's a free-form object", name); LOGGER.info("Model {} not generated since it's a free-form object", name);
continue; continue;

View File

@ -109,7 +109,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
apiTestTemplateFiles.put("api_test.mustache", ".dart"); apiTestTemplateFiles.put("api_test.mustache", ".dart");
final List<String> reservedWordsList = new ArrayList<>(); final List<String> reservedWordsList = new ArrayList<>();
try(BufferedReader reader = new BufferedReader( try (BufferedReader reader = new BufferedReader(
new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"), new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"),
StandardCharsets.UTF_8))) { StandardCharsets.UTF_8))) {
while (reader.ready()) { while (reader.ready()) {
@ -445,7 +445,8 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
return underscore(toModelName(name)); return underscore(toModelName(name));
} }
@Override public String toModelDocFilename(String name) { @Override
public String toModelDocFilename(String name) {
return toModelName(name); return toModelName(name);
} }
@ -488,7 +489,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
@Override @Override
public String getTypeDeclaration(Schema p) { public String getTypeDeclaration(Schema p) {
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, schemaMapping); Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema; Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) { if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema); Schema<?> items = getSchemaItems((ArraySchema) schema);
@ -819,5 +820,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
} }
@Override @Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.DART; } public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.DART;
}
} }

View File

@ -346,7 +346,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
// specification is aligned with the JSON schema specification. // specification is aligned with the JSON schema specification.
// When "items" is not specified, the elements of the array may be anything at all. // When "items" is not specified, the elements of the array may be anything at all.
if (inner != null) { if (inner != null) {
inner = ModelUtils.unaliasSchema(this.openAPI, inner, schemaMapping); inner = unaliasSchema(inner);
} }
String typDecl; String typDecl;
if (inner != null) { if (inner != null) {
@ -360,7 +360,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
return "[]" + typDecl; return "[]" + typDecl;
} else if (ModelUtils.isMapSchema(p)) { } else if (ModelUtils.isMapSchema(p)) {
Schema inner = getAdditionalProperties(p); Schema inner = getAdditionalProperties(p);
return getSchemaType(p) + "[string]" + getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, inner, schemaMapping)); return getSchemaType(p) + "[string]" + getTypeDeclaration(unaliasSchema(inner));
} }
//return super.getTypeDeclaration(p); //return super.getTypeDeclaration(p);
@ -792,7 +792,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
@Override @Override
public String toDefaultValue(Schema schema) { public String toDefaultValue(Schema schema) {
schema = ModelUtils.unaliasSchema(this.openAPI, schema, schemaMapping); schema = unaliasSchema(schema);
if (schema.getDefault() != null) { if (schema.getDefault() != null) {
return schema.getDefault().toString(); return schema.getDefault().toString();
} else { } else {

View File

@ -873,7 +873,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
@Override @Override
public String getTypeDeclaration(Schema p) { public String getTypeDeclaration(Schema p) {
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, schemaMapping); Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema; Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) { if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema); Schema<?> items = getSchemaItems((ArraySchema) schema);

View File

@ -365,7 +365,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
*/ */
@Override @Override
public String getTypeDeclaration(Schema p) { public String getTypeDeclaration(Schema p) {
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, schemaMapping); Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema; Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) { if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema); Schema<?> items = getSchemaItems((ArraySchema) schema);

View File

@ -47,18 +47,18 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
protected String sourceFolder = "src/main/scala"; protected String sourceFolder = "src/main/scala";
protected String appName = "OpenAPI Sample"; protected String appName = "OpenAPI Sample";
protected String appDescription = "A sample openapi server"; protected String appDescription = "A sample openapi server";
protected String infoUrl = "http://org.openapitools" ; protected String infoUrl = "http://org.openapitools";
protected String infoEmail = "team@openapitools.org" ; protected String infoEmail = "team@openapitools.org";
protected String licenseInfo = "All rights reserved"; protected String licenseInfo = "All rights reserved";
protected String licenseUrl = "http://apache.org/licenses/LICENSE-2.0.html"; protected String licenseUrl = "http://apache.org/licenses/LICENSE-2.0.html";
protected String apiVersion = "1.0" ; protected String apiVersion = "1.0";
protected boolean stripPackageName = true; protected boolean stripPackageName = true;
protected String dateLibrary = DateLibraries.java8.name(); protected String dateLibrary = DateLibraries.java8.name();
protected enum DateLibraries { protected enum DateLibraries {
java8("Java 8 native JSR310 (preferred for JDK 1.8+)"), java8("Java 8 native JSR310 (preferred for JDK 1.8+)"),
joda( "Joda (for legacy app)"), joda("Joda (for legacy app)"),
legacy( "Backport to http-client (deprecated)"); legacy("Backport to http-client (deprecated)");
private final String description; private final String description;
@ -187,14 +187,14 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
} }
this.appName = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getTitle()).filter(t -> t != null).orElse(this.appName) ; this.appName = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getTitle()).filter(t -> t != null).orElse(this.appName);
this.appDescription = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getDescription()).filter(d -> d != null).orElse(this.appDescription) ; this.appDescription = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getDescription()).filter(d -> d != null).orElse(this.appDescription);
this.infoUrl = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getContact()).filter(c -> c != null).map(c -> c.getUrl()).filter(u -> u != null).orElse(this.infoUrl) ; this.infoUrl = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getContact()).filter(c -> c != null).map(c -> c.getUrl()).filter(u -> u != null).orElse(this.infoUrl);
this.infoEmail = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getContact()).filter(c -> c != null).map(c -> c.getEmail()).filter(v -> v != null).orElse(this.infoEmail) ; this.infoEmail = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getContact()).filter(c -> c != null).map(c -> c.getEmail()).filter(v -> v != null).orElse(this.infoEmail);
this.licenseInfo = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getLicense()).filter(l -> l != null).map(l -> l.getName()).filter(n -> n != null).orElse(this.licenseInfo) ; this.licenseInfo = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getLicense()).filter(l -> l != null).map(l -> l.getName()).filter(n -> n != null).orElse(this.licenseInfo);
this.licenseUrl = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getLicense()).filter(l -> l != null).map(l -> l.getUrl()).filter(u -> u != null).orElse(this.licenseUrl) ; this.licenseUrl = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getLicense()).filter(l -> l != null).map(l -> l.getUrl()).filter(u -> u != null).orElse(this.licenseUrl);
this.apiVersion = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getVersion()).filter(v -> v != null).orElse(this.apiVersion) ; this.apiVersion = Optional.ofNullable(openAPI).map(o -> o.getInfo()).filter(i -> i != null).map(i -> i.getVersion()).filter(v -> v != null).orElse(this.apiVersion);
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
@ -240,7 +240,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
this.dateLibrary = dateLibrary; this.dateLibrary = dateLibrary;
return; return;
} }
for ( DateLibraries dateLib : DateLibraries.values()) { for (DateLibraries dateLib : DateLibraries.values()) {
if (dateLib.name().equals(dateLibrary)) { if (dateLib.name().equals(dateLibrary)) {
this.dateLibrary = dateLibrary; this.dateLibrary = dateLibrary;
return; return;
@ -357,7 +357,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
@Override @Override
public String getTypeDeclaration(Schema p) { public String getTypeDeclaration(Schema p) {
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, schemaMapping); Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema; Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) { if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema); Schema<?> items = getSchemaItems((ArraySchema) schema);
@ -395,7 +395,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
} else if (ModelUtils.isArraySchema(p)) { } else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p; ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems()); String inner = getSchemaType(ap.getItems());
return ( ModelUtils.isSet(ap) ? instantiationTypes.get("set") : instantiationTypes.get("array") ) + "[" + inner + "]"; return (ModelUtils.isSet(ap) ? instantiationTypes.get("set") : instantiationTypes.get("array")) + "[" + inner + "]";
} else { } else {
return null; return null;
} }
@ -611,5 +611,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
} }
@Override @Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.SCALA; } public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.SCALA;
}
} }

View File

@ -235,12 +235,12 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
} }
@Override @Override
public String toModelImport(String name){ public String toModelImport(String name) {
if(isUnionType(name)){ if (isUnionType(name)) {
LOGGER.warn("The import is a union type. Consider using the toModelImportMap method."); LOGGER.warn("The import is a union type. Consider using the toModelImportMap method.");
return toModelImportMap(name).values().stream().collect(Collectors.joining("|")); return toModelImportMap(name).values().stream().collect(Collectors.joining("|"));
} }
if(isIntersectionType(name)){ if (isIntersectionType(name)) {
LOGGER.warn("The import is a intersection type. Consider using the toModelImportMap method."); LOGGER.warn("The import is a intersection type. Consider using the toModelImportMap method.");
return toModelImportMap(name).values().stream().collect(Collectors.joining("&")); return toModelImportMap(name).values().stream().collect(Collectors.joining("&"));
} }
@ -255,26 +255,26 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
* @return Map between the fully qualified model import and the initial given name. * @return Map between the fully qualified model import and the initial given name.
*/ */
@Override @Override
public Map<String,String> toModelImportMap(String name){ public Map<String, String> toModelImportMap(String name) {
return toImportMap(splitComposedType(name)); return toImportMap(splitComposedType(name));
} }
private String[] splitComposedType (String name) { private String[] splitComposedType(String name) {
return name.replace(" ","").split("[|&<>]"); return name.replace(" ", "").split("[|&<>]");
} }
private boolean isUnionType(String name){ private boolean isUnionType(String name) {
return name.contains("|"); return name.contains("|");
} }
private boolean isIntersectionType(String name){ private boolean isIntersectionType(String name) {
return name.contains("&"); return name.contains("&");
} }
private Map<String,String> toImportMap(String... names) { private Map<String, String> toImportMap(String... names) {
Map<String,String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
for(final String name : names) { for (final String name : names) {
if(needToImport(name)) { if (needToImport(name)) {
result.put(toModelImport(name), name); result.put(toModelImport(name), name);
} }
} }
@ -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, schemaMapping)) + ">"; return getSchemaType(p) + "<" + getTypeDeclaration(unaliasSchema(items)) + ">";
} 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, schemaMapping)) + nullSafeSuffix + "; }"; return "{ [key: string]: " + getTypeDeclaration(unaliasSchema(inner)) + 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)) {
@ -726,7 +726,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
.map(value -> "'" + value.name() + "'") .map(value -> "'" + value.name() + "'")
.collect(Collectors.joining(", ")); .collect(Collectors.joining(", "));
String msg = String.format(Locale.ROOT, "Invalid enum property naming '%s'. Must be one of %s.",naming, values); String msg = String.format(Locale.ROOT, "Invalid enum property naming '%s'. Must be one of %s.", naming, values);
throw new IllegalArgumentException(msg); throw new IllegalArgumentException(msg);
} }
} }
@ -957,5 +957,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
} }
@Override @Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.TYPESCRIPT; } public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.TYPESCRIPT;
}
} }

View File

@ -295,7 +295,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
if (methodResponse != null) { if (methodResponse != null) {
Schema response = ModelUtils.getSchemaFromResponse(methodResponse); Schema response = ModelUtils.getSchemaFromResponse(methodResponse);
response = ModelUtils.unaliasSchema(this.openAPI, response, schemaMapping); response = unaliasSchema(response);
if (response != null) { if (response != null) {
CodegenProperty cm = fromProperty("response", response, false); CodegenProperty cm = fromProperty("response", response, false);
op.vendorExtensions.put("x-codegen-response", cm); op.vendorExtensions.put("x-codegen-response", cm);

View File

@ -215,7 +215,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
} }
@Override @Override
public Schema unaliasSchema(Schema schema, Map<String, String> schemaMappings) { public Schema unaliasSchema(Schema schema) {
Map<String, Schema> allSchemas = ModelUtils.getSchemas(openAPI); Map<String, Schema> allSchemas = ModelUtils.getSchemas(openAPI);
if (allSchemas == null || allSchemas.isEmpty()) { if (allSchemas == null || allSchemas.isEmpty()) {
// skip the warning as the spec can have no model defined // skip the warning as the spec can have no model defined
@ -225,8 +225,8 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) { if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) {
String simpleRef = ModelUtils.getSimpleRef(schema.get$ref()); String simpleRef = ModelUtils.getSimpleRef(schema.get$ref());
if (schemaMappings.containsKey(simpleRef)) { if (schemaMapping.containsKey(simpleRef)) {
LOGGER.debug("Schema unaliasing of {} omitted because aliased class is to be mapped to {}", simpleRef, schemaMappings.get(simpleRef)); LOGGER.debug("Schema unaliasing of {} omitted because aliased class is to be mapped to {}", simpleRef, schemaMapping.get(simpleRef));
return schema; return schema;
} }
Schema ref = allSchemas.get(simpleRef); Schema ref = allSchemas.get(simpleRef);
@ -240,8 +240,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
if (ModelUtils.isGenerateAliasAsModel(ref)) { if (ModelUtils.isGenerateAliasAsModel(ref)) {
return schema; // generate a model extending array return schema; // generate a model extending array
} else { } else {
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
schemaMappings);
} }
} else if (ModelUtils.isComposedSchema(ref)) { } else if (ModelUtils.isComposedSchema(ref)) {
return schema; return schema;
@ -253,8 +252,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
return schema; // generate a model extending map return schema; // generate a model extending map
} else { } else {
// treat it as a typical map // treat it as a typical map
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
schemaMappings);
} }
} }
} else if (ModelUtils.isObjectSchema(ref)) { // model } else if (ModelUtils.isObjectSchema(ref)) { // model
@ -267,8 +265,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
} else if (!getAllOfDescendants(simpleRef, openAPI).isEmpty()) { } else if (!getAllOfDescendants(simpleRef, openAPI).isEmpty()) {
return schema; return schema;
} else { } else {
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
schemaMappings);
} }
} }
} else if (ModelUtils.hasValidation(ref)) { } else if (ModelUtils.hasValidation(ref)) {
@ -279,7 +276,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
// - use those validations when we use this schema in composed oneOf schemas // - use those validations when we use this schema in composed oneOf schemas
return schema; return schema;
} else { } else {
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), schemaMappings); return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
} }
} }
return schema; return schema;
@ -407,7 +404,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
for (String schemaName : allDefinitions.keySet()) { for (String schemaName : allDefinitions.keySet()) {
Schema refSchema = new Schema().$ref("#/components/schemas/" + schemaName); Schema refSchema = new Schema().$ref("#/components/schemas/" + schemaName);
Schema unaliasedSchema = unaliasSchema(refSchema, schemaMapping); Schema unaliasedSchema = unaliasSchema(refSchema);
String modelName = toModelName(schemaName); String modelName = toModelName(schemaName);
if (unaliasedSchema.get$ref() == null) { if (unaliasedSchema.get$ref() == null) {
modelsToRemove.add(modelName); modelsToRemove.add(modelName);
@ -517,7 +514,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
if (schema.get$ref() == null) { if (schema.get$ref() == null) {
return cp; return cp;
} }
Schema unaliasedSchema = unaliasSchema(schema, schemaMapping); Schema unaliasedSchema = unaliasSchema(schema);
CodegenProperty unaliasedProp = fromProperty("body", unaliasedSchema, false); CodegenProperty unaliasedProp = fromProperty("body", unaliasedSchema, false);
Boolean dataTypeMismatch = !cp.dataType.equals(unaliasedProp.dataType); Boolean dataTypeMismatch = !cp.dataType.equals(unaliasedProp.dataType);
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.complexType) && unaliasedProp.complexType != null; Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.complexType) && unaliasedProp.complexType != null;
@ -547,7 +544,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
protected void addBodyModelSchema(CodegenParameter codegenParameter, String name, Schema schema, Set<String> imports, String bodyParameterName, boolean forceSimpleRef) { protected void addBodyModelSchema(CodegenParameter codegenParameter, String name, Schema schema, Set<String> imports, String bodyParameterName, boolean forceSimpleRef) {
if (name != null) { if (name != null) {
Schema bodySchema = new Schema().$ref("#/components/schemas/" + name); Schema bodySchema = new Schema().$ref("#/components/schemas/" + name);
Schema unaliased = unaliasSchema(bodySchema, schemaMapping); Schema unaliased = unaliasSchema(bodySchema);
if (unaliased.get$ref() != null) { if (unaliased.get$ref() != null) {
forceSimpleRef = true; forceSimpleRef = true;
} }
@ -758,7 +755,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
public String getModelName(Schema sc) { public String getModelName(Schema sc) {
if (sc.get$ref() != null) { if (sc.get$ref() != null) {
Schema unaliasedSchema = unaliasSchema(sc, schemaMapping); Schema unaliasedSchema = unaliasSchema(sc);
if (unaliasedSchema.get$ref() != null) { if (unaliasedSchema.get$ref() != null) {
return toModelName(ModelUtils.getSimpleRef(sc.get$ref())); return toModelName(ModelUtils.getSimpleRef(sc.get$ref()));
} }
@ -851,7 +848,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
if (StringUtils.isNotEmpty(p.get$ref())) { if (StringUtils.isNotEmpty(p.get$ref())) {
// The input schema is a reference. If the resolved schema is // The input schema is a reference. If the resolved schema is
// a composed schema, convert the name to a Python class. // a composed schema, convert the name to a Python class.
Schema unaliasedSchema = unaliasSchema(p, schemaMapping); Schema unaliasedSchema = unaliasSchema(p);
if (unaliasedSchema.get$ref() != null) { if (unaliasedSchema.get$ref() != null) {
String modelName = toModelName(ModelUtils.getSimpleRef(p.get$ref())); String modelName = toModelName(ModelUtils.getSimpleRef(p.get$ref()));
if (referencedModelNames != null) { if (referencedModelNames != null) {

View File

@ -564,7 +564,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
} }
@Override @Override
public Schema unaliasSchema(Schema schema, Map<String, String> schemaMappings) { public Schema unaliasSchema(Schema schema) {
Map<String, Schema> allSchemas = ModelUtils.getSchemas(openAPI); Map<String, Schema> allSchemas = ModelUtils.getSchemas(openAPI);
if (allSchemas == null || allSchemas.isEmpty()) { if (allSchemas == null || allSchemas.isEmpty()) {
// skip the warning as the spec can have no model defined // skip the warning as the spec can have no model defined
@ -574,8 +574,8 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) { if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) {
String simpleRef = ModelUtils.getSimpleRef(schema.get$ref()); String simpleRef = ModelUtils.getSimpleRef(schema.get$ref());
if (schemaMappings.containsKey(simpleRef)) { if (schemaMapping.containsKey(simpleRef)) {
LOGGER.debug("Schema unaliasing of {} omitted because aliased class is to be mapped to {}", simpleRef, schemaMappings.get(simpleRef)); LOGGER.debug("Schema unaliasing of {} omitted because aliased class is to be mapped to {}", simpleRef, schemaMapping.get(simpleRef));
return schema; return schema;
} }
Schema ref = allSchemas.get(simpleRef); Schema ref = allSchemas.get(simpleRef);
@ -589,8 +589,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
if (ModelUtils.isGenerateAliasAsModel(ref)) { if (ModelUtils.isGenerateAliasAsModel(ref)) {
return schema; // generate a model extending array return schema; // generate a model extending array
} else { } else {
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
schemaMappings);
} }
} else if (ModelUtils.isComposedSchema(ref)) { } else if (ModelUtils.isComposedSchema(ref)) {
return schema; return schema;
@ -602,8 +601,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
return schema; // generate a model extending map return schema; // generate a model extending map
} else { } else {
// treat it as a typical map // treat it as a typical map
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
schemaMappings);
} }
} }
} else if (ModelUtils.isObjectSchema(ref)) { // model } else if (ModelUtils.isObjectSchema(ref)) { // model
@ -616,8 +614,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
} else if (getAllOfDescendants(simpleRef, openAPI).size() > 0) { } else if (getAllOfDescendants(simpleRef, openAPI).size() > 0) {
return schema; return schema;
} }
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
schemaMappings);
} }
} else if (ModelUtils.hasValidation(ref)) { } else if (ModelUtils.hasValidation(ref)) {
// non object non array non map schemas that have validations // non object non array non map schemas that have validations
@ -631,7 +628,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
// we make these models so instances of this will be subclasses of this model // we make these models so instances of this will be subclasses of this model
return schema; return schema;
} else { } else {
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())), schemaMappings); return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
} }
} }
return schema; return schema;
@ -756,7 +753,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
for (String schemaName : allDefinitions.keySet()) { for (String schemaName : allDefinitions.keySet()) {
Schema refSchema = new Schema().$ref("#/components/schemas/" + schemaName); Schema refSchema = new Schema().$ref("#/components/schemas/" + schemaName);
Schema unaliasedSchema = unaliasSchema(refSchema, schemaMapping); Schema unaliasedSchema = unaliasSchema(refSchema);
String modelName = toModelName(schemaName); String modelName = toModelName(schemaName);
if (unaliasedSchema.get$ref() == null) { if (unaliasedSchema.get$ref() == null) {
continue; continue;
@ -877,7 +874,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
if (cp.isEnum) { if (cp.isEnum) {
updateCodegenPropertyEnum(cp); updateCodegenPropertyEnum(cp);
} }
Schema unaliasedSchema = unaliasSchema(p, schemaMapping); Schema unaliasedSchema = unaliasSchema(p);
if (cp.isPrimitiveType && unaliasedSchema.get$ref() != null) { if (cp.isPrimitiveType && unaliasedSchema.get$ref() != null) {
cp.complexType = cp.dataType; cp.complexType = cp.dataType;
} }
@ -965,7 +962,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
if (schema.get$ref() == null) { if (schema.get$ref() == null) {
return cp; return cp;
} }
Schema unaliasedSchema = unaliasSchema(schema, schemaMapping); Schema unaliasedSchema = unaliasSchema(schema);
CodegenProperty unaliasedProp = fromProperty("body", unaliasedSchema, false); CodegenProperty unaliasedProp = fromProperty("body", unaliasedSchema, false);
Boolean dataTypeMismatch = !cp.dataType.equals(unaliasedProp.dataType); Boolean dataTypeMismatch = !cp.dataType.equals(unaliasedProp.dataType);
Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.complexType) && unaliasedProp.complexType != null; Boolean baseTypeMismatch = !cp.baseType.equals(unaliasedProp.complexType) && unaliasedProp.complexType != null;
@ -996,7 +993,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
protected void addBodyModelSchema(CodegenParameter codegenParameter, String name, Schema schema, Set<String> imports, String bodyParameterName, boolean forceSimpleRef) { protected void addBodyModelSchema(CodegenParameter codegenParameter, String name, Schema schema, Set<String> imports, String bodyParameterName, boolean forceSimpleRef) {
if (name != null) { if (name != null) {
Schema bodySchema = new Schema().$ref("#/components/schemas/" + name); Schema bodySchema = new Schema().$ref("#/components/schemas/" + name);
Schema unaliased = unaliasSchema(bodySchema, schemaMapping); Schema unaliased = unaliasSchema(bodySchema);
if (unaliased.get$ref() != null) { if (unaliased.get$ref() != null) {
forceSimpleRef = true; forceSimpleRef = true;
} }
@ -1253,7 +1250,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
@Override @Override
public CodegenModel fromModel(String name, Schema sc) { public CodegenModel fromModel(String name, Schema sc) {
CodegenModel cm = super.fromModel(name, sc); CodegenModel cm = super.fromModel(name, sc);
Schema unaliasedSchema = unaliasSchema(sc, schemaMapping); Schema unaliasedSchema = unaliasSchema(sc);
if (unaliasedSchema != null) { if (unaliasedSchema != null) {
if (ModelUtils.isDecimalSchema(unaliasedSchema)) { // type: string, format: number if (ModelUtils.isDecimalSchema(unaliasedSchema)) { // type: string, format: number
cm.isString = false; cm.isString = false;
@ -1304,7 +1301,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
public String getModelName(Schema sc) { public String getModelName(Schema sc) {
if (sc.get$ref() != null) { if (sc.get$ref() != null) {
Schema unaliasedSchema = unaliasSchema(sc, schemaMapping); Schema unaliasedSchema = unaliasSchema(sc);
if (unaliasedSchema.get$ref() != null) { if (unaliasedSchema.get$ref() != null) {
return toModelName(ModelUtils.getSimpleRef(sc.get$ref())); return toModelName(ModelUtils.getSimpleRef(sc.get$ref()));
} }
@ -1341,7 +1338,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
if (StringUtils.isNotEmpty(p.get$ref())) { if (StringUtils.isNotEmpty(p.get$ref())) {
// The input schema is a reference. If the resolved schema is // The input schema is a reference. If the resolved schema is
// a composed schema, convert the name to a Python class. // a composed schema, convert the name to a Python class.
Schema unaliasedSchema = unaliasSchema(p, schemaMapping); Schema unaliasedSchema = unaliasSchema(p);
if (unaliasedSchema.get$ref() != null) { if (unaliasedSchema.get$ref() != null) {
String modelName = toModelName(ModelUtils.getSimpleRef(p.get$ref())); String modelName = toModelName(ModelUtils.getSimpleRef(p.get$ref()));
if (referencedModelNames != null) { if (referencedModelNames != null) {

View File

@ -885,10 +885,10 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
Schema inner; Schema inner;
if (ModelUtils.isArraySchema(p)) { if (ModelUtils.isArraySchema(p)) {
inner = ((ArraySchema) p).getItems(); inner = ((ArraySchema) p).getItems();
return this.getSchemaType(p) + "<" + this.getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, inner, schemaMapping)) + ">"; return this.getSchemaType(p) + "<" + this.getTypeDeclaration(unaliasSchema(inner)) + ">";
} else if (ModelUtils.isMapSchema(p)) { } else if (ModelUtils.isMapSchema(p)) {
inner = (Schema) p.getAdditionalProperties(); inner = (Schema) p.getAdditionalProperties();
return "{ [key: string]: " + this.getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, inner, schemaMapping)) + "; }"; return "{ [key: string]: " + this.getTypeDeclaration(unaliasSchema(inner)) + "; }";
} else if (ModelUtils.isFileSchema(p)) { } else if (ModelUtils.isFileSchema(p)) {
return "HttpFile"; return "HttpFile";
} else if (ModelUtils.isBinarySchema(p)) { } else if (ModelUtils.isBinarySchema(p)) {
@ -940,7 +940,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
public String getModelName(Schema sc) { public String getModelName(Schema sc) {
if (sc.get$ref() != null) { if (sc.get$ref() != null) {
Schema unaliasedSchema = unaliasSchema(sc, schemaMapping); Schema unaliasedSchema = unaliasSchema(sc);
if (unaliasedSchema.get$ref() != null) { if (unaliasedSchema.get$ref() != null) {
return toModelName(ModelUtils.getSimpleRef(sc.get$ref())); return toModelName(ModelUtils.getSimpleRef(sc.get$ref()));
} }

View File

@ -510,7 +510,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
} }
if (!op.hasReturnPassthroughVoid) { if (!op.hasReturnPassthroughVoid) {
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse), schemaMapping); Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse));
ExtendedCodegenProperty cp = null; ExtendedCodegenProperty cp = null;
if (op.returnPassthrough instanceof String && cm != null) { if (op.returnPassthrough instanceof String && cm != null) {
cp = (ExtendedCodegenProperty) this.processCodeGenModel(cm).vars.get(1); cp = (ExtendedCodegenProperty) this.processCodeGenModel(cm).vars.get(1);