Skip to content

Commit 5d997f3

Browse files
jonaslagoniclaude
andcommitted
fix: add newline and carriage return escaping to escapeStringForCodeGen
Escape \n and \r characters to prevent syntax errors in generated TypeScript when OpenAPI spec values contain newlines (e.g., via YAML multi-line strings). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2cc39f0 commit 5d997f3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • src/codegen/generators/typescript/channels/protocols/http

src/codegen/generators/typescript/channels/protocols/http/security.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export function escapeStringForCodeGen(value: string | undefined): string {
1414
}
1515
return value
1616
.replace(/\\/g, '\\\\') // Escape backslashes first
17+
.replace(/\n/g, '\\n') // Escape newlines
18+
.replace(/\r/g, '\\r') // Escape carriage returns
1719
.replace(/'/g, "\\'") // Escape single quotes
1820
.replace(/`/g, '\\`') // Escape backticks
1921
.replace(/\$/g, '\\$') // Escape dollar signs (prevents ${} template evaluation)

0 commit comments

Comments
 (0)