hono-openapi 0.1.3 → 0.1.5
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 +2 -1
- package/package.json +4 -4
- package/src/types.d.ts +2 -0
- package/zod.cjs.js +1 -1
- package/zod.esm.js +1 -1
package/README.md
CHANGED
|
@@ -48,7 +48,8 @@ const responseSchema = z.string().openapi({ example: "Hello Steven!" });
|
|
|
48
48
|
|
|
49
49
|
Extending the Zod schema with OpenAPI properties is optional, but it will help you generate the OpenAPI specification. You can learn more about it here - [https://github.com/samchungy/zod-openapi](https://github.com/samchungy/zod-openapi).
|
|
50
50
|
|
|
51
|
-
> [!Tip]
|
|
51
|
+
> [!Tip]
|
|
52
|
+
> The `querySchema` schema will be registered as "#/components/schemas/Query" refs in the OpenAPI document. If you want to register the schema as referenced components, use .openapi() method.
|
|
52
53
|
|
|
53
54
|
Next, create your route -
|
|
54
55
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono-openapi",
|
|
3
3
|
"description": "OpenAPI schema generator for Hono",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"hono",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"hono": "^4.6.4",
|
|
24
24
|
"@hono/zod-validator": "^0.4.1",
|
|
25
25
|
"zod": "^3.23.8",
|
|
26
|
-
"zod-openapi": "^3.1.1"
|
|
26
|
+
"zod-openapi": "^3.1.1",
|
|
27
|
+
"openapi-types": "^12.1.3"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@rollup/plugin-terser": "^0.4.4"
|
|
30
|
-
"openapi-types": "^12.1.3"
|
|
30
|
+
"@rollup/plugin-terser": "^0.4.4"
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
package/src/types.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { ALLOWED_METHODS } from "./utils";
|
|
|
3
3
|
export type OpenAPIRouteHandlerConfig = {
|
|
4
4
|
version: "3.0.0" | "3.0.1" | "3.0.2" | "3.0.3" | "3.1.0";
|
|
5
5
|
components: OpenAPIV3.ComponentsObject["schemas"];
|
|
6
|
+
} & {
|
|
7
|
+
[key: string]: unknown;
|
|
6
8
|
};
|
|
7
9
|
export type ResolverResult = {
|
|
8
10
|
builder: (options?: OpenAPIRouteHandlerConfig) => {
|
package/zod.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@hono/zod-validator"),o=require("zod-openapi"),s=require("./constants.cjs.js");function n(e){return{builder:s=>o.createSchema(e,s?{openapi:s.version,components:s.components}:void 0),validator:e.parse}}exports.resolver=n,exports.validator=function(o,r,
|
|
1
|
+
"use strict";var e=require("@hono/zod-validator"),o=require("zod-openapi"),s=require("./constants.cjs.js");function n(e){return{builder:s=>o.createSchema(e,s?{openapi:s.version,components:s.components,schemaType:s.schemaType}:void 0),validator:e.parse}}exports.resolver=n,exports.validator=function(o,r,a){const t=e.zValidator(o,r,a);return Object.assign(t,{[s.uniqueSymbol]:{resolver:e=>{const s=n(r).builder(e),a={};if("form"===o||"json"===o)a.requestBody={content:{["json"===o?"application/json":"application/x-www-form-urlencoded"]:{schema:s.schema}}};else{const e=[];if("$ref"in s.schema)e.push({in:o,name:s.schema.$ref,schema:s.schema});else for(const[n,r]of Object.entries(s.schema.properties??{}))e.push({in:o,name:n,schema:r});a.parameters=e}return{docs:a,components:s.components}},metadata:{schemaType:"input"}}})};
|
package/zod.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{zValidator as e}from"@hono/zod-validator";import{createSchema as o}from"zod-openapi";import{u as n}from"./constants.esm.js";function s(e){return{builder:n=>o(e,n?{openapi:n.version,components:n.components}:void 0),validator:e.parse}}function t(o,t,r){const a=e(o,t,r);return Object.assign(a,{[n]:{resolver:e=>{const n=s(t).builder(e),r={};if("form"===o||"json"===o)r.requestBody={content:{["json"===o?"application/json":"application/x-www-form-urlencoded"]:{schema:n.schema}}};else{const e=[];if("$ref"in n.schema)e.push({in:o,name:n.schema.$ref,schema:n.schema});else for(const[s,t]of Object.entries(n.schema.properties??{}))e.push({in:o,name:s,schema:t});r.parameters=e}return{docs:r,components:n.components}},metadata:{schemaType:"input"}}})}export{s as resolver,t as validator};
|
|
1
|
+
import{zValidator as e}from"@hono/zod-validator";import{createSchema as o}from"zod-openapi";import{u as n}from"./constants.esm.js";function s(e){return{builder:n=>o(e,n?{openapi:n.version,components:n.components,schemaType:n.schemaType}:void 0),validator:e.parse}}function t(o,t,r){const a=e(o,t,r);return Object.assign(a,{[n]:{resolver:e=>{const n=s(t).builder(e),r={};if("form"===o||"json"===o)r.requestBody={content:{["json"===o?"application/json":"application/x-www-form-urlencoded"]:{schema:n.schema}}};else{const e=[];if("$ref"in n.schema)e.push({in:o,name:n.schema.$ref,schema:n.schema});else for(const[s,t]of Object.entries(n.schema.properties??{}))e.push({in:o,name:s,schema:t});r.parameters=e}return{docs:r,components:n.components}},metadata:{schemaType:"input"}}})}export{s as resolver,t as validator};
|