Skip to content

Errors for required properties do not contain the fragment correctly. #115

Closed
@yorickpeterse

Description

@yorickpeterse

Assume we have the following script (based on the documentation in the README):

require 'json-schema'

schema = {
  "type" => "object",
  "required" => ["a"],
  "properties" => {
    "a" => {"type" => "integer"}
  }
}

data = {}

JSON::Validator.validate!(schema, data)

Running this results in the following output:

The property '#/' did not contain a required property of 'a' in schema 221df103-b050-5d5c-8ee8-aa1d185ac383# (JSON::Schema::ValidationError)

This error message doesn't seem to include the fragment for the "a" property correctly. If we specify an incorrect type on the other hand it is set properly:

require 'json-schema'

schema = {
  "type" => "object",
  "required" => ["a"],
  "properties" => {
    "a" => {"type" => "integer"}
  }
}

data = {'a' => 'foo'}

JSON::Validator.validate!(schema, data)

Which results in:

The property '#/a' of type String did not match the following type: integer in schema 221df103-b050-5d5c-8ee8-aa1d185ac383# (JSON::Schema::ValidationError)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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