Enum values with trailing white space are trimmed #1224
Labels
bug
Something isn't working
good first issue
Straightforward problem, solvable for first-time contributors without deep knowledge of the project
openapi-ts
Relevant to the openapi-typescript library
PRs welcome
PRs are welcome to solve this issue!
Description
In OpenAPI, it is possible to define an enum type, with different string constants as its values. These string constants might contain trailing white space, or in the extreme case consist of only white space.
Example OpenAPI YAML:
Currently, when
openapi-typescript
generates types for such enums, any trailing whitespace is trimmed.Example resulting Typescript Type with current bug:
Expected behaviour for resulting Typescript Type:
Currently, the generated type does not match the OpenAPI spec, and as a result type checking cannot be done, and in fact generates false positive errors.
Reproduction
This occurs for any enum with string values containing trailing white space.
It seems that the trimming occurs here in the code.
Resolution
If the maintainers agree that the current behaviour should be considered as a bug, I'm happy to open an MR with unit tests for this scenario and implement a fix.
Checklist
npx @redocly/cli@latest lint
)The text was updated successfully, but these errors were encountered: