hono-openapi 0.5.0-rc.4 → 1.0.1
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 +1 -1
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -1
- package/package.json +7 -23
package/dist/index.cjs
CHANGED
|
@@ -331,7 +331,7 @@ async function getSpec(middlewareHandler, defaultOptions) {
|
|
|
331
331
|
return { schema: tmp, components };
|
|
332
332
|
}
|
|
333
333
|
const result = await middlewareHandler.toOpenAPISchema();
|
|
334
|
-
const docs = {};
|
|
334
|
+
const docs = defaultOptions ?? {};
|
|
335
335
|
if (middlewareHandler.target === "form" || middlewareHandler.target === "json") {
|
|
336
336
|
const media = middlewareHandler.options?.media ?? middlewareHandler.target === "json" ? "application/json" : "multipart/form-data";
|
|
337
337
|
if (!docs.requestBody || !("content" in docs.requestBody) || !docs.requestBody.content) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
import {
|
|
4
|
+
import { TypedResponse, RouterRoute, ValidationTargets as ValidationTargets$1, BlankEnv, Input as Input$1, BlankInput, Schema, BlankSchema, MiddlewareHandler as MiddlewareHandler$1 } from 'hono/types';
|
|
5
5
|
import * as json_schema from 'json-schema';
|
|
6
6
|
import { Hook } from '@hono/standard-validator';
|
|
7
7
|
import { StatusCode } from 'hono/utils/http-status';
|
|
@@ -118,8 +118,8 @@ type Num<T> = T extends `${infer N extends number}` ? N : T;
|
|
|
118
118
|
type HandlerResponse<T extends Partial<Record<StatusCode, StandardSchemaV1>> = Partial<Record<StatusCode, StandardSchemaV1>>> = {
|
|
119
119
|
[K in keyof T]: T[K] extends StandardSchemaV1 ? PromiseOr<TypedResponse<StandardSchemaV1.InferOutput<T[K]>, Num<K> extends StatusCode ? Num<K> : never>> : never;
|
|
120
120
|
}[keyof T];
|
|
121
|
-
type Handler<E extends Env
|
|
122
|
-
declare function describeResponse<E extends Env
|
|
121
|
+
type Handler<E extends Env, P extends string, I extends Input, T extends Partial<Record<StatusCode, StandardSchemaV1>> = Partial<Record<StatusCode, StandardSchemaV1>>> = (c: Context<E, P, I>, next: Next) => HandlerResponse<T>;
|
|
122
|
+
declare function describeResponse<E extends Env, P extends string, I extends Input, T extends Partial<Record<StatusCode, StandardSchemaV1>> = Partial<Record<StatusCode, StandardSchemaV1>>>(handler: Handler<E, P, I>, responses: ResponseObject<T>, options?: Record<string, unknown>): Handler<E, P, I>;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* The unique symbol for the middlewares, which makes it easier to identify them. Not meant to be used directly, unless you're creating a custom middleware.
|
|
@@ -184,7 +184,9 @@ type GenerateSpecOptions = {
|
|
|
184
184
|
*/
|
|
185
185
|
defaultOptions: Partial<Record<AllowedMethods | "ALL", DescribeRouteOptions>>;
|
|
186
186
|
};
|
|
187
|
-
type
|
|
187
|
+
type OperationId = string | ((route: RouterRoute) => string);
|
|
188
|
+
type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "parameters" | "operationId"> & {
|
|
189
|
+
operationId?: OperationId;
|
|
188
190
|
/**
|
|
189
191
|
* Pass `true` to hide route from OpenAPI/swagger document
|
|
190
192
|
*/
|
|
@@ -209,7 +211,7 @@ type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "par
|
|
|
209
211
|
type RegisterSchemaPathOptions = {
|
|
210
212
|
route: RouterRoute;
|
|
211
213
|
specs?: DescribeRouteOptions & {
|
|
212
|
-
operationId?:
|
|
214
|
+
operationId?: OperationId;
|
|
213
215
|
};
|
|
214
216
|
paths: Partial<OpenAPIV3_1.PathsObject>;
|
|
215
217
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
import {
|
|
4
|
+
import { TypedResponse, RouterRoute, ValidationTargets as ValidationTargets$1, BlankEnv, Input as Input$1, BlankInput, Schema, BlankSchema, MiddlewareHandler as MiddlewareHandler$1 } from 'hono/types';
|
|
5
5
|
import * as json_schema from 'json-schema';
|
|
6
6
|
import { Hook } from '@hono/standard-validator';
|
|
7
7
|
import { StatusCode } from 'hono/utils/http-status';
|
|
@@ -118,8 +118,8 @@ type Num<T> = T extends `${infer N extends number}` ? N : T;
|
|
|
118
118
|
type HandlerResponse<T extends Partial<Record<StatusCode, StandardSchemaV1>> = Partial<Record<StatusCode, StandardSchemaV1>>> = {
|
|
119
119
|
[K in keyof T]: T[K] extends StandardSchemaV1 ? PromiseOr<TypedResponse<StandardSchemaV1.InferOutput<T[K]>, Num<K> extends StatusCode ? Num<K> : never>> : never;
|
|
120
120
|
}[keyof T];
|
|
121
|
-
type Handler<E extends Env
|
|
122
|
-
declare function describeResponse<E extends Env
|
|
121
|
+
type Handler<E extends Env, P extends string, I extends Input, T extends Partial<Record<StatusCode, StandardSchemaV1>> = Partial<Record<StatusCode, StandardSchemaV1>>> = (c: Context<E, P, I>, next: Next) => HandlerResponse<T>;
|
|
122
|
+
declare function describeResponse<E extends Env, P extends string, I extends Input, T extends Partial<Record<StatusCode, StandardSchemaV1>> = Partial<Record<StatusCode, StandardSchemaV1>>>(handler: Handler<E, P, I>, responses: ResponseObject<T>, options?: Record<string, unknown>): Handler<E, P, I>;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* The unique symbol for the middlewares, which makes it easier to identify them. Not meant to be used directly, unless you're creating a custom middleware.
|
|
@@ -184,7 +184,9 @@ type GenerateSpecOptions = {
|
|
|
184
184
|
*/
|
|
185
185
|
defaultOptions: Partial<Record<AllowedMethods | "ALL", DescribeRouteOptions>>;
|
|
186
186
|
};
|
|
187
|
-
type
|
|
187
|
+
type OperationId = string | ((route: RouterRoute) => string);
|
|
188
|
+
type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "parameters" | "operationId"> & {
|
|
189
|
+
operationId?: OperationId;
|
|
188
190
|
/**
|
|
189
191
|
* Pass `true` to hide route from OpenAPI/swagger document
|
|
190
192
|
*/
|
|
@@ -209,7 +211,7 @@ type DescribeRouteOptions = Omit<OpenAPIV3_1.OperationObject, "responses" | "par
|
|
|
209
211
|
type RegisterSchemaPathOptions = {
|
|
210
212
|
route: RouterRoute;
|
|
211
213
|
specs?: DescribeRouteOptions & {
|
|
212
|
-
operationId?:
|
|
214
|
+
operationId?: OperationId;
|
|
213
215
|
};
|
|
214
216
|
paths: Partial<OpenAPIV3_1.PathsObject>;
|
|
215
217
|
};
|
package/dist/index.js
CHANGED
|
@@ -329,7 +329,7 @@ async function getSpec(middlewareHandler, defaultOptions) {
|
|
|
329
329
|
return { schema: tmp, components };
|
|
330
330
|
}
|
|
331
331
|
const result = await middlewareHandler.toOpenAPISchema();
|
|
332
|
-
const docs = {};
|
|
332
|
+
const docs = defaultOptions ?? {};
|
|
333
333
|
if (middlewareHandler.target === "form" || middlewareHandler.target === "json") {
|
|
334
334
|
const media = middlewareHandler.options?.media ?? middlewareHandler.target === "json" ? "application/json" : "multipart/form-data";
|
|
335
335
|
if (!docs.requestBody || !("content" in docs.requestBody) || !docs.requestBody.content) {
|
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": "
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -43,48 +43,32 @@
|
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@hono/standard-validator": "^0.1.2",
|
|
46
|
-
"@sinclair/typebox": "^0.34.9",
|
|
47
46
|
"@standard-community/standard-json": "^0.3.0-rc.4",
|
|
48
47
|
"@standard-community/standard-openapi": "^0.2.0-rc.1",
|
|
49
48
|
"@types/json-schema": "^7.0.15",
|
|
50
|
-
"arktype": "^2.0.0",
|
|
51
|
-
"effect": "^3.16.12",
|
|
52
49
|
"hono": "^4.8.3",
|
|
53
|
-
"openapi-types": "^12.1.3"
|
|
54
|
-
"valibot": "^1.0.0-beta.9",
|
|
55
|
-
"zod": "^3.23.8"
|
|
50
|
+
"openapi-types": "^12.1.3"
|
|
56
51
|
},
|
|
57
52
|
"peerDependenciesMeta": {
|
|
58
53
|
"@hono/standard-validator": {
|
|
59
54
|
"optional": true
|
|
60
55
|
},
|
|
61
|
-
"@sinclair/typebox": {
|
|
62
|
-
"optional": true
|
|
63
|
-
},
|
|
64
|
-
"arktype": {
|
|
65
|
-
"optional": true
|
|
66
|
-
},
|
|
67
|
-
"effect": {
|
|
68
|
-
"optional": true
|
|
69
|
-
},
|
|
70
56
|
"hono": {
|
|
71
57
|
"optional": true
|
|
72
|
-
},
|
|
73
|
-
"valibot": {
|
|
74
|
-
"optional": true
|
|
75
|
-
},
|
|
76
|
-
"zod": {
|
|
77
|
-
"optional": true
|
|
78
58
|
}
|
|
79
59
|
},
|
|
80
60
|
"devDependencies": {
|
|
81
61
|
"@biomejs/biome": "^2.0.6",
|
|
82
62
|
"@standard-schema/spec": "^1.0.0",
|
|
83
63
|
"@valibot/to-json-schema": "^1.3.0",
|
|
64
|
+
"arktype": "^2.1.22",
|
|
65
|
+
"effect": "^3.17.13",
|
|
84
66
|
"pkgroll": "^2.13.1",
|
|
85
67
|
"typescript": "^5.8.3",
|
|
68
|
+
"valibot": "^1.1.0",
|
|
86
69
|
"vitest": "^3.2.4",
|
|
87
|
-
"zod
|
|
70
|
+
"zod": "^3.23.8",
|
|
71
|
+
"zod-openapi": "^4"
|
|
88
72
|
},
|
|
89
73
|
"scripts": {
|
|
90
74
|
"build": "pkgroll --clean-dist",
|