@hono/zod-openapi 0.12.2 → 0.14.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/dist/index.d.mts +15 -6
- package/dist/index.d.ts +15 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
|
-
import {
|
|
3
|
+
import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject } from '@asteasolutions/zod-to-openapi';
|
|
4
4
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
|
-
import { TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema
|
|
5
|
+
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
6
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
|
-
import { StatusCode } from 'hono/utils/http-status';
|
|
7
|
+
import { StatusCode, InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode } from 'hono/utils/http-status';
|
|
8
8
|
import { RemoveBlankRecord } from 'hono/utils/types';
|
|
9
9
|
import { ZodError, AnyZodObject, z, ZodSchema, ZodType } from 'zod';
|
|
10
10
|
export { z } from 'zod';
|
|
@@ -54,9 +54,18 @@ type InputTypeCookie<R extends RouteConfig> = InputTypeBase<R, 'cookies', 'cooki
|
|
|
54
54
|
type ExtractContent<T> = T extends {
|
|
55
55
|
[K in keyof T]: infer A;
|
|
56
56
|
} ? A extends Record<'schema', ZodSchema> ? z.infer<A['schema']> : never : never;
|
|
57
|
+
type StatusCodeRangeDefinitions = {
|
|
58
|
+
'1XX': InfoStatusCode;
|
|
59
|
+
'2XX': SuccessStatusCode;
|
|
60
|
+
'3XX': RedirectStatusCode;
|
|
61
|
+
'4XX': ClientErrorStatusCode;
|
|
62
|
+
'5XX': ServerErrorStatusCode;
|
|
63
|
+
};
|
|
64
|
+
type RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode;
|
|
65
|
+
type ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions ? StatusCodeRangeDefinitions[T] : T;
|
|
57
66
|
type RouteConfigToTypedResponse<R extends RouteConfig> = {
|
|
58
|
-
[Status in keyof R['responses'] &
|
|
59
|
-
}[keyof R['responses'] &
|
|
67
|
+
[Status in keyof R['responses'] & RouteConfigStatusCode]: IsJson<keyof R['responses'][Status]['content']> extends never ? TypedResponse<{}, ExtractStatusCode<Status>, string> : TypedResponse<ExtractContent<R['responses'][Status]['content']>, ExtractStatusCode<Status>, 'json'>;
|
|
68
|
+
}[keyof R['responses'] & RouteConfigStatusCode];
|
|
60
69
|
type Hook<T, E extends Env, P extends string, R> = (result: {
|
|
61
70
|
success: true;
|
|
62
71
|
data: T;
|
|
@@ -139,4 +148,4 @@ declare const createRoute: <P extends string, R extends Omit<RouteConfig, "path"
|
|
|
139
148
|
getRoutingPath(): RoutingPath<R['path']>;
|
|
140
149
|
};
|
|
141
150
|
|
|
142
|
-
export { type Hook, OpenAPIHono, type OpenAPIHonoOptions, type OpenAPIObjectConfigure, type RouteConfigToTypedResponse, type RouteHandler, type RouteHook, createRoute };
|
|
151
|
+
export { type Hook, OpenAPIHono, type OpenAPIHonoOptions, type OpenAPIObjectConfigure, type RouteConfig, type RouteConfigToTypedResponse, type RouteHandler, type RouteHook, createRoute };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
|
-
import {
|
|
3
|
+
import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject } from '@asteasolutions/zod-to-openapi';
|
|
4
4
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
|
-
import { TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema
|
|
5
|
+
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
6
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
|
-
import { StatusCode } from 'hono/utils/http-status';
|
|
7
|
+
import { StatusCode, InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode } from 'hono/utils/http-status';
|
|
8
8
|
import { RemoveBlankRecord } from 'hono/utils/types';
|
|
9
9
|
import { ZodError, AnyZodObject, z, ZodSchema, ZodType } from 'zod';
|
|
10
10
|
export { z } from 'zod';
|
|
@@ -54,9 +54,18 @@ type InputTypeCookie<R extends RouteConfig> = InputTypeBase<R, 'cookies', 'cooki
|
|
|
54
54
|
type ExtractContent<T> = T extends {
|
|
55
55
|
[K in keyof T]: infer A;
|
|
56
56
|
} ? A extends Record<'schema', ZodSchema> ? z.infer<A['schema']> : never : never;
|
|
57
|
+
type StatusCodeRangeDefinitions = {
|
|
58
|
+
'1XX': InfoStatusCode;
|
|
59
|
+
'2XX': SuccessStatusCode;
|
|
60
|
+
'3XX': RedirectStatusCode;
|
|
61
|
+
'4XX': ClientErrorStatusCode;
|
|
62
|
+
'5XX': ServerErrorStatusCode;
|
|
63
|
+
};
|
|
64
|
+
type RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode;
|
|
65
|
+
type ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions ? StatusCodeRangeDefinitions[T] : T;
|
|
57
66
|
type RouteConfigToTypedResponse<R extends RouteConfig> = {
|
|
58
|
-
[Status in keyof R['responses'] &
|
|
59
|
-
}[keyof R['responses'] &
|
|
67
|
+
[Status in keyof R['responses'] & RouteConfigStatusCode]: IsJson<keyof R['responses'][Status]['content']> extends never ? TypedResponse<{}, ExtractStatusCode<Status>, string> : TypedResponse<ExtractContent<R['responses'][Status]['content']>, ExtractStatusCode<Status>, 'json'>;
|
|
68
|
+
}[keyof R['responses'] & RouteConfigStatusCode];
|
|
60
69
|
type Hook<T, E extends Env, P extends string, R> = (result: {
|
|
61
70
|
success: true;
|
|
62
71
|
data: T;
|
|
@@ -139,4 +148,4 @@ declare const createRoute: <P extends string, R extends Omit<RouteConfig, "path"
|
|
|
139
148
|
getRoutingPath(): RoutingPath<R['path']>;
|
|
140
149
|
};
|
|
141
150
|
|
|
142
|
-
export { type Hook, OpenAPIHono, type OpenAPIHonoOptions, type OpenAPIObjectConfigure, type RouteConfigToTypedResponse, type RouteHandler, type RouteHook, createRoute };
|
|
151
|
+
export { type Hook, OpenAPIHono, type OpenAPIHonoOptions, type OpenAPIObjectConfigure, type RouteConfig, type RouteConfigToTypedResponse, type RouteHandler, type RouteHook, createRoute };
|