Stop treating schema warnings as errors #178
Merged
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.
Motivation
In #130, we introduced extra validation by calling into OpenAPIKit's
validate
method. (It's hidden behind a feature flag, but I've been testing with it enabled.)It looks for structural issues, such as non-unique operation ids, which would result in us generating non-compiling code anyway, so the validation helps catch these early and emit descriptive errors that adopters can use to fix their doc.
However, the method also takes a parameter
strict
, which defaults totrue
, and when enabled, it turns warnings emitted during schema parsing into errors. This part is too strict for us and was rejecting OpenAPI documents that were valid enough for our needs.An example of a schema warning is a schema having
minItems: 1
on a non-array schema. While it's not technically correct, it also doesn't impede our understanding of the non-array schema, as we never actually check what the value ofminItems
is. That's why these are just warnings, not errors, so we should stop promoting them to fatal errors that block an adopter from generating code.Modifications
This PR flips the
strict
parameter tofalse
. This doesn't make us miss out on these warnings, as recently (in #174), we started forwarding these schema warnings into generator diagnostics, so the adopter will see them still, and can address them on their own schedule.Result
Now documents with only schema warnings aren't rejected by the generator anymore.
Test Plan
Added a unit test of the broken-out
validateDoc
function, ensures that a schema with warnings doesn't trip it up anymore.