add StrictValidation to BundleCompositionConfig to support more user friendly errors on invalid specs #482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a
StrictValidationfield toBundleCompositionConfigto handle reporting errors when trying to compose the bundle.Scenario
I've run into an issue using the bundler, where an invalid spec was causing a confusing error which states a file did not exist, if a component was trying to refer to another component whilst including an invalid sibling ref node, i.e.:
spec:
./components/CountryCode.json
{ "type": "string", "description": "Country code in ISO 3166 ALPHA-2 format", "enum": [ "US", "CA", "GB", "DE", "FR" ] }./components/HistoricalShippingOption.json
{ "title": "HistoricalShippingOption", "type": "object", "properties": { "country_code": { "$ref": "CountryCode.json", "description": "this should not be here" } }, "required": [ "country_code" ] }Warning
This is invalid, the
country_codeproperty should not have adescriptionwith the$ref.Deleting this description key fixes everything, but teams using this have been confused by how this error is reported.
The bundle gets created incorrectly, and linting then says
rolodex count not find filefor the external refCountryCode.json, which is confusing as it's not that the file can't be found, it's the input is invalid.Example code for bundling:
When I build with these changes and enable the
StrictValidationmy specific error gets flagged, which avoids the confusion of the file not found errors that are currently flagged.