hyperjump-io / json-schema

JSON Schema Validation, Annotation, and Bundling. Supports Draft 04, 06, 07, 2019-09, 2020-12, OpenAPI 3.0, and OpenAPI 3.1
https://json-schema.hyperjump.io/
MIT License
216 stars 22 forks source link

bug: prefixItems schema does not evaluate #34

Closed jeremyfiel closed 1 year ago

jeremyfiel commented 1 year ago

The following schema does not produce an error as expected where idddd is an additional property. Is this a bug or is my schema wrong?

{
    "$id": "https://www.freecodecamp.org/classroom/userDataRequest",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "UserDataRequest",
    "description": "Queries a collection of users and certifications",
    "users": {
        "type": "array",
        "uniqueItems": true,
        "prefixItems": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "id": {
                    "type": "string"
                }
            }
        },
        "items": {
            "description": "name of the certification block",
            "type": "string",
            "pattern": "^[A-Za-z][\/A-Za-z0-9-]*[A-Za-z]$"
        }
    },
    "required": ["users"]
}
{
  "users": [
    {
      "idddd": "123456"
    },
    "2022/responsive-web-design",
    "quality-assurance"
  ]
}
jeremyfiel commented 1 year ago

I tried a few different things and none of them are evaluated, not only additionalProperties

adding required": ["id"] did not produce an error passing a number to idddd did not produce an error.

{
  "users": [
    {
      "idddd": 123456
    },
    "2022/responsive-web-design",
    "quality-assurance"
  ]
}
jeremyfiel commented 1 year ago

I missed the root level properties definition also the prefixItems is an array schema.