@kubb/adapter-oas 5.28.0 → 5.28.2
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 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -18,7 +18,7 @@ var compatibility = {
|
|
|
18
18
|
"node": ">=22.22"
|
|
19
19
|
};
|
|
20
20
|
// package.json
|
|
21
|
-
var version = "5.28.
|
|
21
|
+
var version = "5.28.2";
|
|
22
22
|
// src/constants.ts
|
|
23
23
|
/**
|
|
24
24
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -2023,6 +2023,13 @@ function extractExamples(schema) {
|
|
|
2023
2023
|
if (Array.isArray(schema.examples)) return schema.examples;
|
|
2024
2024
|
return schema.example !== void 0 ? [schema.example] : void 0;
|
|
2025
2025
|
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Whether the schema and its inline `allOf` members hold more than one distinct `pattern`. A value must match every one.
|
|
2028
|
+
*/
|
|
2029
|
+
function hasSeveralPatterns(schema) {
|
|
2030
|
+
const patterns = [schema, ...schema.allOf ?? []].map((item) => isReference(item) ? void 0 : item.pattern).filter((pattern) => pattern !== void 0);
|
|
2031
|
+
return new Set(patterns).size > 1;
|
|
2032
|
+
}
|
|
2026
2033
|
function hasStructuralKeywords(fragment) {
|
|
2027
2034
|
return Object.keys(fragment).some((key) => structuralKeys.has(key));
|
|
2028
2035
|
}
|
|
@@ -2046,6 +2053,7 @@ function flattenSchema(schema) {
|
|
|
2046
2053
|
const allOfFragments = schema.allOf;
|
|
2047
2054
|
if (allOfFragments.some((item) => isReference(item))) return schema;
|
|
2048
2055
|
if (allOfFragments.some(hasStructuralKeywords)) return schema;
|
|
2056
|
+
if (hasSeveralPatterns(schema)) return schema;
|
|
2049
2057
|
const { allOf: _allOf, ...rest } = schema;
|
|
2050
2058
|
const merged = rest;
|
|
2051
2059
|
for (const fragment of allOfFragments) for (const [key, value] of Object.entries(fragment)) merged[key] ??= value;
|
|
@@ -3193,11 +3201,26 @@ function mergeAnnotations(schema) {
|
|
|
3193
3201
|
} : schema;
|
|
3194
3202
|
}
|
|
3195
3203
|
/**
|
|
3204
|
+
* Whether the parent's own keywords become an intersection member: always beside `properties`, and
|
|
3205
|
+
* beside several patterns when the parent holds more than its type and annotations, such as `minLength`.
|
|
3206
|
+
*/
|
|
3207
|
+
function keepsOwnKeywords(schema) {
|
|
3208
|
+
if (schema.properties) return true;
|
|
3209
|
+
if (!hasSeveralPatterns(schema)) return false;
|
|
3210
|
+
return Object.keys(schema).some((key) => key !== "allOf" && key !== "type" && key !== "nullable" && !annotationKeys.has(key));
|
|
3211
|
+
}
|
|
3212
|
+
/**
|
|
3213
|
+
* Whether a one-member `allOf` adds nothing but annotations, so it parses as that member.
|
|
3214
|
+
*/
|
|
3215
|
+
function isSingleMemberAllOf(schema) {
|
|
3216
|
+
return schema.allOf.length === 1 && !schema.properties && !(Array.isArray(schema.required) && schema.required.length) && schema.additionalProperties === void 0 && !hasSeveralPatterns(schema);
|
|
3217
|
+
}
|
|
3218
|
+
/**
|
|
3196
3219
|
* Converts an `allOf` schema into a flattened node or an `IntersectionSchemaNode`.
|
|
3197
3220
|
*/
|
|
3198
3221
|
function convertAllOf({ schema: original, name, nullable, defaultValue, parse, refs }) {
|
|
3199
3222
|
const schema = mergeAnnotations(original);
|
|
3200
|
-
if (
|
|
3223
|
+
if (isSingleMemberAllOf(schema)) {
|
|
3201
3224
|
const [memberSchema] = schema.allOf;
|
|
3202
3225
|
const memberNode = parse({
|
|
3203
3226
|
schema: memberSchema,
|
|
@@ -3270,7 +3293,7 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
|
|
|
3270
3293
|
}
|
|
3271
3294
|
}
|
|
3272
3295
|
}
|
|
3273
|
-
if (schema
|
|
3296
|
+
if (keepsOwnKeywords(schema)) {
|
|
3274
3297
|
const { allOf: _allOf, ...schemaWithoutAllOf } = schema;
|
|
3275
3298
|
allOfMembers.push(parse({ schema: schemaWithoutAllOf }));
|
|
3276
3299
|
}
|