fix: preserve non-oneOf schema array order (#91891)

This commit is contained in:
Dallin Romney
2026-06-10 15:58:30 -07:00
committed by GitHub
parent a450ff036a
commit c7ed990769
2 changed files with 53 additions and 14 deletions

View File

@@ -206,16 +206,31 @@ describe("Codex app-server protocol JSON canonicalizer", () => {
`);
});
it("sorts arrays only when plain object items expose top-level type values", () => {
it("sorts typed-object arrays only for order-insensitive schema keywords", () => {
expect(
canonicalizeCodexAppServerProtocolJson({
enum: ["z", "a"],
anyOf: [
{ z: 1, type: "string" },
{ type: "integer", a: 2 },
],
enum: [
{ z: 1, type: "z" },
{ type: "a", a: 2 },
],
mixed: [{ type: "b" }, "item", { type: "a" }],
oneOf: [
{ title: "Second", z: true },
{ a: true, title: "First" },
{ type: "object", z: true },
{ a: true, type: "array" },
{ type: "object", z: false },
],
prefixItems: [
{ z: 1, type: "string" },
{ type: "number", a: 2 },
],
required: [
{ z: 1, type: "z" },
{ type: "a", a: 2 },
],
required: ["z", "a"],
typed: [
{ type: "beta", z: 1 },
{ type: "alpha", z: 2 },
@@ -223,16 +238,31 @@ describe("Codex app-server protocol JSON canonicalizer", () => {
],
}),
).toEqual({
enum: ["z", "a"],
anyOf: [
{ a: 2, type: "integer" },
{ type: "string", z: 1 },
],
enum: [
{ a: 2, type: "a" },
{ type: "z", z: 1 },
],
mixed: [{ type: "b" }, "item", { type: "a" }],
oneOf: [
{ title: "Second", z: true },
{ a: true, title: "First" },
{ a: true, type: "array" },
{ type: "object", z: true },
{ type: "object", z: false },
],
prefixItems: [
{ type: "string", z: 1 },
{ a: 2, type: "number" },
],
required: [
{ a: 2, type: "a" },
{ type: "z", z: 1 },
],
required: ["z", "a"],
typed: [
{ type: "alpha", z: 2 },
{ type: "beta", z: 1 },
{ type: "alpha", z: 2 },
{ type: "beta", z: 3 },
],
});