This repository was archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
isSubset is not correct #30
Copy link
Copy link
Open
Description
Given the two schemas;
const s1 = {
type: "object",
properties: { test1: { type: "string" }, test2: { type: "string" } },
required: ["test1"],
nullable: false,
additionalProperties: true,
}
const s2 = {
type: "object",
properties: { test1: { type: "string" }, test2: { type: "string" } },
required: ["test1", "test2"],
nullable: false,
additionalProperties: true,
}s2 is more restrictive than s1, hence isSubset(s1, s2) should be true.
If I merge up two schemas with noRequired, I will surely loose context. But if I use ignoreRequired on the check it feels like I will loose context too...
Also;
export const isSubsetSchema = async (superset: any, subset: any) => {
return isSubset(superset, subset, { ignoreRequired: false });
};
describe("jsonSchemaGen", () => {
test("sanity", async () => {
const s1 = {
type: "object",
properties: { test: { type: "string" } },
required: ["test"],
nullable: false,
additionalProperties: false,
};
const s2 = {
type: "object",
properties: { test: { type: "string" } },
required: ["test"],
nullable: false,
additionalProperties: true,
};
expect(await isSubsetSchema(s2, s1)).toBeTruthy();
expect(await isSubsetSchema(s1, s2)).toBeFalsy();
});
test("sanity2", async () => {
const s1 = {
type: "object",
properties: { test: { type: "string" } },
required: ["test"],
nullable: true,
additionalProperties: true,
};
const s2 = {
type: "object",
properties: { test: { type: "string" } },
required: ["test"],
nullable: false,
additionalProperties: true,
};
expect(await isSubsetSchema(s2, s1)).toBeTruthy();
expect(await isSubsetSchema(s1, s2)).toBeFalsy();
});
});These test are failing.
Is this repository accepts PRs, or it is dead or in low maintanance mode?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels