hono-openapi 1.0.5 → 1.0.6
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 +17 -10
- package/dist/index.js +17 -10
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -252,6 +252,7 @@ async function generateSpecs(hono, options = DEFAULT_OPTIONS, c) {
|
|
|
252
252
|
}
|
|
253
253
|
async function generatePaths(hono, ctx) {
|
|
254
254
|
const paths = {};
|
|
255
|
+
const promises = [];
|
|
255
256
|
for (const route of hono.routes) {
|
|
256
257
|
const middlewareHandler = route.handler[uniqueSymbol];
|
|
257
258
|
if (!middlewareHandler) {
|
|
@@ -273,17 +274,20 @@ async function generatePaths(hono, ctx) {
|
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
const defaultOptionsForThisMethod = ctx.options.defaultOptions?.[routeMethod];
|
|
276
|
-
|
|
277
|
-
middlewareHandler,
|
|
278
|
-
|
|
277
|
+
promises.push(
|
|
278
|
+
getSpec(middlewareHandler, defaultOptionsForThisMethod).then(
|
|
279
|
+
({ schema: routeSpecs, components = {} }) => {
|
|
280
|
+
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
281
|
+
registerSchemaPath({
|
|
282
|
+
route,
|
|
283
|
+
specs: routeSpecs,
|
|
284
|
+
paths
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
)
|
|
279
288
|
);
|
|
280
|
-
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
281
|
-
registerSchemaPath({
|
|
282
|
-
route,
|
|
283
|
-
specs: routeSpecs,
|
|
284
|
-
paths
|
|
285
|
-
});
|
|
286
289
|
}
|
|
290
|
+
await Promise.all(promises);
|
|
287
291
|
return paths;
|
|
288
292
|
}
|
|
289
293
|
function getHiddenValue(options) {
|
|
@@ -320,7 +324,10 @@ async function getSpec(middlewareHandler, defaultOptions) {
|
|
|
320
324
|
const result2 = await raw.schema.toOpenAPISchema();
|
|
321
325
|
raw.schema = result2.schema;
|
|
322
326
|
if (result2.components) {
|
|
323
|
-
components = mergeComponentsObjects(
|
|
327
|
+
components = mergeComponentsObjects(
|
|
328
|
+
components,
|
|
329
|
+
result2.components
|
|
330
|
+
);
|
|
324
331
|
}
|
|
325
332
|
}
|
|
326
333
|
}
|
package/dist/index.js
CHANGED
|
@@ -250,6 +250,7 @@ async function generateSpecs(hono, options = DEFAULT_OPTIONS, c) {
|
|
|
250
250
|
}
|
|
251
251
|
async function generatePaths(hono, ctx) {
|
|
252
252
|
const paths = {};
|
|
253
|
+
const promises = [];
|
|
253
254
|
for (const route of hono.routes) {
|
|
254
255
|
const middlewareHandler = route.handler[uniqueSymbol];
|
|
255
256
|
if (!middlewareHandler) {
|
|
@@ -271,17 +272,20 @@ async function generatePaths(hono, ctx) {
|
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
const defaultOptionsForThisMethod = ctx.options.defaultOptions?.[routeMethod];
|
|
274
|
-
|
|
275
|
-
middlewareHandler,
|
|
276
|
-
|
|
275
|
+
promises.push(
|
|
276
|
+
getSpec(middlewareHandler, defaultOptionsForThisMethod).then(
|
|
277
|
+
({ schema: routeSpecs, components = {} }) => {
|
|
278
|
+
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
279
|
+
registerSchemaPath({
|
|
280
|
+
route,
|
|
281
|
+
specs: routeSpecs,
|
|
282
|
+
paths
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
)
|
|
277
286
|
);
|
|
278
|
-
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
279
|
-
registerSchemaPath({
|
|
280
|
-
route,
|
|
281
|
-
specs: routeSpecs,
|
|
282
|
-
paths
|
|
283
|
-
});
|
|
284
287
|
}
|
|
288
|
+
await Promise.all(promises);
|
|
285
289
|
return paths;
|
|
286
290
|
}
|
|
287
291
|
function getHiddenValue(options) {
|
|
@@ -318,7 +322,10 @@ async function getSpec(middlewareHandler, defaultOptions) {
|
|
|
318
322
|
const result2 = await raw.schema.toOpenAPISchema();
|
|
319
323
|
raw.schema = result2.schema;
|
|
320
324
|
if (result2.components) {
|
|
321
|
-
components = mergeComponentsObjects(
|
|
325
|
+
components = mergeComponentsObjects(
|
|
326
|
+
components,
|
|
327
|
+
result2.components
|
|
328
|
+
);
|
|
322
329
|
}
|
|
323
330
|
}
|
|
324
331
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono-openapi",
|
|
3
3
|
"description": "OpenAPI schema generator for Hono",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -63,6 +63,9 @@
|
|
|
63
63
|
"@valibot/to-json-schema": "^1.3.0",
|
|
64
64
|
"arktype": "^2.1.22",
|
|
65
65
|
"effect": "^3.17.13",
|
|
66
|
+
"husky": "^9.1.7",
|
|
67
|
+
"is-ci": "^4.1.0",
|
|
68
|
+
"nano-staged": "^0.8.0",
|
|
66
69
|
"pkgroll": "^2.13.1",
|
|
67
70
|
"typescript": "^5.8.3",
|
|
68
71
|
"valibot": "^1.1.0",
|