[BUG][JAVA/TYPESCRIPT] Invalid consumes headers generated
Created by: whydoievenneedthis
Description
When image/* is specified for requestBody content type, the generated spring server and typescript client (probably others as well) end up invalid.
On spring side:
@RequestMapping(
method = RequestMethod.POST,
value = "/v1",
consumes = { "image/_*" }
)
On typescript side:
// to determine the Content-Type header
const consumes: string[] = [
'image/_*'
];
openapi-generator version
5.2.1
OpenAPI declaration file content or url
{
"paths": {
"/v1": {
"post": {
"summary": "uploadImage",
"operationId": "uploadImage",
"requestBody": {
"content": {
"image/*": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
Generation Details
Generator names were "spring" and "typescript-angular".
Suggest a fix
Tweak DefaultCodegen.addConsumesInfo. Issue is with this line:
mediaType.put("mediaType", escapeText(escapeQuotationMark(key)));
The method escapeText
is explicitly breaking /*
and */
.