@hono/zod-openapi
Advanced tools
Comparing version 0.9.0 to 0.9.1
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31'; | ||
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30'; | ||
import { RouteConfig, OpenAPIRegistry, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi'; | ||
import { RouteConfig, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi'; | ||
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator'; | ||
@@ -58,3 +58,4 @@ import { Env, Input, Handler, Context, Schema, Hono, ToSchema, TypedResponse } from 'hono'; | ||
type ConvertPathType<T extends string> = T extends `${infer Start}/{${infer Param}}${infer Rest}` ? `${Start}/:${Param}${ConvertPathType<Rest>}` : T; | ||
type HandlerResponse<O> = TypedResponse<O> | Promise<TypedResponse<O>> | Response | Promise<Response>; | ||
type HandlerTypedResponse<O> = TypedResponse<O> | Promise<TypedResponse<O>>; | ||
type HandlerAllResponse<O> = Response | Promise<Response> | TypedResponse<O> | Promise<TypedResponse<O>>; | ||
type OpenAPIHonoOptions<E extends Env> = { | ||
@@ -64,3 +65,11 @@ defaultHook?: Hook<any, E, any, any>; | ||
type HonoInit<E extends Env> = ConstructorParameters<typeof Hono>[0] & OpenAPIHonoOptions<E>; | ||
type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I, HandlerResponse<OutputType<R>>>; | ||
type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I, R extends { | ||
responses: { | ||
[statusCode: string]: { | ||
content: { | ||
[mediaType: string]: ZodMediaTypeObject; | ||
}; | ||
}; | ||
}; | ||
} ? HandlerTypedResponse<OutputType<R>> : HandlerAllResponse<OutputType<R>>>; | ||
type RouteHook<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Hook<I, E, P, OutputType<R>>; | ||
@@ -72,3 +81,11 @@ type OpenAPIObjectConfigure<E extends Env, P extends string> = OpenAPIObjectConfig | ((context: Context<E, P>) => OpenAPIObjectConfig); | ||
constructor(init?: HonoInit<E>); | ||
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeBase<R, "headers", "header"> & InputTypeBase<R, "cookies", "cookie"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, HandlerResponse<OutputType<R>>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>; | ||
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeBase<R, "headers", "header"> & InputTypeBase<R, "cookies", "cookie"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, R extends { | ||
responses: { | ||
[statusCode: string]: { | ||
content: { | ||
[mediaType: string]: ZodMediaTypeObject; | ||
}; | ||
}; | ||
}; | ||
} ? HandlerTypedResponse<OutputType<R>> : HandlerAllResponse<OutputType<R>>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>; | ||
getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject; | ||
@@ -75,0 +92,0 @@ getOpenAPI31Document: (config: OpenAPIObjectConfig) => openapi3_ts_oas31.OpenAPIObject; |
{ | ||
"name": "@hono/zod-openapi", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "A wrapper class of Hono which supports OpenAPI.", | ||
@@ -41,3 +41,3 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"hono": ">=3.9.0", | ||
"hono": ">=3.11.1", | ||
"zod": "3.*" | ||
@@ -47,3 +47,3 @@ }, | ||
"@hono/zod-validator": "^0.1.11", | ||
"hono": "^3.9.1", | ||
"hono": "^3.11.1", | ||
"zod": "^3.22.1" | ||
@@ -58,2 +58,2 @@ }, | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34559
399