dataclasses-jsonschema icon indicating copy to clipboard operation
dataclasses-jsonschema copied to clipboard

Invalid schema generated when using inheritance and allow_additional_props=False

Open s-knibbs opened this issue 4 years ago • 1 comments

Due to the way that $allOf and additionalProperties interact in json schema, currently, a schema that validates against nothing will be generated in the following case:

@dataclass
class Pet(JsonSchemaMixin):
    name: str

@dataclass
class Cat(Pet, allow_additional_props=False):
    hunting_skill: str

s-knibbs avatar Oct 18 '19 16:10 s-knibbs

To fix this will require supporting the unevaluatedProperties which was introduced in the latest JSON schema draft.

Initially, I propose to raise an error when inheritance and allow_additional_props=False are used together and later on add support for the 2019-09 draft with unevaluatedProperties once that's supported by the validation libraries.

s-knibbs avatar Oct 19 '19 09:10 s-knibbs