Skip to content

Schema nesting with id key is not validating as expected #270

Closed
@pelted

Description

Given the simple schema bellow it is expected to not validate because of the foo required key in the nested attributes object but it in fact does validate when the response does not contain foo.

Doing some digging, it appears the reason may have to do with the id property being returned in the response.

Schema

{
  "$schema": "http://json-schema.org/draft-04/hyper-schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "required": ["id", "type", "attributes"],
      "properties": {
        "id" : { "type" : "string" },
        "type" : { "type" : "string" },
        "attributes" : { "type" : "object" }
      },
      "attributes": {
        "type": "object",
        "required": ["user_name", "email", "auth_token", "foo"]
      }
    }
  }
}

Response

{
  "data":{
    "id": "1",
    "type": "users",
    "attributes": {
      "user_name": "admin", 
      "email":"admin@example.com"
    }
  }
}

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