hono-openapi 0.5.0-rc.2 → 0.5.0-rc.3

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.cts CHANGED
@@ -2,176 +2,10 @@ import * as openapi_types from 'openapi-types';
2
2
  import { OpenAPIV3_1 } from 'openapi-types';
3
3
  import { Env, Input, Context, Next, MiddlewareHandler, ValidationTargets, Hono } from 'hono';
4
4
  import { BlankInput, TypedResponse, ValidationTargets as ValidationTargets$1, RouterRoute, BlankEnv, Input as Input$1, Schema, BlankSchema, MiddlewareHandler as MiddlewareHandler$1 } from 'hono/types';
5
+ import * as json_schema from 'json-schema';
5
6
  import { Hook } from '@hono/standard-validator';
6
7
  import { StatusCode } from 'hono/utils/http-status';
7
8
 
8
- // ==================================================================================================
9
- // JSON Schema Draft 07
10
- // ==================================================================================================
11
- // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
12
- // --------------------------------------------------------------------------------------------------
13
-
14
- /**
15
- * Primitive type
16
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
17
- */
18
- type JSONSchema7TypeName =
19
- | "string" //
20
- | "number"
21
- | "integer"
22
- | "boolean"
23
- | "object"
24
- | "array"
25
- | "null";
26
-
27
- /**
28
- * Primitive type
29
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
30
- */
31
- type JSONSchema7Type =
32
- | string //
33
- | number
34
- | boolean
35
- | JSONSchema7Object
36
- | JSONSchema7Array
37
- | null;
38
-
39
- // Workaround for infinite type recursion
40
- interface JSONSchema7Object {
41
- [key: string]: JSONSchema7Type;
42
- }
43
-
44
- // Workaround for infinite type recursion
45
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
46
- interface JSONSchema7Array extends Array<JSONSchema7Type> {}
47
-
48
- /**
49
- * Meta schema
50
- *
51
- * Recommended values:
52
- * - 'http://json-schema.org/schema#'
53
- * - 'http://json-schema.org/hyper-schema#'
54
- * - 'http://json-schema.org/draft-07/schema#'
55
- * - 'http://json-schema.org/draft-07/hyper-schema#'
56
- *
57
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
58
- */
59
- type JSONSchema7Version = string;
60
-
61
- /**
62
- * JSON Schema v7
63
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
64
- */
65
- type JSONSchema7Definition = JSONSchema7 | boolean;
66
- interface JSONSchema7 {
67
- $id?: string | undefined;
68
- $ref?: string | undefined;
69
- $schema?: JSONSchema7Version | undefined;
70
- $comment?: string | undefined;
71
-
72
- /**
73
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
74
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
75
- */
76
- $defs?: {
77
- [key: string]: JSONSchema7Definition;
78
- } | undefined;
79
-
80
- /**
81
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
82
- */
83
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
84
- enum?: JSONSchema7Type[] | undefined;
85
- const?: JSONSchema7Type | undefined;
86
-
87
- /**
88
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
89
- */
90
- multipleOf?: number | undefined;
91
- maximum?: number | undefined;
92
- exclusiveMaximum?: number | undefined;
93
- minimum?: number | undefined;
94
- exclusiveMinimum?: number | undefined;
95
-
96
- /**
97
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
98
- */
99
- maxLength?: number | undefined;
100
- minLength?: number | undefined;
101
- pattern?: string | undefined;
102
-
103
- /**
104
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
105
- */
106
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
107
- additionalItems?: JSONSchema7Definition | undefined;
108
- maxItems?: number | undefined;
109
- minItems?: number | undefined;
110
- uniqueItems?: boolean | undefined;
111
- contains?: JSONSchema7Definition | undefined;
112
-
113
- /**
114
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
115
- */
116
- maxProperties?: number | undefined;
117
- minProperties?: number | undefined;
118
- required?: string[] | undefined;
119
- properties?: {
120
- [key: string]: JSONSchema7Definition;
121
- } | undefined;
122
- patternProperties?: {
123
- [key: string]: JSONSchema7Definition;
124
- } | undefined;
125
- additionalProperties?: JSONSchema7Definition | undefined;
126
- dependencies?: {
127
- [key: string]: JSONSchema7Definition | string[];
128
- } | undefined;
129
- propertyNames?: JSONSchema7Definition | undefined;
130
-
131
- /**
132
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
133
- */
134
- if?: JSONSchema7Definition | undefined;
135
- then?: JSONSchema7Definition | undefined;
136
- else?: JSONSchema7Definition | undefined;
137
-
138
- /**
139
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
140
- */
141
- allOf?: JSONSchema7Definition[] | undefined;
142
- anyOf?: JSONSchema7Definition[] | undefined;
143
- oneOf?: JSONSchema7Definition[] | undefined;
144
- not?: JSONSchema7Definition | undefined;
145
-
146
- /**
147
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
148
- */
149
- format?: string | undefined;
150
-
151
- /**
152
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
153
- */
154
- contentMediaType?: string | undefined;
155
- contentEncoding?: string | undefined;
156
-
157
- /**
158
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
159
- */
160
- definitions?: {
161
- [key: string]: JSONSchema7Definition;
162
- } | undefined;
163
-
164
- /**
165
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
166
- */
167
- title?: string | undefined;
168
- description?: string | undefined;
169
- default?: JSONSchema7Type | undefined;
170
- readOnly?: boolean | undefined;
171
- writeOnly?: boolean | undefined;
172
- examples?: JSONSchema7Type | undefined;
173
- }
174
-
175
9
  /** The Standard Schema interface. */
