openapi-typescript-codegen
openapi-typescript-codegen copied to clipboard
Invalid enum name generation for property names containing hyphens
Describe the bug
Invalid enum name generation for property names containing hyphens.
Sample api:
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0"
},
"components": {
"schemas": {
"TestModel": {
"properties": {
"rates": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Testing"
}
}
}
},
"Testing": {
"properties": {
"test-hyphen": {
"type": "string",
"enum": ["First", "Second"]
}
}
}
}
}
}
Output Testing.ts:
export type Testing = {
'test-hyphen'?: Testing.'test-hyphen';
};
export namespace Testing {
export enum 'test-hyphen' {
FIRST = 'First',
SECOND = 'Second',
}
}
Hitting the same issue when trying to generate code from Flink OpenAPI
https://nightlies.apache.org/flink/flink-docs-release-1.15/generated/rest_v1_dispatcher.yml
I don't own this OpenAPI, so I can't add x-enum-varnames to workaround it.
Perhaps there can be a logic to automatically convert such names to CamelCase?