@hono/zod-openapi 0.1.2 → 0.2.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 CHANGED
@@ -6,7 +6,6 @@ _Note: This is not standalone middleware but is hosted on the monorepo "[github.
6
6
 
7
7
  ## Limitations
8
8
 
9
- - Currently, it does not support validation of _headers_ and _cookies_.
10
9
  - An instance of Zod OpenAPI Hono cannot be used as a "subApp" in conjunction with `rootApp.route('/api', subApp)`.
11
10
 
12
11
  ## Usage
package/dist/index.cjs CHANGED
@@ -64,6 +64,14 @@ var OpenAPIHono = class extends import_hono.Hono {
64
64
  const validator = (0, import_zod_validator.zValidator)("param", route.request.params, hook);
65
65
  validators.push(validator);
66
66
  }
67
+ if (route.request?.headers) {
68
+ const validator = (0, import_zod_validator.zValidator)("header", route.request.headers, hook);
69
+ validators.push(validator);
70
+ }
71
+ if (route.request?.cookies) {
72
+ const validator = (0, import_zod_validator.zValidator)("cookie", route.request.cookies, hook);
73
+ validators.push(validator);
74
+ }
67
75
  const bodyContent = route.request?.body?.content;
68
76
  if (bodyContent) {
69
77
  for (const mediaType of Object.keys(bodyContent)) {
package/dist/index.d.cts CHANGED
@@ -51,7 +51,7 @@ type ConvertPathType<T extends string> = T extends `${infer _}/{${infer Param}}$
51
51
  declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
52
52
  #private;
53
53
  constructor();
54
- openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E, ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
54
+ 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, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E, ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
55
55
  getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject;
56
56
  doc: (path: string, config: OpenAPIObjectConfig) => void;
57
57
  }
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ type ConvertPathType<T extends string> = T extends `${infer _}/{${infer Param}}$
51
51
  declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
52
52
  #private;
53
53
  constructor();
54
- openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E, ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
54
+ 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, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E, ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
55
55
  getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject;
56
56
  doc: (path: string, config: OpenAPIObjectConfig) => void;
57
57
  }
package/dist/index.js CHANGED
@@ -39,6 +39,14 @@ var OpenAPIHono = class extends Hono {
39
39
  const validator = zValidator("param", route.request.params, hook);
40
40
  validators.push(validator);
41
41
  }
42
+ if (route.request?.headers) {
43
+ const validator = zValidator("header", route.request.headers, hook);
44
+ validators.push(validator);
45
+ }
46
+ if (route.request?.cookies) {
47
+ const validator = zValidator("cookie", route.request.cookies, hook);
48
+ validators.push(validator);
49
+ }
42
50
  const bodyContent = route.request?.body?.content;
43
51
  if (bodyContent) {
44
52
  for (const mediaType of Object.keys(bodyContent)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/zod-openapi",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "A wrapper class of Hono which supports OpenAPI.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",