forked from loafle/openapi-generator-original
* [typescript] Prevent generating invalid enum code due to empty variable names After sanitizing all characters (e.g. multibyte characters), the enum variable name may become an empty string. Since an empty string would cause a syntax error, this patch pads the pseudo variable name (`STRING`) to avoid that issue. For example, given the following OpenAPI definition: ```yaml openapi: "3.0.0" info: title: Sample project version: '1.0' description: 'Sample API Check "API Key" ' license: name: Apache 2.0 url: 'https://www.apache.org/licenses/LICENSE-2.0' paths: {} components: schemas: Greeting: type: string enum: - 'こんにちは' - '你好' - '안녕하세요' ``` The current logic generates the following code for Greeting: ```typescript export enum Greeting { = 'こんにちは', 2 = '你好', 3 = '안녕하세요' } ``` This code is invalid. With this patch, the generated code becomes: ```typescript export enum Greeting { STRING = 'こんにちは', STRING2 = '你好', STRING3 = '안녕하세요' } ``` Signed-off-by: moznion <moznion@mail.moznion.net> * Remove unnecessary imports Signed-off-by: moznion <moznion@mail.moznion.net> * Use new sanitizer for TypeScript symbol which takes wider variety characters for enum var name Signed-off-by: moznion <moznion@mail.moznion.net> --------- Signed-off-by: moznion <moznion@mail.moznion.net>