@workos/openapi-spec 0.4.0 → 0.6.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 +42 -3
- package/{open-api-spec.yaml → dist/open-api-spec.yaml} +442 -162
- package/dist/operationOverrides.node.json +122 -0
- package/dist/policy.d.mts +85 -0
- package/dist/policy.mjs +398 -0
- package/{types.d.ts → dist/types.d.ts} +401 -127
- package/package.json +52 -8
package/README.md
CHANGED
|
@@ -22,7 +22,9 @@ The WorkOS API provides a comprehensive platform for enterprise-ready features i
|
|
|
22
22
|
|
|
23
23
|
## SDK Generation
|
|
24
24
|
|
|
25
|
-
This repository is the canonical source for SDK generation. The consumer
|
|
25
|
+
This repository is the canonical source for SDK generation. The consumer policy lives under [`src/policy/`](src/policy/) — split into focused modules ([`operation-hints.ts`](src/policy/operation-hints.ts), [`mount-rules.ts`](src/policy/mount-rules.ts), [`model-hints.ts`](src/policy/model-hints.ts), [`transforms.ts`](src/policy/transforms.ts) for the NestJS `operationId` transform / schema-name transform / pre-IR spec overlay, and [`types.ts`](src/policy/types.ts) for vendored type definitions). The barrel [`src/policy/index.ts`](src/policy/index.ts) re-exports the whole thing and is published as `@workos/openapi-spec/policy` so downstream consumers (the WorkOS docs build's snippet generators, partner tooling) can apply the exact same naming conventions the SDKs use.
|
|
26
|
+
|
|
27
|
+
`oagen.config.ts` at the repo root is a thin shim that combines that policy with the `workosEmittersPlugin` bundle from `@workos/oagen-emitters` and feeds the whole thing to `npx oagen generate`.
|
|
26
28
|
|
|
27
29
|
### Orchestration scripts
|
|
28
30
|
|
|
@@ -122,11 +124,13 @@ node scripts/sdk-compat-pr-comment.mjs \
|
|
|
122
124
|
### Typical workflow
|
|
123
125
|
|
|
124
126
|
1. Edit `spec/open-api-spec.yaml`
|
|
125
|
-
2. Update `
|
|
127
|
+
2. Update the relevant file under [`src/policy/`](src/policy/) if the change needs new operation hints, mount rules, model hints, schema renames, or pre-IR transforms (only touch `oagen.config.ts` for changes that affect emitter wiring, e.g. `emitterOptions`)
|
|
126
128
|
3. `npm run sdk:resolve` to inspect naming
|
|
127
129
|
4. `npm run sdk:generate -- --lang <lang> --output .oagen/<lang>/sdk` to generate
|
|
128
130
|
5. `npm run sdk:verify -- --lang <lang> --output .oagen/<lang>/sdk` to verify
|
|
129
131
|
|
|
132
|
+
Changes to any file under `src/policy/` (or to `operationOverrides.node.json` or `tsdown.config.ts`) trigger a new release of `@workos/openapi-spec` the same way changes to the spec YAML do — see the publish workflow at `.github/workflows/release.yml`.
|
|
133
|
+
|
|
130
134
|
## Grabbing from npm
|
|
131
135
|
|
|
132
136
|
The spec is published to npm as [`@workos/openapi-spec`](https://www.npmjs.com/package/@workos/openapi-spec).
|
|
@@ -137,7 +141,14 @@ npm install @workos/openapi-spec
|
|
|
137
141
|
|
|
138
142
|
### Usage
|
|
139
143
|
|
|
140
|
-
The package ships TypeScript types generated from the spec,
|
|
144
|
+
The package ships TypeScript types generated from the spec, the raw `open-api-spec.yaml` file, the SDK resolution policy module, and the Node-specific operation overrides.
|
|
145
|
+
|
|
146
|
+
| Export | What it gives you |
|
|
147
|
+
| ------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
148
|
+
| `@workos/openapi-spec` | Generated TypeScript `paths` / `components` / `operations` types (default), spec YAML as file. |
|
|
149
|
+
| `@workos/openapi-spec/spec` | Path to the bundled `open-api-spec.yaml`. |
|
|
150
|
+
| `@workos/openapi-spec/policy` | Operation hints, mount rules, model hints, and transform functions used by SDK generation. |
|
|
151
|
+
| `@workos/openapi-spec/operation-overrides/node` | JSON path for the Node-emitter-specific operation overrides. |
|
|
141
152
|
|
|
142
153
|
**TypeScript types:**
|
|
143
154
|
|
|
@@ -189,6 +200,34 @@ const spec = yaml.load(readFileSync(specPath, "utf8"));
|
|
|
189
200
|
import spec from "@workos/openapi-spec/spec";
|
|
190
201
|
```
|
|
191
202
|
|
|
203
|
+
**Applying the SDK resolution policy (e.g. for docs code snippets):**
|
|
204
|
+
|
|
205
|
+
The `/policy` export exposes the same hints, mount rules, and transforms that drive SDK generation, so downstream tooling can resolve operations against the WorkOS spec with method names, mount targets, and parameter shapes that match the published SDKs.
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { parseSpec, resolveOperations } from "@workos/oagen";
|
|
209
|
+
import {
|
|
210
|
+
operationHints,
|
|
211
|
+
mountRules,
|
|
212
|
+
modelHints,
|
|
213
|
+
nestjsOperationIdTransform,
|
|
214
|
+
schemaNameTransform,
|
|
215
|
+
transformSpec,
|
|
216
|
+
} from "@workos/openapi-spec/policy";
|
|
217
|
+
|
|
218
|
+
const spec = await parseSpec("./open-api-spec.yaml", {
|
|
219
|
+
operationIdTransform: nestjsOperationIdTransform,
|
|
220
|
+
schemaNameTransform,
|
|
221
|
+
transformSpec,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const resolved = resolveOperations(spec, operationHints, mountRules);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
`@workos/oagen` is installed transitively when you install `@workos/openapi-spec` — no separate add needed.
|
|
228
|
+
|
|
229
|
+
The vendored type aliases (`OperationHint`, `SplitHint`, `OpenApiDocument`) are inlined into the published `policy.d.mts`, so TypeScript users get full autocomplete without having to import types from `@workos/oagen` themselves.
|
|
230
|
+
|
|
192
231
|
## Generating Postman Collections
|
|
193
232
|
|
|
194
233
|
This repository includes scripts to generate Postman collections from the OpenAPI specification. See the `scripts/postman` folder for more information.
|