@kubb/adapter-oas 5.18.5 → 5.18.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/dist/index.cjs +64 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +69 -74
- package/dist/index.js.map +1 -1
- package/docs/options.md +68 -24
- package/docs/overview.md +3 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var compatibility = {
|
|
|
36
36
|
"node": ">=22.22"
|
|
37
37
|
};
|
|
38
38
|
// package.json
|
|
39
|
-
var version = "5.18.
|
|
39
|
+
var version = "5.18.7";
|
|
40
40
|
// src/constants.ts
|
|
41
41
|
/**
|
|
42
42
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -76,17 +76,6 @@ const SUPPORTED_METHODS = /* @__PURE__ */ new Set([
|
|
|
76
76
|
"query"
|
|
77
77
|
]);
|
|
78
78
|
/**
|
|
79
|
-
* Media types OpenAPI 3.2 reads as a stream of items (its "sequential media types"), each described by `itemSchema`.
|
|
80
|
-
*/
|
|
81
|
-
const STREAM_MEDIA_TYPES = /* @__PURE__ */ new Set([
|
|
82
|
-
"application/jsonl",
|
|
83
|
-
"application/x-ndjson",
|
|
84
|
-
"application/json-seq",
|
|
85
|
-
"application/geo+json-seq",
|
|
86
|
-
"text/event-stream",
|
|
87
|
-
"multipart/mixed"
|
|
88
|
-
]);
|
|
89
|
-
/**
|
|
90
79
|
* Set of JSON Schema keywords that prevent a schema fragment from being inlined during `allOf` flattening.
|
|
91
80
|
*
|
|
92
81
|
* A fragment that contains any of these keys carries structural meaning of its own and must stay as a separate
|
|
@@ -183,21 +172,21 @@ const enumDescriptionKeys = ["x-enumDescriptions", "x-enum-descriptions"];
|
|
|
183
172
|
function buildDiscriminatorChildMap(schemas) {
|
|
184
173
|
const childMap = /* @__PURE__ */ new Map();
|
|
185
174
|
for (const schema of schemas) {
|
|
186
|
-
const unionNode = _kubb_kit.ast.
|
|
175
|
+
const unionNode = _kubb_kit.ast.schema.narrow(schema, "union") ?? _kubb_kit.ast.schema.narrow(schema, "intersection")?.members?.map((member) => _kubb_kit.ast.schema.narrow(member, "union")).find((union) => union);
|
|
187
176
|
if (!unionNode?.discriminatorPropertyName || !unionNode.members) continue;
|
|
188
177
|
const { discriminatorPropertyName, members } = unionNode;
|
|
189
178
|
for (const member of members) {
|
|
190
|
-
const intersectionNode = _kubb_kit.ast.
|
|
179
|
+
const intersectionNode = _kubb_kit.ast.schema.narrow(member, "intersection");
|
|
191
180
|
if (!intersectionNode?.members) continue;
|
|
192
181
|
let refNode = null;
|
|
193
182
|
let objNode = null;
|
|
194
183
|
for (const m of intersectionNode.members) {
|
|
195
|
-
refNode ??= _kubb_kit.ast.
|
|
196
|
-
objNode ??= _kubb_kit.ast.
|
|
184
|
+
refNode ??= _kubb_kit.ast.schema.narrow(m, "ref");
|
|
185
|
+
objNode ??= _kubb_kit.ast.schema.narrow(m, "object");
|
|
197
186
|
}
|
|
198
187
|
if (!refNode?.name || !objNode) continue;
|
|
199
188
|
const prop = objNode.properties.find((p) => p.name === discriminatorPropertyName);
|
|
200
|
-
const enumNode = prop ? _kubb_kit.ast.
|
|
189
|
+
const enumNode = prop ? _kubb_kit.ast.schema.narrow(prop.schema, "enum") : null;
|
|
201
190
|
if (!enumNode?.enumValues?.length) continue;
|
|
202
191
|
const enumValues = enumNode.enumValues.filter((v) => v !== null);
|
|
203
192
|
if (!enumValues.length) continue;
|
|
@@ -232,7 +221,7 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
232
221
|
required: true,
|
|
233
222
|
schema: enumSchema
|
|
234
223
|
});
|
|
235
|
-
const objectNode = _kubb_kit.ast.
|
|
224
|
+
const objectNode = _kubb_kit.ast.schema.narrow(node, "object");
|
|
236
225
|
if (objectNode) {
|
|
237
226
|
const existingIdx = objectNode.properties.findIndex((p) => p.name === propertyName);
|
|
238
227
|
const newProperties = existingIdx >= 0 ? objectNode.properties.map((p, i) => i === existingIdx ? newProp : p) : [...objectNode.properties, newProp];
|
|
@@ -241,14 +230,14 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
241
230
|
properties: newProperties
|
|
242
231
|
};
|
|
243
232
|
}
|
|
244
|
-
const intersectionNode = _kubb_kit.ast.
|
|
233
|
+
const intersectionNode = _kubb_kit.ast.schema.narrow(node, "intersection");
|
|
245
234
|
if (!intersectionNode?.members) return node;
|
|
246
235
|
const discriminantNode = _kubb_kit.ast.factory.createSchema({
|
|
247
236
|
type: "object",
|
|
248
237
|
primitive: "object",
|
|
249
238
|
properties: [newProp]
|
|
250
239
|
});
|
|
251
|
-
const patchedIdx = intersectionNode.members.findIndex((member) => _kubb_kit.ast.
|
|
240
|
+
const patchedIdx = intersectionNode.members.findIndex((member) => _kubb_kit.ast.schema.narrow(member, "object")?.properties.some((p) => p.name === propertyName));
|
|
252
241
|
const newMembers = patchedIdx >= 0 ? intersectionNode.members.map((member, i) => i === patchedIdx ? patchDiscriminatorNode(member, entry) : member) : [...intersectionNode.members, discriminantNode];
|
|
253
242
|
return {
|
|
254
243
|
...intersectionNode,
|
|
@@ -1471,22 +1460,16 @@ function toInputTags(tags) {
|
|
|
1471
1460
|
}
|
|
1472
1461
|
// src/model/mediaType.ts
|
|
1473
1462
|
/**
|
|
1474
|
-
*
|
|
1475
|
-
*/
|
|
1476
|
-
function baseMediaType(contentType) {
|
|
1477
|
-
return contentType.split(";")[0].trim().toLowerCase();
|
|
1478
|
-
}
|
|
1479
|
-
/**
|
|
1480
|
-
* Returns `true` for a media type read as a stream of items: one that OpenAPI 3.2 lists, or any that declares `itemSchema`.
|
|
1463
|
+
* Returns `true` for a media type read as a stream of items: one `ast.mediaType.isStream` accepts, or any that declares `itemSchema`.
|
|
1481
1464
|
*/
|
|
1482
1465
|
function isStream(contentType, mediaType) {
|
|
1483
|
-
return
|
|
1466
|
+
return _kubb_kit.ast.mediaType.isStream(contentType) || mediaType?.itemSchema !== void 0;
|
|
1484
1467
|
}
|
|
1485
1468
|
/**
|
|
1486
1469
|
* Whether the media type is `text/event-stream`, with or without parameters.
|
|
1487
1470
|
*/
|
|
1488
1471
|
function isEventStream(contentType) {
|
|
1489
|
-
return
|
|
1472
|
+
return _kubb_kit.ast.mediaType.getBase(contentType) === "text/event-stream";
|
|
1490
1473
|
}
|
|
1491
1474
|
/**
|
|
1492
1475
|
* Replaces a `data` string that holds JSON with its `contentSchema`, so the event reads as parsed.
|
|
@@ -1776,10 +1759,10 @@ function memberValues(node, propertyName, seen = /* @__PURE__ */ new Set()) {
|
|
|
1776
1759
|
seen.add(node);
|
|
1777
1760
|
const target = node.type === "ref" && node.schema ? node.schema : node;
|
|
1778
1761
|
if (target.type === "union") return [...new Set(target.members?.flatMap((member) => memberValues(member, propertyName, seen)))];
|
|
1779
|
-
return intersect(_kubb_kit.ast.
|
|
1762
|
+
return intersect(_kubb_kit.ast.schema.findProperties({
|
|
1780
1763
|
node,
|
|
1781
1764
|
propertyName
|
|
1782
|
-
}).map((property) => [..._kubb_kit.ast.
|
|
1765
|
+
}).map((property) => [..._kubb_kit.ast.schema.getLiterals(property.schema)]));
|
|
1783
1766
|
}
|
|
1784
1767
|
function intersect(slices) {
|
|
1785
1768
|
const pinned = slices.filter((values) => values.length > 0);
|
|
@@ -2047,6 +2030,25 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
|
|
|
2047
2030
|
...param.allowEmptyValue && { allowEmptyValue: true }
|
|
2048
2031
|
});
|
|
2049
2032
|
}
|
|
2033
|
+
function spreadQuerystring(param) {
|
|
2034
|
+
if (param.in !== "querystring") return [param];
|
|
2035
|
+
const schema = _kubb_kit.ast.ref.getSchema(param.schema);
|
|
2036
|
+
const formEncoded = !param.contentType || _kubb_kit.ast.mediaType.getBase(param.contentType) === "application/x-www-form-urlencoded";
|
|
2037
|
+
if (schema.type !== "object" || !formEncoded) return [param];
|
|
2038
|
+
return schema.properties.map((property) => {
|
|
2039
|
+
const { style, explode, allowReserved } = param.encoding?.[property.name] ?? {};
|
|
2040
|
+
return _kubb_kit.ast.factory.createParameter({
|
|
2041
|
+
...param.pointer ? { pointer: param.pointer } : {},
|
|
2042
|
+
name: property.name,
|
|
2043
|
+
in: "query",
|
|
2044
|
+
schema: property.schema,
|
|
2045
|
+
required: param.required && property.required,
|
|
2046
|
+
...style !== void 0 && { style },
|
|
2047
|
+
...explode !== void 0 && { explode },
|
|
2048
|
+
...allowReserved !== void 0 && { allowReserved }
|
|
2049
|
+
});
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2050
2052
|
/**
|
|
2051
2053
|
* Converts an OAS `Operation` into an `OperationNode`.
|
|
2052
2054
|
*/
|
|
@@ -2064,7 +2066,7 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2064
2066
|
refs,
|
|
2065
2067
|
...entry,
|
|
2066
2068
|
parentName: operationName
|
|
2067
|
-
}));
|
|
2069
|
+
})).flatMap(spreadQuerystring);
|
|
2068
2070
|
const body = getRequestBody({
|
|
2069
2071
|
operation,
|
|
2070
2072
|
refs
|
|
@@ -2084,7 +2086,7 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2084
2086
|
contentType: ct,
|
|
2085
2087
|
refs
|
|
2086
2088
|
});
|
|
2087
|
-
const node = _kubb_kit.ast.
|
|
2089
|
+
const node = _kubb_kit.ast.schema.applyOptionality(parseSchema({
|
|
2088
2090
|
schema,
|
|
2089
2091
|
name: requestBodyName
|
|
2090
2092
|
}), bodyRequired);
|
|
@@ -2377,7 +2379,7 @@ function isObjectLike(member, refs) {
|
|
|
2377
2379
|
*/
|
|
2378
2380
|
function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode, parentType, parse, name, refs }) {
|
|
2379
2381
|
function pickDiscriminatorPropertyNode(node, propertyName) {
|
|
2380
|
-
const discriminatorProperty = _kubb_kit.ast.
|
|
2382
|
+
const discriminatorProperty = _kubb_kit.ast.schema.narrow(node, "object")?.properties?.find((property) => property.name === propertyName);
|
|
2381
2383
|
if (!discriminatorProperty) return null;
|
|
2382
2384
|
return _kubb_kit.ast.factory.createSchema({
|
|
2383
2385
|
type: "object",
|
|
@@ -2387,7 +2389,7 @@ function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode,
|
|
|
2387
2389
|
}
|
|
2388
2390
|
function implicitDiscriminantValue(member) {
|
|
2389
2391
|
if (!discriminator || discriminator.mapping || !isReference(member)) return null;
|
|
2390
|
-
const value =
|
|
2392
|
+
const value = _kubb_kit.ast.ref.getName(member.$ref);
|
|
2391
2393
|
if (!value) return null;
|
|
2392
2394
|
const variant = refs.resolve(member.$ref, { report: false });
|
|
2393
2395
|
if (!variant) return null;
|
|
@@ -2435,7 +2437,7 @@ function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode,
|
|
|
2435
2437
|
name
|
|
2436
2438
|
});
|
|
2437
2439
|
if (!discriminatorValues.length || !discriminator || !isObjectLike(s, refs)) return memberNode;
|
|
2438
|
-
const narrowedDiscriminatorNode = sharedPropertiesNode ? pickDiscriminatorPropertyNode(_kubb_kit.ast.
|
|
2440
|
+
const narrowedDiscriminatorNode = sharedPropertiesNode ? pickDiscriminatorPropertyNode(_kubb_kit.ast.macro.apply(sharedPropertiesNode, [(0, _kubb_kit.macroDiscriminatorEnum)({
|
|
2439
2441
|
propertyName: discriminator.propertyName,
|
|
2440
2442
|
values: discriminatorValues
|
|
2441
2443
|
})], { depth: "shallow" }), discriminator.propertyName) : void 0;
|
|
@@ -2627,7 +2629,7 @@ function resolveUnionSchema(schema, siblingProperties) {
|
|
|
2627
2629
|
*
|
|
2628
2630
|
* The resolved schema is stored in `node.schema`. Usage-site sibling fields
|
|
2629
2631
|
* (description, readOnly, nullable, etc.) are stored directly on the ref node.
|
|
2630
|
-
* Use `
|
|
2632
|
+
* Use `ast.ref.mergeSchema(node)` in printers to get a merged view of both.
|
|
2631
2633
|
* Circular refs are detected in `refs.resolveNode` and leave `schema` as `null`.
|
|
2632
2634
|
*/
|
|
2633
2635
|
function convertRef({ schema, name, nullable, defaultValue, document, parse, refs, renames }) {
|
|
@@ -2639,7 +2641,7 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
|
|
|
2639
2641
|
nullable,
|
|
2640
2642
|
defaultValue
|
|
2641
2643
|
};
|
|
2642
|
-
if (refPath && document.components && !refs.resolve(refPath, { report: false })) return createNode(ctx, { type: _kubb_kit.ast.
|
|
2644
|
+
if (refPath && document.components && !refs.resolve(refPath, { report: false })) return createNode(ctx, { type: _kubb_kit.ast.schema.types.unknown });
|
|
2643
2645
|
if (refPath && !refPath.startsWith("#/components/schemas/") && resolvedSchema) return _kubb_kit.ast.factory.createSchema({
|
|
2644
2646
|
...resolvedSchema,
|
|
2645
2647
|
title: schema.title ?? resolvedSchema.title,
|
|
@@ -2653,8 +2655,8 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
|
|
|
2653
2655
|
});
|
|
2654
2656
|
const targetName = renames?.get(schema.$ref);
|
|
2655
2657
|
return createNode(ctx, {
|
|
2656
|
-
type: _kubb_kit.ast.
|
|
2657
|
-
name:
|
|
2658
|
+
type: _kubb_kit.ast.schema.types.ref,
|
|
2659
|
+
name: _kubb_kit.ast.ref.getName(schema.$ref),
|
|
2658
2660
|
ref: schema.$ref,
|
|
2659
2661
|
...targetName ? { targetName } : {},
|
|
2660
2662
|
schema: resolvedSchema
|
|
@@ -2665,7 +2667,7 @@ function convertNot({ schema, name, nullable, defaultValue, parse }) {
|
|
|
2665
2667
|
const { not, ...rest } = schema;
|
|
2666
2668
|
const [subschema] = resolveUnionMembers([not], rest.properties ?? {});
|
|
2667
2669
|
const notNode = _kubb_kit.ast.factory.createSchema({
|
|
2668
|
-
type: _kubb_kit.ast.
|
|
2670
|
+
type: _kubb_kit.ast.schema.types.not,
|
|
2669
2671
|
members: [parse({ schema: subschema })]
|
|
2670
2672
|
});
|
|
2671
2673
|
return createNode({
|
|
@@ -2674,7 +2676,7 @@ function convertNot({ schema, name, nullable, defaultValue, parse }) {
|
|
|
2674
2676
|
nullable,
|
|
2675
2677
|
defaultValue
|
|
2676
2678
|
}, {
|
|
2677
|
-
type: _kubb_kit.ast.
|
|
2679
|
+
type: _kubb_kit.ast.schema.types.intersection,
|
|
2678
2680
|
members: [parse({
|
|
2679
2681
|
schema: rest,
|
|
2680
2682
|
name
|
|
@@ -2802,7 +2804,7 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
|
|
|
2802
2804
|
nullable,
|
|
2803
2805
|
defaultValue
|
|
2804
2806
|
}, {
|
|
2805
|
-
type: _kubb_kit.ast.
|
|
2807
|
+
type: _kubb_kit.ast.schema.types.intersection,
|
|
2806
2808
|
members: [...(0, _kubb_kit.mergeAdjacentObjectsLazy)(allOfMembers.slice(0, syntheticStart)), ...(0, _kubb_kit.mergeAdjacentObjectsLazy)(allOfMembers.slice(syntheticStart))]
|
|
2807
2809
|
});
|
|
2808
2810
|
}
|
|
@@ -2846,24 +2848,24 @@ function convertUnion(context) {
|
|
|
2846
2848
|
refs
|
|
2847
2849
|
});
|
|
2848
2850
|
const unionNode = createNode(ctx, {
|
|
2849
|
-
type: _kubb_kit.ast.
|
|
2851
|
+
type: _kubb_kit.ast.schema.types.union,
|
|
2850
2852
|
strategy,
|
|
2851
2853
|
members,
|
|
2852
|
-
discriminatorPropertyName: explicitDiscriminatorPropertyName ?? _kubb_kit.ast.
|
|
2854
|
+
discriminatorPropertyName: explicitDiscriminatorPropertyName ?? _kubb_kit.ast.schema.inferDiscriminator(members)
|
|
2853
2855
|
});
|
|
2854
2856
|
const requiredProperties = missingRequired.map((name) => _kubb_kit.ast.factory.createProperty({
|
|
2855
2857
|
name,
|
|
2856
2858
|
required: true,
|
|
2857
|
-
schema: _kubb_kit.ast.factory.createSchema({ type: _kubb_kit.ast.
|
|
2859
|
+
schema: _kubb_kit.ast.factory.createSchema({ type: _kubb_kit.ast.schema.types.unknown })
|
|
2858
2860
|
}));
|
|
2859
2861
|
const siblings = sharedPropertiesNode ? [sharedPropertiesNode] : [];
|
|
2860
2862
|
if (requiredProperties.length) siblings.push(_kubb_kit.ast.factory.createSchema({
|
|
2861
|
-
type: _kubb_kit.ast.
|
|
2863
|
+
type: _kubb_kit.ast.schema.types.object,
|
|
2862
2864
|
properties: requiredProperties
|
|
2863
2865
|
}));
|
|
2864
2866
|
if (!siblings.length) return unionNode;
|
|
2865
2867
|
return createNode(ctx, {
|
|
2866
|
-
type: _kubb_kit.ast.
|
|
2868
|
+
type: _kubb_kit.ast.schema.types.intersection,
|
|
2867
2869
|
members: [unionNode, ...siblings]
|
|
2868
2870
|
});
|
|
2869
2871
|
}
|
|
@@ -2872,12 +2874,12 @@ function convertUnion(context) {
|
|
|
2872
2874
|
name
|
|
2873
2875
|
}));
|
|
2874
2876
|
const unionNode = createNode(ctx, {
|
|
2875
|
-
type: _kubb_kit.ast.
|
|
2877
|
+
type: _kubb_kit.ast.schema.types.union,
|
|
2876
2878
|
strategy,
|
|
2877
2879
|
members,
|
|
2878
|
-
discriminatorPropertyName: explicitDiscriminatorPropertyName ?? _kubb_kit.ast.
|
|
2880
|
+
discriminatorPropertyName: explicitDiscriminatorPropertyName ?? _kubb_kit.ast.schema.inferDiscriminator(members)
|
|
2879
2881
|
});
|
|
2880
|
-
return _kubb_kit.ast.
|
|
2882
|
+
return _kubb_kit.ast.macro.apply(unionNode, [_kubb_kit.macroDedupeUnion], { depth: "shallow" });
|
|
2881
2883
|
}
|
|
2882
2884
|
/**
|
|
2883
2885
|
* Converts an OAS 3.1 multi-type array (e.g. `type: ['string', 'number']`) into a `UnionSchemaNode`.
|
|
@@ -2894,7 +2896,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
|
|
|
2894
2896
|
nullable: types.includes("null") || nullable || void 0,
|
|
2895
2897
|
defaultValue
|
|
2896
2898
|
}, {
|
|
2897
|
-
type: _kubb_kit.ast.
|
|
2899
|
+
type: _kubb_kit.ast.schema.types.union,
|
|
2898
2900
|
members: nonNullTypes.map((t) => {
|
|
2899
2901
|
return parse({
|
|
2900
2902
|
schema: {
|
|
@@ -3173,10 +3175,10 @@ function resolveMapSchema(mapSchema, { options, parse }) {
|
|
|
3173
3175
|
*/
|
|
3174
3176
|
function nameEnums(node, options) {
|
|
3175
3177
|
const macro = (0, _kubb_kit.macroEnumName)(options);
|
|
3176
|
-
const named = _kubb_kit.ast.
|
|
3177
|
-
const tupleNode = _kubb_kit.ast.
|
|
3178
|
+
const named = _kubb_kit.ast.macro.apply(node, [macro], { depth: "shallow" });
|
|
3179
|
+
const tupleNode = _kubb_kit.ast.schema.narrow(named, "tuple");
|
|
3178
3180
|
if (tupleNode?.items) {
|
|
3179
|
-
const namedItems = tupleNode.items.map((item) => _kubb_kit.ast.
|
|
3181
|
+
const namedItems = tupleNode.items.map((item) => _kubb_kit.ast.macro.apply(item, [macro], { depth: "shallow" }));
|
|
3180
3182
|
if (namedItems.some((item, i) => item !== tupleNode.items[i])) return {
|
|
3181
3183
|
...tupleNode,
|
|
3182
3184
|
items: namedItems
|
|
@@ -3259,7 +3261,7 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
|
|
|
3259
3261
|
})
|
|
3260
3262
|
});
|
|
3261
3263
|
const enumName = name ? (0, _kubb_kit.enumPropName)(name, discPropName, options.enumSuffix) : void 0;
|
|
3262
|
-
return _kubb_kit.ast.
|
|
3264
|
+
return _kubb_kit.ast.macro.apply(objectNode, [(0, _kubb_kit.macroDiscriminatorEnum)({
|
|
3263
3265
|
propertyName: discPropName,
|
|
3264
3266
|
values,
|
|
3265
3267
|
enumName
|
|
@@ -3503,9 +3505,9 @@ function createSchemaParser(ctx) {
|
|
|
3503
3505
|
}
|
|
3504
3506
|
const presenceKeys = /* @__PURE__ */ new WeakMap();
|
|
3505
3507
|
function requireKeys(keys) {
|
|
3506
|
-
const unknown = _kubb_kit.ast.factory.createSchema({ type: _kubb_kit.ast.
|
|
3508
|
+
const unknown = _kubb_kit.ast.factory.createSchema({ type: _kubb_kit.ast.schema.types.unknown });
|
|
3507
3509
|
const node = _kubb_kit.ast.factory.createSchema({
|
|
3508
|
-
type: _kubb_kit.ast.
|
|
3510
|
+
type: _kubb_kit.ast.schema.types.object,
|
|
3509
3511
|
primitive: "object",
|
|
3510
3512
|
properties: keys.map((name) => _kubb_kit.ast.factory.createProperty({
|
|
3511
3513
|
name,
|
|
@@ -3585,8 +3587,8 @@ function createSchemaParser(ctx) {
|
|
|
3585
3587
|
function collectInlineEnums(roots, topLevelNames) {
|
|
3586
3588
|
const promoted = /* @__PURE__ */ new Map();
|
|
3587
3589
|
for (const root of roots) {
|
|
3588
|
-
const isSchemaRoot = root.kind === _kubb_kit.ast.
|
|
3589
|
-
for (const node of _kubb_kit.ast.collect(root, { schema: (schemaNode) => schemaNode })) {
|
|
3590
|
+
const isSchemaRoot = root.kind === _kubb_kit.ast.node.kinds.schema;
|
|
3591
|
+
for (const node of _kubb_kit.ast.node.collect(root, { schema: (schemaNode) => schemaNode })) {
|
|
3590
3592
|
if (node.type !== "enum" || !node.name) continue;
|
|
3591
3593
|
if (isSchemaRoot && node === root) continue;
|
|
3592
3594
|
if (topLevelNames.has(node.name)) continue;
|
|
@@ -3605,7 +3607,7 @@ function collectInlineEnums(roots, topLevelNames) {
|
|
|
3605
3607
|
*/
|
|
3606
3608
|
function refPromotedEnums(node, promoted) {
|
|
3607
3609
|
if (promoted.size === 0) return node;
|
|
3608
|
-
return _kubb_kit.ast.transform(node, { schema(schemaNode) {
|
|
3610
|
+
return _kubb_kit.ast.node.transform(node, { schema(schemaNode) {
|
|
3609
3611
|
if (schemaNode.type !== "enum" || !schemaNode.name || !promoted.has(schemaNode.name)) return void 0;
|
|
3610
3612
|
return _kubb_kit.ast.factory.createSchema({
|
|
3611
3613
|
type: "ref",
|
|
@@ -3867,7 +3869,7 @@ const adapterOas = (0, _kubb_core.defineExtension)({
|
|
|
3867
3869
|
const promotedEnums = enums === "root" ? collectInlineEnums([...parsedByName.values(), ...operationNodes], new Set(Object.keys(schemas))) : null;
|
|
3868
3870
|
const aliasTargetOf = (name) => {
|
|
3869
3871
|
const node = refAliasMap.get(name);
|
|
3870
|
-
return node?.ref ? _kubb_kit.ast.
|
|
3872
|
+
return node?.ref ? _kubb_kit.ast.ref.getName(node.ref) : node?.name;
|
|
3871
3873
|
};
|
|
3872
3874
|
function isAliasCycle(name) {
|
|
3873
3875
|
const seen = /* @__PURE__ */ new Set([name]);
|