Skip to content

Commit 4c85ef2

Browse files
committed
Escape JSON Schema $id for empty struct
1 parent 6866230 commit 4c85ef2

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.changeset/bright-dolls-raise.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@effect/platform": patch
3+
"effect": patch
4+
---
5+
6+
Escape JSON Schema $id for empty struct

packages/effect/src/JSONSchema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface JsonSchema7object extends JsonSchemaAnnotations {
7272
* @since 3.10.0
7373
*/
7474
export interface JsonSchema7empty extends JsonSchemaAnnotations {
75-
$id: "/schemas/{}"
75+
$id: "/schemas/%7B%7D"
7676
anyOf: [
7777
{ type: "object" },
7878
{ type: "array" }
@@ -348,7 +348,7 @@ const constAnyObject: JsonSchema7 = {
348348
}
349349

350350
const constEmpty: JsonSchema7 = {
351-
"$id": "/schemas/{}",
351+
"$id": "/schemas/%7B%7D",
352352
"anyOf": [
353353
{ "type": "object" },
354354
{ "type": "array" }

packages/effect/test/Schema/JSONSchema.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ describe("fromAST", () => {
406406
it("NullOr(Struct({}))", () => {
407407
const schema = Schema.NullOr(Schema.Struct({}))
408408
expectJSONSchemaOpenApi31(schema, {
409-
"$id": "/schemas/{}",
409+
"$id": "/schemas/%7B%7D",
410410
"anyOf": [
411411
{ "type": "object" },
412412
{ "type": "array" }
@@ -834,7 +834,7 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema`
834834
it("empty struct: Schema.Struct({})", () => {
835835
const schema = Schema.Struct({})
836836
const jsonSchema: Root = {
837-
"$id": "/schemas/{}",
837+
"$id": "/schemas/%7B%7D",
838838
"anyOf": [{
839839
"type": "object"
840840
}, {

packages/platform/src/OpenApiJsonSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export interface AnyObject extends Annotations {
6969
* @since 0.71.0
7070
*/
7171
export interface Empty extends Annotations {
72-
$id: "/schemas/{}"
72+
$id: "/schemas/%7B%7D"
7373
anyOf: [
7474
{ type: "object" },
7575
{ type: "array" }

0 commit comments

Comments
 (0)