@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.cjs
CHANGED
|
@@ -65,7 +65,7 @@ const SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
|
65
65
|
* HTTP methods that count as operations on an OpenAPI path item. Other keys
|
|
66
66
|
* (`parameters`, `summary`, `$ref`, vendor extensions) are skipped when iterating operations.
|
|
67
67
|
*/
|
|
68
|
-
const SUPPORTED_METHODS = new Set([
|
|
68
|
+
const SUPPORTED_METHODS = /* @__PURE__ */ new Set([
|
|
69
69
|
"get",
|
|
70
70
|
"put",
|
|
71
71
|
"post",
|
|
@@ -89,7 +89,7 @@ const SUPPORTED_METHODS = new Set([
|
|
|
89
89
|
* // true when fragment has e.g. 'properties' or 'oneOf'
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
const structuralKeys = new Set([
|
|
92
|
+
const structuralKeys = /* @__PURE__ */ new Set([
|
|
93
93
|
"properties",
|
|
94
94
|
"items",
|
|
95
95
|
"additionalProperties",
|
|
@@ -104,7 +104,7 @@ const structuralKeys = new Set([
|
|
|
104
104
|
* special-cases in `parser.ts`. `isHandledFormat` reads it so the
|
|
105
105
|
* `KUBB_UNSUPPORTED_FORMAT` diagnostic and the parser agree on what is handled.
|
|
106
106
|
*/
|
|
107
|
-
const specialCasedFormats = new Set([
|
|
107
|
+
const specialCasedFormats = /* @__PURE__ */ new Set([
|
|
108
108
|
"int64",
|
|
109
109
|
"date-time",
|
|
110
110
|
"date",
|
|
@@ -1339,6 +1339,24 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1339
1339
|
*/
|
|
1340
1340
|
const resolvedRefCache = /* @__PURE__ */ new Map();
|
|
1341
1341
|
/**
|
|
1342
|
+
* Memoized record of whether a `$ref` path resolves to a node the document actually defines.
|
|
1343
|
+
* A circular ref still resolves to an existing target, so this stays `true` for cycles and only
|
|
1344
|
+
* goes `false` for a `$ref` that points at a component the spec never declares.
|
|
1345
|
+
*/
|
|
1346
|
+
const refExistence = /* @__PURE__ */ new Map();
|
|
1347
|
+
function refExists(refPath) {
|
|
1348
|
+
if (!refExistence.has(refPath)) {
|
|
1349
|
+
let exists = false;
|
|
1350
|
+
try {
|
|
1351
|
+
exists = !!dialect.schema.resolveRef(document, refPath);
|
|
1352
|
+
} catch {
|
|
1353
|
+
exists = false;
|
|
1354
|
+
}
|
|
1355
|
+
refExistence.set(refPath, exists);
|
|
1356
|
+
}
|
|
1357
|
+
return refExistence.get(refPath) ?? false;
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1342
1360
|
* Converts a `$ref` schema into a `RefSchemaNode`.
|
|
1343
1361
|
*
|
|
1344
1362
|
* The resolved schema is stored in `node.schema`. Usage-site sibling fields
|
|
@@ -1363,6 +1381,10 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1363
1381
|
}
|
|
1364
1382
|
resolvedSchema = resolvedRefCache.get(refPath) ?? null;
|
|
1365
1383
|
}
|
|
1384
|
+
if (refPath && document.components && !refExists(refPath)) return _kubb_core.ast.factory.createSchema({
|
|
1385
|
+
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1386
|
+
type: "unknown"
|
|
1387
|
+
});
|
|
1366
1388
|
return _kubb_core.ast.factory.createSchema({
|
|
1367
1389
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
1368
1390
|
type: "ref",
|
|
@@ -1482,7 +1504,7 @@ function createSchemaParser(ctx, dialect = oasDialect) {
|
|
|
1482
1504
|
const variant = resolveRefSilent(member.$ref);
|
|
1483
1505
|
if (!variant) return null;
|
|
1484
1506
|
const propertyName = discriminator.propertyName;
|
|
1485
|
-
const seen = new Set([member.$ref]);
|
|
1507
|
+
const seen = /* @__PURE__ */ new Set([member.$ref]);
|
|
1486
1508
|
function constrains(v) {
|
|
1487
1509
|
const prop = v.properties?.[propertyName];
|
|
1488
1510
|
const resolved = prop && dialect.schema.isReference(prop) ? resolveRefSilent(prop.$ref) : prop;
|