@kizunajs/openapi 2.0.0-beta.16 → 2.0.0-beta.18
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/index.cjs +23 -14
- package/dist/index.mjs +23 -14
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -169,7 +169,7 @@ const deriveHeadOperation = (getOperation) => {
|
|
|
169
169
|
const openApiWalk = (options, api) => {
|
|
170
170
|
const paths = {};
|
|
171
171
|
return {
|
|
172
|
-
processRoute({ routeKey, route,
|
|
172
|
+
processRoute({ routeKey, route, routeGroups, deprecated, hidden }) {
|
|
173
173
|
if (hidden && options.includeHidden !== true) return;
|
|
174
174
|
const openApiPath = convertPath(route.path);
|
|
175
175
|
const method = route.method.toLowerCase();
|
|
@@ -180,9 +180,8 @@ const openApiWalk = (options, api) => {
|
|
|
180
180
|
};
|
|
181
181
|
if (options.setOperationId) operation.operationId = options.setOperationId === "concatenated-path" ? routeKey : routeKey.slice(routeKey.lastIndexOf(".") + 1);
|
|
182
182
|
if (deprecated) operation.deprecated = true;
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
if (mergedTags.length > 0) operation.tags = mergedTags;
|
|
183
|
+
const tags = [...new Set(routeGroups.flatMap((group) => options.groupTags?.get(group) ?? [group]))];
|
|
184
|
+
if (tags.length > 0) operation.tags = tags;
|
|
186
185
|
if (route.security && route.security.length > 0) {
|
|
187
186
|
const emittedSecurity = toOpenApiSecurity(route.security, api);
|
|
188
187
|
if (emittedSecurity.length > 0) operation.security = emittedSecurity;
|
|
@@ -443,19 +442,29 @@ const buildSecuritySchemes = (api) => {
|
|
|
443
442
|
}
|
|
444
443
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
445
444
|
};
|
|
446
|
-
const buildTagLookup = (api) => new Map(Object.entries(api.tags?.tags ?? {}));
|
|
447
445
|
/**
|
|
448
|
-
*
|
|
449
|
-
*
|
|
446
|
+
* The tag for each group path: its top-level group's title, since OpenAPI 3.1.0
|
|
447
|
+
* has no nested tags.
|
|
448
|
+
*/
|
|
449
|
+
const buildGroupTags = (api) => {
|
|
450
|
+
const groups = api.groups?.groups;
|
|
451
|
+
const tags = /* @__PURE__ */ new Map();
|
|
452
|
+
if (!groups) return tags;
|
|
453
|
+
for (const group of groups.values()) tags.set(group.path, [groups.get(group.lineage[0]).title]);
|
|
454
|
+
return tags;
|
|
455
|
+
};
|
|
456
|
+
/**
|
|
457
|
+
* One tag per top-level group.
|
|
450
458
|
*/
|
|
451
459
|
const tagsFromApi = (api) => {
|
|
452
|
-
const
|
|
453
|
-
if (!
|
|
460
|
+
const groups = api.groups?.groups;
|
|
461
|
+
if (!groups) return [];
|
|
454
462
|
const tags = [];
|
|
455
|
-
for (const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if (
|
|
463
|
+
for (const group of groups.values()) {
|
|
464
|
+
if (group.lineage.length > 1) continue;
|
|
465
|
+
const entry = { name: group.title };
|
|
466
|
+
if (group.description) entry.description = group.description;
|
|
467
|
+
if (group.externalDocs) entry.externalDocs = group.externalDocs;
|
|
459
468
|
tags.push(entry);
|
|
460
469
|
}
|
|
461
470
|
return tags;
|
|
@@ -473,7 +482,7 @@ const optionsFromInstalledPlugin = (api) => {
|
|
|
473
482
|
function renderOpenApi(api, options) {
|
|
474
483
|
const renderer = (0, kizunajs_generator.walkApi)(api, openApiWalk({
|
|
475
484
|
...options,
|
|
476
|
-
|
|
485
|
+
groupTags: buildGroupTags(api)
|
|
477
486
|
}, api));
|
|
478
487
|
const tags = tagsFromApi(api);
|
|
479
488
|
if (tags.length > 0) renderer("json").tags = tags;
|
package/dist/index.mjs
CHANGED
|
@@ -168,7 +168,7 @@ const deriveHeadOperation = (getOperation) => {
|
|
|
168
168
|
const openApiWalk = (options, api) => {
|
|
169
169
|
const paths = {};
|
|
170
170
|
return {
|
|
171
|
-
processRoute({ routeKey, route,
|
|
171
|
+
processRoute({ routeKey, route, routeGroups, deprecated, hidden }) {
|
|
172
172
|
if (hidden && options.includeHidden !== true) return;
|
|
173
173
|
const openApiPath = convertPath(route.path);
|
|
174
174
|
const method = route.method.toLowerCase();
|
|
@@ -179,9 +179,8 @@ const openApiWalk = (options, api) => {
|
|
|
179
179
|
};
|
|
180
180
|
if (options.setOperationId) operation.operationId = options.setOperationId === "concatenated-path" ? routeKey : routeKey.slice(routeKey.lastIndexOf(".") + 1);
|
|
181
181
|
if (deprecated) operation.deprecated = true;
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
if (mergedTags.length > 0) operation.tags = mergedTags;
|
|
182
|
+
const tags = [...new Set(routeGroups.flatMap((group) => options.groupTags?.get(group) ?? [group]))];
|
|
183
|
+
if (tags.length > 0) operation.tags = tags;
|
|
185
184
|
if (route.security && route.security.length > 0) {
|
|
186
185
|
const emittedSecurity = toOpenApiSecurity(route.security, api);
|
|
187
186
|
if (emittedSecurity.length > 0) operation.security = emittedSecurity;
|
|
@@ -442,19 +441,29 @@ const buildSecuritySchemes = (api) => {
|
|
|
442
441
|
}
|
|
443
442
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
444
443
|
};
|
|
445
|
-
const buildTagLookup = (api) => new Map(Object.entries(api.tags?.tags ?? {}));
|
|
446
444
|
/**
|
|
447
|
-
*
|
|
448
|
-
*
|
|
445
|
+
* The tag for each group path: its top-level group's title, since OpenAPI 3.1.0
|
|
446
|
+
* has no nested tags.
|
|
447
|
+
*/
|
|
448
|
+
const buildGroupTags = (api) => {
|
|
449
|
+
const groups = api.groups?.groups;
|
|
450
|
+
const tags = /* @__PURE__ */ new Map();
|
|
451
|
+
if (!groups) return tags;
|
|
452
|
+
for (const group of groups.values()) tags.set(group.path, [groups.get(group.lineage[0]).title]);
|
|
453
|
+
return tags;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* One tag per top-level group.
|
|
449
457
|
*/
|
|
450
458
|
const tagsFromApi = (api) => {
|
|
451
|
-
const
|
|
452
|
-
if (!
|
|
459
|
+
const groups = api.groups?.groups;
|
|
460
|
+
if (!groups) return [];
|
|
453
461
|
const tags = [];
|
|
454
|
-
for (const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (
|
|
462
|
+
for (const group of groups.values()) {
|
|
463
|
+
if (group.lineage.length > 1) continue;
|
|
464
|
+
const entry = { name: group.title };
|
|
465
|
+
if (group.description) entry.description = group.description;
|
|
466
|
+
if (group.externalDocs) entry.externalDocs = group.externalDocs;
|
|
458
467
|
tags.push(entry);
|
|
459
468
|
}
|
|
460
469
|
return tags;
|
|
@@ -472,7 +481,7 @@ const optionsFromInstalledPlugin = (api) => {
|
|
|
472
481
|
function renderOpenApi(api, options) {
|
|
473
482
|
const renderer = walkApi(api, openApiWalk({
|
|
474
483
|
...options,
|
|
475
|
-
|
|
484
|
+
groupTags: buildGroupTags(api)
|
|
476
485
|
}, api));
|
|
477
486
|
const tags = tagsFromApi(api);
|
|
478
487
|
if (tags.length > 0) renderer("json").tags = tags;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizunajs/openapi",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.18",
|
|
4
4
|
"description": "OpenAPI 3.1 generation for Kizuna.js APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kizunajs",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"yaml": "^2.8.4"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"kizunajs": "2.0.0-beta.
|
|
62
|
+
"kizunajs": "2.0.0-beta.18",
|
|
63
63
|
"zod": "^4.0.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"kizunajs": "2.0.0-beta.
|
|
67
|
-
"@kizunajs/express": "2.0.0-beta.
|
|
66
|
+
"kizunajs": "2.0.0-beta.18",
|
|
67
|
+
"@kizunajs/express": "2.0.0-beta.18",
|
|
68
68
|
"@types/express": "^5.0.0",
|
|
69
69
|
"express": "^5.0.0",
|
|
70
70
|
"tsdown": "^0.21.0",
|