@softistx/alxia-openapi 0.7.0 → 0.7.2
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 +5 -5
- package/docs/README.md +1 -1
- package/docs/guide/checks.md +1 -1
- package/docs/guide/spec-first.md +4 -4
- package/docs/guide/testing.md +1 -1
- package/docs/roadmap.md +2 -2
- package/docs/troubleshooting.md +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
OpenAPI spec first for [`@softistx/alxia`](https://www.npmjs.com/package/@softistx/alxia).
|
|
6
6
|
The OpenAPI document is the source:
|
|
7
|
-
[`@
|
|
7
|
+
[`@softistx/openapi-codegen`](https://www.npmjs.com/package/@softistx/openapi-codegen)'s
|
|
8
8
|
`alxia` option generates each operation as `{ method, path, schema }`,
|
|
9
9
|
`@softistx/alxia`'s `app.route(operation, ...middlewares, handler)` binds a
|
|
10
10
|
handler to it, and this package's `implemented` and `matchesSpec` check
|
|
@@ -14,12 +14,12 @@ fails a test, not a client.
|
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
bun add -d @softistx/alxia-openapi typescript
|
|
17
|
-
bun add -d --exact @
|
|
17
|
+
bun add -d --exact @softistx/openapi-codegen
|
|
18
18
|
bun add zod
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
`@softistx/alxia` and `typescript` are its peers; `@softistx/alxia` is the app's
|
|
22
|
-
own dependency. `@
|
|
22
|
+
own dependency. `@softistx/openapi-codegen` writes the operations, and the code
|
|
23
23
|
it writes imports `zod` (4.5.4 or later) at runtime. For a check at startup
|
|
24
24
|
rather than in a test, install `@softistx/alxia-openapi` without `-d`.
|
|
25
25
|
|
|
@@ -32,7 +32,7 @@ operation — then point the generator at it:
|
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
34
|
// openapi-codegen.config.ts
|
|
35
|
-
import { defineConfig } from '@
|
|
35
|
+
import { defineConfig } from '@softistx/openapi-codegen';
|
|
36
36
|
|
|
37
37
|
export default defineConfig({
|
|
38
38
|
input: 'openapi.yaml',
|
|
@@ -211,7 +211,7 @@ would reveal the schema.
|
|
|
211
211
|
alxia's `{ error: 'validation', issues }` in the spec.
|
|
212
212
|
- The generator does not turn `security` into a middleware: write one with
|
|
213
213
|
`defineMiddleware` and give it to `route(operation, auth, handler)`.
|
|
214
|
-
- In `@
|
|
214
|
+
- In `@softistx/openapi-codegen` 0.11.0, a `cookie` parameter is validated as
|
|
215
215
|
`cookies` by `alxia.ts` alone: the client files leave it out with an
|
|
216
216
|
`ignored` warning, since a client does not set cookies. A cookie that is a
|
|
217
217
|
list or an object fails the run.
|
package/docs/README.md
CHANGED
|
@@ -7,7 +7,7 @@ generator print.
|
|
|
7
7
|
|
|
8
8
|
| Page | Read it when |
|
|
9
9
|
| --- | --- |
|
|
10
|
-
| [Spec first](guide/spec-first.md) | starting an API from its OpenAPI document: configuring `@
|
|
10
|
+
| [Spec first](guide/spec-first.md) | starting an API from its OpenAPI document: configuring `@softistx/openapi-codegen`, declaring alxia's 400, binding the generated operations with middlewares, committing the generated files, checking them in CI, and generating a client from the same document |
|
|
11
11
|
| [Testing with the generated client](guide/testing.md) | calling the app in a test through `@nxgt/openapi-httpyz` and `app.fetch`, with no server, every call typed by the spec, and keeping `app.request` for requests the spec forbids |
|
|
12
12
|
| [API docs](guide/api-docs.md) | serving an interactive page and the document from the app, choosing Scalar or Swagger UI, turning it off in production, using it with `secureHeaders`, or running it beside a GraphQL endpoint |
|
|
13
13
|
| [The checks](guide/checks.md) | calling `implemented` or `matchesSpec` in a test or at startup, checking an app with routes with middlewares, or choosing what `matchesSpec` leaves out |
|
package/docs/guide/checks.md
CHANGED
|
@@ -228,7 +228,7 @@ not in `app.routes` yet.
|
|
|
228
228
|
|
|
229
229
|
## What it cannot see
|
|
230
230
|
|
|
231
|
-
- **An operation the generator left out.** `@
|
|
231
|
+
- **An operation the generator left out.** `@softistx/openapi-codegen` skips an
|
|
232
232
|
operation alxia cannot route or validate yet — a `TRACE`, a binary body,
|
|
233
233
|
JSON Lines, server-sent events with text data — with an `ignored` warning,
|
|
234
234
|
and it is not in `operations`. Read the generator's warnings: the check only
|
package/docs/guide/spec-first.md
CHANGED
|
@@ -17,7 +17,7 @@ export const app = alxia().route(operations.getTodo, ({ params, reply }) =>
|
|
|
17
17
|
| Step | Who | What it gives |
|
|
18
18
|
| --- | --- | --- |
|
|
19
19
|
| [1. Write the document](#1-write-the-document) | you | the contract: operations, bodies, replies, alxia's 400 |
|
|
20
|
-
| [2. Generate](#2-generate-the-operations) | `@
|
|
20
|
+
| [2. Generate](#2-generate-the-operations) | `@softistx/openapi-codegen` 0.11.0, `alxia: true` | `src/generated/alxia.ts`: each operation as `{ method, path, schema }` |
|
|
21
21
|
| [3. Bind the routes](#3-bind-the-routes) | `@softistx/alxia`'s `app.route()` | the handlers, typed by the spec, with their middlewares |
|
|
22
22
|
| [4. Check](#4-check-the-app-against-the-spec) | `@softistx/alxia-openapi`'s `matchesSpec` | a failing test while an operation has no route |
|
|
23
23
|
| [5. A client](#5-a-client-from-the-same-document) | `@nxgt/openapi-httpyz`, or any OpenAPI client | the other side of the contract |
|
|
@@ -100,7 +100,7 @@ const app = alxia().use(async (_ctx, next) => {
|
|
|
100
100
|
|
|
101
101
|
```ts
|
|
102
102
|
// openapi-codegen.config.ts
|
|
103
|
-
import { defineConfig } from '@
|
|
103
|
+
import { defineConfig } from '@softistx/openapi-codegen';
|
|
104
104
|
|
|
105
105
|
export default defineConfig({
|
|
106
106
|
input: 'openapi.yaml',
|
|
@@ -161,7 +161,7 @@ files are not what the document gives, so drift fails CI:
|
|
|
161
161
|
}
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
Pin `@
|
|
164
|
+
Pin `@softistx/openapi-codegen` exactly (`bun add -d --exact @softistx/openapi-codegen`):
|
|
165
165
|
another release may write the files differently, and `--check` would then
|
|
166
166
|
fail until you generate again. Keep your linter and formatter off
|
|
167
167
|
`src/generated/`.
|
|
@@ -279,7 +279,7 @@ calling the check at startup. Prefixes are in [matching.md](matching.md#under-a-
|
|
|
279
279
|
## 5. A client from the same document
|
|
280
280
|
|
|
281
281
|
alxia generates no client: the document is the contract, and any OpenAPI
|
|
282
|
-
client works against it. The same run of `@
|
|
282
|
+
client works against it. The same run of `@softistx/openapi-codegen` already
|
|
283
283
|
wrote `operations.ts`, the table [`@nxgt/openapi-httpyz`](https://www.npmjs.com/package/@nxgt/openapi-httpyz)
|
|
284
284
|
binds onto an [`@nxgt/httpyz`](https://www.npmjs.com/package/@nxgt/httpyz)
|
|
285
285
|
client, and `paths.ts`, in openapi-typescript's shape, for a client that
|
package/docs/guide/testing.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Testing with the generated client
|
|
2
2
|
|
|
3
|
-
The same run of `@
|
|
3
|
+
The same run of `@softistx/openapi-codegen` that writes `alxia.ts` writes
|
|
4
4
|
`operations.ts`, the table [`@nxgt/openapi-httpyz`](https://www.npmjs.com/package/@nxgt/openapi-httpyz)
|
|
5
5
|
binds onto an [`@nxgt/httpyz`](https://www.npmjs.com/package/@nxgt/httpyz)
|
|
6
6
|
client. The client takes a `fetch`: give it `app.fetch`, and a test calls the
|
package/docs/roadmap.md
CHANGED
|
@@ -61,7 +61,7 @@ retired. The releases below are this package's, under its former name,
|
|
|
61
61
|
servers alone — with Scalar's AI agent, MCP, developer tools and
|
|
62
62
|
telemetry off, and `matchesSpec` leaves its routes out.
|
|
63
63
|
- **The spec-first `@alxia/openapi`.** The OpenAPI document is the source:
|
|
64
|
-
`@
|
|
64
|
+
`@softistx/openapi-codegen`'s `alxia` option generates the operations,
|
|
65
65
|
`@alxia/core`'s `app.route(operation, ...middlewares, handler)` binds
|
|
66
66
|
them, and `implemented` and `matchesSpec` check the app against them.
|
|
67
67
|
The package that was `@alxia/openapi-routes` now carries this name.
|
|
@@ -96,6 +96,6 @@ are these checks.
|
|
|
96
96
|
the document does not declare; `exclude` leaves out the ones it should
|
|
97
97
|
not, such as a health check.
|
|
98
98
|
- **The generated shape.** Both take the `operations` object
|
|
99
|
-
`@
|
|
99
|
+
`@softistx/openapi-codegen`'s `alxia` option writes, or a list of operations,
|
|
100
100
|
typed as `@alxia/core`'s `RouteOperation`; `prefix` looks them up under
|
|
101
101
|
the app's prefix.
|
package/docs/troubleshooting.md
CHANGED
|
@@ -19,7 +19,7 @@ it to fail prints nothing; those are under [Traps](#traps), by symptom.
|
|
|
19
19
|
- [The page is blank, and the console reports a blocked script](#the-page-is-blank-and-the-console-reports-a-blocked-script)
|
|
20
20
|
- [`matchesSpec(): … routes have no operation: GET /docs, …`](#matchesspec--routes-have-no-operation-get-docs-)
|
|
21
21
|
|
|
22
|
-
**Generator** (`@
|
|
22
|
+
**Generator** (`@softistx/openapi-codegen` 0.11.0)
|
|
23
23
|
|
|
24
24
|
- [`alxia.ts leaves it out. … [ignored]`](#alxiats-leaves-it-out--ignored)
|
|
25
25
|
- [A cookie parameter is missing from `types.ts` and the client files](#a-cookie-parameter-is-missing-from-typests-and-the-client-files)
|
|
@@ -484,7 +484,7 @@ hand-written operation, write its path `/pets/:petId`.
|
|
|
484
484
|
|
|
485
485
|
**Symptom:** a route the spec declares is missing, and the check passes.
|
|
486
486
|
|
|
487
|
-
**Why:** the operation is not in `operations`. `@
|
|
487
|
+
**Why:** the operation is not in `operations`. `@softistx/openapi-codegen`
|
|
488
488
|
leaves out what alxia cannot route or validate yet — a `TRACE`, a binary
|
|
489
489
|
body, JSON Lines, events with text data — with an `ignored` warning
|
|
490
490
|
([one of them](#alxiats-leaves-it-out--ignored)). The check only knows the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softistx/alxia-openapi",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "OpenAPI spec first for @softistx/alxia: the routes of an app bound to the operations generated from its document, and checked against them",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
]
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@softistx/alxia": "^0.
|
|
45
|
-
"@softistx/alxia-secure-headers": "^0.6.
|
|
46
|
-
"@types/bun": "^1.4.
|
|
44
|
+
"@softistx/alxia": "^0.29.1",
|
|
45
|
+
"@softistx/alxia-secure-headers": "^0.6.2",
|
|
46
|
+
"@types/bun": "^1.4.5",
|
|
47
47
|
"zod": "^4.2.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@softistx/alxia": "^0.
|
|
50
|
+
"@softistx/alxia": "^0.29.1",
|
|
51
51
|
"typescript": "^6.0.3 || ^7.0.0"
|
|
52
52
|
}
|
|
53
53
|
}
|