diff --git a/.changeset/kind-countries-press.md b/.changeset/kind-countries-press.md new file mode 100644 index 000000000..6bd578c72 --- /dev/null +++ b/.changeset/kind-countries-press.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": patch +--- + +fix: do not throw when failing to decode URI diff --git a/packages/openapi-ts/src/compiler/utils.ts b/packages/openapi-ts/src/compiler/utils.ts index 53ba0b4e4..646a5778e 100644 --- a/packages/openapi-ts/src/compiler/utils.ts +++ b/packages/openapi-ts/src/compiler/utils.ts @@ -23,7 +23,11 @@ const blankSourceFile = createSourceFile(''); */ export function tsNodeToString(node: ts.Node): string { const result = printer.printNode(ts.EmitHint.Unspecified, node, blankSourceFile); - return decodeURIComponent(result); + try { + return decodeURIComponent(result); + } catch { + return result; + } } // ots for openapi-ts is helpers to reduce repetition of basic ts factory functions.