hono-openapi 0.4.7 → 0.5.0-rc.0
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/README.md +4 -253
- package/dist/index.cjs +410 -0
- package/dist/index.d.cts +413 -0
- package/dist/index.d.ts +413 -0
- package/dist/index.js +401 -0
- package/package.json +34 -98
- package/arktype.cjs +0 -1
- package/arktype.d.cts +0 -1
- package/arktype.d.ts +0 -1
- package/arktype.js +0 -1
- package/effect.cjs +0 -1
- package/effect.d.cts +0 -1
- package/effect.d.ts +0 -1
- package/effect.js +0 -1
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/src/arktype.d.ts +0 -36
- package/src/effect.d.ts +0 -33
- package/src/helper.d.ts +0 -10
- package/src/index.d.ts +0 -4
- package/src/openapi.d.ts +0 -201
- package/src/route.d.ts +0 -49
- package/src/toOpenAPISchema.d.ts +0 -21
- package/src/typebox.d.ts +0 -25
- package/src/types.d.ts +0 -101
- package/src/utils.d.ts +0 -31
- package/src/valibot.d.ts +0 -36
- package/src/zod.d.ts +0 -31
- package/toOpenAPISchema.cjs +0 -1
- package/toOpenAPISchema.js +0 -1
- package/typebox.cjs +0 -1
- package/typebox.d.cts +0 -1
- package/typebox.d.ts +0 -1
- package/typebox.js +0 -1
- package/utils.cjs +0 -1
- package/utils.js +0 -1
- package/valibot.cjs +0 -1
- package/valibot.d.cts +0 -1
- package/valibot.d.ts +0 -1
- package/valibot.js +0 -1
- package/zod.cjs +0 -1
- package/zod.d.cts +0 -1
- package/zod.d.ts +0 -1
- package/zod.js +0 -1
package/src/effect.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import type { Env, Input as HonoInput, MiddlewareHandler, ValidationTargets } from "hono";
|
|
3
|
-
import type { HasUndefined, ResolverResult } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Generate a resolver for an Effect schema
|
|
6
|
-
* @param schema Effect schema
|
|
7
|
-
* @returns Resolver result
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolver<Type, Context>(schema: Schema.Schema<Type, Context, never>): ResolverResult;
|
|
10
|
-
/**
|
|
11
|
-
* Create a validator middleware
|
|
12
|
-
* @param target Target for validation
|
|
13
|
-
* @param schema Effect schema
|
|
14
|
-
* @returns Middleware handler
|
|
15
|
-
*/
|
|
16
|
-
export declare function validator<Type, Context, Target extends keyof ValidationTargets, E extends Env, P extends string, In = Schema.Schema<Type, Context, never>["Encoded"], Out = Schema.Schema<Type, Context, never>["Type"], I extends HonoInput = {
|
|
17
|
-
in: HasUndefined<In> extends true ? {
|
|
18
|
-
[K in Target]?: K extends "json" ? In : HasUndefined<keyof ValidationTargets[K]> extends true ? {
|
|
19
|
-
[K2 in keyof In]?: ValidationTargets[K][K2];
|
|
20
|
-
} : {
|
|
21
|
-
[K2 in keyof In]: ValidationTargets[K][K2];
|
|
22
|
-
};
|
|
23
|
-
} : {
|
|
24
|
-
[K in Target]: K extends "json" ? In : HasUndefined<keyof ValidationTargets[K]> extends true ? {
|
|
25
|
-
[K2 in keyof In]?: ValidationTargets[K][K2];
|
|
26
|
-
} : {
|
|
27
|
-
[K2 in keyof In]: ValidationTargets[K][K2];
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
out: {
|
|
31
|
-
[K in Target]: Out;
|
|
32
|
-
};
|
|
33
|
-
}, V extends I = I>(target: Target, schema: Schema.Schema<Type, Context, never>): MiddlewareHandler<E, P, V>;
|
package/src/helper.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import type { OpenAPIRoute, OpenApiSpecsOptions } from "./types.js";
|
|
3
|
-
export declare const ALLOWED_METHODS: readonly ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
|
|
4
|
-
export declare const toOpenAPIPath: (path: string) => string;
|
|
5
|
-
export declare const capitalize: (word: string) => string;
|
|
6
|
-
export declare const generateOperationId: (method: string, paths: string) => string;
|
|
7
|
-
export declare function registerSchemaPath({ path, method: _method, data, schema, }: OpenAPIRoute & {
|
|
8
|
-
schema: Partial<OpenAPIV3.PathsObject>;
|
|
9
|
-
}): void;
|
|
10
|
-
export declare function filterPaths(paths: OpenAPIV3.PathsObject, { excludeStaticFile, exclude, }: Pick<OpenApiSpecsOptions, "excludeStaticFile" | "exclude">): OpenAPIV3.PathsObject<{}, {}>;
|
package/src/index.d.ts
DELETED
package/src/openapi.d.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import type { Context, Env, Hono, Input, Schema } from "hono";
|
|
2
|
-
import type { BlankEnv, BlankInput, BlankSchema, MiddlewareHandler } from "hono/types";
|
|
3
|
-
import type { OpenAPIV3 } from "openapi-types";
|
|
4
|
-
import type { OpenAPIRouteHandlerConfig, OpenApiSpecsOptions } from "./types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Route handler for OpenAPI specs
|
|
7
|
-
* @param hono Instance of Hono
|
|
8
|
-
* @param options Options for generating OpenAPI specs
|
|
9
|
-
* @returns Middleware handler for OpenAPI specs
|
|
10
|
-
*/
|
|
11
|
-
export declare function openAPISpecs<E extends Env = BlankEnv, P extends string = string, I extends Input = BlankInput, S extends Schema = BlankSchema>(hono: Hono<E, S, P>, options?: OpenApiSpecsOptions): MiddlewareHandler<E, P, I>;
|
|
12
|
-
/**
|
|
13
|
-
* Generate OpenAPI specs for the given Hono instance
|
|
14
|
-
* @param hono Instance of Hono
|
|
15
|
-
* @param options Options for generating OpenAPI specs
|
|
16
|
-
* @param config Configuration for OpenAPI route handler
|
|
17
|
-
* @param Context Route context for hiding routes
|
|
18
|
-
* @returns OpenAPI specs
|
|
19
|
-
*/
|
|
20
|
-
export declare function generateSpecs<E extends Env = BlankEnv, P extends string = string, I extends Input = BlankInput, S extends Schema = BlankSchema>(hono: Hono<E, S, P>, options?: OpenApiSpecsOptions, config?: OpenAPIRouteHandlerConfig, c?: Context<E, P, I>): Promise<{
|
|
21
|
-
tags: OpenAPIV3.TagObject[] | undefined;
|
|
22
|
-
info: {
|
|
23
|
-
title: string;
|
|
24
|
-
description: string;
|
|
25
|
-
termsOfService?: string;
|
|
26
|
-
contact?: OpenAPIV3.ContactObject;
|
|
27
|
-
license?: OpenAPIV3.LicenseObject;
|
|
28
|
-
version: string;
|
|
29
|
-
};
|
|
30
|
-
paths: {
|
|
31
|
-
[x: string]: ({
|
|
32
|
-
$ref?: string;
|
|
33
|
-
summary?: string;
|
|
34
|
-
description?: string;
|
|
35
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
36
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
37
|
-
} & {
|
|
38
|
-
get?: {
|
|
39
|
-
tags?: string[];
|
|
40
|
-
summary?: string;
|
|
41
|
-
description?: string;
|
|
42
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
43
|
-
operationId?: string;
|
|
44
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
45
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
46
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
47
|
-
callbacks?: {
|
|
48
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
49
|
-
};
|
|
50
|
-
deprecated?: boolean;
|
|
51
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
52
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
53
|
-
} | undefined;
|
|
54
|
-
put?: {
|
|
55
|
-
tags?: string[];
|
|
56
|
-
summary?: string;
|
|
57
|
-
description?: string;
|
|
58
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
59
|
-
operationId?: string;
|
|
60
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
61
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
62
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
63
|
-
callbacks?: {
|
|
64
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
65
|
-
};
|
|
66
|
-
deprecated?: boolean;
|
|
67
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
68
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
69
|
-
} | undefined;
|
|
70
|
-
post?: {
|
|
71
|
-
tags?: string[];
|
|
72
|
-
summary?: string;
|
|
73
|
-
description?: string;
|
|
74
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
75
|
-
operationId?: string;
|
|
76
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
77
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
78
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
79
|
-
callbacks?: {
|
|
80
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
81
|
-
};
|
|
82
|
-
deprecated?: boolean;
|
|
83
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
84
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
85
|
-
} | undefined;
|
|
86
|
-
delete?: {
|
|
87
|
-
tags?: string[];
|
|
88
|
-
summary?: string;
|
|
89
|
-
description?: string;
|
|
90
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
91
|
-
operationId?: string;
|
|
92
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
93
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
94
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
95
|
-
callbacks?: {
|
|
96
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
97
|
-
};
|
|
98
|
-
deprecated?: boolean;
|
|
99
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
100
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
101
|
-
} | undefined;
|
|
102
|
-
options?: {
|
|
103
|
-
tags?: string[];
|
|
104
|
-
summary?: string;
|
|
105
|
-
description?: string;
|
|
106
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
107
|
-
operationId?: string;
|
|
108
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
109
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
110
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
111
|
-
callbacks?: {
|
|
112
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
113
|
-
};
|
|
114
|
-
deprecated?: boolean;
|
|
115
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
116
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
117
|
-
} | undefined;
|
|
118
|
-
head?: {
|
|
119
|
-
tags?: string[];
|
|
120
|
-
summary?: string;
|
|
121
|
-
description?: string;
|
|
122
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
123
|
-
operationId?: string;
|
|
124
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
125
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
126
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
127
|
-
callbacks?: {
|
|
128
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
129
|
-
};
|
|
130
|
-
deprecated?: boolean;
|
|
131
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
132
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
133
|
-
} | undefined;
|
|
134
|
-
patch?: {
|
|
135
|
-
tags?: string[];
|
|
136
|
-
summary?: string;
|
|
137
|
-
description?: string;
|
|
138
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
139
|
-
operationId?: string;
|
|
140
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
141
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
142
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
143
|
-
callbacks?: {
|
|
144
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
145
|
-
};
|
|
146
|
-
deprecated?: boolean;
|
|
147
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
148
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
149
|
-
} | undefined;
|
|
150
|
-
trace?: {
|
|
151
|
-
tags?: string[];
|
|
152
|
-
summary?: string;
|
|
153
|
-
description?: string;
|
|
154
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
155
|
-
operationId?: string;
|
|
156
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
157
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
158
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
159
|
-
callbacks?: {
|
|
160
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
161
|
-
};
|
|
162
|
-
deprecated?: boolean;
|
|
163
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
164
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
165
|
-
} | undefined;
|
|
166
|
-
}) | undefined;
|
|
167
|
-
};
|
|
168
|
-
components: {
|
|
169
|
-
schemas: {
|
|
170
|
-
[x: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;
|
|
171
|
-
};
|
|
172
|
-
responses?: {
|
|
173
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ResponseObject;
|
|
174
|
-
};
|
|
175
|
-
parameters?: {
|
|
176
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject;
|
|
177
|
-
};
|
|
178
|
-
examples?: {
|
|
179
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ExampleObject;
|
|
180
|
-
};
|
|
181
|
-
requestBodies?: {
|
|
182
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
183
|
-
};
|
|
184
|
-
headers?: {
|
|
185
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject;
|
|
186
|
-
};
|
|
187
|
-
securitySchemes?: {
|
|
188
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.SecuritySchemeObject;
|
|
189
|
-
};
|
|
190
|
-
links?: {
|
|
191
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.LinkObject;
|
|
192
|
-
};
|
|
193
|
-
callbacks?: {
|
|
194
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
openapi: string;
|
|
198
|
-
servers?: OpenAPIV3.ServerObject[] | undefined;
|
|
199
|
-
security?: OpenAPIV3.SecurityRequirementObject[] | undefined;
|
|
200
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject | undefined;
|
|
201
|
-
}>;
|
package/src/route.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { MiddlewareHandler } from "hono/types";
|
|
2
|
-
import type { ClientErrorStatusCode, ServerErrorStatusCode } from "hono/utils/http-status";
|
|
3
|
-
import type { DescribeRouteOptions, OpenAPIRouteHandlerConfig } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Describe a route with OpenAPI specs.
|
|
6
|
-
* @param specs Options for describing a route
|
|
7
|
-
* @returns Middleware handler
|
|
8
|
-
*/
|
|
9
|
-
export declare function describeRoute(specs: DescribeRouteOptions): MiddlewareHandler;
|
|
10
|
-
/**
|
|
11
|
-
* Generate OpenAPI specs for the given route
|
|
12
|
-
* @param config Route handler configuration
|
|
13
|
-
* @param docs Route description in OpenAPI specs
|
|
14
|
-
* @param defaultOptions Default options for describing a route
|
|
15
|
-
*/
|
|
16
|
-
export declare function generateRouteSpecs(config: OpenAPIRouteHandlerConfig, docs: DescribeRouteOptions, defaultOptions?: DescribeRouteOptions): Promise<{
|
|
17
|
-
docs: {
|
|
18
|
-
responses: {
|
|
19
|
-
[x: string]: import("openapi-types").OpenAPIV3.ReferenceObject | (import("openapi-types").OpenAPIV3.ResponseObject & {
|
|
20
|
-
content?: {
|
|
21
|
-
[key: string]: Omit<import("openapi-types").OpenAPIV3.MediaTypeObject, "schema"> & {
|
|
22
|
-
schema?: import("openapi-types").OpenAPIV3.ReferenceObject | import("openapi-types").OpenAPIV3.SchemaObject | import("./types.js").ResolverResult;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
tags?: string[];
|
|
28
|
-
summary?: string;
|
|
29
|
-
description?: string;
|
|
30
|
-
externalDocs?: import("openapi-types").OpenAPIV3.ExternalDocumentationObject;
|
|
31
|
-
operationId?: string;
|
|
32
|
-
requestBody?: import("openapi-types").OpenAPIV3.ReferenceObject | import("openapi-types").OpenAPIV3.RequestBodyObject;
|
|
33
|
-
callbacks?: {
|
|
34
|
-
[callback: string]: import("openapi-types").OpenAPIV3.ReferenceObject | import("openapi-types").OpenAPIV3.CallbackObject;
|
|
35
|
-
};
|
|
36
|
-
deprecated?: boolean;
|
|
37
|
-
security?: import("openapi-types").OpenAPIV3.SecurityRequirementObject[];
|
|
38
|
-
servers?: import("openapi-types").OpenAPIV3.ServerObject[];
|
|
39
|
-
hide?: boolean | (<E extends import("hono").Env = import("hono").Env, P extends string = string, I extends import("hono").Input = import("hono/types").BlankInput>(c: import("hono").Context<E, P, I>) => boolean);
|
|
40
|
-
validateResponse?: boolean | {
|
|
41
|
-
status: ClientErrorStatusCode | ServerErrorStatusCode;
|
|
42
|
-
message?: string;
|
|
43
|
-
};
|
|
44
|
-
parameters?: (import("openapi-types").OpenAPIV3.ParameterObject | (import("openapi-types").OpenAPIV3.ParameterObject & {
|
|
45
|
-
schema: import("./types.js").ResolverResult;
|
|
46
|
-
}))[];
|
|
47
|
-
};
|
|
48
|
-
components: {};
|
|
49
|
-
}>;
|
package/src/toOpenAPISchema.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { JSONSchema, ParserOptions } from "@apidevtools/json-schema-ref-parser";
|
|
2
|
-
import type { JSONSchema4 } from "json-schema";
|
|
3
|
-
import type { OpenAPIV3 } from "openapi-types";
|
|
4
|
-
export type addPrefixToObject = {
|
|
5
|
-
[K in keyof JSONSchema as `x-${K}`]: JSONSchema[K];
|
|
6
|
-
};
|
|
7
|
-
export interface Options {
|
|
8
|
-
cloneSchema?: boolean;
|
|
9
|
-
dereference?: boolean;
|
|
10
|
-
convertUnreferencedDefinitions?: boolean;
|
|
11
|
-
dereferenceOptions?: ParserOptions | undefined;
|
|
12
|
-
}
|
|
13
|
-
type ExtendedJSONSchema = addPrefixToObject & JSONSchema;
|
|
14
|
-
export type SchemaType = ExtendedJSONSchema & {
|
|
15
|
-
example?: JSONSchema["examples"][number];
|
|
16
|
-
"x-patternProperties"?: JSONSchema["patternProperties"];
|
|
17
|
-
nullable?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export type SchemaTypeKeys = keyof SchemaType;
|
|
20
|
-
declare const convert: <T extends object = JSONSchema4>(schema: T, options?: Options) => Promise<OpenAPIV3.Document>;
|
|
21
|
-
export default convert;
|
package/src/typebox.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type Hook } from "@hono/typebox-validator";
|
|
2
|
-
import type { Static, TSchema } from "@sinclair/typebox";
|
|
3
|
-
import type { Env, MiddlewareHandler, ValidationTargets } from "hono";
|
|
4
|
-
import type { ResolverResult } from "./types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Generate a resolver for a TypeBox schema
|
|
7
|
-
* @param schema TypeBox schema
|
|
8
|
-
* @returns Resolver result
|
|
9
|
-
*/
|
|
10
|
-
export declare function resolver<T extends TSchema>(schema: T): ResolverResult;
|
|
11
|
-
/**
|
|
12
|
-
* Create a validator middleware
|
|
13
|
-
* @param target Target for validation
|
|
14
|
-
* @param schema TypeBox schema
|
|
15
|
-
* @param hook Hook for validation
|
|
16
|
-
* @returns Middleware handler
|
|
17
|
-
*/
|
|
18
|
-
export declare function validator<T extends TSchema, Target extends keyof ValidationTargets, E extends Env, P extends string, V extends {
|
|
19
|
-
in: {
|
|
20
|
-
[K in Target]: Static<T>;
|
|
21
|
-
};
|
|
22
|
-
out: {
|
|
23
|
-
[K in Target]: Static<T>;
|
|
24
|
-
};
|
|
25
|
-
}>(target: Target, schema: T, hook?: Hook<Static<T>, E, P>): MiddlewareHandler<E, P, V>;
|
package/src/types.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { Context, Env, Input } from "hono";
|
|
2
|
-
import type { BlankInput } from "hono/types";
|
|
3
|
-
import type { ClientErrorStatusCode, ServerErrorStatusCode } from "hono/utils/http-status";
|
|
4
|
-
import type { OpenAPIV3 } from "openapi-types";
|
|
5
|
-
import type { ALLOWED_METHODS } from "./helper.js";
|
|
6
|
-
export type HasUndefined<T> = undefined extends T ? true : false;
|
|
7
|
-
export type PromiseOr<T> = T | Promise<T>;
|
|
8
|
-
export type OpenAPIRouteHandlerConfig = {
|
|
9
|
-
version: "3.0.0" | "3.0.1" | "3.0.2" | "3.0.3" | "3.1.0";
|
|
10
|
-
components: OpenAPIV3.ComponentsObject["schemas"];
|
|
11
|
-
} & {
|
|
12
|
-
[key: string]: unknown;
|
|
13
|
-
};
|
|
14
|
-
export type ResolverResult = {
|
|
15
|
-
builder: (options?: OpenAPIRouteHandlerConfig) => PromiseOr<{
|
|
16
|
-
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
17
|
-
components?: OpenAPIV3.ComponentsObject["schemas"];
|
|
18
|
-
}>;
|
|
19
|
-
validator: (values: unknown) => PromiseOr<void>;
|
|
20
|
-
};
|
|
21
|
-
export type HandlerResponse = {
|
|
22
|
-
resolver: (config: OpenAPIRouteHandlerConfig, defaultOptions?: DescribeRouteOptions) => PromiseOr<{
|
|
23
|
-
docs: OpenAPIV3.OperationObject;
|
|
24
|
-
components?: OpenAPIV3.ComponentsObject["schemas"];
|
|
25
|
-
}>;
|
|
26
|
-
metadata?: Record<string, unknown>;
|
|
27
|
-
};
|
|
28
|
-
export type DescribeRouteOptions = Omit<OpenAPIV3.OperationObject, "responses" | "parameters"> & {
|
|
29
|
-
/**
|
|
30
|
-
* Pass `true` to hide route from OpenAPI/swagger document
|
|
31
|
-
*/
|
|
32
|
-
hide?: boolean | (<E extends Env = Env, P extends string = string, I extends Input = BlankInput>(c: Context<E, P, I>) => boolean);
|
|
33
|
-
/**
|
|
34
|
-
* Validate response of the route
|
|
35
|
-
*/
|
|
36
|
-
validateResponse?: boolean | {
|
|
37
|
-
status: ClientErrorStatusCode | ServerErrorStatusCode;
|
|
38
|
-
message?: string;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Responses of the request
|
|
42
|
-
*/
|
|
43
|
-
responses?: {
|
|
44
|
-
[key: string]: (OpenAPIV3.ResponseObject & {
|
|
45
|
-
content?: {
|
|
46
|
-
[key: string]: Omit<OpenAPIV3.MediaTypeObject, "schema"> & {
|
|
47
|
-
schema?: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | ResolverResult;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
}) | OpenAPIV3.ReferenceObject;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Parameters of the request
|
|
54
|
-
*/
|
|
55
|
-
parameters?: (OpenAPIV3.ParameterObject | (OpenAPIV3.ParameterObject & {
|
|
56
|
-
schema: ResolverResult;
|
|
57
|
-
}))[];
|
|
58
|
-
};
|
|
59
|
-
export interface OpenAPIRoute {
|
|
60
|
-
path: string;
|
|
61
|
-
method: (typeof ALLOWED_METHODS)[number] | "ALL";
|
|
62
|
-
data?: DescribeRouteOptions | Pick<OpenAPIV3.OperationObject, "parameters" | "requestBody">;
|
|
63
|
-
}
|
|
64
|
-
export type OpenApiSpecsOptions = {
|
|
65
|
-
/**
|
|
66
|
-
* Customize OpenAPI config, refers to Swagger 2.0 config
|
|
67
|
-
*
|
|
68
|
-
* @see https://swagger.io/specification/v2/
|
|
69
|
-
*/
|
|
70
|
-
documentation?: Omit<Partial<OpenAPIV3.Document>, "x-express-openapi-additional-middleware" | "x-express-openapi-validation-strict">;
|
|
71
|
-
/**
|
|
72
|
-
* Include paths which don't have the handlers.
|
|
73
|
-
* This is useful when you want to document the
|
|
74
|
-
* API without implementing it or index all the paths.
|
|
75
|
-
*/
|
|
76
|
-
includeEmptyPaths?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Determine if Swagger should exclude static files.
|
|
79
|
-
*
|
|
80
|
-
* @default true
|
|
81
|
-
*/
|
|
82
|
-
excludeStaticFile?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Paths to exclude from OpenAPI endpoint
|
|
85
|
-
*
|
|
86
|
-
* @default []
|
|
87
|
-
*/
|
|
88
|
-
exclude?: string | RegExp | Array<string | RegExp>;
|
|
89
|
-
/**
|
|
90
|
-
* Exclude methods from Open API
|
|
91
|
-
*/
|
|
92
|
-
excludeMethods?: (typeof ALLOWED_METHODS)[number][];
|
|
93
|
-
/**
|
|
94
|
-
* Exclude tags from OpenAPI
|
|
95
|
-
*/
|
|
96
|
-
excludeTags?: string[];
|
|
97
|
-
/**
|
|
98
|
-
* Default options for `describeRoute` method
|
|
99
|
-
*/
|
|
100
|
-
defaultOptions?: Partial<Record<(typeof ALLOWED_METHODS)[number] | "ALL", DescribeRouteOptions>>;
|
|
101
|
-
};
|
package/src/utils.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ValidationTargets } from "hono";
|
|
2
|
-
import type { OpenAPIV3 } from "openapi-types";
|
|
3
|
-
import type { ResolverResult } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* 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.
|
|
6
|
-
*/
|
|
7
|
-
export declare const uniqueSymbol: unique symbol;
|
|
8
|
-
/**
|
|
9
|
-
* Generate OpenAPI docs for a validator middleware. Not meant to be used directly, unless you're creating a custom middleware.
|
|
10
|
-
*/
|
|
11
|
-
export declare function generateValidatorDocs<Target extends keyof ValidationTargets>(target: Target, _result: ReturnType<ResolverResult["builder"]>): Promise<{
|
|
12
|
-
docs: Pick<{
|
|
13
|
-
tags?: string[];
|
|
14
|
-
summary?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
|
17
|
-
operationId?: string;
|
|
18
|
-
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[];
|
|
19
|
-
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject;
|
|
20
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
21
|
-
callbacks?: {
|
|
22
|
-
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
23
|
-
};
|
|
24
|
-
deprecated?: boolean;
|
|
25
|
-
security?: OpenAPIV3.SecurityRequirementObject[];
|
|
26
|
-
servers?: OpenAPIV3.ServerObject[];
|
|
27
|
-
}, "parameters" | "requestBody">;
|
|
28
|
-
components: {
|
|
29
|
-
[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;
|
|
30
|
-
} | undefined;
|
|
31
|
-
}>;
|
package/src/valibot.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type Hook } from "@hono/valibot-validator";
|
|
2
|
-
import { type ConversionConfig } from "@valibot/to-json-schema";
|
|
3
|
-
import type { Env, Input as HonoInput, MiddlewareHandler, ValidationTargets } from "hono";
|
|
4
|
-
import { type BaseIssue, type BaseSchema, type GenericSchema, type GenericSchemaAsync, type InferInput, type InferOutput } from "valibot";
|
|
5
|
-
import type { HasUndefined, ResolverResult } from "./types.js";
|
|
6
|
-
/**
|
|
7
|
-
* Generate a resolver for a Valibot schema
|
|
8
|
-
* @param schema Valibot schema
|
|
9
|
-
* @returns Resolver result
|
|
10
|
-
*/
|
|
11
|
-
export declare function resolver<T extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(schema: T, config?: ConversionConfig): ResolverResult;
|
|
12
|
-
/**
|
|
13
|
-
* Create a validator middleware
|
|
14
|
-
* @param target Target for validation
|
|
15
|
-
* @param schema Valibot schema
|
|
16
|
-
* @param hook Hook for validation
|
|
17
|
-
* @returns Middleware handler
|
|
18
|
-
*/
|
|
19
|
-
export declare function validator<T extends GenericSchema | GenericSchemaAsync, Target extends keyof ValidationTargets, E extends Env, P extends string, In = InferInput<T>, Out = InferOutput<T>, I extends HonoInput = {
|
|
20
|
-
in: HasUndefined<In> extends true ? {
|
|
21
|
-
[K in Target]?: K extends "json" ? In : HasUndefined<keyof ValidationTargets[K]> extends true ? {
|
|
22
|
-
[K2 in keyof In]?: ValidationTargets[K][K2];
|
|
23
|
-
} : {
|
|
24
|
-
[K2 in keyof In]: ValidationTargets[K][K2];
|
|
25
|
-
};
|
|
26
|
-
} : {
|
|
27
|
-
[K in Target]: K extends "json" ? In : HasUndefined<keyof ValidationTargets[K]> extends true ? {
|
|
28
|
-
[K2 in keyof In]?: ValidationTargets[K][K2];
|
|
29
|
-
} : {
|
|
30
|
-
[K2 in keyof In]: ValidationTargets[K][K2];
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
out: {
|
|
34
|
-
[K in Target]: Out;
|
|
35
|
-
};
|
|
36
|
-
}, V extends I = I>(target: Target, schema: T, hook?: Hook<T, E, P>): MiddlewareHandler<E, P, V>;
|
package/src/zod.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type Hook } from "@hono/zod-validator";
|
|
2
|
-
import type { Env, Input, MiddlewareHandler, ValidationTargets } from "hono";
|
|
3
|
-
import type { ZodSchema, z } from "zod";
|
|
4
|
-
import type { HasUndefined, ResolverResult } from "./types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Generate a resolver for a Zod schema
|
|
7
|
-
* @param schema Zod schema
|
|
8
|
-
* @returns Resolver result
|
|
9
|
-
*/
|
|
10
|
-
export declare function resolver<T extends ZodSchema>(schema: T): ResolverResult;
|
|
11
|
-
/**
|
|
12
|
-
* Create a validator middleware
|
|
13
|
-
* @param target Target for validation
|
|
14
|
-
* @param schema Zod schema
|
|
15
|
-
* @param hook Hook for validation
|
|
16
|
-
* @returns Middleware handler
|
|
17
|
-
*/
|
|
18
|
-
export declare function validator<T extends ZodSchema, Target extends keyof ValidationTargets, E extends Env, P extends string, In = z.input<T>, Out = z.output<T>, I extends Input = {
|
|
19
|
-
in: HasUndefined<In> extends true ? {
|
|
20
|
-
[K in Target]?: In extends ValidationTargets[K] ? In : {
|
|
21
|
-
[K2 in keyof In]?: ValidationTargets[K][K2];
|
|
22
|
-
};
|
|
23
|
-
} : {
|
|
24
|
-
[K in Target]: In extends ValidationTargets[K] ? In : {
|
|
25
|
-
[K2 in keyof In]: ValidationTargets[K][K2];
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
out: {
|
|
29
|
-
[K in Target]: Out;
|
|
30
|
-
};
|
|
31
|
-
}, V extends I = I>(target: Target, schema: T, hook?: Hook<z.infer<T>, E, P, Target>): MiddlewareHandler<E, P, V>;
|
package/toOpenAPISchema.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("json-schema-walker");const t=["$ref","definitions","title","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","enum","type","not","allOf","oneOf","anyOf","items","properties","additionalProperties","description","format","default","nullable","discriminator","readOnly","writeOnly","example","externalDocs","deprecated","xml"];let n=class extends Error{constructor(e){super(e),this.name="InvalidTypeError",this.message=e}};const i="x-",r=async(t,n)=>{if("object"!=typeof t)return t;if(t.type){const i=new e.Walker;return await i.loadSchema({definitions:n.definitions||[],...t,$schema:n.$schema},{dereference:!0,cloneSchema:!0,dereferenceOptions:{dereference:{circular:"ignore"}}}),await i.walk(o,i.vocabularies.DRAFT_07),"definitions"in i.rootSchema&&(i.rootSchema.definitions=void 0),i.rootSchema}if(Array.isArray(t)){const e=t;if(e.includes("null")){const t=e.filter((e=>"null"!==e));return{type:1===t.length?t[0]:t,nullable:!0}}}return t};function o(e){let r=e;return r?(r=function(e){return"object"!=typeof e||(e.$schema=void 0,e.$id=void 0,"id"in e&&(e.id=void 0)),e}(r),r=function(e){if("object"!=typeof e)return e;if(void 0===e.type)return e;if(function(e){if("object"==typeof e&&!Array.isArray(e)){if(e&&"$ref"in e&&e.$ref)return;if(e&&"properties"in e&&e.properties)return}const t=Array.isArray(e)?e:[e];for(const e of t)if(e&&!a.has(e))throw new n(`Type "${e}" is not a valid type`)}(e.type),Array.isArray(e.type)){e.type.includes("null")&&(e.nullable=!0);const t=e.type.filter((e=>"null"!==e));0===t.length?e.type=void 0:1===t.length?e.type=t[0]:(e.type=void 0,e.anyOf=t.map((e=>({type:e}))))}else"null"===e.type&&(e.type=void 0,e.nullable=!0);return e}(r),r=function(e){void 0!==e.const&&(e.enum=[e.const],e.const=void 0);return e}(r),r=function(e){const t=e.dependencies;if("object"!=typeof t)return e;e.dependencies=void 0,Array.isArray(e.allOf)||(e.allOf=[]);for(const n in t){const i={oneOf:[{not:{required:[n]}},{required:[n,t[n]].flat()}]};e.allOf.push(i)}return e}(r),r=function(e){for(const t of["oneOf","anyOf"]){const n=e[t];if(!n)continue;if(!Array.isArray(n))return e;if(!n.some((e=>"null"===e.type)))return e;const i=n.filter((e=>"null"!==e.type));for(const e of i)e.nullable=!0;e[t]=i}return e}(r),r=function(e){if("object"!=typeof e)return e;"if"in e&&e.if&&e.then&&(e.oneOf=[{allOf:[e.if,e.then].filter(Boolean)},{allOf:[{not:e.if},e.else].filter(Boolean)}],e.if=void 0,e.then=void 0,e.else=void 0);return e}(r),r=function(e){"number"==typeof e.exclusiveMaximum&&(e.maximum=e.exclusiveMaximum,e.exclusiveMaximum=!0);"number"==typeof e.exclusiveMinimum&&(e.minimum=e.exclusiveMinimum,e.exclusiveMinimum=!0);return e}(r),r=function(e){e.examples&&Array.isArray(e.examples)&&(e.example=e.examples[0],e.examples=void 0);return e}(r),"object"==typeof r.patternProperties&&(r=function(e){return e["x-patternProperties"]=e.patternProperties,e.patternProperties=void 0,e.additionalProperties??=!0,e}(r)),"array"===r.type&&void 0===r.items&&(r.items={}),r=function(e){const n=Object.keys(e);for(const r of n)if(!r.startsWith(i)&&!t.includes(r)){e[`${i}${r}`]=e[r],e[r]=void 0}return e}(r),r):r}const a=new Set(["null","boolean","object","array","number","string","integer"]);exports.convert=async(t,n)=>{const i=new e.Walker;await i.loadSchema(t,n),await i.walk(o,i.vocabularies.DRAFT_07);const a=i.rootSchema;if(a?.definitions)for(const e in a.definitions){const n=a.definitions[e];a.definitions[e]=await r(n,t)}return a};
|
package/toOpenAPISchema.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Walker as e}from"json-schema-walker";const t=["$ref","definitions","title","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","enum","type","not","allOf","oneOf","anyOf","items","properties","additionalProperties","description","format","default","nullable","discriminator","readOnly","writeOnly","example","externalDocs","deprecated","xml"];let n=class extends Error{constructor(e){super(e),this.name="InvalidTypeError",this.message=e}};const i="x-",r=async(t,n)=>{if("object"!=typeof t)return t;if(t.type){const i=new e;return await i.loadSchema({definitions:n.definitions||[],...t,$schema:n.$schema},{dereference:!0,cloneSchema:!0,dereferenceOptions:{dereference:{circular:"ignore"}}}),await i.walk(a,i.vocabularies.DRAFT_07),"definitions"in i.rootSchema&&(i.rootSchema.definitions=void 0),i.rootSchema}if(Array.isArray(t)){const e=t;if(e.includes("null")){const t=e.filter((e=>"null"!==e));return{type:1===t.length?t[0]:t,nullable:!0}}}return t},o=async(t,n)=>{const i=new e;await i.loadSchema(t,n),await i.walk(a,i.vocabularies.DRAFT_07);const o=i.rootSchema;if(o?.definitions)for(const e in o.definitions){const n=o.definitions[e];o.definitions[e]=await r(n,t)}return o};function a(e){let r=e;return r?(r=function(e){return"object"!=typeof e||(e.$schema=void 0,e.$id=void 0,"id"in e&&(e.id=void 0)),e}(r),r=function(e){if("object"!=typeof e)return e;if(void 0===e.type)return e;if(function(e){if("object"==typeof e&&!Array.isArray(e)){if(e&&"$ref"in e&&e.$ref)return;if(e&&"properties"in e&&e.properties)return}const t=Array.isArray(e)?e:[e];for(const e of t)if(e&&!s.has(e))throw new n(`Type "${e}" is not a valid type`)}(e.type),Array.isArray(e.type)){e.type.includes("null")&&(e.nullable=!0);const t=e.type.filter((e=>"null"!==e));0===t.length?e.type=void 0:1===t.length?e.type=t[0]:(e.type=void 0,e.anyOf=t.map((e=>({type:e}))))}else"null"===e.type&&(e.type=void 0,e.nullable=!0);return e}(r),r=function(e){void 0!==e.const&&(e.enum=[e.const],e.const=void 0);return e}(r),r=function(e){const t=e.dependencies;if("object"!=typeof t)return e;e.dependencies=void 0,Array.isArray(e.allOf)||(e.allOf=[]);for(const n in t){const i={oneOf:[{not:{required:[n]}},{required:[n,t[n]].flat()}]};e.allOf.push(i)}return e}(r),r=function(e){for(const t of["oneOf","anyOf"]){const n=e[t];if(!n)continue;if(!Array.isArray(n))return e;if(!n.some((e=>"null"===e.type)))return e;const i=n.filter((e=>"null"!==e.type));for(const e of i)e.nullable=!0;e[t]=i}return e}(r),r=function(e){if("object"!=typeof e)return e;"if"in e&&e.if&&e.then&&(e.oneOf=[{allOf:[e.if,e.then].filter(Boolean)},{allOf:[{not:e.if},e.else].filter(Boolean)}],e.if=void 0,e.then=void 0,e.else=void 0);return e}(r),r=function(e){"number"==typeof e.exclusiveMaximum&&(e.maximum=e.exclusiveMaximum,e.exclusiveMaximum=!0);"number"==typeof e.exclusiveMinimum&&(e.minimum=e.exclusiveMinimum,e.exclusiveMinimum=!0);return e}(r),r=function(e){e.examples&&Array.isArray(e.examples)&&(e.example=e.examples[0],e.examples=void 0);return e}(r),"object"==typeof r.patternProperties&&(r=function(e){return e["x-patternProperties"]=e.patternProperties,e.patternProperties=void 0,e.additionalProperties??=!0,e}(r)),"array"===r.type&&void 0===r.items&&(r.items={}),r=function(e){const n=Object.keys(e);for(const r of n)if(!r.startsWith(i)&&!t.includes(r)){e[`${i}${r}`]=e[r],e[r]=void 0}return e}(r),r):r}const s=new Set(["null","boolean","object","array","number","string","integer"]);export{o as c};
|
package/typebox.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@hono/typebox-validator"),r=require("@sinclair/typebox/value"),a=require("./toOpenAPISchema.cjs"),t=require("./utils.cjs");function i(e){return{builder:async()=>({schema:await a.convert(e)}),validator:a=>{r.Value.Parse(e,a)}}}require("json-schema-walker"),exports.resolver=i,exports.validator=function(r,a,o){const s=e.tbValidator(r,a,o);return Object.assign(s,{[t.uniqueSymbol]:{resolver:async e=>t.generateValidatorDocs(r,await i(a).builder(e))}})};
|
package/typebox.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/typebox";
|
package/typebox.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/typebox.js";
|
package/typebox.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{tbValidator as r}from"@hono/typebox-validator";import{Value as o}from"@sinclair/typebox/value";import{c as a}from"./toOpenAPISchema.js";import{u as t,g as e}from"./utils.js";import"json-schema-walker";function i(r){return{builder:async()=>({schema:await a(r)}),validator:a=>{o.Parse(r,a)}}}function s(o,a,s){const n=r(o,a,s);return Object.assign(n,{[t]:{resolver:async r=>e(o,await i(a).builder(r))}})}export{i as resolver,s as validator};
|
package/utils.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=Symbol("openapi");exports.generateValidatorDocs=async function(e,s){const t=await s,n={};if("form"===e||"json"===e){const s="json"===e?"application/json":"multipart/form-data";n.requestBody&&"content"in n.requestBody&&n.requestBody.content?n.requestBody.content[s]={schema:t.schema}:n.requestBody={content:{[s]:{schema:t.schema}}}}else{const s=[];if("$ref"in t.schema)s.push({in:e,name:t.schema.$ref,schema:t.schema});else for(const[n,o]of Object.entries(t.schema.properties??{}))s.push({in:e,name:n,schema:o,required:t.schema.required?.includes(n)});n.parameters=s}return{docs:n,components:t.components}},exports.uniqueSymbol=e;
|
package/utils.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=Symbol("openapi");async function s(e,s){const n=await s,o={};if("form"===e||"json"===e){const s="json"===e?"application/json":"multipart/form-data";o.requestBody&&"content"in o.requestBody&&o.requestBody.content?o.requestBody.content[s]={schema:n.schema}:o.requestBody={content:{[s]:{schema:n.schema}}}}else{const s=[];if("$ref"in n.schema)s.push({in:e,name:n.schema.$ref,schema:n.schema});else for(const[o,t]of Object.entries(n.schema.properties??{}))s.push({in:e,name:o,schema:t,required:n.schema.required?.includes(o)});o.parameters=s}return{docs:o,components:n.components}}export{s as g,e as u};
|
package/valibot.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@hono/valibot-validator"),r=require("@valibot/to-json-schema"),a=require("valibot"),o=require("./toOpenAPISchema.cjs"),t=require("./utils.cjs");function i(e,t){return{builder:async()=>({schema:await o.convert(r.toJsonSchema(e,t))}),validator:async r=>{await a.parseAsync(e,r)}}}require("json-schema-walker"),exports.resolver=i,exports.validator=function(r,a,o){const s=e.vValidator(r,a,o);return Object.assign(s,{[t.uniqueSymbol]:{resolver:async e=>t.generateValidatorDocs(r,await i(a,{errorMode:"ignore"}).builder(e))}})};
|
package/valibot.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/valibot";
|
package/valibot.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/valibot.js";
|
package/valibot.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{vValidator as o}from"@hono/valibot-validator";import{toJsonSchema as r}from"@valibot/to-json-schema";import{parseAsync as a}from"valibot";import{c as t}from"./toOpenAPISchema.js";import{u as i,g as s}from"./utils.js";import"json-schema-walker";function e(o,i){return{builder:async()=>({schema:await t(r(o,i))}),validator:async r=>{await a(o,r)}}}function n(r,a,t){const n=o(r,a,t);return Object.assign(n,{[i]:{resolver:async o=>s(r,await e(a,{errorMode:"ignore"}).builder(o))}})}export{e as resolver,n as validator};
|
package/zod.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@hono/zod-validator"),r=require("zod-openapi"),a=require("./utils.cjs");function t(e){return{builder:a=>{const{version:t,...o}=a??{};return r.createSchema(e,a?{openapi:t,...o}:void 0)},validator:e.parse}}exports.resolver=t,exports.validator=function(r,o,i){const n=e.zValidator(r,o,i);return Object.assign(n,{[a.uniqueSymbol]:{resolver:async e=>a.generateValidatorDocs(r,await t(o).builder(e)),metadata:{schemaType:"input"}}})};
|
package/zod.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/zod";
|
package/zod.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/zod.js";
|
package/zod.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{zValidator as o}from"@hono/zod-validator";import{createSchema as r}from"zod-openapi";import{u as t,g as a}from"./utils.js";function i(o){return{builder:t=>{const{version:a,...i}=t??{};return r(o,t?{openapi:a,...i}:void 0)},validator:o.parse}}function e(r,e,n){const s=o(r,e,n);return Object.assign(s,{[t]:{resolver:async o=>a(r,await i(e).builder(o)),metadata:{schemaType:"input"}}})}export{i as resolver,e as validator};
|