@kubb/oas 4.12.8 → 4.12.9
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 +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Oas.ts +33 -1
- package/src/utils.ts +2 -0
package/dist/index.cjs
CHANGED
|
@@ -4118,6 +4118,15 @@ var require_yaml = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4118
4118
|
//#endregion
|
|
4119
4119
|
//#region src/utils.ts
|
|
4120
4120
|
var import_yaml = /* @__PURE__ */ __toESM(require_yaml(), 1);
|
|
4121
|
+
const STRUCTURAL_KEYS = new Set([
|
|
4122
|
+
"properties",
|
|
4123
|
+
"items",
|
|
4124
|
+
"additionalProperties",
|
|
4125
|
+
"oneOf",
|
|
4126
|
+
"anyOf",
|
|
4127
|
+
"allOf",
|
|
4128
|
+
"not"
|
|
4129
|
+
]);
|
|
4121
4130
|
function isOpenApiV2Document(doc) {
|
|
4122
4131
|
return doc && (0, remeda.isPlainObject)(doc) && !("openapi" in doc);
|
|
4123
4132
|
}
|
|
@@ -4451,6 +4460,16 @@ var Oas = class extends oas.default {
|
|
|
4451
4460
|
colorizeErrors: true
|
|
4452
4461
|
}).validate({ parser: { validate: { errors: { colorize: true } } } });
|
|
4453
4462
|
}
|
|
4463
|
+
flattenSchema(schema) {
|
|
4464
|
+
if (!schema?.allOf || schema.allOf.length === 0) return schema;
|
|
4465
|
+
if (schema.allOf.some((item) => isReference(item))) return schema;
|
|
4466
|
+
const isPlainFragment = (item) => !Object.keys(item).some((key) => STRUCTURAL_KEYS.has(key));
|
|
4467
|
+
if (!schema.allOf.every((item) => isPlainFragment(item))) return schema;
|
|
4468
|
+
const merged = { ...schema };
|
|
4469
|
+
delete merged.allOf;
|
|
4470
|
+
for (const fragment of schema.allOf) for (const [key, value] of Object.entries(fragment)) if (merged[key] === void 0) merged[key] = value;
|
|
4471
|
+
return merged;
|
|
4472
|
+
}
|
|
4454
4473
|
};
|
|
4455
4474
|
|
|
4456
4475
|
//#endregion
|