@hono/zod-openapi
Advanced tools
Comparing version 0.13.0 to 0.14.0
@@ -7,3 +7,3 @@ import * as openapi3_ts_oas31 from 'openapi3-ts/oas31'; | ||
import { MergePath, MergeSchemaPath } from 'hono/types'; | ||
import { StatusCode } from 'hono/utils/http-status'; | ||
import { StatusCode, InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode } from 'hono/utils/http-status'; | ||
import { RemoveBlankRecord } from 'hono/utils/types'; | ||
@@ -58,5 +58,14 @@ import { ZodError, AnyZodObject, z, ZodSchema, ZodType } from 'zod'; | ||
} ? A extends Record<'schema', ZodSchema> ? z.infer<A['schema']> : never : never; | ||
type StatusCodeRangeDefinitions = { | ||
'1XX': InfoStatusCode; | ||
'2XX': SuccessStatusCode; | ||
'3XX': RedirectStatusCode; | ||
'4XX': ClientErrorStatusCode; | ||
'5XX': ServerErrorStatusCode; | ||
}; | ||
type RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode; | ||
type ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions ? StatusCodeRangeDefinitions[T] : T; | ||
type RouteConfigToTypedResponse<R extends RouteConfig> = { | ||
[Status in keyof R['responses'] & StatusCode]: IsJson<keyof R['responses'][Status]['content']> extends never ? TypedResponse<{}, Status, string> : TypedResponse<ExtractContent<R['responses'][Status]['content']>, Status, 'json'>; | ||
}[keyof R['responses'] & StatusCode]; | ||
[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'>; | ||
}[keyof R['responses'] & RouteConfigStatusCode]; | ||
type Hook<T, E extends Env, P extends string, R> = (result: { | ||
@@ -63,0 +72,0 @@ success: true; |
{ | ||
"name": "@hono/zod-openapi", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "A wrapper class of Hono which supports OpenAPI.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
41970
547