@kubb/adapter-oas 5.0.0-beta.91 → 5.0.0-beta.93
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 +51 -153
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +51 -153
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1138,10 +1138,6 @@ type SchemaObject$1 = {
|
|
|
1138
1138
|
*/
|
|
1139
1139
|
enum?: Array<string | number | boolean | null>;
|
|
1140
1140
|
} & (OpenAPIV3_1.SchemaObject | JSONSchema4 | JSONSchema6 | JSONSchema7);
|
|
1141
|
-
/**
|
|
1142
|
-
* HTTP method in the lowercase form an OpenAPI path item uses for its keys.
|
|
1143
|
-
*/
|
|
1144
|
-
type HttpMethod = Lowercase<ast.HttpMethod>;
|
|
1145
1141
|
/**
|
|
1146
1142
|
* Normalized OpenAPI document after parsing.
|
|
1147
1143
|
*/
|
|
@@ -1308,5 +1304,5 @@ declare const adapterOasName = "oas";
|
|
|
1308
1304
|
*/
|
|
1309
1305
|
declare const adapterOas: (options?: AdapterOasOptions | undefined) => import("@kubb/core").Adapter<AdapterOas>;
|
|
1310
1306
|
//#endregion
|
|
1311
|
-
export { type AdapterOas, type AdapterOasOptions, type AdapterOasResolvedOptions, type ContentType, type DiscriminatorObject$1 as DiscriminatorObject, type Document, type
|
|
1307
|
+
export { type AdapterOas, type AdapterOasOptions, type AdapterOasResolvedOptions, type ContentType, type DiscriminatorObject$1 as DiscriminatorObject, type Document, type MediaTypeObject$1 as MediaTypeObject, type Operation, type ReferenceObject$1 as ReferenceObject, type ResponseObject$1 as ResponseObject, type SchemaObject$1 as SchemaObject, adapterOas, adapterOasName };
|
|
1312
1308
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -10,13 +10,6 @@ import { bundle } from "api-ref-bundler";
|
|
|
10
10
|
//#region src/constants.ts
|
|
11
11
|
/**
|
|
12
12
|
* Default parser options applied when no explicit options are provided.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { DEFAULT_PARSER_OPTIONS, parseOas } from '@kubb/adapter-oas'
|
|
17
|
-
*
|
|
18
|
-
* const { root } = parseOas(document, { ...DEFAULT_PARSER_OPTIONS, dateType: 'date' })
|
|
19
|
-
* ```
|
|
20
13
|
*/
|
|
21
14
|
const DEFAULT_PARSER_OPTIONS = {
|
|
22
15
|
dateType: "string",
|
|
@@ -55,14 +48,6 @@ const SUPPORTED_METHODS = /* @__PURE__ */ new Set([
|
|
|
55
48
|
*
|
|
56
49
|
* A fragment that contains any of these keys carries structural meaning of its own and must stay as a separate
|
|
57
50
|
* intersection member rather than being merged into the parent.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* import { structuralKeys } from '@kubb/adapter-oas'
|
|
62
|
-
*
|
|
63
|
-
* const isStructural = Object.keys(fragment).some((key) => structuralKeys.has(key))
|
|
64
|
-
* // true when fragment has e.g. 'properties' or 'oneOf'
|
|
65
|
-
* ```
|
|
66
51
|
*/
|
|
67
52
|
const structuralKeys = /* @__PURE__ */ new Set([
|
|
68
53
|
"properties",
|
|
@@ -92,15 +77,6 @@ const specialCasedFormats = /* @__PURE__ */ new Set([
|
|
|
92
77
|
* Formats that depend on runtime options (`int64`, `date-time`, `date`, `time`) are handled
|
|
93
78
|
* separately in the parser. `ipv4` and `ipv6` map to their own dedicated schema types. `hostname`
|
|
94
79
|
* and `idn-hostname` map to `'url'` as the closest generic string-format type.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```ts
|
|
98
|
-
* import { formatMap } from '@kubb/adapter-oas'
|
|
99
|
-
*
|
|
100
|
-
* formatMap['uuid'] // 'uuid'
|
|
101
|
-
* formatMap['binary'] // 'blob'
|
|
102
|
-
* formatMap['float'] // 'number'
|
|
103
|
-
* ```
|
|
104
80
|
*/
|
|
105
81
|
const formatMap = {
|
|
106
82
|
uuid: "uuid",
|
|
@@ -121,24 +97,10 @@ const formatMap = {
|
|
|
121
97
|
};
|
|
122
98
|
/**
|
|
123
99
|
* Vendor extension keys that attach human-readable labels to enum values, checked in priority order.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```ts
|
|
127
|
-
* import { enumExtensionKeys } from '@kubb/adapter-oas'
|
|
128
|
-
*
|
|
129
|
-
* const key = enumExtensionKeys.find((k) => k in schema) // 'x-enumNames' | 'x-enum-varnames' | undefined
|
|
130
|
-
* ```
|
|
131
100
|
*/
|
|
132
101
|
const enumExtensionKeys = ["x-enumNames", "x-enum-varnames"];
|
|
133
102
|
/**
|
|
134
103
|
* Vendor extension keys that attach human-readable descriptions to enum values, checked in priority order.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* import { enumDescriptionKeys } from '@kubb/adapter-oas'
|
|
139
|
-
*
|
|
140
|
-
* const key = enumDescriptionKeys.find((k) => k in schema) // 'x-enumDescriptions' | 'x-enum-descriptions' | undefined
|
|
141
|
-
* ```
|
|
142
104
|
*/
|
|
143
105
|
const enumDescriptionKeys = ["x-enumDescriptions", "x-enum-descriptions"];
|
|
144
106
|
//#endregion
|
|
@@ -542,6 +504,18 @@ function isDiscriminator(obj) {
|
|
|
542
504
|
const record = obj;
|
|
543
505
|
return !!obj && !!record["discriminator"] && typeof record["discriminator"] !== "string";
|
|
544
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Returns `true` when a schema is a binary payload: an octet-stream string body.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```ts
|
|
512
|
+
* isBinary({ type: 'string', contentMediaType: 'application/octet-stream' }) // true
|
|
513
|
+
* isBinary({ type: 'string' }) // false
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
516
|
+
function isBinary(schema) {
|
|
517
|
+
return schema.type === "string" && schema.contentMediaType === "application/octet-stream";
|
|
518
|
+
}
|
|
545
519
|
//#endregion
|
|
546
520
|
//#region src/mime.ts
|
|
547
521
|
/**
|
|
@@ -763,37 +737,6 @@ function getOperations(document) {
|
|
|
763
737
|
return operations;
|
|
764
738
|
}
|
|
765
739
|
//#endregion
|
|
766
|
-
//#region src/dialect.ts
|
|
767
|
-
/**
|
|
768
|
-
* The OpenAPI / Swagger dialect, the default used by `@kubb/adapter-oas`.
|
|
769
|
-
*
|
|
770
|
-
* Implements the spec-agnostic {@link ast.SchemaDialect} contract: it isolates the
|
|
771
|
-
* decisions that differ between specs (nullability, `$ref`, discriminator, binary,
|
|
772
|
-
* ref resolution) so the converter pipeline and dispatch rules stay shared. A
|
|
773
|
-
* future adapter (e.g. AsyncAPI) ships its own dialect, `type: ['null', …]`
|
|
774
|
-
* nullability, no discriminator object, binary via `contentEncoding` and reuses
|
|
775
|
-
* the rest unchanged.
|
|
776
|
-
*
|
|
777
|
-
* Formats (`uuid`, `email`, dates, …) are intentionally NOT here: they are shared
|
|
778
|
-
* JSON Schema vocabulary, so the converters keep that common case.
|
|
779
|
-
*
|
|
780
|
-
* @example
|
|
781
|
-
* ```ts
|
|
782
|
-
* const parser = createSchemaParser(context) // uses oasDialect
|
|
783
|
-
* const parser = createSchemaParser(context, oasDialect) // explicit
|
|
784
|
-
* ```
|
|
785
|
-
*/
|
|
786
|
-
const oasDialect = ast.defineDialect({
|
|
787
|
-
name: "oas",
|
|
788
|
-
schema: {
|
|
789
|
-
isNullable,
|
|
790
|
-
isReference,
|
|
791
|
-
isDiscriminator,
|
|
792
|
-
isBinary: (schema) => schema.type === "string" && schema.contentMediaType === "application/octet-stream",
|
|
793
|
-
resolveRef
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
//#endregion
|
|
797
740
|
//#region src/resolvers.ts
|
|
798
741
|
/**
|
|
799
742
|
* Reads the server URL from the document's `servers` array at `server.index`,
|
|
@@ -901,19 +844,10 @@ function getResponseBody(responseBody, contentType) {
|
|
|
901
844
|
if (!(contentType in body.content)) return false;
|
|
902
845
|
return body.content[contentType];
|
|
903
846
|
}
|
|
904
|
-
let availableContentType;
|
|
905
847
|
const contentTypes = Object.keys(body.content);
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
}
|
|
910
|
-
if (!availableContentType) availableContentType = contentTypes[0];
|
|
911
|
-
if (availableContentType) return [
|
|
912
|
-
availableContentType,
|
|
913
|
-
body.content[availableContentType],
|
|
914
|
-
...body.description ? [body.description] : []
|
|
915
|
-
];
|
|
916
|
-
return false;
|
|
848
|
+
const availableContentType = contentTypes.find(isJsonMimeType) ?? contentTypes[0];
|
|
849
|
+
if (!availableContentType) return false;
|
|
850
|
+
return body.content[availableContentType];
|
|
917
851
|
}
|
|
918
852
|
/**
|
|
919
853
|
* Returns the response schema for a given operation and HTTP status code.
|
|
@@ -942,7 +876,7 @@ function getResponseSchema(document, operation, statusCode, options = {}) {
|
|
|
942
876
|
statusCode
|
|
943
877
|
}), options.contentType);
|
|
944
878
|
if (responseBody === false) return {};
|
|
945
|
-
const schema =
|
|
879
|
+
const schema = responseBody.schema;
|
|
946
880
|
if (!schema) return {};
|
|
947
881
|
return dereferenceWithRef(document, schema);
|
|
948
882
|
}
|
|
@@ -1313,7 +1247,7 @@ function nameEnums(node, options) {
|
|
|
1313
1247
|
*
|
|
1314
1248
|
* @internal
|
|
1315
1249
|
*/
|
|
1316
|
-
function createSchemaParser(ctx
|
|
1250
|
+
function createSchemaParser(ctx) {
|
|
1317
1251
|
const document = ctx.document;
|
|
1318
1252
|
/**
|
|
1319
1253
|
* Tracks `$ref` paths that are currently being resolved to prevent infinite
|
|
@@ -1339,7 +1273,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1339
1273
|
if (!refExistence.has(refPath)) {
|
|
1340
1274
|
let exists = false;
|
|
1341
1275
|
try {
|
|
1342
|
-
exists = !!
|
|
1276
|
+
exists = !!resolveRef(document, refPath);
|
|
1343
1277
|
} catch {
|
|
1344
1278
|
exists = false;
|
|
1345
1279
|
}
|
|
@@ -1361,7 +1295,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1361
1295
|
if (refPath && !resolvingRefs.has(refPath)) {
|
|
1362
1296
|
if (!resolvedRefCache.has(refPath)) {
|
|
1363
1297
|
try {
|
|
1364
|
-
const referenced =
|
|
1298
|
+
const referenced = resolveRef(document, refPath);
|
|
1365
1299
|
if (referenced) {
|
|
1366
1300
|
resolvingRefs.add(refPath);
|
|
1367
1301
|
resolvedSchema = parseSchema({ schema: referenced }, rawOptions);
|
|
@@ -1414,13 +1348,13 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1414
1348
|
}
|
|
1415
1349
|
const filteredDiscriminantValues = [];
|
|
1416
1350
|
const allOfMembers = schema.allOf.filter((item) => {
|
|
1417
|
-
if (!
|
|
1418
|
-
const deref =
|
|
1419
|
-
if (!deref || !
|
|
1351
|
+
if (!isReference(item) || !name) return true;
|
|
1352
|
+
const deref = resolveRef(document, item.$ref);
|
|
1353
|
+
if (!deref || !isDiscriminator(deref)) return true;
|
|
1420
1354
|
const parentUnion = deref.oneOf ?? deref.anyOf;
|
|
1421
1355
|
if (!parentUnion) return true;
|
|
1422
1356
|
const childRef = `${SCHEMA_REF_PREFIX}${name}`;
|
|
1423
|
-
const inOneOf = parentUnion.some((oneOfItem) =>
|
|
1357
|
+
const inOneOf = parentUnion.some((oneOfItem) => isReference(oneOfItem) && oneOfItem.$ref === childRef);
|
|
1424
1358
|
const inMapping = Object.values(deref.discriminator.mapping ?? {}).some((v) => v === childRef);
|
|
1425
1359
|
if (inOneOf || inMapping) {
|
|
1426
1360
|
const discriminatorValue = findDiscriminator(deref.discriminator.mapping, childRef);
|
|
@@ -1441,9 +1375,9 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1441
1375
|
const missingRequired = schema.required.filter((key) => !outerKeys.has(key));
|
|
1442
1376
|
if (missingRequired.length) {
|
|
1443
1377
|
const resolvedMembers = schema.allOf.flatMap((item) => {
|
|
1444
|
-
if (!
|
|
1445
|
-
const deref =
|
|
1446
|
-
return deref && !
|
|
1378
|
+
if (!isReference(item)) return [item];
|
|
1379
|
+
const deref = resolveRef(document, item.$ref);
|
|
1380
|
+
return deref && !isReference(deref) ? [deref] : [];
|
|
1447
1381
|
});
|
|
1448
1382
|
for (const key of missingRequired) for (const resolved of resolvedMembers) if (resolved.properties?.[key]) {
|
|
1449
1383
|
allOfMembers.push(parseSchema({
|
|
@@ -1489,7 +1423,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1489
1423
|
return decodeURIComponent($ref.substring(1)).split("/").filter(Boolean).reduce((obj, key) => obj?.[key], document) ?? null;
|
|
1490
1424
|
}
|
|
1491
1425
|
function implicitDiscriminantValue(member) {
|
|
1492
|
-
if (!discriminator || discriminator.mapping || !
|
|
1426
|
+
if (!discriminator || discriminator.mapping || !isReference(member)) return null;
|
|
1493
1427
|
const value = extractRefName(member.$ref);
|
|
1494
1428
|
if (!value) return null;
|
|
1495
1429
|
const variant = resolveRefSilent(member.$ref);
|
|
@@ -1498,12 +1432,12 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1498
1432
|
const seen = /* @__PURE__ */ new Set([member.$ref]);
|
|
1499
1433
|
function constrains(v) {
|
|
1500
1434
|
const prop = v.properties?.[propertyName];
|
|
1501
|
-
const resolved = prop &&
|
|
1435
|
+
const resolved = prop && isReference(prop) ? resolveRefSilent(prop.$ref) : prop;
|
|
1502
1436
|
if (resolved && (Array.isArray(resolved.enum) || resolved.const !== void 0)) return true;
|
|
1503
1437
|
const composition = v.allOf ?? v.oneOf ?? v.anyOf;
|
|
1504
1438
|
if (!composition) return false;
|
|
1505
1439
|
return composition.some((m) => {
|
|
1506
|
-
if (!
|
|
1440
|
+
if (!isReference(m)) return constrains(m);
|
|
1507
1441
|
if (seen.has(m.$ref)) return false;
|
|
1508
1442
|
seen.add(m.$ref);
|
|
1509
1443
|
const r = resolveRefSilent(m.$ref);
|
|
@@ -1516,10 +1450,10 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1516
1450
|
const strategy = schema.oneOf ? "one" : "any";
|
|
1517
1451
|
const unionBase = {
|
|
1518
1452
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1519
|
-
discriminatorPropertyName:
|
|
1453
|
+
discriminatorPropertyName: isDiscriminator(schema) ? schema.discriminator.propertyName : void 0,
|
|
1520
1454
|
strategy
|
|
1521
1455
|
};
|
|
1522
|
-
const discriminator =
|
|
1456
|
+
const discriminator = isDiscriminator(schema) ? schema.discriminator : void 0;
|
|
1523
1457
|
const { oneOf: _o, anyOf: _a, discriminator: _d, ...memberBaseSchema } = schema;
|
|
1524
1458
|
const sharedPropertiesNode = schema.properties ? parseSchema({
|
|
1525
1459
|
schema: memberBaseSchema,
|
|
@@ -1527,7 +1461,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1527
1461
|
}, rawOptions) : void 0;
|
|
1528
1462
|
if (sharedPropertiesNode || discriminator) {
|
|
1529
1463
|
const members = unionMembers.map((s) => {
|
|
1530
|
-
const ref =
|
|
1464
|
+
const ref = isReference(s) ? s.$ref : void 0;
|
|
1531
1465
|
const discriminatorValue = findDiscriminator(discriminator?.mapping, ref) ?? implicitDiscriminantValue(s);
|
|
1532
1466
|
const memberNode = parseSchema({
|
|
1533
1467
|
schema: s,
|
|
@@ -1617,39 +1551,15 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1617
1551
|
const specialType = getSchemaType(schema.format);
|
|
1618
1552
|
if (!specialType) return null;
|
|
1619
1553
|
const specialPrimitive = specialType === "number" || specialType === "integer" || specialType === "bigint" ? specialType : "string";
|
|
1620
|
-
|
|
1621
|
-
...base,
|
|
1622
|
-
primitive: specialPrimitive,
|
|
1623
|
-
type: specialType
|
|
1624
|
-
});
|
|
1625
|
-
if (specialType === "url") return ast.factory.createSchema({
|
|
1626
|
-
...base,
|
|
1627
|
-
primitive: "string",
|
|
1628
|
-
type: "url",
|
|
1629
|
-
min: schema.minLength,
|
|
1630
|
-
max: schema.maxLength
|
|
1631
|
-
});
|
|
1632
|
-
if (specialType === "ipv4") return ast.factory.createSchema({
|
|
1633
|
-
...base,
|
|
1634
|
-
primitive: "string",
|
|
1635
|
-
type: "ipv4"
|
|
1636
|
-
});
|
|
1637
|
-
if (specialType === "ipv6") return ast.factory.createSchema({
|
|
1638
|
-
...base,
|
|
1639
|
-
primitive: "string",
|
|
1640
|
-
type: "ipv6"
|
|
1641
|
-
});
|
|
1642
|
-
if (specialType === "uuid" || specialType === "email") return ast.factory.createSchema({
|
|
1643
|
-
...base,
|
|
1644
|
-
primitive: "string",
|
|
1645
|
-
type: specialType,
|
|
1646
|
-
min: schema.minLength,
|
|
1647
|
-
max: schema.maxLength
|
|
1648
|
-
});
|
|
1554
|
+
const hasLength = specialType === "url" || specialType === "uuid" || specialType === "email";
|
|
1649
1555
|
return ast.factory.createSchema({
|
|
1650
1556
|
...base,
|
|
1651
1557
|
primitive: specialPrimitive,
|
|
1652
|
-
type: specialType
|
|
1558
|
+
type: specialType,
|
|
1559
|
+
...hasLength ? {
|
|
1560
|
+
min: schema.minLength,
|
|
1561
|
+
max: schema.maxLength
|
|
1562
|
+
} : {}
|
|
1653
1563
|
});
|
|
1654
1564
|
}
|
|
1655
1565
|
/**
|
|
@@ -1669,16 +1579,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1669
1579
|
const enumBase = {
|
|
1670
1580
|
type: "enum",
|
|
1671
1581
|
primitive: enumPrimitive,
|
|
1672
|
-
name,
|
|
1673
|
-
title: schema.title,
|
|
1674
|
-
description: schema.description,
|
|
1675
|
-
deprecated: schema.deprecated,
|
|
1676
|
-
nullable: enumNullable,
|
|
1677
|
-
readOnly: schema.readOnly,
|
|
1678
|
-
writeOnly: schema.writeOnly,
|
|
1679
|
-
default: enumDefault,
|
|
1680
|
-
examples: extractExamples(schema),
|
|
1681
|
-
format: schema.format
|
|
1582
|
+
...buildSchemaNode(schema, name, enumNullable, enumDefault)
|
|
1682
1583
|
};
|
|
1683
1584
|
const extensionKey = enumExtensionKeys.find((key) => key in schema);
|
|
1684
1585
|
const descriptionKey = enumDescriptionKeys.find((key) => key in schema);
|
|
@@ -1715,7 +1616,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1715
1616
|
const properties = schema.properties ? Object.entries(schema.properties).map(([propName, propSchema]) => {
|
|
1716
1617
|
const required = Array.isArray(schema.required) ? schema.required.includes(propName) : !!schema.required;
|
|
1717
1618
|
const resolvedPropSchema = propSchema;
|
|
1718
|
-
const propNullable =
|
|
1619
|
+
const propNullable = isNullable(resolvedPropSchema);
|
|
1719
1620
|
const schemaNode = nameEnums(parseSchema({
|
|
1720
1621
|
schema: resolvedPropSchema,
|
|
1721
1622
|
name: childName(name, propName)
|
|
@@ -1752,7 +1653,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1752
1653
|
maxProperties: schema.maxProperties,
|
|
1753
1654
|
...buildSchemaNode(schema, name, nullable, defaultValue)
|
|
1754
1655
|
});
|
|
1755
|
-
if (
|
|
1656
|
+
if (isDiscriminator(schema) && schema.discriminator.mapping) {
|
|
1756
1657
|
const discPropName = schema.discriminator.propertyName;
|
|
1757
1658
|
const values = Object.keys(schema.discriminator.mapping);
|
|
1758
1659
|
const enumName = name ? enumPropName(name, discPropName, options.enumSuffix) : void 0;
|
|
@@ -1880,7 +1781,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1880
1781
|
*/
|
|
1881
1782
|
const schemaRules = [
|
|
1882
1783
|
{
|
|
1883
|
-
match: ({ schema }) =>
|
|
1784
|
+
match: ({ schema }) => isReference(schema),
|
|
1884
1785
|
convert: convertRef
|
|
1885
1786
|
},
|
|
1886
1787
|
{
|
|
@@ -1900,7 +1801,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1900
1801
|
convert: convertFormat
|
|
1901
1802
|
},
|
|
1902
1803
|
{
|
|
1903
|
-
match: ({ schema }) =>
|
|
1804
|
+
match: ({ schema }) => isBinary(schema),
|
|
1904
1805
|
convert: convertBlob
|
|
1905
1806
|
},
|
|
1906
1807
|
{
|
|
@@ -1969,7 +1870,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1969
1870
|
schema: flattenedSchema,
|
|
1970
1871
|
name
|
|
1971
1872
|
}, rawOptions);
|
|
1972
|
-
const nullable =
|
|
1873
|
+
const nullable = isNullable(schema) || void 0;
|
|
1973
1874
|
const schemaCtx = {
|
|
1974
1875
|
schema,
|
|
1975
1876
|
name,
|
|
@@ -2039,7 +1940,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2039
1940
|
const keys = [];
|
|
2040
1941
|
for (const key in schema.properties) {
|
|
2041
1942
|
const prop = schema.properties[key];
|
|
2042
|
-
if (prop && !
|
|
1943
|
+
if (prop && !isReference(prop) && prop[flag]) keys.push(key);
|
|
2043
1944
|
}
|
|
2044
1945
|
return keys.length ? keys : null;
|
|
2045
1946
|
}
|
|
@@ -2106,7 +2007,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
2106
2007
|
});
|
|
2107
2008
|
});
|
|
2108
2009
|
const pathItem = document.paths?.[operation.path];
|
|
2109
|
-
const pathItemDoc = pathItem && !
|
|
2010
|
+
const pathItemDoc = pathItem && !isReference(pathItem) ? pathItem : void 0;
|
|
2110
2011
|
const pickDoc = (key) => {
|
|
2111
2012
|
const own = operation.schema[key];
|
|
2112
2013
|
if (typeof own === "string") return own;
|
|
@@ -2298,13 +2199,10 @@ const adapterOas = createAdapter((options) => {
|
|
|
2298
2199
|
function ensureSchemas(document) {
|
|
2299
2200
|
const cached = schemasCache.get(document);
|
|
2300
2201
|
if (cached) return cached;
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
});
|
|
2306
|
-
schemasCache.set(document, promise);
|
|
2307
|
-
return promise;
|
|
2202
|
+
const result = getSchemas(document, { contentType });
|
|
2203
|
+
nameMapping = result.nameMapping;
|
|
2204
|
+
schemasCache.set(document, result.schemas);
|
|
2205
|
+
return result.schemas;
|
|
2308
2206
|
}
|
|
2309
2207
|
function ensureSchemaParser(document) {
|
|
2310
2208
|
const cached = schemaParserCache.get(document);
|
|
@@ -2420,7 +2318,7 @@ const adapterOas = createAdapter((options) => {
|
|
|
2420
2318
|
const document = await ensureDocument(source);
|
|
2421
2319
|
return parseInput({
|
|
2422
2320
|
document,
|
|
2423
|
-
schemas:
|
|
2321
|
+
schemas: ensureSchemas(document),
|
|
2424
2322
|
parser: ensureSchemaParser(document)
|
|
2425
2323
|
});
|
|
2426
2324
|
}
|