OriginProtocol / origin

Monorepo for our developer tools and decentralized marketplace application
https://www.originprotocol.com/developers
MIT License
652 stars 196 forks source link

Fractional Usage: Look in to $merge for JSON schema #1232

Closed jordajm closed 5 years ago

jordajm commented 5 years ago

Per @franckc's suggestion, we should look into using $merge to DRY up the listing and offer schemas in origin-js. This was prompted by the addition of a large jCal definition for validating fractional usage listings and offers.

If we pull out all of the repeated item definitions in the listing and offer schemas into their own files and then pull them into the schemas using $merge, we'd be able to DRY up the schemas quite a bit.

We'd need to use this library or a similar one: https://github.com/epoberezkin/ajv-merge-patch

jordajm commented 5 years ago

Note: this may not be as straightforward as I originally thought it would be for the jCal schema validation... I realized that we need fewer fields on the "offer" time slots than on the "listing" availability data, so the jCal schema definitions aren't identical across listing and offer schemas any longer.

nick commented 5 years ago

Closing as I don't think we need this anymore