swaggie 2.1.2 → 2.1.3
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/dist/gen/genOperations.js +25 -12
- package/package.json +5 -5
|
@@ -623,23 +623,36 @@ const PRIMITIVES =
|
|
|
623
623
|
* and inline object types (including PascalCase names used as property value types
|
|
624
624
|
* inside `{ key: SomeType }` shapes).
|
|
625
625
|
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
* @example prefixApiType('
|
|
631
|
-
* @example prefixApiType('
|
|
632
|
-
* @example prefixApiType('
|
|
626
|
+
* Quoted string literals (single or double) are left entirely untouched so that
|
|
627
|
+
* enum-derived types like `"AZURE" | "AWS"` are never incorrectly rewritten to
|
|
628
|
+
* `"API.AZURE" | "API.AWS"`.
|
|
629
|
+
*
|
|
630
|
+
* @example prefixApiType('Pet') → 'API.Pet'
|
|
631
|
+
* @example prefixApiType('Pet[]') → 'API.Pet[]'
|
|
632
|
+
* @example prefixApiType('Pet | null') → 'API.Pet | null'
|
|
633
|
+
* @example prefixApiType('unknown') → 'unknown'
|
|
634
|
+
* @example prefixApiType('{ id: number }') → '{ id: number }'
|
|
635
|
+
* @example prefixApiType('{ profile: MyEnum; }') → '{ profile: API.MyEnum; }'
|
|
636
|
+
* @example prefixApiType('API.Pet') → 'API.Pet'
|
|
637
|
+
* @example prefixApiType('"AZURE" | "AWS"') → '"AZURE" | "AWS"'
|
|
638
|
+
* @example prefixApiType('"available" | Pet') → '"available" | API.Pet'
|
|
633
639
|
*/
|
|
634
640
|
function prefixApiType(typeStr) {
|
|
635
641
|
if (!typeStr) {
|
|
636
642
|
return typeStr;
|
|
637
643
|
}
|
|
638
|
-
// The
|
|
639
|
-
//
|
|
640
|
-
//
|
|
641
|
-
|
|
642
|
-
|
|
644
|
+
// The alternation has two branches:
|
|
645
|
+
// Group 1: a full quoted string literal ("..." or '...') — returned as-is so
|
|
646
|
+
// that enum-derived values like "AZURE" are never prefixed.
|
|
647
|
+
// Group 2: an uppercase-starting identifier that is NOT already preceded by a
|
|
648
|
+
// dot (negative lookbehind) — prefixed with API. unless it is a known
|
|
649
|
+
// primitive / built-in.
|
|
650
|
+
return typeStr.replace(
|
|
651
|
+
/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|(?<!\.)\b([A-Z][A-Za-z0-9_]*)\b/g,
|
|
652
|
+
(match, quotedLiteral, ident) => {
|
|
653
|
+
if (quotedLiteral !== undefined) return quotedLiteral;
|
|
654
|
+
return PRIMITIVES.test(ident) ? ident : `API.${ident}`;
|
|
655
|
+
},
|
|
643
656
|
);
|
|
644
657
|
} exports.prefixApiType = prefixApiType;
|
|
645
658
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swaggie",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Generate a fully typed TypeScript API client from your OpenAPI 3 spec",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Piotr Dabrowski",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"case": "^1.6.3",
|
|
74
74
|
"commander": "^14.0.3",
|
|
75
|
-
"eta": "^4.
|
|
75
|
+
"eta": "^4.6.0",
|
|
76
76
|
"yaml": "^2.8.3",
|
|
77
77
|
"picocolors": "^1.1.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"bun-types": "1.3.
|
|
80
|
+
"bun-types": "1.3.13",
|
|
81
81
|
"openapi-types": "^12.1.3",
|
|
82
82
|
"sucrase": "3.35.1",
|
|
83
|
-
"typescript": "6.0.
|
|
83
|
+
"typescript": "6.0.3",
|
|
84
84
|
"vitepress": "^2.0.0-alpha.17",
|
|
85
|
-
"vitepress-plugin-tabs": "0.
|
|
85
|
+
"vitepress-plugin-tabs": "0.9.0"
|
|
86
86
|
}
|
|
87
87
|
}
|