Provide more detail for validation errors from `allOf` etc

Issue #25 resolved
James Navin created an issue

The JSON Schema Validation lib includes a reports field that has extra information for top-level validation errors such as allOf.

It would be useful to include this information in error messages emitted by the Swagger validator.

An example schema that can generate the report:

{
  "$ref": "#/definitions/Cat",
  "definitions": {
    "Pet": {
      "type": "object",
      "discriminator": "petType",
      "properties": {
        "name": {
          "type": "string"
        },
        "petType": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "petType"
      ]
    },
    "Cat": {
      "description": "A representation of a cat",
      "allOf": [
        {
          "$ref": "#/definitions/Pet"
        },
        {
          "type": "object",
          "properties": {
            "huntingSkill": {
              "type": "string",
              "description": "The measured skill for hunting",
              "default": "lazy",
              "enum": [
                "clueless",
                "lazy",
                "adventurous",
                "aggressive"
              ]
            }
          },
          "required": [
            "huntingSkill"
          ]
        }
      ]
    },
    "Dog": {
      "description": "A representation of a dog",
      "allOf": [
        {
          "$ref": "#/definitions/Pet"
        },
        {
          "type": "object",
          "properties": {
            "packSize": {
              "type": "integer",
              "format": "int32",
              "description": "the size of the pack the dog is from",
              "default": 0,
              "minimum": 0
            }
          },
          "required": [
            "packSize"
          ]
        }
      ]
    }
  }
}

with body:

{
    "name":"My Cat",
    "petType":"Cat"
}

Comments (6)

  1. Murthy Kakarlamudi Account Deactivated

    Hi James...I tested this locally with the branch and noticed that we are now getting error details from schema validator...I think it looks good..thanks for fixing it..

  2. Log in to comment