Bug Report Checklist
Foo:
type: object
properties:
msg:
type: string
format: binary
The generator produces msg with the type Blob.
Regardless of the various mappings I attempt to set, I cannot find the correct mapping declaration to ensure that this is instead mapped to string. The obvious typeMapping file=string should work, but it's overriden in code here: https://github.com/OpenAPITools/openapi-generator/blob/v4.0.2/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java#L282
I would like to generate the following:
class Foo {
msg: string;
}
I'm migrating from the io.swagger tool and would like to avoid breaking changes. Blob breaks existing code.
Suggest a fix
If I were to have a stab at this, I think the complete removal of the overriding method would be enough: https://github.com/OpenAPITools/openapi-generator/blob/v4.0.2/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java#L280
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isFileSchema(p)) {
return "Blob";
} else {
return super.getTypeDeclaration(p);
}
}
The correct default behaviour should already be provided with the typeMapping in the constructor:
typeMapping.put("file", "Blob");
However, there is so much going on here, I just can't guesstimate what else this might effect. Such as this method:
@Override
public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals("Blob");
}
Bug Report Checklist
The generator produces
msgwith the typeBlob.Regardless of the various mappings I attempt to set, I cannot find the correct mapping declaration to ensure that this is instead mapped to string. The obvious typeMapping
file=stringshould work, but it's overriden in code here: https://github.com/OpenAPITools/openapi-generator/blob/v4.0.2/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java#L282Have you validated the input using an OpenAPI validator (example)?
Yes
What's the version of OpenAPI Generator used?
4.0.2
Have you search for related issues/PRs?
The keyword blob returns too many deep links into github code. So I looked at the code.
What's the actual output vs expected output?
I would like to generate the following:
I'm migrating from the
io.swaggertool and would like to avoid breaking changes.Blobbreaks existing code.Suggest a fix
If I were to have a stab at this, I think the complete removal of the overriding method would be enough: https://github.com/OpenAPITools/openapi-generator/blob/v4.0.2/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java#L280
The correct default behaviour should already be provided with the typeMapping in the constructor:
However, there is so much going on here, I just can't guesstimate what else this might effect. Such as this method: