Open vdice opened 5 years ago
There is a library that supports all scheme parameters, including the more recent draft-2020-12 (https://github.com/santhosh-tekuri/jsonschema). This library is easily integrated into cnab-go, I have an almost ready-made solution. But there is a nuance, the library does not return an error if incorrect content Encoding is passed, this will change the behavior, and actually I created a pullRequest (https://github.com/cnabio/cnab-go/pull/305) in which I changed the library and corrected the tests for new error texts. I deleted one test, this is due to the behavior that I described above
This project currently uses the qri-io/jsonschema library for parameter validation, as in https://github.com/deislabs/cnab-go/blob/master/bundle/definition/validation.go.
However, this underlying library currently only defines a subset of valid schema properties (see https://github.com/qri-io/jsonschema/blob/master/validate.go#L58-L107) and will fail validation (actually in unmarshal-ing prior to) for properties not in the list and not supplied via a custom validator.
One such property that would trigger this failure is
contentEncoding
. As an example, the validation then fails with:Ways to avoid these validation failures would be:
jsonschema
library before unmarshal-ing/validation. We'd have to do this for any/all missing/desired properties. See https://github.com/deislabs/cnab-go/pull/118 as a first example.