@hono/zod-openapi 0.14.7 → 0.14.9
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.d.mts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +2 -0
- package/dist/index.mjs +1 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
3
|
import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject } from '@asteasolutions/zod-to-openapi';
|
|
4
|
+
export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
4
5
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
|
-
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
|
+
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema, ValidationTargets } from 'hono';
|
|
6
7
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
8
|
import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
8
9
|
import { StatusCode, InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode } from 'hono/utils/http-status';
|
|
@@ -23,9 +24,14 @@ type RequestTypes = {
|
|
|
23
24
|
type IsJson<T> = T extends string ? T extends `application/json${infer _Rest}` ? 'json' : never : never;
|
|
24
25
|
type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
|
|
25
26
|
type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
|
|
26
|
-
type
|
|
27
|
+
type HasUndefined<T> = undefined extends T ? true : false;
|
|
28
|
+
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends keyof ValidationTargets> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends ZodType ? {
|
|
27
29
|
in: {
|
|
28
|
-
[K in Type]:
|
|
30
|
+
[K in Type]: HasUndefined<ValidationTargets[K]> extends true ? {
|
|
31
|
+
[K2 in keyof z.input<RequestPart<R, Part>>]?: ValidationTargets[K][K2];
|
|
32
|
+
} : {
|
|
33
|
+
[K2 in keyof z.input<RequestPart<R, Part>>]: ValidationTargets[K][K2];
|
|
34
|
+
};
|
|
29
35
|
};
|
|
30
36
|
out: {
|
|
31
37
|
[K in Type]: z.output<RequestPart<R, Part>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
3
|
import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject } from '@asteasolutions/zod-to-openapi';
|
|
4
|
+
export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
4
5
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
|
-
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
|
+
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema, ValidationTargets } from 'hono';
|
|
6
7
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
8
|
import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
8
9
|
import { StatusCode, InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode } from 'hono/utils/http-status';
|
|
@@ -23,9 +24,14 @@ type RequestTypes = {
|
|
|
23
24
|
type IsJson<T> = T extends string ? T extends `application/json${infer _Rest}` ? 'json' : never : never;
|
|
24
25
|
type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
|
|
25
26
|
type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
|
|
26
|
-
type
|
|
27
|
+
type HasUndefined<T> = undefined extends T ? true : false;
|
|
28
|
+
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends keyof ValidationTargets> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends ZodType ? {
|
|
27
29
|
in: {
|
|
28
|
-
[K in Type]:
|
|
30
|
+
[K in Type]: HasUndefined<ValidationTargets[K]> extends true ? {
|
|
31
|
+
[K2 in keyof z.input<RequestPart<R, Part>>]?: ValidationTargets[K][K2];
|
|
32
|
+
} : {
|
|
33
|
+
[K2 in keyof z.input<RequestPart<R, Part>>]: ValidationTargets[K][K2];
|
|
34
|
+
};
|
|
29
35
|
};
|
|
30
36
|
out: {
|
|
31
37
|
[K in Type]: z.output<RequestPart<R, Part>>;
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
OpenAPIHono: () => OpenAPIHono,
|
|
24
24
|
createRoute: () => createRoute,
|
|
25
|
+
extendZodWithOpenApi: () => import_zod_to_openapi.extendZodWithOpenApi,
|
|
25
26
|
z: () => import_zod.z
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -213,5 +214,6 @@ function addBasePathToDocument(document, basePath) {
|
|
|
213
214
|
0 && (module.exports = {
|
|
214
215
|
OpenAPIHono,
|
|
215
216
|
createRoute,
|
|
217
|
+
extendZodWithOpenApi,
|
|
216
218
|
z
|
|
217
219
|
});
|
package/dist/index.mjs
CHANGED