176
10
  interface StandardSchemaV1<Input = unknown, Output = Input> {
177
11
  /** The Standard Schema properties. */
@@ -237,7 +71,7 @@ declare namespace StandardSchemaV1 {
237
71
  declare function resolver<Schema extends StandardSchemaV1>(schema: Schema): {
238
72
  vendor: string;
239
73
  validate: (value: unknown) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>;
240
- toJSONSchema: (options?: Record<string, unknown>) => Promise<JSONSchema7>;
74
+ toJSONSchema: (options?: Record<string, unknown>) => Promise<json_schema.JSONSchema7>;
241
75
  toOpenAPISchema: (options?: Record<string, unknown>) => Promise<{
242
76
  schema: OpenAPIV3_1.SchemaObject;
243
77
  components: OpenAPIV3_1.ComponentsObject | undefined;
package/dist/index.d.ts CHANGED
@@ -2,176 +2,10 @@ import * as openapi_types from 'openapi-types';
2
2
  import { OpenAPIV3_1 } from 'openapi-types';
3
3
  import { Env, Input, Context, Next, MiddlewareHandler, ValidationTargets, Hono } from 'hono';
4
4
  import { BlankInput, TypedResponse, ValidationTargets as ValidationTargets$1, RouterRoute, BlankEnv, Input as Input$1, Schema, BlankSchema, MiddlewareHandler as MiddlewareHandler$1 } from 'hono/types';
5
+ import * as json_schema from 'json-schema';
5
6
  import { Hook } from '@hono/standard-validator';
6
7
  import { StatusCode } from 'hono/utils/http-status';
7
8
 
8
- // ==================================================================================================
9
- // JSON Schema Draft 07
10
- // ==================================================================================================
11
- // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
12
- // --------------------------------------------------------------------------------------------------
13
-
14
- /**
15
- * Primitive type
16
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
17
- */
18
- type JSONSchema7TypeName =
19
- | "string" //
20
- | "number"
21
- | "integer"
22
- | "boolean"
23
- | "object"
24
- | "array"
25
- | "null";
26
-
27
- /**
28
- * Primitive type
29
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
30
- */
31
- type JSONSchema7Type =
32
- | string //
33
- | number
34
- | boolean
35
- | JSONSchema7Object
36
- | JSONSchema7Array
37
- | null;
38
-
39
- // Workaround for infinite type recursion
40
- interface JSONSchema7Object {
41
- [key: string]: JSONSchema7Type;
42
- }
43
-
44
- // Workaround for infinite type recursion
45
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
46
- interface JSONSchema7Array extends Array<JSONSchema7Type> {}
47
-
48
- /**
49
- * Meta schema
50
- *
51
- * Recommended values:
52
- * - 'http://json-schema.org/schema#'
53
- * - 'http://json-schema.org/hyper-schema#'
54
- * - 'http://json-schema.org/draft-07/schema#'
55
- * - 'http://json-schema.org/draft-07/hyper-schema#'
56
- *
57
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
58
- */
59
- type JSONSchema7Version = string;
60
-
61
- /**
62
- * JSON Schema v7
63
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
64
- */
65
- type JSONSchema7Definition = JSONSchema7 | boolean;
66
- interface JSONSchema7 {
67
- $id?: string | undefined;
68
- $ref?: string | undefined;
69
- $schema?: JSONSchema7Version | undefined;
70
- $comment?: string | undefined;
71
-
72
- /**
73
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
74
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
75
- */
76
- $defs?: {
77
- [key: string]: JSONSchema7Definition;
78
- } | undefined;
79
-
80
- /**
81
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
82
- */
83
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
84
- enum?: JSONSchema7Type[] | undefined;
85
- const?: JSONSchema7Type | undefined;
86
-
87
- /**
88
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
89
- */
90
- multipleOf?: number | undefined;
91
- maximum?: number | undefined;
92
- exclusiveMaximum?: number | undefined;
93
- minimum?: number | undefined;
94
- exclusiveMinimum?: number | undefined;
95
-
96
- /**
97
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
98
- */
99
- maxLength?: number | undefined;
100
- minLength?: number | undefined;
101
- pattern?: string | undefined;
102
-
103
- /**
104
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
105
- */
106
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
107
- additionalItems?: JSONSchema7Definition | undefined;
108
- maxItems?: number | undefined;
109
- minItems?: number | undefined;
110
- uniqueItems?: boolean | undefined;
111
- contains?: JSONSchema7Definition | undefined;
112
-
113
- /**
114
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
115
- */
116
- maxProperties?: number | undefined;
117
- minProperties?: number | undefined;
118
- required?: string[] | undefined;
119
- properties?: {
120
- [key: string]: JSONSchema7Definition;
121
- } | undefined;
122
- patternProperties?: {
123
- [key: string]: JSONSchema7Definition;
124
- } | undefined;
125
- additionalProperties?: JSONSchema7Definition | undefined;
126
- dependencies?: {
127
- [key: string]: JSONSchema7Definition | string[];
128
- } | undefined;
129
- propertyNames?: JSONSchema7Definition | undefined;
130
-
131
- /**
132
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
133
- */
134
- if?: JSONSchema7Definition | undefined;
135
- then?: JSONSchema7Definition | undefined;
136
- else?: JSONSchema7Definition | undefined;
137
-
138
- /**
139
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
140
- */
141
- allOf?: JSONSchema7Definition[] | undefined;
142
- anyOf?: JSONSchema7Definition[] | undefined;
143
- oneOf?: JSONSchema7Definition[] | undefined;
144
- not?: JSONSchema7Definition | undefined;
145
-
146
- /**
147
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
148
- */
149
- format?: string | undefined;
150
-
151
- /**
152
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
153
- */
154
- contentMediaType?: string | undefined;
155
- contentEncoding?: string | undefined;
156
-
157
- /**
158
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
159
- */
160
- definitions?: {
161
- [key: string]: JSONSchema7Definition;
162
- } | undefined;
163
-
164
- /**
165
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
166
- */
167
- title?: string | undefined;
168
- description?: string | undefined;
169
- default?: JSONSchema7Type | undefined;
170
- readOnly?: boolean | undefined;
171
- writeOnly?: boolean | undefined;
172
- examples?: JSONSchema7Type | undefined;
173
- }
174
-
175
9
  /** The Standard Schema interface. */
176
10
  interface StandardSchemaV1<Input = unknown, Output = Input> {
177
11
  /** The Standard Schema properties. */
@@ -237,7 +71,7 @@ declare namespace StandardSchemaV1 {
237
71
  declare function resolver<Schema extends StandardSchemaV1>(schema: Schema): {
238
72
  vendor: string;
239
73
  validate: (value: unknown) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>;
240
- toJSONSchema: (options?: Record<string, unknown>) => Promise<JSONSchema7>;
74
+ toJSONSchema: (options?: Record<string, unknown>) => Promise<json_schema.JSONSchema7>;
241
75
  toOpenAPISchema: (options?: Record<string, unknown>) => Promise<{
242
76
  schema: OpenAPIV3_1.SchemaObject;
243
77
  components: OpenAPIV3_1.ComponentsObject | undefined;
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.5.0-rc.2",
4
+ "version": "0.5.0-rc.3",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -44,8 +44,9 @@
44
44
  "peerDependencies": {
45
45
  "@hono/standard-validator": "^0.1.2",
46
46
  "@sinclair/typebox": "^0.34.9",
47
- "@standard-community/standard-json": "^0.3.0-rc.1",
47
+ "@standard-community/standard-json": "^0.3.0-rc.3",
48
48
  "@standard-community/standard-openapi": "^0.2.0-rc.1",
49
+ "@types/json-schema": "^7.0.15",
49
50
  "arktype": "^2.0.0",
50
51
  "effect": "^3.16.12",
51
52
  "hono": "^4.8.3",
@@ -79,7 +80,6 @@
79
80
  "devDependencies": {
80
81
  "@biomejs/biome": "^2.0.6",
81
82
  "@standard-schema/spec": "^1.0.0",
82
- "@types/json-schema": "^7.0.15",
83
83
  "@valibot/to-json-schema": "^1.3.0",
84
84
  "pkgroll": "^2.13.1",
85
85
  "typescript": "^5.8.3",