Skip to content

Embedded schemas aren't handled properly #67

@jdesrosiers

Description

@jdesrosiers

I noticed that there are a couple of issues with linting schemas that include embedded schemas. Here's a minimal example where there's an embedded schema with a different dialect than the parent schema.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/main",

  "$ref": "embedded",
  "$defs": {
    "embedded": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$id": "embedded",

      "allOf": [{ "$ref": "#/definitions/foo" }],
      "definitions": {
        "foo": { "type": "number" }
      }
    }
  }
}

EDIT: I forgot to wrap $ref in allOf for draft-07

I get the following result.

definitions was superseded by $defs in 2019-09 and later versions
Location: Line 11, Col 7
Rule ID: definitions_to_defs
Schema: /$defs/embedded/definitions

definitions was superseded by $defs in 2019-09 and later versions
Location: Line 11, Col 7
Rule ID: definitions_to_defs
Schema: /$defs/embedded/definitions

There are two problems with this response. Most obviously, it's the same error reported twice. But, also, it failed to detect the dialect change and it shouldn't be an error at all. definitions is correct for draft-07.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions