Closed xtyrrell closed 3 days ago
Start a new pull request in StackBlitz Codeflow.
Hey @xtyrrell, thanks for reporting. Which approach would you choose if you were to fix it manually in your code?
I would use backticks to quote strings that contain newlines, and leave other strings as is.
@xtyrrell this works as expected in the experimental parser, so I will mark this as resolved!
Description
An OpenAPI schema that includes a
const
with newlines is not processed correctly.open-api-ts
produces an invalidtypes.gen.ts
.For example, the following schema (at DEFAULT_INSTRUCTIONS):
produces this invalid
types.gen.ts
file.This is invalid because a double-quote quoted string cannot contain newlines in TypeScript.
A fix for this could be using
`
backtick characters, which are allowed to contain newlines in TypeScript, rather than"
double quotes. If minimising changes to generated files is a goal, this could be done only for those const values which include newlines (leaving others to use double quotes).Reproducible example or configuration
https://stackblitz.com/edit/hey-api-example-qyowue?file=src%2Fclient%2Ftypes.gen.ts