[v3] Replace JSON schema validation engine

Issue #349 new
James Navin created an issue

The SRV currently uses https://github.com/java-json-tools/json-schema-validator to perform almost all schema validation, and to implement the custom OAI keywords (discriminator etc.)

It has worked so far, but the library has been notoriously patching with support and fixes, and suffers from a few problems that makes it worth considering the effort of replacing it:

  1. Currently only supports up to JSON Schema Draft v4, while OpenAPI 3.1 supports Draft v12
  2. Difficult to implement the discriminator validation as the library “hides” some of the control needed to address e.g. validation loops

We should evaluate some of the other options available as to their suitability https://json-schema.org/implementations.html#validators

Factors to evaluate:

  1. Coverage of the JSON Schema spec (up to Draft v12)
  2. Ability to recreate the custom keyword validations (discriminator, nullable)
  3. Impact on existing library consumers (validation message format, control of validations etc.)
  4. (Lower priority) performance

In all likelihood this will result in a major version bump for SRV to deal with message format changes etc.

Comments (6)

  1. Marc Philipp

    We’d also be very interested in this, in particular in the ability to configure the pattern validator to not use Nashorn or Rhino.

  2. Sravan Kumar Sandela

    We are very much looking forward to all these aspects, including performance improvements.

  3. Sravan Kumar Sandela

    One of the main concerns we see with this JSON Schema validator which is fge (https://github.com/java-json-tools/json-schema-validator/tree/master/src/main) is less performant when compared to networknt. The detailed performance analysis is presented here.

    https://github.com/networknt/json-schema-validator

    so, can you please consider updating our json schema validator to networknt?

    Can you please let us know where are we on this ticket, as its been here from past 2years.

  4. James Navin reporter

    so, can you please consider updating our json schema validator to networknt?

    It looks like a decent candidate. The main consideration I would have (above performance) is the ability to support the discriminator validation (and other non-standard schema validations that Swagger/OpenAPI supports).

    Can you please let us know where are we on this ticket, as its been here from past 2years.

    TBH I have made no progress towards a v3. It will be a pretty major undertaking and I haven’t had the time or need to as yet. I can’t really make any commitments re timelines at this point unfortunately.

  5. Log in to comment