docusaurus-plugin-openapi-docs 0.0.0-1107 → 0.0.0-1109
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.
|
@@ -30,7 +30,7 @@ function mergeAllOf(allOf) {
|
|
|
30
30
|
console.warn(msg);
|
|
31
31
|
};
|
|
32
32
|
const mergedSchemas = (0, allof_merge_1.merge)(allOf, { onMergeError });
|
|
33
|
-
return mergedSchemas;
|
|
33
|
+
return mergedSchemas !== null && mergedSchemas !== void 0 ? mergedSchemas : {};
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* For handling nested anyOf/oneOf.
|
|
@@ -45,4 +45,30 @@ describe("sampleFromSchema", () => {
|
|
|
45
45
|
expect(result).toBe("dog");
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
|
+
describe("allOf with incompatible types", () => {
|
|
49
|
+
it("should return undefined when allOf contains incompatible types", () => {
|
|
50
|
+
const schema = {
|
|
51
|
+
allOf: [{ type: "string" }, { type: "integer" }],
|
|
52
|
+
};
|
|
53
|
+
const context = { type: "request" };
|
|
54
|
+
const result = (0, createSchemaExample_1.sampleFromSchema)(schema, context);
|
|
55
|
+
expect(result).toBeUndefined();
|
|
56
|
+
});
|
|
57
|
+
it("should handle incompatible allOf types in a property", () => {
|
|
58
|
+
const schema = {
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
numero: {
|
|
62
|
+
allOf: [{ type: "string" }, { type: "integer" }],
|
|
63
|
+
},
|
|
64
|
+
name: {
|
|
65
|
+
type: "string",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
const context = { type: "request" };
|
|
70
|
+
const result = (0, createSchemaExample_1.sampleFromSchema)(schema, context);
|
|
71
|
+
expect(result.name).toBe("string");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
48
74
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-1109",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=14"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "96c769dd3f97f033600a157fb9b607b5a05b439e"
|
|
69
69
|
}
|
|
@@ -54,4 +54,36 @@ describe("sampleFromSchema", () => {
|
|
|
54
54
|
expect(result).toBe("dog");
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
describe("allOf with incompatible types", () => {
|
|
59
|
+
it("should return undefined when allOf contains incompatible types", () => {
|
|
60
|
+
const schema: SchemaObject = {
|
|
61
|
+
allOf: [{ type: "string" }, { type: "integer" }],
|
|
62
|
+
};
|
|
63
|
+
const context = { type: "request" as const };
|
|
64
|
+
|
|
65
|
+
const result = sampleFromSchema(schema, context);
|
|
66
|
+
|
|
67
|
+
expect(result).toBeUndefined();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("should handle incompatible allOf types in a property", () => {
|
|
71
|
+
const schema: SchemaObject = {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
numero: {
|
|
75
|
+
allOf: [{ type: "string" }, { type: "integer" }],
|
|
76
|
+
},
|
|
77
|
+
name: {
|
|
78
|
+
type: "string",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
const context = { type: "request" as const };
|
|
83
|
+
|
|
84
|
+
const result = sampleFromSchema(schema, context);
|
|
85
|
+
|
|
86
|
+
expect(result.name).toBe("string");
|
|
87
|
+
});
|
|
88
|
+
});
|
|
57
89
|
});
|