Remove lazy definition initialization in SchemaValidator

Issue #245 resolved
Sven Döring created an issue

That lazy initialization is a possible source of a false positive validation error. The method setupSchemaDefinitionRefs, which loads the definition on first validation, might throw an:

  • JsonParseException leading to validation.{keyPrefix}.schema.invalidJson
  • IOException leading to validation.{keyPrefix}.schema.unknownError

Both is wrong as not the tested schema is wrong but the (OpenAPI) api.

The calculation of definitionsContainAllOf seems wrong, too. It is repeatedly set on a for-loop. So it might be set to true and on the next iteration it is set back to false again.

Plus there are several unneccessary conversions from an Object to a JSON string back to an Object (JsonNode) instead of just converting it directly to the JsonNode.

There is potential to improve the SchemaValidator.

Comments (2)

  1. Sven Döring reporter

    And the SchemaValidator has an additional constructor which is only used for testing. But there is no (visible?) reason why those tests can’t be simply called with the other constructor.

  2. Log in to comment