@kubb/adapter-oas 5.0.0-beta.77 → 5.0.0-beta.78
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 +26 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
|
42
42
|
* HTTP methods that count as operations on an OpenAPI path item. Other keys
|
|
43
43
|
* (`parameters`, `summary`, `$ref`, vendor extensions) are skipped when iterating operations.
|
|
44
44
|
*/
|
|
45
|
-
const SUPPORTED_METHODS = new Set([
|
|
45
|
+
const SUPPORTED_METHODS = /* @__PURE__ */ new Set([
|
|
46
46
|
"get",
|
|
47
47
|
"put",
|
|
48
48
|
"post",
|
|
@@ -66,7 +66,7 @@ const SUPPORTED_METHODS = new Set([
|
|
|
66
66
|
* // true when fragment has e.g. 'properties' or 'oneOf'
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
const structuralKeys = new Set([
|
|
69
|
+
const structuralKeys = /* @__PURE__ */ new Set([
|
|
70
70
|
"properties",
|
|
71
71
|
"items",
|
|
72
72
|
"additionalProperties",
|
|
@@ -81,7 +81,7 @@ const structuralKeys = new Set([
|
|
|
81
81
|
* special-cases in `parser.ts`. `isHandledFormat` reads it so the
|
|
82
82
|
* `KUBB_UNSUPPORTED_FORMAT` diagnostic and the parser agree on what is handled.
|
|
83
83
|
*/
|
|
84
|
-
const specialCasedFormats = new Set([
|
|
84
|
+
const specialCasedFormats = /* @__PURE__ */ new Set([
|
|
85
85
|
"int64",
|
|
86
86
|
"date-time",
|
|
87
87
|
"date",
|
|
@@ -1316,6 +1316,24 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1316
1316
|
*/
|
|
1317
1317
|
const resolvedRefCache = /* @__PURE__ */ new Map();
|
|
1318
1318
|
/**
|
|
1319
|
+
* Memoized record of whether a `$ref` path resolves to a node the document actually defines.
|
|
1320
|
+
* A circular ref still resolves to an existing target, so this stays `true` for cycles and only
|
|
1321
|
+
* goes `false` for a `$ref` that points at a component the spec never declares.
|
|
1322
|
+
*/
|
|
1323
|
+
const refExistence = /* @__PURE__ */ new Map();
|
|
1324
|
+
function refExists(refPath) {
|
|
1325
|
+
if (!refExistence.has(refPath)) {
|
|
1326
|
+
let exists = false;
|
|
1327
|
+
try {
|
|
1328
|
+
exists = !!dialect.schema.resolveRef(document, refPath);
|
|
1329
|
+
} catch {
|
|
1330
|
+
exists = false;
|
|
1331
|
+
}
|
|
1332
|
+
refExistence.set(refPath, exists);
|
|
1333
|
+
}
|
|
1334
|
+
return refExistence.get(refPath) ?? false;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1319
1337
|
* Converts a `$ref` schema into a `RefSchemaNode`.
|
|
1320
1338
|
*
|
|
1321
1339
|
* The resolved schema is stored in `node.schema`. Usage-site sibling fields
|
|
@@ -1340,6 +1358,10 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1340
1358
|
}
|
|
1341
1359
|
resolvedSchema = resolvedRefCache.get(refPath) ?? null;
|
|
1342
1360
|
}
|
|
1361
|
+
if (refPath && document.components && !refExists(refPath)) return ast.factory.createSchema({
|
|
1362
|
+
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1363
|
+
type: "unknown"
|
|
1364
|
+
});
|
|
1343
1365
|
return ast.factory.createSchema({
|
|
1344
1366
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1345
1367
|
type: "ref",
|
|
@@ -1459,7 +1481,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1459
1481
|
const variant = resolveRefSilent(member.$ref);
|
|
1460
1482
|
if (!variant) return null;
|
|
1461
1483
|
const propertyName = discriminator.propertyName;
|
|
1462
|
-
const seen = new Set([member.$ref]);
|
|
1484
|
+
const seen = /* @__PURE__ */ new Set([member.$ref]);
|
|
1463
1485
|
function constrains(v) {
|
|
1464
1486
|
const prop = v.properties?.[propertyName];
|
|
1465
1487
|
const resolved = prop && dialect.schema.isReference(prop) ? resolveRefSilent(prop.$ref) : prop;
|