@erenthedeveloper0/zen-openapi 0.1.0-alpha.1
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/LICENSE +9 -0
- package/README.md +76 -0
- package/dist/diff.d.ts +37 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +320 -0
- package/dist/diff.js.map +1 -0
- package/dist/document.d.ts +75 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +689 -0
- package/dist/document.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +29 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +84 -0
- package/dist/plugin.js.map +1 -0
- package/dist/schema.d.ts +103 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +434 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +154 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/ui.d.ts +19 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +192 -0
- package/dist/ui.js.map +1 -0
- package/package.json +65 -0
- package/src/diff.ts +439 -0
- package/src/document.ts +882 -0
- package/src/index.ts +20 -0
- package/src/plugin.ts +135 -0
- package/src/schema.ts +497 -0
- package/src/types.ts +166 -0
- package/src/ui.ts +198 -0
package/dist/schema.js
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { resolveRef } from '@erenthedeveloper0/zen-core';
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// Component registry — §29.3
|
|
4
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
/**
|
|
6
|
+
* Deduplication runs in three passes, cheapest and most authoritative first:
|
|
7
|
+
* schema *identity* (the same imported object used by four routes is one
|
|
8
|
+
* component), then a *declared* name (`$id` / `title`), then *structural*
|
|
9
|
+
* equality. The third pass is a backstop, not the strategy — two schemas that
|
|
10
|
+
* happen to have the same shape today are not necessarily the same concept, so
|
|
11
|
+
* structural merging only ever fires for schemas that had no name to begin with.
|
|
12
|
+
*/
|
|
13
|
+
export class Components {
|
|
14
|
+
#byName = new Map();
|
|
15
|
+
#byKey = new Map();
|
|
16
|
+
/** `name + shape` → the name that owns it. What makes two arrivals one component. */
|
|
17
|
+
#byIdentity = new Map();
|
|
18
|
+
/** A name that turned out to duplicate another, and the name it defers to. */
|
|
19
|
+
#aliases = new Map();
|
|
20
|
+
#reserved = new Set();
|
|
21
|
+
/**
|
|
22
|
+
* Claim a name for a shape that is already projected.
|
|
23
|
+
*
|
|
24
|
+
* `key` is the identity the caller wants deduplicated on, and it is a
|
|
25
|
+
* parameter rather than always the shape for a reason: two *named* schemas
|
|
26
|
+
* that happen to look alike today are not the same concept, so the caller
|
|
27
|
+
* folds the name into the key and they stay separate. Anonymous schemas pass
|
|
28
|
+
* the shape and do collapse. Different keys wanting the same name get `Name2`.
|
|
29
|
+
*/
|
|
30
|
+
claim(preferred, schema, key, variant) {
|
|
31
|
+
const existing = this.#byKey.get(key);
|
|
32
|
+
if (existing !== undefined)
|
|
33
|
+
return existing;
|
|
34
|
+
const identity = identityOf(preferred, schema);
|
|
35
|
+
const owner = this.#byIdentity.get(identity);
|
|
36
|
+
if (owner !== undefined) {
|
|
37
|
+
this.#byKey.set(key, owner);
|
|
38
|
+
return owner;
|
|
39
|
+
}
|
|
40
|
+
const name = this.#free(preferred, variant);
|
|
41
|
+
this.#reserved.add(name);
|
|
42
|
+
this.#byName.set(name, schema);
|
|
43
|
+
this.#byKey.set(key, name);
|
|
44
|
+
this.#byIdentity.set(identity, name);
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Reserve a name for a shape that cannot be projected yet — a `$def` whose body
|
|
49
|
+
* may refer back to itself, or refer to a sibling def not yet visited. Keyed on
|
|
50
|
+
* the *raw* schema so recursion terminates.
|
|
51
|
+
*
|
|
52
|
+
* The reservation is provisional: the same concept can arrive twice, once as a
|
|
53
|
+
* converter's `$defs` entry and once as an inline titled object, and which one
|
|
54
|
+
* is seen first depends on route order. `fill` reconciles that.
|
|
55
|
+
*/
|
|
56
|
+
reserve(preferred, rawKey, variant) {
|
|
57
|
+
const existing = this.#byKey.get(rawKey);
|
|
58
|
+
if (existing !== undefined)
|
|
59
|
+
return { name: existing, fresh: false };
|
|
60
|
+
const name = this.#free(preferred, variant);
|
|
61
|
+
this.#reserved.add(name);
|
|
62
|
+
this.#byKey.set(rawKey, name);
|
|
63
|
+
return { name, fresh: true };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Attach a body to a reserved name — and collapse it onto an existing
|
|
67
|
+
* component if it turns out to be the same concept under the same name.
|
|
68
|
+
*
|
|
69
|
+
* This is the fix for a bug the first real application found: Zod hoists a
|
|
70
|
+
* schema carrying an `id` into `$defs` when it is nested, and emits it inline
|
|
71
|
+
* when it is not, so `PublicUser` arrived by both routes and the document
|
|
72
|
+
* published `PublicUser` *and* `PublicUser2`. Two names for one type in a
|
|
73
|
+
* generated client is exactly the drift this subsystem exists to prevent.
|
|
74
|
+
*/
|
|
75
|
+
fill(name, schema) {
|
|
76
|
+
const identity = identityOf(name, schema);
|
|
77
|
+
const owner = this.#byIdentity.get(identity);
|
|
78
|
+
if (owner !== undefined && owner !== name) {
|
|
79
|
+
this.#aliases.set(name, owner);
|
|
80
|
+
this.#reserved.delete(name);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.#byIdentity.set(identity, name);
|
|
84
|
+
this.#byName.set(name, schema);
|
|
85
|
+
}
|
|
86
|
+
/** `duplicate → canonical`, for the final `$ref` rewrite. Empty in the common case. */
|
|
87
|
+
aliases() {
|
|
88
|
+
return this.#aliases;
|
|
89
|
+
}
|
|
90
|
+
has(name) {
|
|
91
|
+
return this.#byName.has(name);
|
|
92
|
+
}
|
|
93
|
+
get size() {
|
|
94
|
+
return this.#byName.size;
|
|
95
|
+
}
|
|
96
|
+
/** Sorted, because a document that reorders itself between runs cannot be diffed. */
|
|
97
|
+
toRecord() {
|
|
98
|
+
const out = {};
|
|
99
|
+
for (const name of [...this.#byName.keys()].sort()) {
|
|
100
|
+
if (this.#aliases.has(name))
|
|
101
|
+
continue;
|
|
102
|
+
out[name] = this.#byName.get(name);
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* `variant` is tried before the numeric fallback, and it exists for one very
|
|
108
|
+
* common case: the same named schema appears on both sides of the API, and the
|
|
109
|
+
* two are not identical — a converter describes a request body as it is
|
|
110
|
+
* *received* (extra keys tolerated) and a response as it is *emitted* (extra
|
|
111
|
+
* keys impossible, §13.3.1).
|
|
112
|
+
*
|
|
113
|
+
* They are genuinely two schemas, so they must be two components. But
|
|
114
|
+
* `OrderLine` and `OrderLineInput` tell a client author which is which, and
|
|
115
|
+
* `OrderLine` and `OrderLine2` do not.
|
|
116
|
+
*/
|
|
117
|
+
#free(preferred, variant) {
|
|
118
|
+
const base = sanitizeName(preferred);
|
|
119
|
+
if (!this.#reserved.has(base))
|
|
120
|
+
return base;
|
|
121
|
+
if (variant !== undefined) {
|
|
122
|
+
const varied = `${base}${variant}`;
|
|
123
|
+
if (!this.#reserved.has(varied))
|
|
124
|
+
return varied;
|
|
125
|
+
}
|
|
126
|
+
for (let n = 2;; n++) {
|
|
127
|
+
const candidate = `${base}${n}`;
|
|
128
|
+
if (!this.#reserved.has(candidate))
|
|
129
|
+
return candidate;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A component's identity: its name plus its *shape*, with the top-level
|
|
135
|
+
* annotations removed.
|
|
136
|
+
*
|
|
137
|
+
* `title` and `description` are stripped because converters do not emit them
|
|
138
|
+
* consistently between an inline occurrence and a `$defs` entry for the very
|
|
139
|
+
* same schema — and two schemas with the same name and the same structure are
|
|
140
|
+
* one type whichever prose happens to be attached. Nested annotations are left
|
|
141
|
+
* alone; they are part of the shape as far as a client generator is concerned.
|
|
142
|
+
*/
|
|
143
|
+
function identityOf(name, schema) {
|
|
144
|
+
const { title: _title, description: _description, ...rest } = schema;
|
|
145
|
+
return `${sanitizeName(name)}::${canonical(rest)}`;
|
|
146
|
+
}
|
|
147
|
+
const NAME_ILLEGAL = /[^A-Za-z0-9_.-]/g;
|
|
148
|
+
export function sanitizeName(raw) {
|
|
149
|
+
const cleaned = raw.replace(NAME_ILLEGAL, '_').replace(/^_+|_+$/g, '');
|
|
150
|
+
return cleaned.length > 0 ? cleaned : 'Schema';
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Key-sorted JSON. Used for structural identity, so it must be stable across
|
|
154
|
+
* runs and across property insertion order — `{a,b}` and `{b,a}` are one shape.
|
|
155
|
+
*/
|
|
156
|
+
export function canonical(value) {
|
|
157
|
+
if (value === null || typeof value !== 'object')
|
|
158
|
+
return JSON.stringify(value) ?? 'null';
|
|
159
|
+
if (Array.isArray(value))
|
|
160
|
+
return `[${value.map(canonical).join(',')}]`;
|
|
161
|
+
const entries = Object.entries(value)
|
|
162
|
+
.filter(([, v]) => v !== undefined)
|
|
163
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
164
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(',')}}`;
|
|
165
|
+
}
|
|
166
|
+
/** Keywords handled structurally; everything else is copied through verbatim. */
|
|
167
|
+
const STRUCTURAL = new Set([
|
|
168
|
+
'$ref', '$defs', 'definitions', '$schema', '$id',
|
|
169
|
+
'type', 'nullable', 'properties', 'required', 'additionalProperties',
|
|
170
|
+
'items', 'prefixItems', 'anyOf', 'oneOf', 'allOf',
|
|
171
|
+
]);
|
|
172
|
+
export function projectSchema(raw, options) {
|
|
173
|
+
return new Projector(raw, options).walk(raw, new Set(), 0);
|
|
174
|
+
}
|
|
175
|
+
class Projector {
|
|
176
|
+
#root;
|
|
177
|
+
#opts;
|
|
178
|
+
/** `#/$defs/User` → component name. Populated before the body is walked. */
|
|
179
|
+
#refs = new Map();
|
|
180
|
+
/** Name suffix for the open (request) side, so both sides can coexist. */
|
|
181
|
+
#variant;
|
|
182
|
+
constructor(root, options) {
|
|
183
|
+
this.#root = root;
|
|
184
|
+
this.#opts = options;
|
|
185
|
+
this.#variant = options.closed ? undefined : 'Input';
|
|
186
|
+
this.#hoistDefs(root.$defs, '#/$defs/');
|
|
187
|
+
this.#hoistDefs(root.definitions, '#/definitions/');
|
|
188
|
+
}
|
|
189
|
+
#hoistDefs(defs, prefix) {
|
|
190
|
+
if (defs === undefined)
|
|
191
|
+
return;
|
|
192
|
+
// Names are reserved for every def first, then bodies are projected. A
|
|
193
|
+
// recursive `$def` refers to itself through a name that must already exist.
|
|
194
|
+
const pending = [];
|
|
195
|
+
for (const key of Object.keys(defs)) {
|
|
196
|
+
const schema = defs[key];
|
|
197
|
+
if (schema === undefined)
|
|
198
|
+
continue;
|
|
199
|
+
// The closure flag is part of the identity: the same raw schema projected
|
|
200
|
+
// open (a request) and closed (a response) is two different documents.
|
|
201
|
+
const rawKey = `def:${this.#opts.closed ? 'closed' : 'open'}:${canonical(schema)}`;
|
|
202
|
+
const claimed = this.#opts.components.reserve(key, rawKey, this.#variant);
|
|
203
|
+
this.#refs.set(`${prefix}${key}`, claimed.name);
|
|
204
|
+
if (claimed.fresh)
|
|
205
|
+
pending.push({ name: claimed.name, schema });
|
|
206
|
+
}
|
|
207
|
+
for (const job of pending) {
|
|
208
|
+
this.#opts.components.fill(job.name, this.walk(job.schema, new Set(), 0));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* `depth` exists for one rule: **a titled subschema becomes a component
|
|
213
|
+
* wherever it appears.**
|
|
214
|
+
*
|
|
215
|
+
* A response of `{ users: PublicUser[] }` should say `$ref: PublicUser`, not
|
|
216
|
+
* inline a second copy of the same object — otherwise a generated client
|
|
217
|
+
* grows `UserListUsersItem` alongside `PublicUser` and the two drift the first
|
|
218
|
+
* time someone edits one. A `title` is the author naming a type, so it is
|
|
219
|
+
* honoured at every level. Anonymous subschemas stay inline, because hoisting
|
|
220
|
+
* those would fill `components` with `Schema1..Schema40`.
|
|
221
|
+
*
|
|
222
|
+
* Depth 0 is exempt: the caller decides whether the *root* is hoisted, since
|
|
223
|
+
* only it knows how many operations share it (§29.3).
|
|
224
|
+
*/
|
|
225
|
+
walk(node, seen, depth) {
|
|
226
|
+
if (node === undefined || node === true)
|
|
227
|
+
return {};
|
|
228
|
+
if (node === false)
|
|
229
|
+
return { not: {} };
|
|
230
|
+
if (typeof node !== 'object')
|
|
231
|
+
return {};
|
|
232
|
+
if (typeof node.$ref === 'string')
|
|
233
|
+
return this.#ref(node.$ref, seen, depth);
|
|
234
|
+
const title = depth > 0 ? declaredName(node) : null;
|
|
235
|
+
if (title !== null) {
|
|
236
|
+
const body = this.#body(node, seen, depth);
|
|
237
|
+
const name = this.#opts.components.claim(title, body, `named:${title}:${canonical(body)}`, this.#variant);
|
|
238
|
+
if (name !== title && name !== `${title}${this.#variant ?? ''}`) {
|
|
239
|
+
this.#opts.diagnostics.push({
|
|
240
|
+
severity: 'warning',
|
|
241
|
+
code: 'ZEN_OAS_TITLE_COLLISION',
|
|
242
|
+
message: `Two different schemas are both named "${title}"; this one was published as "${name}".`,
|
|
243
|
+
where: this.#opts.where,
|
|
244
|
+
hint: 'Give them distinct titles — a generated client names its types from these.',
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return { $ref: `#/components/schemas/${name}` };
|
|
248
|
+
}
|
|
249
|
+
return this.#body(node, seen, depth);
|
|
250
|
+
}
|
|
251
|
+
#body(node, seen, depth) {
|
|
252
|
+
const out = {};
|
|
253
|
+
for (const key of Object.keys(node)) {
|
|
254
|
+
if (STRUCTURAL.has(key))
|
|
255
|
+
continue;
|
|
256
|
+
const value = node[key];
|
|
257
|
+
if (value !== undefined)
|
|
258
|
+
out[key] = value;
|
|
259
|
+
}
|
|
260
|
+
// `const` and `enum` short-circuit shape in the IR, so they do here too:
|
|
261
|
+
// closing an object that can only ever be one literal adds nothing.
|
|
262
|
+
if (node.const !== undefined || Array.isArray(node.enum)) {
|
|
263
|
+
this.#applyType(node, out);
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
const allOf = node.allOf;
|
|
267
|
+
if (Array.isArray(allOf) && allOf.length > 0)
|
|
268
|
+
return this.#allOf(node, allOf, out, seen, depth);
|
|
269
|
+
const union = node.oneOf ?? node.anyOf;
|
|
270
|
+
if (Array.isArray(union) && union.length > 0) {
|
|
271
|
+
const keyword = node.oneOf !== undefined ? 'oneOf' : 'anyOf';
|
|
272
|
+
out[keyword] = union.map((member) => this.walk(member, seen, depth + 1));
|
|
273
|
+
this.#applyType(node, out);
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
this.#applyType(node, out);
|
|
277
|
+
if (isObjectShape(node))
|
|
278
|
+
this.#object(node, out, seen, depth);
|
|
279
|
+
else if (node.items !== undefined || node.prefixItems !== undefined)
|
|
280
|
+
this.#array(node, out, seen, depth);
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
283
|
+
/** OAS 3.1 has no `nullable`; `type: [T, 'null']` is the same statement. */
|
|
284
|
+
#applyType(node, out) {
|
|
285
|
+
const declared = node.type;
|
|
286
|
+
if (declared === undefined) {
|
|
287
|
+
if (node.nullable === true)
|
|
288
|
+
out['type'] = 'null';
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const types = Array.isArray(declared) ? declared : [declared];
|
|
292
|
+
const withNull = node.nullable === true && !types.includes('null') ? [...types, 'null'] : types;
|
|
293
|
+
out['type'] = withNull.length === 1 ? withNull[0] : withNull;
|
|
294
|
+
}
|
|
295
|
+
#object(node, out, seen, depth) {
|
|
296
|
+
const properties = node.properties;
|
|
297
|
+
if (properties !== undefined) {
|
|
298
|
+
const projected = {};
|
|
299
|
+
for (const key of Object.keys(properties))
|
|
300
|
+
projected[key] = this.walk(properties[key], seen, depth + 1);
|
|
301
|
+
out['properties'] = projected;
|
|
302
|
+
}
|
|
303
|
+
if (node.required !== undefined && node.required.length > 0)
|
|
304
|
+
out['required'] = [...node.required];
|
|
305
|
+
const additional = node.additionalProperties;
|
|
306
|
+
if (additional === undefined) {
|
|
307
|
+
// §13.3.1 — the one deliberate deviation, written down in the document
|
|
308
|
+
// rather than left as folklore. Absent means *drop*, so the document says
|
|
309
|
+
// `false` and a generated client will not offer a field that cannot arrive.
|
|
310
|
+
if (this.#opts.closed)
|
|
311
|
+
out['additionalProperties'] = false;
|
|
312
|
+
}
|
|
313
|
+
else if (typeof additional === 'boolean') {
|
|
314
|
+
out['additionalProperties'] = additional;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
out['additionalProperties'] = this.walk(additional, seen, depth + 1);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
#array(node, out, seen, depth) {
|
|
321
|
+
if (Array.isArray(node.prefixItems)) {
|
|
322
|
+
out['prefixItems'] = node.prefixItems.map((item) => this.walk(item, seen, depth + 1));
|
|
323
|
+
// Draft 2020-12: with `prefixItems`, `items` constrains the tail. `false`
|
|
324
|
+
// is how a fixed-length tuple is spelled, and the IR reads it the same way.
|
|
325
|
+
out['items'] = node.items === undefined || node.items === false ? false : this.walk(node.items, seen, depth + 1);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (node.items !== undefined)
|
|
329
|
+
out['items'] = this.walk(node.items, seen, depth + 1);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* `allOf` is an intersection, and the serializer resolves it by *merging* the
|
|
333
|
+
* members into one object (§13.3, `Builder#allOf`). The document must say the
|
|
334
|
+
* same thing — and there is a second reason beyond fidelity: an `allOf` of two
|
|
335
|
+
* closed objects is unsatisfiable, because every property of one member is
|
|
336
|
+
* "additional" to the other. Emitting the merge avoids publishing a schema
|
|
337
|
+
* that nothing can validate against.
|
|
338
|
+
*/
|
|
339
|
+
#allOf(node, members, out, seen, depth) {
|
|
340
|
+
if (!this.#opts.closed) {
|
|
341
|
+
out['allOf'] = members.map((member) => this.walk(member, seen, depth + 1));
|
|
342
|
+
this.#applyType(node, out);
|
|
343
|
+
return out;
|
|
344
|
+
}
|
|
345
|
+
const resolved = [];
|
|
346
|
+
for (const member of members) {
|
|
347
|
+
const target = typeof member.$ref === 'string' ? resolveRef(this.#root, member.$ref) : member;
|
|
348
|
+
if (target === null || !isObjectShape(target)) {
|
|
349
|
+
this.#opts.diagnostics.push({
|
|
350
|
+
severity: 'info',
|
|
351
|
+
code: 'ZEN_OAS_ALLOF_UNMERGED',
|
|
352
|
+
message: 'allOf member is not an object schema, so the document keeps allOf rather than merging it.',
|
|
353
|
+
where: this.#opts.where,
|
|
354
|
+
hint: 'The serializer reports the same case as a boot diagnostic; see rfcs/0001 §13.3.',
|
|
355
|
+
});
|
|
356
|
+
out['allOf'] = members.map((m) => this.walk(m, seen, depth + 1));
|
|
357
|
+
this.#applyType(node, out);
|
|
358
|
+
return out;
|
|
359
|
+
}
|
|
360
|
+
resolved.push(target);
|
|
361
|
+
}
|
|
362
|
+
const properties = {};
|
|
363
|
+
const required = new Set();
|
|
364
|
+
let additional;
|
|
365
|
+
for (const member of [...resolved, node]) {
|
|
366
|
+
for (const [key, value] of Object.entries(member.properties ?? {}))
|
|
367
|
+
properties[key] = value;
|
|
368
|
+
for (const key of member.required ?? [])
|
|
369
|
+
required.add(key);
|
|
370
|
+
if (member.additionalProperties !== undefined)
|
|
371
|
+
additional = member.additionalProperties;
|
|
372
|
+
}
|
|
373
|
+
const merged = {
|
|
374
|
+
type: 'object',
|
|
375
|
+
properties,
|
|
376
|
+
...(required.size > 0 ? { required: [...required] } : {}),
|
|
377
|
+
...(additional !== undefined ? { additionalProperties: additional } : {}),
|
|
378
|
+
};
|
|
379
|
+
const projected = this.#body(merged, seen, depth);
|
|
380
|
+
return { ...out, ...projected };
|
|
381
|
+
}
|
|
382
|
+
#ref(ref, seen, depth) {
|
|
383
|
+
const hoisted = this.#refs.get(ref);
|
|
384
|
+
if (hoisted !== undefined)
|
|
385
|
+
return { $ref: `#/components/schemas/${hoisted}` };
|
|
386
|
+
// Not a `$defs` entry: resolve and inline. A pointer into `properties` is
|
|
387
|
+
// legal JSON Schema and rare, but inlining beats emitting a `$ref` that
|
|
388
|
+
// points nowhere in the published document.
|
|
389
|
+
if (seen.has(ref)) {
|
|
390
|
+
this.#opts.diagnostics.push({
|
|
391
|
+
severity: 'warning',
|
|
392
|
+
code: 'ZEN_OAS_REF_CYCLE',
|
|
393
|
+
message: `Circular $ref "${ref}" outside $defs; the document inlines it as an unconstrained schema.`,
|
|
394
|
+
where: this.#opts.where,
|
|
395
|
+
hint: 'Move the recursive schema into $defs so it can be hoisted into components.schemas.',
|
|
396
|
+
});
|
|
397
|
+
return {};
|
|
398
|
+
}
|
|
399
|
+
const target = resolveRef(this.#root, ref);
|
|
400
|
+
if (target === null) {
|
|
401
|
+
this.#opts.diagnostics.push({
|
|
402
|
+
severity: 'warning',
|
|
403
|
+
code: 'ZEN_OAS_REF_UNRESOLVED',
|
|
404
|
+
message: `Unresolvable $ref "${ref}"; the document describes this position as unconstrained.`,
|
|
405
|
+
where: this.#opts.where,
|
|
406
|
+
hint: 'Only same-document refs are supported (#/$defs/Name, #/definitions/Name).',
|
|
407
|
+
});
|
|
408
|
+
return {};
|
|
409
|
+
}
|
|
410
|
+
return this.walk(target, new Set([...seen, ref]), depth);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
/** Mirrors `Builder#byType`/`#inferShape`: when does the IR build an object node? */
|
|
414
|
+
export function isObjectShape(node) {
|
|
415
|
+
const declared = node.type;
|
|
416
|
+
const types = declared === undefined ? [] : Array.isArray(declared) ? declared : [declared];
|
|
417
|
+
if (types.includes('object'))
|
|
418
|
+
return true;
|
|
419
|
+
if (types.filter((t) => t !== 'null').length > 0)
|
|
420
|
+
return false;
|
|
421
|
+
return node.properties !== undefined || node.required !== undefined || node.additionalProperties !== undefined;
|
|
422
|
+
}
|
|
423
|
+
/** A component name to suggest for a schema that carries one. */
|
|
424
|
+
export function declaredName(schema) {
|
|
425
|
+
const id = schema['$id'];
|
|
426
|
+
if (typeof id === 'string' && id.length > 0) {
|
|
427
|
+
const tail = id.split('/').pop();
|
|
428
|
+
if (tail !== undefined && tail.length > 0)
|
|
429
|
+
return tail.replace(/\.json$/, '');
|
|
430
|
+
}
|
|
431
|
+
const title = schema.title;
|
|
432
|
+
return typeof title === 'string' && title.length > 0 ? title : null;
|
|
433
|
+
}
|
|
434
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAoCxD,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACZ,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC1C,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC3C,qFAAqF;IAC5E,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAA;IAChD,8EAA8E;IACrE,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAA;IACpC,SAAS,GAAG,IAAI,GAAG,EAAU,CAAA;IAEtC;;;;;;;;OAQG;IACH,KAAK,CAAC,SAAiB,EAAE,MAAqB,EAAE,GAAW,EAAE,OAAgB;QAC3E,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACrC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAA;QAE3C,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC9C,MAAM,KAAK,G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K,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACrE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { JsonSchema } from '@erenthedeveloper0/zen-core';
|
|
2
|
+
/**
|
|
3
|
+
* OpenAPI 3.1 document types — rfcs/0001 §29.
|
|
4
|
+
*
|
|
5
|
+
* 3.1 rather than 3.0 for one reason that matters here: 3.1's Schema Object *is*
|
|
6
|
+
* JSON Schema 2020-12, the same dialect the validation layer produces and the
|
|
7
|
+
* serializer IR consumes. Under 3.0 every schema would need lossy
|
|
8
|
+
* down-conversion (`nullable`, `exclusiveMinimum`, tuples, `const`) — which is
|
|
9
|
+
* precisely the silent drift this subsystem exists to prevent.
|
|
10
|
+
*
|
|
11
|
+
* Only the parts Zen emits are typed. A partial-but-honest type is more useful
|
|
12
|
+
* than a complete one nobody reads, and `[extension: string]` keeps `x-` fields
|
|
13
|
+
* legal without pretending to enumerate them.
|
|
14
|
+
*/
|
|
15
|
+
/** OAS 3.1 Schema Objects are JSON Schema 2020-12, so this is not an alias of convenience. */
|
|
16
|
+
export type OpenApiSchema = JsonSchema;
|
|
17
|
+
export interface OpenApiDocument {
|
|
18
|
+
readonly openapi: string;
|
|
19
|
+
readonly info: InfoObject;
|
|
20
|
+
readonly servers?: readonly ServerObject[] | undefined;
|
|
21
|
+
readonly paths: Readonly<Record<string, PathItemObject>>;
|
|
22
|
+
readonly components?: ComponentsObject | undefined;
|
|
23
|
+
readonly tags?: readonly TagObject[] | undefined;
|
|
24
|
+
readonly security?: readonly SecurityRequirement[] | undefined;
|
|
25
|
+
readonly externalDocs?: ExternalDocs | undefined;
|
|
26
|
+
readonly [extension: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface InfoObject {
|
|
29
|
+
readonly title: string;
|
|
30
|
+
readonly version: string;
|
|
31
|
+
readonly summary?: string | undefined;
|
|
32
|
+
readonly description?: string | undefined;
|
|
33
|
+
readonly license?: {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly identifier?: string;
|
|
36
|
+
readonly url?: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
readonly contact?: {
|
|
39
|
+
readonly name?: string;
|
|
40
|
+
readonly url?: string;
|
|
41
|
+
readonly email?: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
}
|
|
44
|
+
export interface ServerObject {
|
|
45
|
+
readonly url: string;
|
|
46
|
+
readonly description?: string | undefined;
|
|
47
|
+
readonly variables?: Readonly<Record<string, {
|
|
48
|
+
readonly default: string;
|
|
49
|
+
readonly enum?: readonly string[];
|
|
50
|
+
readonly description?: string;
|
|
51
|
+
}>> | undefined;
|
|
52
|
+
}
|
|
53
|
+
export interface TagObject {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly description?: string | undefined;
|
|
56
|
+
readonly externalDocs?: ExternalDocs | undefined;
|
|
57
|
+
}
|
|
58
|
+
export interface ExternalDocs {
|
|
59
|
+
readonly url: string;
|
|
60
|
+
readonly description?: string | undefined;
|
|
61
|
+
}
|
|
62
|
+
export type HttpOperation = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';
|
|
63
|
+
export type PathItemObject = {
|
|
64
|
+
readonly [M in HttpOperation]?: OperationObject;
|
|
65
|
+
} & {
|
|
66
|
+
readonly summary?: string | undefined;
|
|
67
|
+
readonly description?: string | undefined;
|
|
68
|
+
readonly parameters?: readonly ParameterObject[] | undefined;
|
|
69
|
+
};
|
|
70
|
+
export interface OperationObject {
|
|
71
|
+
readonly operationId: string;
|
|
72
|
+
readonly summary?: string | undefined;
|
|
73
|
+
readonly description?: string | undefined;
|
|
74
|
+
readonly tags?: readonly string[] | undefined;
|
|
75
|
+
readonly deprecated?: boolean | undefined;
|
|
76
|
+
readonly parameters?: readonly ParameterObject[] | undefined;
|
|
77
|
+
readonly requestBody?: RequestBodyObject | undefined;
|
|
78
|
+
readonly responses: Readonly<Record<string, ResponseObject>>;
|
|
79
|
+
readonly security?: readonly SecurityRequirement[] | undefined;
|
|
80
|
+
readonly externalDocs?: ExternalDocs | undefined;
|
|
81
|
+
readonly [extension: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
export type ParameterLocation = 'path' | 'query' | 'header' | 'cookie';
|
|
84
|
+
export interface ParameterObject {
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly in: ParameterLocation;
|
|
87
|
+
readonly required?: boolean | undefined;
|
|
88
|
+
readonly description?: string | undefined;
|
|
89
|
+
readonly deprecated?: boolean | undefined;
|
|
90
|
+
readonly schema: OpenApiSchema;
|
|
91
|
+
readonly [extension: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
export interface RequestBodyObject {
|
|
94
|
+
readonly required?: boolean | undefined;
|
|
95
|
+
readonly description?: string | undefined;
|
|
96
|
+
readonly content: Readonly<Record<string, MediaTypeObject>>;
|
|
97
|
+
}
|
|
98
|
+
export interface ResponseObject {
|
|
99
|
+
readonly description: string;
|
|
100
|
+
readonly content?: Readonly<Record<string, MediaTypeObject>> | undefined;
|
|
101
|
+
readonly headers?: Readonly<Record<string, HeaderObject>> | undefined;
|
|
102
|
+
}
|
|
103
|
+
export interface HeaderObject {
|
|
104
|
+
readonly description?: string | undefined;
|
|
105
|
+
readonly required?: boolean | undefined;
|
|
106
|
+
readonly schema: OpenApiSchema;
|
|
107
|
+
}
|
|
108
|
+
export interface MediaTypeObject {
|
|
109
|
+
readonly schema: OpenApiSchema;
|
|
110
|
+
readonly example?: unknown;
|
|
111
|
+
}
|
|
112
|
+
export interface ComponentsObject {
|
|
113
|
+
readonly schemas?: Readonly<Record<string, OpenApiSchema>> | undefined;
|
|
114
|
+
readonly securitySchemes?: Readonly<Record<string, SecurityScheme>> | undefined;
|
|
115
|
+
}
|
|
116
|
+
export type SecurityRequirement = Readonly<Record<string, readonly string[]>>;
|
|
117
|
+
export interface SecurityScheme {
|
|
118
|
+
readonly type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect' | 'mutualTLS';
|
|
119
|
+
readonly description?: string | undefined;
|
|
120
|
+
readonly name?: string | undefined;
|
|
121
|
+
readonly in?: 'query' | 'header' | 'cookie' | undefined;
|
|
122
|
+
readonly scheme?: string | undefined;
|
|
123
|
+
readonly bearerFormat?: string | undefined;
|
|
124
|
+
readonly openIdConnectUrl?: string | undefined;
|
|
125
|
+
readonly flows?: Readonly<Record<string, unknown>> | undefined;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Route metadata this generator reads — rfcs/0001 §5.1.
|
|
129
|
+
*
|
|
130
|
+
* `meta` is a free-form map on purpose, but a generator that reads undocumented
|
|
131
|
+
* keys is a generator nobody can predict. These are the keys, and they are the
|
|
132
|
+
* whole list:
|
|
133
|
+
*
|
|
134
|
+
* ```ts
|
|
135
|
+
* app.get('/users/:id<int>', {
|
|
136
|
+
* name: 'users.show',
|
|
137
|
+
* meta: { summary: 'Fetch one user', tags: ['users'], deprecated: true },
|
|
138
|
+
* response: { 200: PublicUser },
|
|
139
|
+
* }, handler)
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export interface RouteDocMeta {
|
|
143
|
+
readonly summary?: string;
|
|
144
|
+
readonly description?: string;
|
|
145
|
+
readonly tags?: readonly string[];
|
|
146
|
+
readonly operationId?: string;
|
|
147
|
+
readonly deprecated?: boolean;
|
|
148
|
+
/** Excluded from the document entirely. The docs endpoints set this on themselves. */
|
|
149
|
+
readonly hidden?: boolean;
|
|
150
|
+
readonly security?: readonly SecurityRequirement[];
|
|
151
|
+
readonly externalDocs?: ExternalDocs;
|
|
152
|
+
}
|
|
153
|
+
export declare const DOC_META_KEYS: readonly ["summary", "description", "tags", "operationId", "deprecated", "hidden", "security", "externalDocs"];
|
|
154
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"A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AAY,CAAC,EAAE,YAAY,CAAA;CACrC;AAED,eAAO,MAAM,aAAa,gHAE0B,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmKA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc;CACjD,CAAA"}
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OpenApiDocument } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A self-contained API reference — rfcs/0001 §29.2.
|
|
4
|
+
*
|
|
5
|
+
* Scalar, Swagger UI and Redoc are all better-looking than this, and all three
|
|
6
|
+
* are normally wired in with a `<script src="https://cdn…">`. That is a fine
|
|
7
|
+
* default for a public docs site and a bad one for a framework: it makes an
|
|
8
|
+
* internal endpoint phone a third party on every page load, it breaks behind a
|
|
9
|
+
* strict CSP, it breaks in an air-gapped deployment, and it breaks on a laptop
|
|
10
|
+
* on a train. So the built-in viewer has **no external requests at all** — the
|
|
11
|
+
* document is inlined at boot and the page is HTML, CSS and ~90 lines of script.
|
|
12
|
+
*
|
|
13
|
+
* `ui: false` turns it off; serving Scalar or Redoc instead is a five-line route
|
|
14
|
+
* in application code, and the README shows it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function renderReference(document: OpenApiDocument, options?: {
|
|
17
|
+
jsonPath: string | null;
|
|
18
|
+
}): string;
|
|
19
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,GAAE;IAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAuB,GAAG,MAAM,CA6B5H"}
|