@ng-forge/openapi-generator
Advanced tools
@@ -310,3 +310,3 @@ #!/usr/bin/env node | ||
| function toLabel(name) { | ||
| return name.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).trim(); | ||
| return name.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2").replace(/[_-]/g, " ").replace(/(^|\s)(\p{L})/gu, (_, separator, letter) => separator + letter.toUpperCase()).trim(); | ||
| } | ||
@@ -359,3 +359,3 @@ var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([ | ||
| function toEnumLabel(value) { | ||
| if (/^[A-Z][A-Z0-9_-]*$/.test(value)) { | ||
| if (/^\p{Lu}[\p{Lu}\p{N}_-]*$/u.test(value)) { | ||
| if (value.length <= 3 && !/[_-]/.test(value)) { | ||
@@ -367,3 +367,3 @@ return value; | ||
| const label = toLabel(value); | ||
| return label.replace(/\b\w+\b/g, (word) => { | ||
| return label.replace(/[\p{L}\p{N}]+/gu, (word) => { | ||
| if (KNOWN_ACRONYMS.has(word.toLowerCase())) { | ||
@@ -376,3 +376,3 @@ return word.toUpperCase(); | ||
| function toPascalCase(str) { | ||
| return str.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[^a-zA-Z0-9]/g, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(""); | ||
| return str.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, "$1 $2").replace(/[^\p{L}\p{N}]/gu, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(""); | ||
| } | ||
@@ -384,3 +384,3 @@ function toCamelCase(str) { | ||
| function toKebabCase(str) { | ||
| return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, ""); | ||
| return str.replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/[^\p{L}\p{N}]/gu, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, ""); | ||
| } | ||
@@ -387,0 +387,0 @@ function cleanPathParams(path, prefix) { |
+1
-1
| { | ||
| "name": "@ng-forge/openapi-generator", | ||
| "version": "1.2.0-next.1", | ||
| "version": "1.2.0-next.2", | ||
| "description": "Generate @ng-forge/dynamic-forms configurations from OpenAPI specs", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+5
-5
@@ -302,3 +302,3 @@ // packages/openapi-generator/src/parser/openapi-parser.ts | ||
| function toLabel(name) { | ||
| return name.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).trim(); | ||
| return name.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2").replace(/[_-]/g, " ").replace(/(^|\s)(\p{L})/gu, (_, separator, letter) => separator + letter.toUpperCase()).trim(); | ||
| } | ||
@@ -351,3 +351,3 @@ var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([ | ||
| function toEnumLabel(value) { | ||
| if (/^[A-Z][A-Z0-9_-]*$/.test(value)) { | ||
| if (/^\p{Lu}[\p{Lu}\p{N}_-]*$/u.test(value)) { | ||
| if (value.length <= 3 && !/[_-]/.test(value)) { | ||
@@ -359,3 +359,3 @@ return value; | ||
| const label = toLabel(value); | ||
| return label.replace(/\b\w+\b/g, (word) => { | ||
| return label.replace(/[\p{L}\p{N}]+/gu, (word) => { | ||
| if (KNOWN_ACRONYMS.has(word.toLowerCase())) { | ||
@@ -368,3 +368,3 @@ return word.toUpperCase(); | ||
| function toPascalCase(str) { | ||
| return str.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[^a-zA-Z0-9]/g, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(""); | ||
| return str.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, "$1 $2").replace(/[^\p{L}\p{N}]/gu, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(""); | ||
| } | ||
@@ -376,3 +376,3 @@ function toCamelCase(str) { | ||
| function toKebabCase(str) { | ||
| return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, ""); | ||
| return str.replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/[^\p{L}\p{N}]/gu, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, ""); | ||
| } | ||
@@ -379,0 +379,0 @@ function cleanPathParams(path, prefix) { |
@@ -14,3 +14,5 @@ /** | ||
| * Convert a string to PascalCase. | ||
| * Examples: "create pet" → "CreatePet", "POST:/pets" → "PostPets" | ||
| * Letters outside ASCII are kept — they are valid in TypeScript identifiers, and | ||
| * dropping them would collapse names that differ only by a diacritic. | ||
| * Examples: "create pet" → "CreatePet", "POST:/pets" → "PostPets", "größe" → "Größe" | ||
| */ | ||
@@ -17,0 +19,0 @@ export declare function toPascalCase(str: string): string; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../../../packages/openapi-generator/src/utils/naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AAiDD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED,qCAAqC;AACrC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO/C;AA0BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAM3F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAMzF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAM1F"} | ||
| {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../../../packages/openapi-generator/src/utils/naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AAiDD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBjD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED,qCAAqC;AACrC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO/C;AA0BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAM3F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAMzF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAM1F"} |
163967
0.21%3431
0.06%