Skip to content

getSchema() from URI should support subschema references #619

@aznan2

Description

@aznan2

Suppose we have a schema at http://example.com/schema.json that looks like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "oneOf": [
    {
      "$ref": "#/definitions/one"
    },
    {
      "$ref": "#/definitions/two"
    }
  ],
  "definitions": {
    "one": {
      "type": "integer",
      "enum": [1]
    },
    "two": {
      "type": "integer",
      "enum": [2]
    }
  }
}

If the "one" subschema is referenced through another schema ("$ref": "http://example.com/schema.json#/definitions/one"), then data will only be validated against the subschema - 1 will pass validation while 2 will fail.

Currently, however, if the same URI is used in a schema factory (jsonSchemaFactory.getSchema(new URI("http://example.com/schema.json#/definitions/one"))), then the fragment part of the URI is ignored and both 1 and 2 will pass validation.

It would be great if getSchema() would behave the same way as $ref and only return the referenced subschema.

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