Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ const stepType = {

const oneOfIndex = targetSchema.oneOf.findIndex((s) => s === resolvedSchema);

resolvedSchema = JSON.parse(JSON.stringify(resolvedSchema));
resolvedSchema.variableSchema = true;
resolvedSchema.oneOfIndex = oneOfIndex;
resolvedSchema.oneOfSchema = targetSchema;
Expand Down
32 changes: 32 additions & 0 deletions test/unit/step/step.oneOf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,36 @@ describe("step.oneof", () => {

expect(res.oneOfIndex).to.eq(1);
});

it("should maintain references from a remote schema when resolving oneOf with $ref", () => {
core.addRemoteSchema("https://my-other-schema.com/schema.json", {
type: "object",
properties: {
innerTitle: { $ref: "#/definitions/number" }
},
definitions: {
number: { type: "number", title: "Zahl" }
}
});
const schema = core.compileSchema({
type: "object",
properties: {
title: {
oneOf: [
{
type: "object",
properties: { innerTitle: { type: "string", title: "Zeichenkette" } }
},
{ $ref: "https://my-other-schema.com/schema.json" }
]
}
}
});
const res = step(core, "title", schema, { title: { innerTitle: 111 } });

expect(res.type).to.eq("object");

const nextRes = step(core, "innerTitle", res, { innerTitle: 111 });
expect(nextRes.type).to.eq("number");
});
});