hono-openapi 1.0.6 → 1.0.8
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 +9 -13
- package/dist/index.d.cts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +9 -13
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -252,7 +252,6 @@ async function generateSpecs(hono, options = DEFAULT_OPTIONS, c) {
|
|
|
252
252
|
}
|
|
253
253
|
async function generatePaths(hono, ctx) {
|
|
254
254
|
const paths = {};
|
|
255
|
-
const promises = [];
|
|
256
255
|
for (const route of hono.routes) {
|
|
257
256
|
const middlewareHandler = route.handler[uniqueSymbol];
|
|
258
257
|
if (!middlewareHandler) {
|
|
@@ -274,20 +273,17 @@ async function generatePaths(hono, ctx) {
|
|
|
274
273
|
}
|
|
275
274
|
}
|
|
276
275
|
const defaultOptionsForThisMethod = ctx.options.defaultOptions?.[routeMethod];
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
281
|
-
registerSchemaPath({
|
|
282
|
-
route,
|
|
283
|
-
specs: routeSpecs,
|
|
284
|
-
paths
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
)
|
|
276
|
+
const { schema: routeSpecs, components = {} } = await getSpec(
|
|
277
|
+
middlewareHandler,
|
|
278
|
+
defaultOptionsForThisMethod
|
|
288
279
|
);
|
|
280
|
+
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
281
|
+
registerSchemaPath({
|
|
282
|
+
route,
|
|
283
|
+
specs: routeSpecs,
|
|
284
|
+
paths
|
|
285
|
+
});
|
|
289
286
|
}
|
|
290
|
-
await Promise.all(promises);
|
|
291
287
|
return paths;
|
|
292
288
|
}
|
|
293
289
|
function getHiddenValue(options) {
|
package/dist/index.d.cts
CHANGED
|
@@ -2,9 +2,9 @@ import * as openapi_types from 'openapi-types';
|
|
|
2
2
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
3
3
|
import { Env, Input, Context, Next, MiddlewareHandler, ValidationTargets, Hono } from 'hono';
|
|
4
4
|
import { TypedResponse, RouterRoute, ValidationTargets as ValidationTargets$1, BlankEnv, Input as Input$1, BlankInput, Schema, BlankSchema, MiddlewareHandler as MiddlewareHandler$1 } from 'hono/types';
|
|
5
|
+
import { loadVendor as loadVendor$2, ToOpenAPISchemaContext } from '@standard-community/standard-openapi';
|
|
5
6
|
import { Hook } from '@hono/standard-validator';
|
|
6
7
|
import { loadVendor as loadVendor$1 } from '@standard-community/standard-json';
|
|
7
|
-
import { loadVendor as loadVendor$2 } from '@standard-community/standard-openapi';
|
|
8
8
|
import { StatusCode } from 'hono/utils/http-status';
|
|
9
9
|
import { JSONSchema7 } from 'json-schema';
|
|
10
10
|
|
|
@@ -143,9 +143,7 @@ type ResolverReturnType = ReturnType<typeof resolver> & {
|
|
|
143
143
|
* Override the media type of the request body, if not specified, it will be `application/json` for `json` target and `multipart/form-data` for `form` target.
|
|
144
144
|
*/
|
|
145
145
|
media?: string;
|
|
146
|
-
} &
|
|
147
|
-
[key: string]: unknown;
|
|
148
|
-
};
|
|
146
|
+
} & Partial<ToOpenAPISchemaContext>;
|
|
149
147
|
};
|
|
150
148
|
type HandlerUniqueProperty = (ResolverReturnType & {
|
|
151
149
|
target: keyof ValidationTargets$1;
|
|
@@ -191,7 +189,7 @@ type GenerateSpecOptions = {
|
|
|
191
189
|
defaultOptions: Partial<Record<AllowedMethods | "ALL", DescribeRouteOptions>>;
|
|
192
190
|
};
|
|
193
191
|
type OperationId = string | ((route: RouterRoute) => string);
|
|
194
|
-
type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "
|
|
192
|
+
type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "operationId"> & {
|
|
195
193
|
operationId?: OperationId;
|
|
196
194
|
/**
|
|
197
195
|
* Pass `true` to hide route from OpenAPI/swagger document
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import * as openapi_types from 'openapi-types';
|
|
|
2
2
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
3
3
|
import { Env, Input, Context, Next, MiddlewareHandler, ValidationTargets, Hono } from 'hono';
|
|
4
4
|
import { TypedResponse, RouterRoute, ValidationTargets as ValidationTargets$1, BlankEnv, Input as Input$1, BlankInput, Schema, BlankSchema, MiddlewareHandler as MiddlewareHandler$1 } from 'hono/types';
|
|
5
|
+
import { loadVendor as loadVendor$2, ToOpenAPISchemaContext } from '@standard-community/standard-openapi';
|
|
5
6
|
import { Hook } from '@hono/standard-validator';
|
|
6
7
|
import { loadVendor as loadVendor$1 } from '@standard-community/standard-json';
|
|
7
|
-
import { loadVendor as loadVendor$2 } from '@standard-community/standard-openapi';
|
|
8
8
|
import { StatusCode } from 'hono/utils/http-status';
|
|
9
9
|
import { JSONSchema7 } from 'json-schema';
|
|
10
10
|
|
|
@@ -143,9 +143,7 @@ type ResolverReturnType = ReturnType<typeof resolver> & {
|
|
|
143
143
|
* Override the media type of the request body, if not specified, it will be `application/json` for `json` target and `multipart/form-data` for `form` target.
|
|
144
144
|
*/
|
|
145
145
|
media?: string;
|
|
146
|
-
} &
|
|
147
|
-
[key: string]: unknown;
|
|
148
|
-
};
|
|
146
|
+
} & Partial<ToOpenAPISchemaContext>;
|
|
149
147
|
};
|
|
150
148
|
type HandlerUniqueProperty = (ResolverReturnType & {
|
|
151
149
|
target: keyof ValidationTargets$1;
|
|
@@ -191,7 +189,7 @@ type GenerateSpecOptions = {
|
|
|
191
189
|
defaultOptions: Partial<Record<AllowedMethods | "ALL", DescribeRouteOptions>>;
|
|
192
190
|
};
|
|
193
191
|
type OperationId = string | ((route: RouterRoute) => string);
|
|
194
|
-
type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "
|
|
192
|
+
type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "operationId"> & {
|
|
195
193
|
operationId?: OperationId;
|
|
196
194
|
/**
|
|
197
195
|
* Pass `true` to hide route from OpenAPI/swagger document
|
package/dist/index.js
CHANGED
|
@@ -250,7 +250,6 @@ async function generateSpecs(hono, options = DEFAULT_OPTIONS, c) {
|
|
|
250
250
|
}
|
|
251
251
|
async function generatePaths(hono, ctx) {
|
|
252
252
|
const paths = {};
|
|
253
|
-
const promises = [];
|
|
254
253
|
for (const route of hono.routes) {
|
|
255
254
|
const middlewareHandler = route.handler[uniqueSymbol];
|
|
256
255
|
if (!middlewareHandler) {
|
|
@@ -272,20 +271,17 @@ async function generatePaths(hono, ctx) {
|
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
273
|
const defaultOptionsForThisMethod = ctx.options.defaultOptions?.[routeMethod];
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
279
|
-
registerSchemaPath({
|
|
280
|
-
route,
|
|
281
|
-
specs: routeSpecs,
|
|
282
|
-
paths
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
)
|
|
274
|
+
const { schema: routeSpecs, components = {} } = await getSpec(
|
|
275
|
+
middlewareHandler,
|
|
276
|
+
defaultOptionsForThisMethod
|
|
286
277
|
);
|
|
278
|
+
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
279
|
+
registerSchemaPath({
|
|
280
|
+
route,
|
|
281
|
+
specs: routeSpecs,
|
|
282
|
+
paths
|
|
283
|
+
});
|
|
287
284
|
}
|
|
288
|
-
await Promise.all(promises);
|
|
289
285
|
return paths;
|
|
290
286
|
}
|
|
291
287
|
function getHiddenValue(options) {
|
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.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@hono/standard-validator": "^0.1.2",
|
|
46
46
|
"@standard-community/standard-json": "^0.3.1",
|
|
47
|
-
"@standard-community/standard-openapi": "^0.2.
|
|
47
|
+
"@standard-community/standard-openapi": "^0.2.4",
|
|
48
48
|
"@types/json-schema": "^7.0.15",
|
|
49
49
|
"hono": "^4.8.3",
|
|
50
50
|
"openapi-types": "^12.1.3"
|