@hono/zod-openapi 0.19.8 → 0.19.9
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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/index.cjs +8 -4
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +8 -4
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hono/zod-openapi
|
|
2
2
|
|
|
3
|
+
## 0.19.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1217](https://github.com/honojs/middleware/pull/1217) [`9f64138406a2c513462f2a4873b2ef8be36df9d8`](https://github.com/honojs/middleware/commit/9f64138406a2c513462f2a4873b2ef8be36df9d8) Thanks [@BarryThePenguin](https://github.com/BarryThePenguin)! - Add explicit return types
|
|
8
|
+
|
|
3
9
|
## 0.19.8
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -472,7 +472,7 @@ Be careful when combining `OpenAPIHono` instances with plain `Hono` instances. `
|
|
|
472
472
|
|
|
473
473
|
If you're migrating from plain `Hono` to `OpenAPIHono`, we recommend porting your top-level app, then working your way down the router tree.
|
|
474
474
|
|
|
475
|
-
When using the `.route()` method to mount a child OpenAPIHono app that uses path parameters, you should use the Hono
|
|
475
|
+
When using the `.route()` method to mount a child OpenAPIHono app that uses path parameters, you should use the Hono _:param_ syntax in the parent route path, rather than the OpenAPI _{param}_ syntax:
|
|
476
476
|
|
|
477
477
|
```
|
|
478
478
|
const bookActionsApp = new OpenAPIHono()
|
package/dist/index.cjs
CHANGED
|
@@ -189,8 +189,8 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
189
189
|
switch (def.type) {
|
|
190
190
|
case "component":
|
|
191
191
|
return this.openAPIRegistry.registerComponent(def.componentType, def.name, def.component);
|
|
192
|
-
case "route":
|
|
193
|
-
|
|
192
|
+
case "route": {
|
|
193
|
+
this.openAPIRegistry.registerPath({
|
|
194
194
|
...def.route,
|
|
195
195
|
path: (0, import_url.mergePath)(
|
|
196
196
|
pathForOpenAPI,
|
|
@@ -199,8 +199,10 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
199
199
|
def.route.path
|
|
200
200
|
)
|
|
201
201
|
});
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
case "webhook": {
|
|
205
|
+
this.openAPIRegistry.registerWebhook({
|
|
204
206
|
...def.webhook,
|
|
205
207
|
path: (0, import_url.mergePath)(
|
|
206
208
|
pathForOpenAPI,
|
|
@@ -209,6 +211,8 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
209
211
|
def.webhook.path
|
|
210
212
|
)
|
|
211
213
|
});
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
212
216
|
case "schema":
|
|
213
217
|
return this.openAPIRegistry.register(def.schema._def.openapi._internal.refId, def.schema);
|
|
214
218
|
case "parameter":
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
|
-
import * as _asteasolutions_zod_to_openapi_dist_v3_1_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.1/openapi-generator';
|
|
3
|
-
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
4
|
-
import * as _asteasolutions_zod_to_openapi_dist_v3_0_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
1
|
import { RouteConfig as RouteConfig$1, ZodRequestBody, ZodContentObject, ZodMediaTypeObject, OpenApiGeneratorV3, OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
6
2
|
export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
7
3
|
import { MiddlewareHandler, TypedResponse, Env, ValidationTargets, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
8
4
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
9
5
|
import { InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode, StatusCode } from 'hono/utils/http-status';
|
|
10
6
|
import { SimplifyDeepArray, JSONValue, JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
7
|
+
import { OpenAPIObject } from 'openapi3-ts/oas30';
|
|
8
|
+
import { OpenAPIObject as OpenAPIObject$1 } from 'openapi3-ts/oas31';
|
|
11
9
|
import { ZodSchema, z, ZodError, ZodType } from 'zod';
|
|
12
10
|
export { z } from 'zod';
|
|
13
11
|
|
|
@@ -193,8 +191,8 @@ declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath e
|
|
|
193
191
|
};
|
|
194
192
|
};
|
|
195
193
|
} ? MaybePromise<RouteConfigToTypedResponse<R>> | undefined : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response> | undefined> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], MergePath<BasePath, P>, I, RouteConfigToTypedResponse<R>>, BasePath>;
|
|
196
|
-
getOpenAPIDocument: (config: OpenAPIObjectConfig) =>
|
|
197
|
-
getOpenAPI31Document: (config: OpenAPIObjectConfig) =>
|
|
194
|
+
getOpenAPIDocument: (config: OpenAPIObjectConfig) => OpenAPIObject;
|
|
195
|
+
getOpenAPI31Document: (config: OpenAPIObjectConfig) => OpenAPIObject$1;
|
|
198
196
|
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
199
197
|
doc31: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
200
198
|
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): OpenAPIHono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
|
-
import * as _asteasolutions_zod_to_openapi_dist_v3_1_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.1/openapi-generator';
|
|
3
|
-
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
4
|
-
import * as _asteasolutions_zod_to_openapi_dist_v3_0_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
1
|
import { RouteConfig as RouteConfig$1, ZodRequestBody, ZodContentObject, ZodMediaTypeObject, OpenApiGeneratorV3, OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
6
2
|
export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
7
3
|
import { MiddlewareHandler, TypedResponse, Env, ValidationTargets, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
8
4
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
9
5
|
import { InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode, StatusCode } from 'hono/utils/http-status';
|
|
10
6
|
import { SimplifyDeepArray, JSONValue, JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
7
|
+
import { OpenAPIObject } from 'openapi3-ts/oas30';
|
|
8
|
+
import { OpenAPIObject as OpenAPIObject$1 } from 'openapi3-ts/oas31';
|
|
11
9
|
import { ZodSchema, z, ZodError, ZodType } from 'zod';
|
|
12
10
|
export { z } from 'zod';
|
|
13
11
|
|
|
@@ -193,8 +191,8 @@ declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath e
|
|
|
193
191
|
};
|
|
194
192
|
};
|
|
195
193
|
} ? MaybePromise<RouteConfigToTypedResponse<R>> | undefined : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response> | undefined> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], MergePath<BasePath, P>, I, RouteConfigToTypedResponse<R>>, BasePath>;
|
|
196
|
-
getOpenAPIDocument: (config: OpenAPIObjectConfig) =>
|
|
197
|
-
getOpenAPI31Document: (config: OpenAPIObjectConfig) =>
|
|
194
|
+
getOpenAPIDocument: (config: OpenAPIObjectConfig) => OpenAPIObject;
|
|
195
|
+
getOpenAPI31Document: (config: OpenAPIObjectConfig) => OpenAPIObject$1;
|
|
198
196
|
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
199
197
|
doc31: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
200
198
|
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): OpenAPIHono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>;
|
package/dist/index.js
CHANGED
|
@@ -167,8 +167,8 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
167
167
|
switch (def.type) {
|
|
168
168
|
case "component":
|
|
169
169
|
return this.openAPIRegistry.registerComponent(def.componentType, def.name, def.component);
|
|
170
|
-
case "route":
|
|
171
|
-
|
|
170
|
+
case "route": {
|
|
171
|
+
this.openAPIRegistry.registerPath({
|
|
172
172
|
...def.route,
|
|
173
173
|
path: mergePath(
|
|
174
174
|
pathForOpenAPI,
|
|
@@ -177,8 +177,10 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
177
177
|
def.route.path
|
|
178
178
|
)
|
|
179
179
|
});
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
case "webhook": {
|
|
183
|
+
this.openAPIRegistry.registerWebhook({
|
|
182
184
|
...def.webhook,
|
|
183
185
|
path: mergePath(
|
|
184
186
|
pathForOpenAPI,
|
|
@@ -187,6 +189,8 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
187
189
|
def.webhook.path
|
|
188
190
|
)
|
|
189
191
|
});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
190
194
|
case "schema":
|
|
191
195
|
return this.openAPIRegistry.register(def.schema._def.openapi._internal.refId, def.schema);
|
|
192
196
|
case "parameter":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/zod-openapi",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.9",
|
|
4
4
|
"description": "A wrapper class of Hono which supports OpenAPI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -47,13 +47,14 @@
|
|
|
47
47
|
"publint": "^0.3.9",
|
|
48
48
|
"tsup": "^8.4.0",
|
|
49
49
|
"typescript": "^5.8.2",
|
|
50
|
-
"vitest": "^3.
|
|
50
|
+
"vitest": "^3.2.4",
|
|
51
51
|
"yaml": "^2.4.3",
|
|
52
52
|
"zod": "^3.22.1"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@asteasolutions/zod-to-openapi": "^7.3.0",
|
|
56
|
-
"@hono/zod-validator": "^0.7.0"
|
|
56
|
+
"@hono/zod-validator": "^0.7.0",
|
|
57
|
+
"openapi3-ts": "^4.5.0"
|
|
57
58
|
},
|
|
58
59
|
"engines": {
|
|
59
60
|
"node": ">=16.0.0"
|