Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSchema() from URI should support subschema references #619

Closed
aznan2 opened this issue Oct 26, 2022 · 0 comments
Closed

getSchema() from URI should support subschema references #619

aznan2 opened this issue Oct 26, 2022 · 0 comments

Comments

@aznan2
Copy link
Contributor

aznan2 commented Oct 26, 2022

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.

aznan2 pushed a commit to aznan2/json-schema-validator that referenced this issue Oct 26, 2022
aznan2 pushed a commit to aznan2/json-schema-validator that referenced this issue Oct 27, 2022
aznan2 pushed a commit to aznan2/json-schema-validator that referenced this issue Oct 27, 2022
aznan2 pushed a commit to aznan2/json-schema-validator that referenced this issue Nov 21, 2022
stevehu pushed a commit that referenced this issue Dec 2, 2022
Co-authored-by: Matti Hansson <matti.hansson@lm.se>
@stevehu stevehu closed this as completed Jan 23, 2023
stevehu pushed a commit that referenced this issue Jun 28, 2023
…ively (#827)

* Add support for subschema references in getSchema(URI) (#619)

* Fixes unevaluatedProperties and unevaluatedItems being applied recursively (#826)

---------

Co-authored-by: Matti Hansson <matti.hansson@lm.se>
Co-authored-by: mathan <mathan@lm.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants