diff --git a/packages/effect/test/JsonSchema.test.ts b/packages/effect/test/JsonSchema.test.ts index 9c152988f08..8abc9d4747b 100644 --- a/packages/effect/test/JsonSchema.test.ts +++ b/packages/effect/test/JsonSchema.test.ts @@ -1,4 +1,4 @@ -import { describe, it } from "@effect/vitest" +import { assert, describe, it } from "@effect/vitest" import { deepStrictEqual } from "@effect/vitest/utils" import * as JsonSchema from "effect/JsonSchema" @@ -1210,6 +1210,21 @@ describe("JsonSchema", () => { } }) }) + + it("preserves definitions whose keys sanitize to the same component name", () => { + const input: JsonSchema.MultiDocument<"draft-2020-12"> = { + dialect: "draft-2020-12", + schemas: [{ anyOf: [{ $ref: "#/$defs/A$B" }, { $ref: "#/$defs/A B" }] }], + definitions: { + "A$B": { const: 1 }, + "A B": { const: 2 } + } + } + + const result = JsonSchema.toMultiDocumentOpenApi3_1(input) + + assert.strictEqual(Object.keys(result.definitions).length, 2) + }) }) describe("roundtrip conversions", () => {