eclipse-vertx / vertx-json-schema

Vert.x Json Schema
Other
78 stars 32 forks source link

feat: add custom format validator #128

Closed pk-work closed 8 months ago

pk-work commented 8 months ago

This is a proposal for PR (#125).

After I cleaned up the constructors of SchemaValidatorImpl, I saw that there were only 2 places, where the custom JsonFormatValidator needs to be added.

  1. Validator.java https://github.com/eclipse-vertx/vertx-json-schema/pull/128/files#diff-2e1fb547e8e1538ba2b1077bbd72d66d0e9365fe54455ed3bd5c66ba63e7f3a7R57
  2. SchemaRepository.java https://github.com/eclipse-vertx/vertx-json-schema/pull/128/files#diff-55b554f9d69c21b8d6a68359aef901cf24fcedf8c39e917f86d95cb46447fbd6R47

These create methods are very simple, so I decided against a builder pattern, which would add more complexity in my opinion.

This JsonFormatValidator also provides the instanceType, which could be very beneficial.

AsciiDoc is missing. I will add it, when we agreed on the API.

pk-work commented 8 months ago

@CheesyBoy123 what do you think?

CheesyBoy123 commented 8 months ago

Thanks @pk-work for this! This looks like it is exactly what we need for vertx-openapi. I've compiled this locally and installed the artifact to be used in https://github.com/eclipse-vertx/vertx-openapi/pull/51. It is working without any issues, and with this change the changes are pretty minimal for vertx-openapi (only adding the custom formats)! 😄