x-openapi-flow 1.3.5 → 1.3.7
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 +338 -306
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,435 +1,467 @@
|
|
|
1
|
+
<!-- Auto-generated from /README.md via scripts/sync-package-readme.js. Do not edit directly. -->
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/x-openapi-flow)
|
|
6
|
+
[](https://www.npmjs.com/package/x-openapi-flow)
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
[](https://github.com/tiago-marques/x-openapi-flow/actions/workflows/x-openapi-flow-validate.yml)
|
|
10
|
+
[](https://github.com/tiago-marques/x-openapi-flow/issues)
|
|
11
|
+
[](https://github.com/tiago-marques/x-openapi-flow/commits/main)
|
|
12
|
+

|
|
13
|
+
|
|
1
14
|
# x-openapi-flow
|
|
2
15
|
|
|
3
|
-
|
|
16
|
+
**OpenAPI describes APIs.**
|
|
17
|
+
**x-openapi-flow describes how they actually work — for developers and AI.**
|
|
4
18
|
|
|
5
|
-
|
|
19
|
+
`x-openapi-flow` is an OpenAPI vendor extension and CLI for documenting and validating resource lifecycle workflows.
|
|
20
|
+
It adds explicit state-machine metadata (`x-openapi-flow`) to operations and validates both schema and lifecycle graph consistency.
|
|
6
21
|
|
|
7
|
-
|
|
22
|
+
---
|
|
8
23
|
|
|
9
|
-
|
|
24
|
+
## Why This Project Matters
|
|
10
25
|
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
- Optional quality checks for transitions and references
|
|
26
|
+
Most teams document endpoints but not lifecycle behavior. State transitions become implicit, inconsistent, and hard to validate in CI.
|
|
27
|
+
`x-openapi-flow` makes flows explicit, so teams can:
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
- Validate lifecycle consistency early in CI
|
|
30
|
+
- Generate flow-aware docs and diagrams
|
|
31
|
+
- Build SDKs that reduce invalid API calls
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
Result: faster onboarding, fewer integration regressions, and clearer contracts between API producers and consumers.
|
|
18
34
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## TL;DR / Quick Start
|
|
22
38
|
|
|
23
|
-
|
|
39
|
+
From your API project root:
|
|
24
40
|
|
|
25
41
|
```bash
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
npx x-openapi-flow init
|
|
43
|
+
```
|
|
44
|
+
or
|
|
45
|
+
```bash
|
|
46
|
+
npx x-openapi-flow apply openapi.x.yaml
|
|
28
47
|
```
|
|
29
48
|
|
|
30
|
-
|
|
49
|
+
Default adoption path:
|
|
31
50
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
1. Generate or update your OpenAPI source.
|
|
52
|
+
2. Run `init` to create/sync sidecar flow metadata.
|
|
53
|
+
3. Run `apply` whenever the OpenAPI file is regenerated.
|
|
35
54
|
|
|
36
|
-
|
|
55
|
+
Full rollout guide: [docs/wiki/Adoption-Playbook.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Adoption-Playbook.md)
|
|
56
|
+
Troubleshooting: [docs/wiki/Troubleshooting.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Troubleshooting.md)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Day-to-Day Workflow (API Server Team)
|
|
61
|
+
|
|
62
|
+
Typical routine when your OpenAPI source changes frequently:
|
|
37
63
|
|
|
38
|
-
|
|
64
|
+
1. Bootstrap once per project.
|
|
39
65
|
|
|
40
66
|
```bash
|
|
41
67
|
npx x-openapi-flow init
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
2. Re-apply sidecar metadata after each OpenAPI regeneration.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
42
73
|
npx x-openapi-flow apply openapi.yaml
|
|
43
74
|
```
|
|
44
75
|
|
|
45
|
-
|
|
76
|
+
3. Validate lifecycle quality before opening a PR.
|
|
46
77
|
|
|
47
78
|
```bash
|
|
48
|
-
npx x-openapi-flow validate openapi.yaml --profile strict
|
|
49
|
-
npx x-openapi-flow lint openapi.yaml
|
|
50
|
-
npx x-openapi-flow graph openapi.yaml
|
|
79
|
+
npx x-openapi-flow validate openapi.flow.yaml --profile strict --strict-quality
|
|
51
80
|
```
|
|
52
81
|
|
|
53
|
-
|
|
82
|
+
4. Optional diagnostics for review and troubleshooting.
|
|
54
83
|
|
|
55
84
|
```bash
|
|
56
|
-
npx x-openapi-flow
|
|
57
|
-
npx x-openapi-flow
|
|
58
|
-
npx x-openapi-flow
|
|
59
|
-
npx x-openapi-flow --version
|
|
60
|
-
npx x-openapi-flow validate <openapi-file> [--format pretty|json] [--profile core|relaxed|strict] [--strict-quality] [--config path]
|
|
61
|
-
npx x-openapi-flow init [--flows path] [--force] [--dry-run]
|
|
62
|
-
npx x-openapi-flow apply [openapi-file] [--flows path] [--out path]
|
|
63
|
-
npx x-openapi-flow diff [openapi-file] [--flows path] [--format pretty|json]
|
|
64
|
-
npx x-openapi-flow lint [openapi-file] [--format pretty|json] [--config path]
|
|
65
|
-
npx x-openapi-flow analyze [openapi-file] [--format pretty|json] [--out path] [--merge] [--flows path]
|
|
66
|
-
npx x-openapi-flow generate-sdk [openapi-file] --lang typescript [--output path]
|
|
67
|
-
npx x-openapi-flow export-doc-flows [openapi-file] [--output path] [--format markdown|json]
|
|
68
|
-
npx x-openapi-flow generate-postman [openapi-file] [--output path] [--with-scripts]
|
|
69
|
-
npx x-openapi-flow generate-insomnia [openapi-file] [--output path]
|
|
70
|
-
npx x-openapi-flow generate-redoc [openapi-file] [--output path]
|
|
71
|
-
npx x-openapi-flow graph <openapi-file> [--format mermaid|json]
|
|
72
|
-
npx x-openapi-flow doctor [--config path]
|
|
73
|
-
npx x-openapi-flow completion [bash|zsh]
|
|
85
|
+
npx x-openapi-flow diff openapi.yaml --format pretty
|
|
86
|
+
npx x-openapi-flow lint openapi.flow.yaml
|
|
87
|
+
npx x-openapi-flow graph openapi.flow.yaml --format mermaid
|
|
74
88
|
```
|
|
75
89
|
|
|
76
|
-
|
|
90
|
+
What this gives your team in practice:
|
|
77
91
|
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
92
|
+
- deterministic lifecycle checks in local dev and CI
|
|
93
|
+
- explicit transition contracts instead of implicit tribal knowledge
|
|
94
|
+
- safer API evolution with fewer integration regressions
|
|
81
95
|
|
|
82
|
-
|
|
96
|
+
---
|
|
83
97
|
|
|
84
|
-
|
|
98
|
+
## Integration Experience (What You See)
|
|
85
99
|
|
|
86
|
-
|
|
87
|
-
- Adapters: docs (`export-doc-flows`), SDK (`generate-sdk`), Postman (`generate-postman`), Insomnia (`generate-insomnia`)
|
|
88
|
-
and Redoc package (`generate-redoc`)
|
|
100
|
+
### Swagger UI
|
|
89
101
|
|
|
90
|
-
|
|
102
|
+
Use this when you want interactive docs with lifecycle context on each operation.
|
|
91
103
|
|
|
92
104
|
```bash
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
cd example/swagger-ui
|
|
106
|
+
npm install
|
|
107
|
+
npm run apply
|
|
108
|
+
npm start
|
|
95
109
|
```
|
|
96
110
|
|
|
97
|
-
|
|
111
|
+
Experience outcome:
|
|
112
|
+
|
|
113
|
+
- operation docs enriched with `x-openapi-flow` fields
|
|
114
|
+
- visual lifecycle context while navigating endpoints
|
|
115
|
+
|
|
116
|
+
Demo media:
|
|
117
|
+
|
|
118
|
+
- GIF slot: `docs/assets/demo-swagger-ui.gif`
|
|
119
|
+
- Image slot: `docs/assets/demo-swagger-ui.png`
|
|
98
120
|
|
|
99
|
-
|
|
100
|
-
- Mermaid diagram per resource
|
|
101
|
-
- Current state, prerequisites (`prerequisite_operation_ids`), next operations (`next_operation_id`)
|
|
121
|
+
### Redoc
|
|
102
122
|
|
|
103
|
-
|
|
123
|
+
Use this when you want a static docs bundle to share internally or publish.
|
|
104
124
|
|
|
105
125
|
```bash
|
|
106
|
-
|
|
126
|
+
cd example/redoc
|
|
127
|
+
npm install
|
|
128
|
+
npm run apply
|
|
129
|
+
npm run generate
|
|
107
130
|
```
|
|
108
131
|
|
|
109
|
-
|
|
132
|
+
Experience outcome:
|
|
110
133
|
|
|
111
|
-
- `
|
|
112
|
-
-
|
|
113
|
-
- `flow-model.json` (flow graph model)
|
|
114
|
-
- copied OpenAPI spec (`openapi.yaml`/`openapi.json`)
|
|
134
|
+
- portable `redoc-flow/` package with lifecycle panel
|
|
135
|
+
- stable documentation artifact for teams and portals
|
|
115
136
|
|
|
116
|
-
|
|
137
|
+
Demo media:
|
|
138
|
+
|
|
139
|
+
- GIF slot: `docs/assets/demo-redoc.gif`
|
|
140
|
+
- Image slot: `docs/assets/demo-redoc.png`
|
|
141
|
+
|
|
142
|
+
### Postman
|
|
143
|
+
|
|
144
|
+
Use this when you want collections aligned with lifecycle transitions.
|
|
117
145
|
|
|
118
146
|
```bash
|
|
119
|
-
|
|
147
|
+
cd example/postman
|
|
148
|
+
npm install
|
|
149
|
+
npm run apply
|
|
150
|
+
npm run generate
|
|
120
151
|
```
|
|
121
152
|
|
|
122
|
-
|
|
153
|
+
Experience outcome:
|
|
154
|
+
|
|
155
|
+
- flow-oriented Postman collection
|
|
156
|
+
- request execution closer to real transition paths
|
|
123
157
|
|
|
124
|
-
|
|
125
|
-
- propagated operation tracking and ID persistence in collection variables
|
|
158
|
+
Demo media:
|
|
126
159
|
|
|
127
|
-
|
|
160
|
+
- GIF slot: `docs/assets/demo-postman.gif`
|
|
161
|
+
- Image slot: `docs/assets/demo-postman.png`
|
|
162
|
+
|
|
163
|
+
### Insomnia
|
|
164
|
+
|
|
165
|
+
Use this when your team runs API scenarios in Insomnia workspaces.
|
|
128
166
|
|
|
129
167
|
```bash
|
|
130
|
-
|
|
168
|
+
cd example/insomnia
|
|
169
|
+
npm install
|
|
170
|
+
npm run apply
|
|
171
|
+
npm run generate
|
|
131
172
|
```
|
|
132
173
|
|
|
133
|
-
|
|
174
|
+
Experience outcome:
|
|
175
|
+
|
|
176
|
+
- generated workspace export with grouped lifecycle requests
|
|
177
|
+
- faster onboarding to operation prerequisites and flow order
|
|
178
|
+
|
|
179
|
+
Demo media:
|
|
180
|
+
|
|
181
|
+
- GIF slot: `docs/assets/demo-insomnia.gif`
|
|
182
|
+
- Image slot: `docs/assets/demo-insomnia.png`
|
|
183
|
+
|
|
184
|
+
More integration details:
|
|
185
|
+
|
|
186
|
+
- [docs/wiki/Swagger-UI-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Swagger-UI-Integration.md)
|
|
187
|
+
- [docs/wiki/Redoc-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Redoc-Integration.md)
|
|
188
|
+
- [docs/wiki/Postman-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Postman-Integration.md)
|
|
189
|
+
- [docs/wiki/Insomnia-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Insomnia-Integration.md)
|
|
190
|
+
|
|
191
|
+
---
|
|
134
192
|
|
|
135
|
-
##
|
|
193
|
+
## CLI in Practice (Server Workflow)
|
|
136
194
|
|
|
137
|
-
|
|
195
|
+
Use this sequence as your default lifecycle guardrail in backend projects:
|
|
138
196
|
|
|
139
197
|
```bash
|
|
140
|
-
|
|
141
|
-
|
|
198
|
+
# 1) Bootstrap sidecar from OpenAPI source
|
|
199
|
+
npx x-openapi-flow init
|
|
142
200
|
|
|
143
|
-
|
|
201
|
+
# 2) Merge sidecar into flow-aware OpenAPI output
|
|
202
|
+
npx x-openapi-flow apply openapi.yaml --out openapi.flow.yaml
|
|
144
203
|
|
|
145
|
-
|
|
146
|
-
-
|
|
147
|
-
- `src/http-client.ts`: pluggable HTTP client interface and fetch implementation
|
|
148
|
-
- `src/flow-helpers.ts`: `runFlow("authorize -> capture")`
|
|
149
|
-
- `flow-model.json`: intermediate model `{ resource, operations, prerequisites, nextOperations, states }`
|
|
204
|
+
# 3) Detect drift before commit
|
|
205
|
+
npx x-openapi-flow diff openapi.yaml --format pretty
|
|
150
206
|
|
|
151
|
-
|
|
207
|
+
# 4) Enforce lifecycle quality gates
|
|
208
|
+
npx x-openapi-flow validate openapi.flow.yaml --profile strict --strict-quality
|
|
209
|
+
npx x-openapi-flow lint openapi.flow.yaml
|
|
210
|
+
|
|
211
|
+
# 5) Generate graph artifact for PR discussion
|
|
212
|
+
npx x-openapi-flow graph openapi.flow.yaml --format mermaid
|
|
213
|
+
```
|
|
152
214
|
|
|
153
|
-
|
|
154
|
-
- Resource instance/state layer: objects expose valid lifecycle transitions (`payment.capture()`, etc.)
|
|
155
|
-
- Optional lifecycle helper methods at service level (`api.payments.capture(id, params, { autoPrerequisites: true })`)
|
|
215
|
+
CLI quick references for daily usage:
|
|
156
216
|
|
|
157
|
-
|
|
217
|
+
```bash
|
|
218
|
+
npx x-openapi-flow help [command]
|
|
219
|
+
npx x-openapi-flow <command> --help
|
|
220
|
+
npx x-openapi-flow <command> --verbose
|
|
221
|
+
npx x-openapi-flow completion [bash|zsh]
|
|
222
|
+
```
|
|
158
223
|
|
|
159
|
-
|
|
160
|
-
- Reuses lifecycle graph logic from the validator to stay consistent with `validate`, `graph`, and `diff`
|
|
161
|
-
- Transition ordering uses `next_operation_id`, `prerequisite_operation_ids`, and state transitions from `x-openapi-flow`
|
|
224
|
+
---
|
|
162
225
|
|
|
163
|
-
##
|
|
226
|
+
## SDK Generation Experience (TypeScript)
|
|
164
227
|
|
|
165
|
-
|
|
228
|
+
Generate a flow-aware SDK directly from your OpenAPI + `x-openapi-flow` metadata:
|
|
166
229
|
|
|
167
230
|
```bash
|
|
168
|
-
npx x-openapi-flow
|
|
169
|
-
npx x-openapi-flow analyze openapi.yaml --format json
|
|
170
|
-
npx x-openapi-flow analyze openapi.yaml --merge --flows openapi.x.yaml
|
|
231
|
+
npx x-openapi-flow generate-sdk openapi.flow.yaml --lang typescript --output ./sdk
|
|
171
232
|
```
|
|
172
233
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
{
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
{
|
|
190
|
-
"operationId": "listItems",
|
|
191
|
-
"changedPaths": ["current_state"]
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
}
|
|
234
|
+
What you get:
|
|
235
|
+
|
|
236
|
+
- resource-centric classes with lifecycle-safe methods
|
|
237
|
+
- operation transition awareness (`next_operation_id`, prerequisites, propagated fields)
|
|
238
|
+
- reusable client layer for application services
|
|
239
|
+
|
|
240
|
+
Typical integration snippet:
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import { FlowApiClient } from "./sdk/src";
|
|
244
|
+
|
|
245
|
+
const api = new FlowApiClient({ baseUrl: process.env.API_BASE_URL });
|
|
246
|
+
|
|
247
|
+
const payment = await api.payments.create({ amount: 1000 });
|
|
248
|
+
await payment.authorize();
|
|
249
|
+
await payment.capture();
|
|
196
250
|
```
|
|
197
251
|
|
|
198
|
-
|
|
252
|
+
Demo media:
|
|
199
253
|
|
|
200
|
-
|
|
254
|
+
- GIF slot: `docs/assets/demo-sdk-generation.gif`
|
|
255
|
+
- Image slot: `docs/assets/demo-sdk-generation.png`
|
|
201
256
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
'
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Example: Payment Flow
|
|
260
|
+
|
|
261
|
+
```mermaid
|
|
262
|
+
graph TD
|
|
263
|
+
CreatePayment --> AuthorizePayment
|
|
264
|
+
AuthorizePayment --> CapturePayment
|
|
265
|
+
CapturePayment --> RefundPayment
|
|
213
266
|
```
|
|
214
267
|
|
|
215
|
-
|
|
268
|
+
### Flow-aware SDK Example (TypeScript)
|
|
216
269
|
|
|
217
|
-
|
|
270
|
+
```ts
|
|
271
|
+
const payment = await sdk.payments.create({ amount: 1000 });
|
|
272
|
+
await payment.authorize();
|
|
273
|
+
await payment.capture();
|
|
274
|
+
await payment.refund();
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
At each stage, only valid lifecycle actions should be available.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Installation
|
|
218
282
|
|
|
219
|
-
|
|
283
|
+
Install from npm (default):
|
|
220
284
|
|
|
221
285
|
```bash
|
|
222
|
-
|
|
223
|
-
npx x-openapi-flow lint openapi.yaml --format json
|
|
286
|
+
npm install x-openapi-flow
|
|
224
287
|
```
|
|
225
288
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
- `next_operation_id_exists`
|
|
229
|
-
- `prerequisite_operation_ids_exist`
|
|
230
|
-
- `duplicate_transitions`
|
|
231
|
-
- `terminal_path` (states without path to terminal)
|
|
232
|
-
|
|
233
|
-
Disable individual rules with config (`x-openapi-flow.config.json`):
|
|
234
|
-
|
|
235
|
-
```json
|
|
236
|
-
{
|
|
237
|
-
"lint": {
|
|
238
|
-
"rules": {
|
|
239
|
-
"next_operation_id_exists": true,
|
|
240
|
-
"prerequisite_operation_ids_exist": true,
|
|
241
|
-
"duplicate_transitions": false,
|
|
242
|
-
"terminal_path": true
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
```
|
|
289
|
+
Optional mirror from GitHub Packages:
|
|
247
290
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
- `format_version`: output contract version (currently `"1.0"`).
|
|
253
|
-
- `flowCount`: number of operations with `x-openapi-flow`.
|
|
254
|
-
- `nodes`: sorted state names (deterministic order).
|
|
255
|
-
- `edges`: sorted transitions by `from`, `to`, `next_operation_id`, and prerequisites.
|
|
256
|
-
- `mermaid`: deterministic Mermaid rendering of the same graph.
|
|
257
|
-
|
|
258
|
-
Example:
|
|
259
|
-
|
|
260
|
-
```json
|
|
261
|
-
{
|
|
262
|
-
"format_version": "1.0",
|
|
263
|
-
"flowCount": 3,
|
|
264
|
-
"nodes": ["CONFIRMED", "CREATED", "SHIPPED"],
|
|
265
|
-
"edges": [
|
|
266
|
-
{
|
|
267
|
-
"from": "CONFIRMED",
|
|
268
|
-
"to": "SHIPPED",
|
|
269
|
-
"next_operation_id": "shipOrder",
|
|
270
|
-
"prerequisite_operation_ids": []
|
|
271
|
-
}
|
|
272
|
-
],
|
|
273
|
-
"mermaid": "stateDiagram-v2\n state CONFIRMED\n state CREATED\n state SHIPPED\n CONFIRMED --> SHIPPED: next:shipOrder"
|
|
274
|
-
}
|
|
291
|
+
```bash
|
|
292
|
+
npm config set @tiago-marques:registry https://npm.pkg.github.com
|
|
293
|
+
npm install @tiago-marques/x-openapi-flow
|
|
275
294
|
```
|
|
276
295
|
|
|
277
|
-
|
|
296
|
+
If authentication is required, add to `.npmrc`:
|
|
278
297
|
|
|
279
|
-
|
|
298
|
+
```ini
|
|
299
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
|
|
300
|
+
```
|
|
280
301
|
|
|
281
|
-
|
|
282
|
-
- `put`
|
|
283
|
-
- `post`
|
|
284
|
-
- `delete`
|
|
285
|
-
- `options`
|
|
286
|
-
- `head`
|
|
287
|
-
- `patch`
|
|
288
|
-
- `trace`
|
|
302
|
+
Use a GitHub PAT with `read:packages` (install) and `write:packages` (publish).
|
|
289
303
|
|
|
290
|
-
|
|
304
|
+
---
|
|
291
305
|
|
|
292
|
-
|
|
306
|
+
## CLI Reference (Selected Commands)
|
|
293
307
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
308
|
+
```bash
|
|
309
|
+
npx x-openapi-flow help [command]
|
|
310
|
+
npx x-openapi-flow --help
|
|
311
|
+
npx x-openapi-flow version
|
|
312
|
+
npx x-openapi-flow --version
|
|
313
|
+
npx x-openapi-flow validate <openapi-file> [--profile core|relaxed|strict] [--strict-quality]
|
|
314
|
+
npx x-openapi-flow init [--flows path] [--force] [--dry-run]
|
|
315
|
+
npx x-openapi-flow apply [openapi-file] [--flows path] [--out path]
|
|
316
|
+
npx x-openapi-flow analyze [openapi-file] [--format pretty|json] [--out path] [--merge] [--flows path]
|
|
317
|
+
npx x-openapi-flow generate-sdk [openapi-file] --lang typescript [--output path]
|
|
318
|
+
npx x-openapi-flow export-doc-flows [openapi-file] [--output path] [--format markdown|json]
|
|
319
|
+
npx x-openapi-flow generate-postman [openapi-file] [--output path] [--with-scripts]
|
|
320
|
+
npx x-openapi-flow generate-insomnia [openapi-file] [--output path]
|
|
321
|
+
npx x-openapi-flow generate-redoc [openapi-file] [--output path]
|
|
322
|
+
npx x-openapi-flow graph <openapi-file> [--format mermaid|json]
|
|
323
|
+
npx x-openapi-flow doctor [--config path]
|
|
324
|
+
npx x-openapi-flow completion [bash|zsh]
|
|
325
|
+
```
|
|
303
326
|
|
|
304
|
-
|
|
327
|
+
Global flag for troubleshooting:
|
|
305
328
|
|
|
306
329
|
```bash
|
|
307
|
-
npx x-openapi-flow
|
|
308
|
-
npx x-openapi-flow init --dry-run
|
|
309
|
-
# edit {context}.x.(json|yaml)
|
|
310
|
-
npx x-openapi-flow diff openapi.yaml
|
|
311
|
-
npx x-openapi-flow apply openapi.yaml
|
|
330
|
+
npx x-openapi-flow <command> --verbose
|
|
312
331
|
```
|
|
313
332
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
prerequisite_operation_ids:
|
|
336
|
-
- createOrder
|
|
337
|
-
prerequisite_field_refs:
|
|
338
|
-
- createOrder:request.body.customer_id
|
|
339
|
-
propagated_field_refs:
|
|
340
|
-
- createOrder:response.201.body.order_id
|
|
333
|
+
Full command details:
|
|
334
|
+
|
|
335
|
+
- [docs/wiki/CLI-Reference.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/CLI-Reference.md)
|
|
336
|
+
- [x-openapi-flow/README.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/x-openapi-flow/README.md)
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Initialization Behavior
|
|
341
|
+
|
|
342
|
+
Running `init`:
|
|
343
|
+
|
|
344
|
+
- Auto-detects OpenAPI source files (`openapi.yaml`, `openapi.json`, `swagger.yaml`, etc.)
|
|
345
|
+
- Creates or syncs `{context}.x.(json|yaml)` (sidecar with lifecycle metadata)
|
|
346
|
+
- Generates `{context}.flow.(json|yaml)` automatically when missing
|
|
347
|
+
- In interactive mode, asks before recreating existing flow files
|
|
348
|
+
- In non-interactive mode, requires `--force` to recreate when flow file already exists
|
|
349
|
+
|
|
350
|
+
Recommended quality gate:
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
npx x-openapi-flow validate openapi.yaml --profile strict
|
|
341
354
|
```
|
|
342
355
|
|
|
343
|
-
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Validation Profiles
|
|
359
|
+
|
|
360
|
+
- `strict` (default): schema + advanced graph checks as errors; quality as warnings (or errors with `--strict-quality`)
|
|
361
|
+
- `relaxed`: schema and orphan checks as errors; advanced/quality checks as warnings
|
|
362
|
+
- `core`: schema and orphan checks only
|
|
363
|
+
|
|
364
|
+
Validation covers:
|
|
365
|
+
|
|
366
|
+
- Schema contract correctness
|
|
367
|
+
- Orphan states
|
|
368
|
+
- Initial/terminal state structure
|
|
369
|
+
- Cycles and unreachable states
|
|
370
|
+
- Quality findings (duplicate transitions, invalid refs, non-terminating states)
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Integrations
|
|
344
375
|
|
|
345
|
-
-
|
|
346
|
-
-
|
|
376
|
+
- Swagger UI: flow overview + operation-level extension panels
|
|
377
|
+
- Redoc: generated package with flow panel
|
|
378
|
+
- Postman and Insomnia: generated lifecycle-aware collections/workspaces
|
|
379
|
+
- SDK generator: TypeScript available, other languages planned
|
|
347
380
|
|
|
348
|
-
|
|
381
|
+
Example images:
|
|
349
382
|
|
|
350
|
-
|
|
351
|
-
-
|
|
352
|
-
- `key` (optional, legacy): backward-compatibility fallback key used by apply.
|
|
383
|
+

|
|
384
|
+

|
|
353
385
|
|
|
354
|
-
|
|
386
|
+
Integration docs:
|
|
355
387
|
|
|
356
|
-
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
- Optional:
|
|
361
|
-
- `description` (string): human-readable purpose.
|
|
362
|
-
- `idempotency` (object):
|
|
363
|
-
- `header` (required, string)
|
|
364
|
-
- `required` (optional, boolean)
|
|
365
|
-
- `transitions` (array of transition objects)
|
|
388
|
+
- [docs/wiki/Swagger-UI-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Swagger-UI-Integration.md)
|
|
389
|
+
- [docs/wiki/Redoc-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Redoc-Integration.md)
|
|
390
|
+
- [docs/wiki/Postman-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Postman-Integration.md)
|
|
391
|
+
- [docs/wiki/Insomnia-Integration.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Insomnia-Integration.md)
|
|
366
392
|
|
|
367
|
-
|
|
393
|
+
---
|
|
368
394
|
|
|
369
|
-
|
|
370
|
-
- `target_state` (string)
|
|
371
|
-
- `trigger_type` (enum): `synchronous`, `webhook`, `polling`
|
|
372
|
-
- Optional:
|
|
373
|
-
- `condition` (string)
|
|
374
|
-
- `next_operation_id` (string)
|
|
375
|
-
- `prerequisite_operation_ids` (array of strings)
|
|
376
|
-
- `prerequisite_field_refs` (array of strings)
|
|
377
|
-
- `propagated_field_refs` (array of strings)
|
|
395
|
+
## Copilot Ready (AI Sidecar Authoring)
|
|
378
396
|
|
|
379
|
-
|
|
397
|
+
Use [llm.txt](https://github.com/tiago-marques/x-openapi-flow/blob/main/llm.txt) as authoring guidance for sidecar population.
|
|
380
398
|
|
|
381
|
-
-
|
|
382
|
-
- `operationId:request.path.paramName`
|
|
383
|
-
- `operationId:response.<status>.body.field`
|
|
399
|
+
Typical AI-assisted loop:
|
|
384
400
|
|
|
385
|
-
|
|
401
|
+
1. `init`
|
|
402
|
+
2. AI fills `{context}.x.(json|yaml)`
|
|
403
|
+
3. `apply`
|
|
404
|
+
4. `validate --profile strict`
|
|
386
405
|
|
|
387
|
-
|
|
406
|
+
Prompt template:
|
|
388
407
|
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
408
|
+
```text
|
|
409
|
+
Use llm.txt from this repository as authoring rules.
|
|
410
|
+
Populate {context}.x.(json|yaml) per operationId with coherent lifecycle states and transitions,
|
|
411
|
+
including next_operation_id, prerequisite_field_refs, and propagated_field_refs when applicable.
|
|
412
|
+
Do not change endpoint paths or HTTP methods.
|
|
395
413
|
```
|
|
396
414
|
|
|
397
|
-
|
|
415
|
+
---
|
|
398
416
|
|
|
399
|
-
|
|
400
|
-
- Validation processes OAS content with the `x-openapi-flow` extension
|
|
417
|
+
## Regeneration Workflow
|
|
401
418
|
|
|
402
|
-
|
|
419
|
+
```bash
|
|
420
|
+
# 1) Generate or update OpenAPI source
|
|
421
|
+
# 2) Initialize sidecar metadata
|
|
422
|
+
npx x-openapi-flow init
|
|
423
|
+
# 3) Edit {context}.x.(json|yaml)
|
|
424
|
+
# 4) Re-apply after each OpenAPI regeneration
|
|
425
|
+
npx x-openapi-flow apply openapi.x.yaml
|
|
426
|
+
```
|
|
403
427
|
|
|
404
|
-
|
|
405
|
-
- `prerequisite_operation_ids`: operationIds expected before a transition
|
|
406
|
-
- `prerequisite_field_refs`: required field refs before transition
|
|
407
|
-
- `propagated_field_refs`: field refs used by downstream flows
|
|
428
|
+
---
|
|
408
429
|
|
|
409
|
-
|
|
430
|
+
## Included Examples
|
|
410
431
|
|
|
411
|
-
- `
|
|
412
|
-
- `
|
|
432
|
+
- `payment-api.yaml` (financial)
|
|
433
|
+
- `order-api.yaml` (e-commerce/logistics)
|
|
434
|
+
- `ticket-api.yaml` (support)
|
|
435
|
+
- `quality-warning-api.yaml` (quality warnings)
|
|
436
|
+
- `non-terminating-api.yaml` (non-terminating states)
|
|
413
437
|
|
|
414
|
-
|
|
438
|
+
More examples: [docs/wiki/Real-Examples.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/docs/wiki/Real-Examples.md)
|
|
415
439
|
|
|
416
|
-
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Repository Structure
|
|
443
|
+
|
|
444
|
+
- [x-openapi-flow/schema/flow-schema.json](https://github.com/tiago-marques/x-openapi-flow/blob/main/x-openapi-flow/schema/flow-schema.json): extension JSON Schema contract
|
|
445
|
+
- [x-openapi-flow/lib/validator.js](https://github.com/tiago-marques/x-openapi-flow/blob/main/x-openapi-flow/lib/validator.js): schema + graph validation engine
|
|
446
|
+
- [x-openapi-flow/bin/x-openapi-flow.js](https://github.com/tiago-marques/x-openapi-flow/blob/main/x-openapi-flow/bin/x-openapi-flow.js): CLI entrypoint
|
|
447
|
+
- `x-openapi-flow/examples/*.yaml`: sample OpenAPI files
|
|
448
|
+
- [.github/workflows/x-openapi-flow-validate.yml](https://github.com/tiago-marques/x-openapi-flow/blob/main/.github/workflows/x-openapi-flow-validate.yml): CI validation example
|
|
449
|
+
|
|
450
|
+
---
|
|
417
451
|
|
|
418
|
-
|
|
419
|
-
- For UI interpretation of `x-openapi-flow`, use `showExtensions: true` with the plugin at `adapters/ui/swagger-ui/x-openapi-flow-plugin.js`.
|
|
420
|
-
- A ready HTML example is available at `../example/openapi-swagger-ui/examples/swagger-ui/index.html`.
|
|
421
|
-
- The plugin renders a global **Flow Overview** (Mermaid image) near the top of the docs, plus operation-level flow cards.
|
|
452
|
+
## Changelog
|
|
422
453
|
|
|
423
|
-
|
|
454
|
+
Version history: [CHANGELOG.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/CHANGELOG.md)
|
|
455
|
+
Release notes: [RELEASE_NOTES_v1.3.7.md](https://github.com/tiago-marques/x-openapi-flow/blob/main/RELEASE_NOTES_v1.3.7.md)
|
|
424
456
|
|
|
425
|
-
|
|
457
|
+
---
|
|
426
458
|
|
|
427
|
-
|
|
428
|
-
The `graph` command accepts both full OpenAPI source files and sidecar files (`{context}.x.(json|yaml)` and legacy `{context}-openapi-flow.(json|yaml)`).
|
|
459
|
+
## Documentation Language Policy
|
|
429
460
|
|
|
430
|
-
|
|
461
|
+
All project documentation must be written in English, including:
|
|
431
462
|
|
|
432
|
-
|
|
463
|
+
- Repository Markdown files
|
|
464
|
+
- Wiki pages
|
|
465
|
+
- Release notes and changelog entries
|
|
433
466
|
|
|
434
|
-
-
|
|
435
|
-
- Full guide and changelog are available in the root repository.
|
|
467
|
+
If a contribution includes non-English documentation content, it should be translated to English before merge.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-openapi-flow",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "OpenAPI extension for resource workflow and lifecycle management",
|
|
5
5
|
"main": "lib/validator.js",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
"x-openapi-flow": "bin/x-openapi-flow.js"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
+
"sync:readme": "node ../scripts/sync-package-readme.js",
|
|
35
|
+
"prepack": "npm run sync:readme",
|
|
34
36
|
"test": "npm run test:cli && npm run test:ui && npm run test:integration && npm run test:smoke",
|
|
35
37
|
"test:cli": "node --test tests/cli/cli.test.js",
|
|
36
38
|
"test:ui": "node --test tests/plugins/plugin-ui.test.js",
|