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

Strange error #62

Open
alebian opened this issue Oct 10, 2017 · 2 comments
Open

Strange error #62

alebian opened this issue Oct 10, 2017 · 2 comments

Comments

@alebian
Copy link

alebian commented Oct 10, 2017

Hi!

I have this schema definitions:

article.json
{
  "type":"object",
  "required": [
    "id",
    "article_sections"
  ],
  "properties": {
    "id": {
      "type":"integer",
      "not": {
        "type":"null"
      }
    },
    "article_sections": {
      "type":"array",
      "items": {
        "$ref":"article_section.json"
      }
    }
  }
}
article_section.json
{
  "type":"object",
  "required": [
    "id",
    "pictures"
  ],
  "properties": {
    "id": {
      "type":"integer",
      "not": {
        "type":"null"
      }
    },
    "pictures": {
      "type":"array",
      "items": {
        "$ref":"uploader.json"
      }
    }
  }
}
uploader.json
{
  "type":"object",
  "required": ["url"],
  "properties": {
    "url": {
      "type": ["string", "null"]
    },
    "thumb": {
      "type":"object",
      "optional": true,
      "properties": {
        "url": {
          "type": ["string", "null"]
        }
      }
    }
  }
}

With this JSON:

{
  "id": 1,
  "article_sections": [
    {
      "id": 1,
      "pictures": [
        {
          "url": "/uploads/article_section/pictures/1/wolox3.png"
        }
      ]
    }
  ]
}

I am getting this error:
The property '#/article_sections/0/pictures/0' did not contain a required property of 'thumb' in schema file...CORRECT_PATH...
I am really confused because I have other schema that uses the same uploader.json (but has the thumb property) and it works just fine.

Thanks!

@dangoosby
Copy link

Hi @alebian. Were you able to solve this issue? I'm having a similar issue where my rspec tests are failing due to missing properties that are not required. Here's my rspec output:

The property '#/' did not contain a required property of 'locations'

       ---

       expected

       {
         "uuid": "00000000-0000-0000-0000-000000000001",
         "name": "Charles Inc.",
         "status": "active",
         "is_potential": false,
         "is_private": false
       }

       to match schema "company":

       {
         "type": "object",
         "properties": {
           "uuid": {
             "type": "string",
             "format": "uuid",
             "example": "50f50f52-0d41-4a08-85ea-56423b2803c8"
           },
           "name": {
             "type": "string",
             "example": "john.smith"
           },
           "status": {
             "type": "string",
             "example": "inactive"
           },
           "is_potential": {
             "type": "boolean",
             "example": true
           },
           "is_private": {
             "type": "boolean",
             "example": true
           },
           "locations": {
             "type": "array",
             "items": {
               "$ref": "./location.json"
             }
           },
           "enterprise": {
             "type": "boolean",
             "example": true
           },
           "primary_member": {
             "type": "object",
             "items": {
               "$ref": "./primary-member.json"
             }
           },
           "printer_login": {
             "type": "integer",
             "example": 860702
           },
           "printer_pin": {
             "type": "string",
             "example": "860702"
           },
           "created_at_ms": {
             "type": "string",
             "example": "1524248493034"
           },
           "updated_at_ms": {
             "type": "string",
             "example": "1524248493034"
           },
           "tags": {
             "type": "array",
             "items": {
               "$ref": "./tag.json"
             }
           },
           "location_uuids": {
             "type": "array",
             "items": {
               "$ref": "./location.json"
             }
           },
           "is_active": {
             "type": "boolean",
             "example": true
           },
           "authorized_signatory_name": {
             "type": [
               "string",
               "null"
             ],
             "example": "john.smith"
           },
           "authorized_signatory_email": {
             "type": [
               "string",
               "null"
             ],
             "example": "[email protected]"
           },
           "non_profit": {
             "type": "boolean",
             "example": true
           },
           "non_profit_confirmed": {
             "type": "boolean",
             "example": false
           },
           "users_count": {
             "type": "integer",
             "example": 1
           },
           "manual_verification_enabled": {
             "type": "boolean",
             "example": true
           },
           "merged_to_uuid": {
             "type": [
               "string",
               "null"
             ],
             "format": "uuid",
             "example": "50f50f52-0d41-4a08-85ea-56423b2803c8"
           }
         },
         "required": [
           "uuid",
           "name",
           "status"
         ]
       }

@seanpdoyle
Copy link
Collaborator

Have you tried adding additionalProperties: true as a top-level key-value pair in your schema?

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

3 participants