@ng-forge/openapi-generator 1.2.0-next.1 → 1.2.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/ng-forge-generator.js +5 -5
- package/package.json +5 -5
- package/src/index.js +5 -5
- package/src/utils/naming.d.ts +3 -1
- package/src/utils/naming.d.ts.map +1 -1
|
@@ -307,7 +307,7 @@ function mapSchemaToValidators(schema, required) {
|
|
|
307
307
|
|
|
308
308
|
// packages/openapi-generator/src/utils/naming.ts
|
|
309
309
|
function toLabel(name) {
|
|
310
|
-
return name.replace(/(
|
|
310
|
+
return name.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2").replace(/[_-]/g, " ").replace(/(^|\s)(\p{L})/gu, (_, separator, letter) => separator + letter.toUpperCase()).trim();
|
|
311
311
|
}
|
|
312
312
|
var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
|
|
313
313
|
"id",
|
|
@@ -355,14 +355,14 @@ var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
|
|
|
355
355
|
"cd"
|
|
356
356
|
]);
|
|
357
357
|
function toEnumLabel(value) {
|
|
358
|
-
if (
|
|
358
|
+
if (/^\p{Lu}[\p{Lu}\p{N}_-]*$/u.test(value)) {
|
|
359
359
|
if (value.length <= 3 && !/[_-]/.test(value)) {
|
|
360
360
|
return value;
|
|
361
361
|
}
|
|
362
362
|
value = value.toLowerCase();
|
|
363
363
|
}
|
|
364
364
|
const label = toLabel(value);
|
|
365
|
-
return label.replace(
|
|
365
|
+
return label.replace(/[\p{L}\p{N}]+/gu, (word) => {
|
|
366
366
|
if (KNOWN_ACRONYMS.has(word.toLowerCase())) {
|
|
367
367
|
return word.toUpperCase();
|
|
368
368
|
}
|
|
@@ -370,14 +370,14 @@ function toEnumLabel(value) {
|
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
function toPascalCase(str) {
|
|
373
|
-
return str.replace(/([
|
|
373
|
+
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("");
|
|
374
374
|
}
|
|
375
375
|
function toCamelCase(str) {
|
|
376
376
|
const pascal = toPascalCase(str);
|
|
377
377
|
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
378
378
|
}
|
|
379
379
|
function toKebabCase(str) {
|
|
380
|
-
return str.replace(/(
|
|
380
|
+
return str.replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/[^\p{L}\p{N}]/gu, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, "");
|
|
381
381
|
}
|
|
382
382
|
function cleanPathParams(path, prefix) {
|
|
383
383
|
let result = "";
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-forge/openapi-generator",
|
|
3
|
-
"version": "1.2.0-next.
|
|
3
|
+
"version": "1.2.0-next.10",
|
|
4
4
|
"description": "Generate @ng-forge/dynamic-forms configurations from OpenAPI specs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "ng-forge",
|
|
8
|
-
"homepage": "https://ng-forge.com/dynamic-forms/openapi-generator",
|
|
8
|
+
"homepage": "https://ng-forge.com/dynamic-forms/material/openapi-generator",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/ng-forge/ng-forge.git",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@apidevtools/swagger-parser": "^
|
|
49
|
-
"commander": "^
|
|
48
|
+
"@apidevtools/swagger-parser": "^13.0.0",
|
|
49
|
+
"commander": "^15.0.0",
|
|
50
50
|
"@inquirer/prompts": "^8.3.0",
|
|
51
51
|
"chokidar": "^5.0.0",
|
|
52
|
-
"chalk": "^
|
|
52
|
+
"chalk": "^6.0.0",
|
|
53
53
|
"openapi-types": "^12.1.3"
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/index.js
CHANGED
|
@@ -299,7 +299,7 @@ function mapSchemaToValidators(schema, required) {
|
|
|
299
299
|
|
|
300
300
|
// packages/openapi-generator/src/utils/naming.ts
|
|
301
301
|
function toLabel(name) {
|
|
302
|
-
return name.replace(/(
|
|
302
|
+
return name.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2").replace(/[_-]/g, " ").replace(/(^|\s)(\p{L})/gu, (_, separator, letter) => separator + letter.toUpperCase()).trim();
|
|
303
303
|
}
|
|
304
304
|
var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
|
|
305
305
|
"id",
|
|
@@ -347,14 +347,14 @@ var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
|
|
|
347
347
|
"cd"
|
|
348
348
|
]);
|
|
349
349
|
function toEnumLabel(value) {
|
|
350
|
-
if (
|
|
350
|
+
if (/^\p{Lu}[\p{Lu}\p{N}_-]*$/u.test(value)) {
|
|
351
351
|
if (value.length <= 3 && !/[_-]/.test(value)) {
|
|
352
352
|
return value;
|
|
353
353
|
}
|
|
354
354
|
value = value.toLowerCase();
|
|
355
355
|
}
|
|
356
356
|
const label = toLabel(value);
|
|
357
|
-
return label.replace(
|
|
357
|
+
return label.replace(/[\p{L}\p{N}]+/gu, (word) => {
|
|
358
358
|
if (KNOWN_ACRONYMS.has(word.toLowerCase())) {
|
|
359
359
|
return word.toUpperCase();
|
|
360
360
|
}
|
|
@@ -362,14 +362,14 @@ function toEnumLabel(value) {
|
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
function toPascalCase(str) {
|
|
365
|
-
return str.replace(/([
|
|
365
|
+
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("");
|
|
366
366
|
}
|
|
367
367
|
function toCamelCase(str) {
|
|
368
368
|
const pascal = toPascalCase(str);
|
|
369
369
|
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
370
370
|
}
|
|
371
371
|
function toKebabCase(str) {
|
|
372
|
-
return str.replace(/(
|
|
372
|
+
return str.replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/[^\p{L}\p{N}]/gu, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, "");
|
|
373
373
|
}
|
|
374
374
|
function cleanPathParams(path, prefix) {
|
|
375
375
|
let result = "";
|
package/src/utils/naming.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ export declare function toLabel(name: string): string;
|
|
|
11
11
|
export declare function toEnumLabel(value: string): string;
|
|
12
12
|
/**
|
|
13
13
|
* Convert a string to PascalCase.
|
|
14
|
-
*
|
|
14
|
+
* Letters outside ASCII are kept — they are valid in TypeScript identifiers, and
|
|
15
|
+
* dropping them would collapse names that differ only by a diacritic.
|
|
16
|
+
* Examples: "create pet" → "CreatePet", "POST:/pets" → "PostPets", "größe" → "Größe"
|
|
15
17
|
*/
|
|
16
18
|
export declare function toPascalCase(str: string): string;
|
|
17
19
|
/** Convert a string to camelCase. */
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;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"}
|