ExodusMovement / schemasafe

A reasonably safe JSON Schema validator with draft-04/06/07/2019-09/2020-12 support.
https://npmjs.com/@exodus/schemasafe
MIT License
155 stars 12 forks source link

support for "example" keyword #152

Closed larkob closed 1 year ago

larkob commented 2 years ago

I noticed that the "example" keyword (OpenAPI specification) is not supported, only "examples" for the array type. Could you please consider making the following changes:

1) add 'example' to knownKeywords list in known-keywords.js

...['title', 'description', 'deprecated', 'readOnly', 'writeOnly', 'example', 'examples', '$comment'], // unused meta

2) add multi-type handle in compile.js (next to the existing one for "examples"):

handle('example', ['string', 'finite', 'boolean', 'object'], null) // unused, meta-only
handle('examples', ['array'], null) // unused, meta-only
ChALkeR commented 1 year ago

Sorry for the late response.

Yes, it's indeed defined in OpenAPI.

Adding to the next release.