Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Nesting an array inside an object in JSON schema always returns valid (even when it's not) #78

Open
@yogat3ch

Description

Directory structure is as follows:

├── main.json
├── objects.json
└── test.json

main.json:

{
 "$schema": "http://json-schema.org/draft-04/schema#",
 "$id": "1.1.0",
 "title": "My Main Schema",
 "description": "reprex schema",
 "type": "object",
 "properties": {
 "the_object": {
 "type": "object",
 "properties": {
 "my_nested_object": {
 "$ref": "./objects.json#/properties/objects" 
 }
 }
 }
 }
}

objects.json:

{
 "$schema": "http://json-schema.org/draft-04/schema#",
 "$id": "objects",
 "title": "My Main Schema",
 "description": "reprex schema",
 "type": "object",
 "properties": {
 "objects": {
 "type": "array",
 "items": {
 "type": "string",
 "enum": ["a","b","c"]
 }
 }
 }
}

test.json:

{
 "the_object": {
 "my_nested_object": ["d", "e"]
 }
}
jsonvalidate::json_validate("test.json", "main.json")

This will always evaluate to TRUE, disregarding the mismatch between the values in the array in test_json/the_object/my_nested_object and the enum specified in the objects reference. It seems like nested objects disregard the specified constraints of referenced schema?

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

        AltStyle によって変換されたページ (->オリジナル) /