@hono/zod-openapi 0.14.9 → 0.15.1

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 CHANGED
@@ -1,8 +1,7 @@
1
1
  import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
2
  import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
3
- import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject } from '@asteasolutions/zod-to-openapi';
3
+ import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject, OpenApiGeneratorV3 } from '@asteasolutions/zod-to-openapi';
4
4
  export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
5
- import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
6
5
  import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema, ValidationTargets } from 'hono';
7
6
  import { MergePath, MergeSchemaPath } from 'hono/types';
8
7
  import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
@@ -21,7 +20,7 @@ type RequestTypes = {
21
20
  cookies?: ZodType;
22
21
  headers?: ZodType | ZodType[];
23
22
  };
24
- type IsJson<T> = T extends string ? T extends `application/json${infer _Rest}` ? 'json' : never : never;
23
+ type IsJson<T> = T extends string ? T extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? 'json' : never : never : never;
25
24
  type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
26
25
  type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
27
26
  type HasUndefined<T> = undefined extends T ? true : false;
@@ -94,6 +93,7 @@ type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input =
94
93
  };
95
94
  } ? MaybePromise<RouteConfigToTypedResponse<R>> : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response>>;
96
95
  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, RouteConfigToTypedResponse<R> | Response | Promise<Response> | void | Promise<void>>;
96
+ type OpenAPIObjectConfig = Parameters<InstanceType<typeof OpenApiGeneratorV3>['generateDocument']>[0];
97
97
  type OpenAPIObjectConfigure<E extends Env, P extends string> = OpenAPIObjectConfig | ((context: Context<E, P>) => OpenAPIObjectConfig);
98
98
  declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
99
99
  openAPIRegistry: OpenAPIRegistry;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
2
  import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
3
- import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject } from '@asteasolutions/zod-to-openapi';
3
+ import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject, OpenApiGeneratorV3 } from '@asteasolutions/zod-to-openapi';
4
4
  export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
5
- import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
6
5
  import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema, ValidationTargets } from 'hono';
7
6
  import { MergePath, MergeSchemaPath } from 'hono/types';
8
7
  import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
@@ -21,7 +20,7 @@ type RequestTypes = {
21
20
  cookies?: ZodType;
22
21
  headers?: ZodType | ZodType[];
23
22
  };
24
- type IsJson<T> = T extends string ? T extends `application/json${infer _Rest}` ? 'json' : never : never;
23
+ type IsJson<T> = T extends string ? T extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? 'json' : never : never : never;
25
24
  type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
26
25
  type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
27
26
  type HasUndefined<T> = undefined extends T ? true : false;
@@ -94,6 +93,7 @@ type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input =
94
93
  };
95
94
  } ? MaybePromise<RouteConfigToTypedResponse<R>> : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response>>;
96
95
  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, RouteConfigToTypedResponse<R> | Response | Promise<Response> | void | Promise<void>>;
96
+ type OpenAPIObjectConfig = Parameters<InstanceType<typeof OpenApiGeneratorV3>['generateDocument']>[0];
97
97
  type OpenAPIObjectConfigure<E extends Env, P extends string> = OpenAPIObjectConfig | ((context: Context<E, P>) => OpenAPIObjectConfig);
98
98
  declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
99
99
  openAPIRegistry: OpenAPIRegistry;
package/dist/index.js CHANGED
@@ -99,7 +99,7 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
99
99
  if (!(schema instanceof import_zod.ZodType)) {
100
100
  continue;
101
101
  }
102
- if (mediaType.startsWith("application/json")) {
102
+ if (/^application\/([a-z-\.]+\+)?json/.test(mediaType)) {
103
103
  const validator = (0, import_zod_validator.zValidator)("json", schema, hook);
104
104
  validators.push(validator);
105
105
  }
package/dist/index.mjs CHANGED
@@ -77,7 +77,7 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
77
77
  if (!(schema instanceof ZodType)) {
78
78
  continue;
79
79
  }
80
- if (mediaType.startsWith("application/json")) {
80
+ if (/^application\/([a-z-\.]+\+)?json/.test(mediaType)) {
81
81
  const validator = zValidator("json", schema, hook);
82
82
  validators.push(validator);
83
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/zod-openapi",
3
- "version": "0.14.9",
3
+ "version": "0.15.1",
4
4
  "description": "A wrapper class of Hono which supports OpenAPI.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",