@codewithagents/openapi-server 1.1.0 → 1.2.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 +18 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
[](https://npmjs.com/package/@codewithagents/openapi-server)
|
|
4
4
|
[](https://codecov.io/gh/codewithagents/glue)
|
|
5
5
|
|
|
6
|
-
Generate a typed
|
|
6
|
+
Generate a typed service interface from your OpenAPI 3.x spec. Framework-agnostic by design — wire it to Hono, Express, Fastify, or any router you already use.
|
|
7
7
|
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
8
|
+
- **Framework-agnostic service interface** — `service.ts` is a plain TypeScript interface with no framework imports. Implement it however you want: Hono, Express, Fastify, Koa, plain `http`, Bun, Deno — anything.
|
|
9
|
+
- **Optional router scaffolding** — set `"framework": "hono"` and get a ready-to-mount Hono router as a starting point. Set `"framework": "none"` and wire the interface yourself. The generated code only ever imports what you already have.
|
|
10
|
+
- **Type-safe contract** — the compiler tells you if your implementation drifts from the spec. Add an endpoint in the spec and forget to implement it: TypeScript fails the build.
|
|
11
|
+
- **Prettier-clean output** — every generated file passes `prettier --check` out of the box.
|
|
12
|
+
- **OpenAPI 3.x** — 3.1.x primary target, 3.0.x best-effort. Full support for `$ref`, `allOf`, `anyOf`, `oneOf`, `nullable`.
|
|
12
13
|
- **TypeScript strict mode** — all output passes `strict: true`.
|
|
13
14
|
|
|
14
15
|
---
|
|
@@ -33,7 +34,7 @@ Requires [`@codewithagents/openapi-gen`](../openapi-gen) — run both generators
|
|
|
33
34
|
{
|
|
34
35
|
"input_openapi": "./spec/api.json",
|
|
35
36
|
"output": "./generated",
|
|
36
|
-
"framework": "hono"
|
|
37
|
+
"framework": "hono" // or "none" to skip the router and use any framework
|
|
37
38
|
}
|
|
38
39
|
```
|
|
39
40
|
|
|
@@ -206,7 +207,7 @@ serve({ fetch: app.fetch, port: 3001 })
|
|
|
206
207
|
|
|
207
208
|
```json
|
|
208
209
|
{
|
|
209
|
-
"input_openapi": "./spec/api.json", // required — path to OpenAPI 3.
|
|
210
|
+
"input_openapi": "./spec/api.json", // required — path to OpenAPI 3.x spec (JSON or YAML)
|
|
210
211
|
"output": "./generated", // required — directory to write generated files
|
|
211
212
|
"framework": "hono", // optional — router target (default: "hono")
|
|
212
213
|
"input_schema": "./generated/schemas.ts" // optional — Zod schema file for request validation
|
|
@@ -215,7 +216,7 @@ serve({ fetch: app.fetch, port: 3001 })
|
|
|
215
216
|
|
|
216
217
|
| Field | Required | Default | Description |
|
|
217
218
|
|---|---|---|---|
|
|
218
|
-
| `input_openapi` | Yes | — | Path to OpenAPI 3.
|
|
219
|
+
| `input_openapi` | Yes | — | Path to OpenAPI 3.x spec |
|
|
219
220
|
| `output` | Yes | — | Directory to write `service.ts` and `router.ts` |
|
|
220
221
|
| `framework` | No | `"hono"` | Router framework to generate. Use `"none"` to generate only `service.ts` |
|
|
221
222
|
| `input_schema` | No | — | Path to user-owned Zod schema file. Enables server-side request validation (see below) |
|
|
@@ -275,12 +276,15 @@ Invalid requests get a structured `422` response instead of reaching your servic
|
|
|
275
276
|
|
|
276
277
|
---
|
|
277
278
|
|
|
278
|
-
##
|
|
279
|
+
## Framework support
|
|
279
280
|
|
|
280
|
-
|
|
281
|
+
`service.ts` has no framework imports at all. It is always generated, always framework-agnostic, and works with anything.
|
|
282
|
+
|
|
283
|
+
`router.ts` is optional and currently supports:
|
|
284
|
+
|
|
285
|
+
| Value | What you get |
|
|
281
286
|
|---|---|
|
|
282
|
-
|
|
|
283
|
-
|
|
|
284
|
-
| Fastify | Planned |
|
|
287
|
+
| `"none"` | Only `service.ts`. Wire the interface to Express, Fastify, Koa, plain Node `http`, Bun, Deno, or anything else yourself. |
|
|
288
|
+
| `"hono"` | `service.ts` + a ready-to-mount `router.ts` using [Hono](https://hono.dev). Hono must be in your own `dependencies` — this package adds nothing. |
|
|
285
289
|
|
|
286
|
-
|
|
290
|
+
More router targets (Express, Fastify) are planned. The `"none"` path is always available and keeps the zero-footprint promise: the generated code has no runtime dependencies that you did not already choose.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codewithagents/openapi-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Generate typed server-side service interfaces and framework routers from OpenAPI 3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"openapi-types": "^12.1.3",
|
|
20
20
|
"prettier": "^3.5.3",
|
|
21
|
-
"@codewithagents/openapi-gen": "4.
|
|
21
|
+
"@codewithagents/openapi-gen": "4.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.0.0",
|