Skip to content

Commit

Permalink
fix: escaped single letter ids generation (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael M authored Oct 27, 2023
2 parents d48c23a + aa1fe18 commit 2f52a86
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/ng-openapi-gen/src/lib/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export function refName(fullRef: string): string {

/** Escapes the name of a property / parameter if not valid JS identifier */
export function escapeId(name: string) {
// eslint-disable-next-line unicorn/better-regex
return /^[a-zA-Z]\w+$/.test(name) ? name : `'${name.replace(/'/g, "\\'")}'`;
return /^[A-Za-z]\w*$/.test(name) ? name : `'${name.replace(/'/g, "\\'")}'`;
}

/** Returns the TypeScript comments for the given schema description, in a given indentation level */
Expand Down

0 comments on commit 2f52a86

Please sign in to comment.