@nxgt/openapi-hono 0.1.2 → 0.3.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 +48 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +58 -10
- package/dist/types.d.ts.map +1 -1
- package/docs/guide.md +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ from this package: there they are bound to your spec.
|
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
53
|
import { Hono } from 'hono';
|
|
54
|
-
import { createRoutes } from './generated/hono
|
|
54
|
+
import { createRoutes } from './generated/hono';
|
|
55
55
|
|
|
56
56
|
const app = new Hono();
|
|
57
57
|
const routes = createRoutes(app);
|
|
@@ -126,7 +126,7 @@ An operation whose reply the spec describes an item at a time, with OpenAPI
|
|
|
126
126
|
3.2's `itemSchema`, streams it from its handler with the `hono.ts` helpers:
|
|
127
127
|
|
|
128
128
|
```ts
|
|
129
|
-
import { createRoutes, streamEvents, streamLines } from './generated/hono
|
|
129
|
+
import { createRoutes, streamEvents, streamLines } from './generated/hono';
|
|
130
130
|
|
|
131
131
|
createRoutes(app)
|
|
132
132
|
.get('/feed', (c) =>
|
|
@@ -154,7 +154,7 @@ createRoutes(app)
|
|
|
154
154
|
### Modules
|
|
155
155
|
|
|
156
156
|
```ts
|
|
157
|
-
import { createApi } from './generated/hono
|
|
157
|
+
import { createApi } from './generated/hono';
|
|
158
158
|
|
|
159
159
|
export const api = createApi();
|
|
160
160
|
|
|
@@ -420,7 +420,11 @@ get<P extends /* a GET path of the scope, starting with the prefix */>(
|
|
|
420
420
|
```
|
|
421
421
|
|
|
422
422
|
Registers the operation at `path`, written as the spec writes it
|
|
423
|
-
(`/employees/{id}`), with middlewares then its handler.
|
|
423
|
+
(`/employees/{id}`), with middlewares then its handler. Its type,
|
|
424
|
+
[`Register`](#register), has one overload per chain length, up to five
|
|
425
|
+
middlewares, then one for longer chains, as Hono's own `app.get` has. With
|
|
426
|
+
a fixed length, the handler's `c` stays typed while its reply is being
|
|
427
|
+
written, so the editor can offer the body's fields. The handler's
|
|
424
428
|
`c.req.valid()` and replies are those of the operation. Throws at
|
|
425
429
|
registration in the cases listed under [Modules](#modules); `head()` always
|
|
426
430
|
throws, since Hono answers `HEAD` with the `GET` route.
|
|
@@ -432,7 +436,7 @@ operation<Id extends Sc['ids']>(id: Id, ...chain: Chain<S, Id>): Routes<S, Sc, P
|
|
|
432
436
|
```
|
|
433
437
|
|
|
434
438
|
Registers an operation by its `operationId` instead of its path. Throws as
|
|
435
|
-
the methods above.
|
|
439
|
+
the methods above. Its type, `RegisterOperation`, has the same overloads.
|
|
436
440
|
|
|
437
441
|
##### `routes.validate`
|
|
438
442
|
|
|
@@ -560,12 +564,43 @@ The `stream` that `streamLines()` hands to `write`.
|
|
|
560
564
|
|
|
561
565
|
```ts
|
|
562
566
|
type RouteHandler<S extends ApiSpec, Id extends string> = (
|
|
563
|
-
c: Context</* … */>, // c.req.valid() holds the operation's validated input
|
|
567
|
+
c: DeclaredJson<Reply> & Context</* … */>, // c.req.valid() holds the operation's validated input
|
|
564
568
|
next: Next,
|
|
565
569
|
) => Reply | Promise<Reply>; // S['replies'][Id]
|
|
566
570
|
```
|
|
567
571
|
|
|
568
|
-
The handler of operation `Id`: the last argument of a registration.
|
|
572
|
+
The handler of operation `Id`: the last argument of a registration. Its `c`
|
|
573
|
+
is still a `Context`, for any helper that takes one.
|
|
574
|
+
|
|
575
|
+
#### `DeclaredJson`
|
|
576
|
+
|
|
577
|
+
```ts
|
|
578
|
+
interface DeclaredJson<R> {
|
|
579
|
+
json<Status extends /* a JSON status R declares */, Body extends Partial</* its body */>>(
|
|
580
|
+
body: Body,
|
|
581
|
+
status: Status,
|
|
582
|
+
headers?: Record<string, string | string[]>,
|
|
583
|
+
): Response & TypedResponse<JSONParsed<Body>, Status, 'json'>;
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
The `c.json()` a handler gets on top of Hono's own. It types the body by the
|
|
588
|
+
status passed after it, so the editor offers the fields of the body declared
|
|
589
|
+
for that status, and then only those not written yet. Hono's `c.json()` has
|
|
590
|
+
nothing to offer, since it takes any `T`. The reply is typed as Hono types
|
|
591
|
+
it, so what the handler returns is checked against the spec as before. A
|
|
592
|
+
body that is not even part of the declared one falls through to Hono's
|
|
593
|
+
`c.json()`, and the handler's return is refused there.
|
|
594
|
+
|
|
595
|
+
#### `Register`
|
|
596
|
+
|
|
597
|
+
```ts
|
|
598
|
+
interface Register<S extends ApiSpec, Sc extends Scope, Prefix extends string, M extends Method>;
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
The type of `routes.get()` and the other methods: see
|
|
602
|
+
[`routes.get()`](#routesget-routesput-routespost-routesdelete-routesoptions-routeshead-routespatch-routestrace-routesquery).
|
|
603
|
+
`RegisterOperation<S, Sc, Prefix>` is `routes.operation()`'s.
|
|
569
604
|
|
|
570
605
|
#### `Chain`
|
|
571
606
|
|
|
@@ -675,7 +710,12 @@ the table is one.
|
|
|
675
710
|
## Traps
|
|
676
711
|
|
|
677
712
|
- **Give `c.json()` a status.** Without one, Hono types the reply with any
|
|
678
|
-
contentful status, and it matches no declared reply.
|
|
713
|
+
contentful status, and it matches no declared reply. Without one, the
|
|
714
|
+
editor also has no declared body to offer.
|
|
715
|
+
- **With `dates: 'date'`, completion stops at the first `Date`.** The
|
|
716
|
+
declared body is the one JSON carries, with dates as strings. A body that
|
|
717
|
+
holds a `Date` falls through to Hono's `c.json()`, which still checks it,
|
|
718
|
+
but has no fields to offer.
|
|
679
719
|
- **Reply with plain objects.** A Mongoose document does not type as its
|
|
680
720
|
schema; return `.lean()` results.
|
|
681
721
|
- **Read the body through `c.req`, never `c.req.raw`.** A middleware that
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
export { createApi, type OperationTable, type RuntimeMedia, type RuntimeOperation, type Validator, } from './engine';
|
|
6
6
|
export { type SchemaIssue, type ValidationErrorHook, type ValidationFailure, type ValidationIssue, type ValidationTarget, validationErrorHandler, } from './errors';
|
|
7
7
|
export { type EventWriter, type LineWriter, streamEvents, streamLines, } from './streams';
|
|
8
|
-
export type { Api, ApiOptions, ApiSpec, Chain, Method, RouteHandler, Routes, RoutesOptions, Scope, ScopeOf, Tagged, Whole, } from './types';
|
|
8
|
+
export type { Api, ApiOptions, ApiSpec, Chain, DeclaredJson, Method, Register, RegisterOperation, RouteHandler, Routes, RoutesOptions, Scope, ScopeOf, Tagged, Whole, } from './types';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,sBAAsB,GACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,YAAY,EACZ,WAAW,GACX,MAAM,WAAW,CAAC;AACnB,YAAY,EACX,GAAG,EACH,UAAU,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,EACZ,MAAM,EACN,aAAa,EACb,KAAK,EACL,OAAO,EACP,MAAM,EACN,KAAK,GACL,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,sBAAsB,GACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,YAAY,EACZ,WAAW,GACX,MAAM,WAAW,CAAC;AACnB,YAAY,EACX,GAAG,EACH,UAAU,EACV,OAAO,EACP,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACN,aAAa,EACb,KAAK,EACL,OAAO,EACP,MAAM,EACN,KAAK,GACL,MAAM,SAAS,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* generator wrote, never a conditional type, so a route costs TypeScript the
|
|
4
4
|
* same whether the spec has five operations or five hundred.
|
|
5
5
|
*/
|
|
6
|
-
import type { Context, Hono, MiddlewareHandler, Next } from 'hono';
|
|
6
|
+
import type { Context, Env, Hono, MiddlewareHandler, Next, TypedResponse } from 'hono';
|
|
7
|
+
import type { JSONParsed } from 'hono/utils/types';
|
|
7
8
|
import type { ValidationErrorHook } from './errors';
|
|
8
9
|
export type Method = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace' | 'query';
|
|
9
10
|
type ByMethod = {
|
|
@@ -43,19 +44,34 @@ export type ScopeOf<S extends ApiSpec, Tag extends string> = [Tag] extends [
|
|
|
43
44
|
] ? Whole<S> : Tagged<S, Tag>;
|
|
44
45
|
type Entry<S extends ApiSpec, Id extends string> = S['operations'][Id & keyof S['operations']];
|
|
45
46
|
type Reply<S extends ApiSpec, Id extends string> = S['replies'][Id & keyof S['replies']];
|
|
47
|
+
/** A JSON reply of the generated `Replies`. */
|
|
48
|
+
type JsonReply = TypedResponse<any, any, 'json'>;
|
|
49
|
+
/**
|
|
50
|
+
* `c.json(body, status)` over the JSON replies `R` declares: the body is typed
|
|
51
|
+
* by its status as it is written, so an editor offers its fields. Hono's own
|
|
52
|
+
* `c.json` stays behind it, and the reply is typed as Hono types it, so what
|
|
53
|
+
* the handler returns is checked against the spec as before. A body that is
|
|
54
|
+
* not even part of the declared one falls to Hono's, and is refused there.
|
|
55
|
+
*/
|
|
56
|
+
export interface DeclaredJson<R> {
|
|
57
|
+
json<Status extends Extract<R, JsonReply>['_status'], Body extends Partial<Extract<R, JsonReply & {
|
|
58
|
+
_status: Status;
|
|
59
|
+
}>['_data']>>(body: Body, status: Status, headers?: Record<string, string | string[]>): Response & TypedResponse<JSONParsed<Body>, Status, 'json'>;
|
|
60
|
+
}
|
|
46
61
|
/**
|
|
47
62
|
* The handler of operation `Id`: `c.req.valid()` holds its validated
|
|
48
63
|
* parameters and body, and it returns one of the replies the spec declares.
|
|
64
|
+
* `c.env` is the app's: `E`, from the `Hono<E>` the routes are registered on.
|
|
49
65
|
*/
|
|
50
|
-
export type RouteHandler<S extends ApiSpec, Id extends string> = (c: Context<
|
|
66
|
+
export type RouteHandler<S extends ApiSpec, Id extends string, E extends Env = any> = (c: DeclaredJson<Reply<S, Id>> & Context<E, (Entry<S, Id> & {
|
|
51
67
|
honoPath: string;
|
|
52
68
|
})['honoPath'], {
|
|
53
69
|
out: Entry<S, Id> & {};
|
|
54
70
|
}>, next: Next) => Reply<S, Id> | Promise<Reply<S, Id>>;
|
|
55
71
|
/** Middlewares, then the handler. */
|
|
56
|
-
export type Chain<S extends ApiSpec, Id extends string> = [
|
|
72
|
+
export type Chain<S extends ApiSpec, Id extends string, E extends Env = any> = [
|
|
57
73
|
...MiddlewareHandler[],
|
|
58
|
-
RouteHandler<S, Id>
|
|
74
|
+
RouteHandler<S, Id, E>
|
|
59
75
|
];
|
|
60
76
|
export interface ApiOptions {
|
|
61
77
|
/** Answers a request the spec refuses. Default `validationErrorHandler`: a 400 listing the issues. */
|
|
@@ -77,11 +93,40 @@ export interface RoutesOptions<Prefix extends string = '', Tag extends string =
|
|
|
77
93
|
/** Offers only the operations with this tag. */
|
|
78
94
|
tag?: Tag;
|
|
79
95
|
}
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
/** The `operationId` at `M P`. */
|
|
97
|
+
type RouteId<S extends ApiSpec, M extends Method, P extends string> = S['routes'][`${M} ${P}` & keyof S['routes']] & string;
|
|
98
|
+
type Mw = MiddlewareHandler;
|
|
99
|
+
/**
|
|
100
|
+
* Registers the route of `M` at a path: the handler, after up to five
|
|
101
|
+
* middlewares, then any number. One overload per length, as Hono's own
|
|
102
|
+
* `app.get` has: with a rest of middlewares before it, a handler whose reply
|
|
103
|
+
* is not finished yet could be one of them, and its `c` would go untyped, so
|
|
104
|
+
* an editor would offer nothing in `c.json({ … })` while it is written.
|
|
105
|
+
*/
|
|
106
|
+
export interface Register<S extends ApiSpec, Sc extends Scope, Prefix extends string, M extends Method, E extends Env = any> {
|
|
107
|
+
<P extends Sc['paths'][M] & `${Prefix}${string}`>(path: P, handler: RouteHandler<S, RouteId<S, M, P>, E>): Routes<S, Sc, Prefix, E>;
|
|
108
|
+
<P extends Sc['paths'][M] & `${Prefix}${string}`>(path: P, m1: Mw, handler: RouteHandler<S, RouteId<S, M, P>, E>): Routes<S, Sc, Prefix, E>;
|
|
109
|
+
<P extends Sc['paths'][M] & `${Prefix}${string}`>(path: P, m1: Mw, m2: Mw, handler: RouteHandler<S, RouteId<S, M, P>, E>): Routes<S, Sc, Prefix, E>;
|
|
110
|
+
<P extends Sc['paths'][M] & `${Prefix}${string}`>(path: P, m1: Mw, m2: Mw, m3: Mw, handler: RouteHandler<S, RouteId<S, M, P>, E>): Routes<S, Sc, Prefix, E>;
|
|
111
|
+
<P extends Sc['paths'][M] & `${Prefix}${string}`>(path: P, m1: Mw, m2: Mw, m3: Mw, m4: Mw, handler: RouteHandler<S, RouteId<S, M, P>, E>): Routes<S, Sc, Prefix, E>;
|
|
112
|
+
<P extends Sc['paths'][M] & `${Prefix}${string}`>(path: P, m1: Mw, m2: Mw, m3: Mw, m4: Mw, m5: Mw, handler: RouteHandler<S, RouteId<S, M, P>, E>): Routes<S, Sc, Prefix, E>;
|
|
113
|
+
<P extends Sc['paths'][M] & `${Prefix}${string}`>(path: P, ...chain: Chain<S, RouteId<S, M, P>, E>): Routes<S, Sc, Prefix, E>;
|
|
114
|
+
}
|
|
115
|
+
/** `routes.operation()`, with the same overloads as a method's. */
|
|
116
|
+
export interface RegisterOperation<S extends ApiSpec, Sc extends Scope, Prefix extends string, E extends Env = any> {
|
|
117
|
+
<Id extends Sc['ids']>(id: Id, handler: RouteHandler<S, Id, E>): Routes<S, Sc, Prefix, E>;
|
|
118
|
+
<Id extends Sc['ids']>(id: Id, m1: Mw, handler: RouteHandler<S, Id, E>): Routes<S, Sc, Prefix, E>;
|
|
119
|
+
<Id extends Sc['ids']>(id: Id, m1: Mw, m2: Mw, handler: RouteHandler<S, Id, E>): Routes<S, Sc, Prefix, E>;
|
|
120
|
+
<Id extends Sc['ids']>(id: Id, m1: Mw, m2: Mw, m3: Mw, handler: RouteHandler<S, Id, E>): Routes<S, Sc, Prefix, E>;
|
|
121
|
+
<Id extends Sc['ids']>(id: Id, m1: Mw, m2: Mw, m3: Mw, m4: Mw, handler: RouteHandler<S, Id, E>): Routes<S, Sc, Prefix, E>;
|
|
122
|
+
<Id extends Sc['ids']>(id: Id, m1: Mw, m2: Mw, m3: Mw, m4: Mw, m5: Mw, handler: RouteHandler<S, Id, E>): Routes<S, Sc, Prefix, E>;
|
|
123
|
+
<Id extends Sc['ids']>(id: Id, ...chain: Chain<S, Id, E>): Routes<S, Sc, Prefix, E>;
|
|
124
|
+
}
|
|
125
|
+
export type Routes<S extends ApiSpec, Sc extends Scope = Whole<S>, Prefix extends string = '', E extends Env = any> = {
|
|
126
|
+
readonly [M in Method]: Register<S, Sc, Prefix, M, E>;
|
|
82
127
|
} & {
|
|
83
128
|
/** Registers an operation by its `operationId`. */
|
|
84
|
-
operation
|
|
129
|
+
readonly operation: RegisterOperation<S, Sc, Prefix, E>;
|
|
85
130
|
/**
|
|
86
131
|
* Marks where in a chain the request is validated, when a middleware
|
|
87
132
|
* needs validated input: `routes.put(path, auth, routes.validate, check, handler)`.
|
|
@@ -89,11 +134,14 @@ export type Routes<S extends ApiSpec, Sc extends Scope = Whole<S>, Prefix extend
|
|
|
89
134
|
*/
|
|
90
135
|
readonly validate: MiddlewareHandler;
|
|
91
136
|
/** The same routes, with other options for the routes registered through it. */
|
|
92
|
-
with(options: ApiOptions): Routes<S, Sc, Prefix>;
|
|
137
|
+
with(options: ApiOptions): Routes<S, Sc, Prefix, E>;
|
|
93
138
|
};
|
|
94
139
|
export interface Api<S extends ApiSpec> {
|
|
95
|
-
/**
|
|
96
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Registers routes on `app`, which may be a module's sub-app. Their
|
|
142
|
+
* handlers' `c.env` is typed by the app's `Env`.
|
|
143
|
+
*/
|
|
144
|
+
routes<Prefix extends string = '', Tag extends keyof S['tags'] & string = never, E extends Env = any>(app: Hono<E, any, any>, options?: RoutesOptions<Prefix, Tag>): Routes<S, ScopeOf<S, Tag>, Prefix, E>;
|
|
97
145
|
/** The `operationId`s no route was registered for, of one tag or of all. */
|
|
98
146
|
missing(tag?: keyof S['tags'] & string): string[];
|
|
99
147
|
/** Throws, listing them, when an operation of the tag, or of the spec, has no route. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACX,OAAO,EACP,GAAG,EACH,IAAI,EACJ,iBAAiB,EACjB,IAAI,EACJ,aAAa,EACb,MAAM,MAAM,CAAC;AACd,OAAO,KAA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-
import { createRoutes } from './generated/hono
|
|
39
|
+
import { createRoutes } from './generated/hono';
|
|
40
40
|
|
|
41
41
|
const app = new Hono();
|
|
42
42
|
const routes = createRoutes(app);
|
|
@@ -195,7 +195,7 @@ at a time, with OpenAPI 3.2's `itemSchema`, is written from the handler with
|
|
|
195
195
|
the helpers `hono.ts` exports when the spec has such an operation:
|
|
196
196
|
|
|
197
197
|
```ts
|
|
198
|
-
import { createRoutes, streamEvents, streamLines } from './generated/hono
|
|
198
|
+
import { createRoutes, streamEvents, streamLines } from './generated/hono';
|
|
199
199
|
|
|
200
200
|
createRoutes(app, { validateResponses: true })
|
|
201
201
|
.get('/feed', (c) =>
|
|
@@ -248,7 +248,7 @@ throws when `id` is not the running route's.
|
|
|
248
248
|
its routes on its own sub-app:
|
|
249
249
|
|
|
250
250
|
```ts
|
|
251
|
-
import { createApi } from './generated/hono
|
|
251
|
+
import { createApi } from './generated/hono';
|
|
252
252
|
|
|
253
253
|
export const api = createApi();
|
|
254
254
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxgt/openapi-hono",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"typecheck": "bun run fixtures && tsc --noEmit"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nxgt/httpyz": "^0.
|
|
40
|
-
"@nxgt/openapi-codegen": "^0.
|
|
39
|
+
"@nxgt/httpyz": "^0.3.0",
|
|
40
|
+
"@nxgt/openapi-codegen": "^0.3.0",
|
|
41
41
|
"@types/bun": "^1.4.0",
|
|
42
42
|
"hono": "^4.13.4",
|
|
43
43
|
"zod": "^4.5.4"
|