Add support for the `discriminator` keyword

Issue #26 resolved
James Navin created an issue

The discriminator keyword is a Swagger/OpenAPI extension to the JSON Schema spec and so is not supported by the JSON schema validation library.

It would be good to add support for this keyword.

See https://github.com/OAI/OpenAPI-Specification/issues/333 for a discussion.

Comments (4)

  1. James Navin reporter

    One option may be to transform the schema and replace discriminator with oneOf - from the discussion in the above thread this may be enough to generate useful validation messages.

  2. James Navin reporter

    Ive decided to implement support using a metaschema for the JSON Schema Validator, which will allow for addition of other Swagger-specific keywords in the future.

    Basic checking of syntax and allowed values for the 'discriminator' field is working. Next step will be to coerce the schema validator to use the sub-schema in place of the parent when performing validation.

  3. Log in to comment