Skip to content

🧹 Clarification: Behavior for duplicate $ids or $anchors #1533

Closed
@gregsdennis

Description

@gregsdennis

Specification section

Core, probably section 8.2 somewhere. (EDIT: Also section 9.1.2 as noted below.)

What is unclear?

A question came up in Slack for the appropriate behavior when duplicate $id were found in subschemas. For example:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://test.example/a",
  "type": "object",
  "properties": {
    "f1": {
      "$id": "https://test.example/b",
      "type": "string"
    },
    "f2": {
      "$id": "https://test.example/b",
      "type": "number"
    },
    "f3": {
      "$ref": "https://test.example/b"
    }
  }
}

The ID https://test.example/b is declared twice.

This could also apply if multiple $anchor values were duplicated within the same resource.

Proposal

This should be a "refuse to process" error.

Currently the behavior is undefined, which means an implementation can do what it wants.

Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)

No

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions