Repository navigation
Warn about unknown fields that lint and test silently ignored - #1711
Merged
Merged
Conversation
The default lint path validated with fastjsonschema, which does not support the draft 2019-09 unevaluatedProperties keyword the ODCS schema uses to reject unknown fields. A misspelled key such as 'qualiti' passed lint, and test silently dropped the checks it held. Validate with jsonschema only, and report fields the ODCS model would drop as warnings in lint and test. Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
|
I pushed a few changes on top:
|
… value
A oneOf/anyOf failure no longer prints the whole object and every schema
branch. Branches whose type the value does not have are ignored, and the
error of the remaining branch is reported at its own path, e.g.
"data.team[0]: Additional properties are not allowed ('rol' was unexpected)".
When several branches match: "must match exactly one of 8 definitions, but
matches several". When none has the value's type: "must be of type 'object'
or 'array'".
With --schema, fields the custom schema rejects through unevaluatedProperties fail lint again instead of being downgraded to a warning or, when the ODCS model knows the field, passing silently. The bundled ODCS schema keeps reporting them as warnings, also with --all-errors, which the changelog now says.
…roperties jsonschema's unevaluatedProperties made lint and test exponentially slower with nesting depth: a contract with properties nested 10 levels deep took 36 s, which the /lint and /test API endpoints were also exposed to. The bundled schema is now validated without that keyword (0.06 s), and the fields the ODCS model drops are found by walking the contract alongside the model. The warnings are the same, except that typos in objects the schema leaves open are now caught too, such as `limitation` under `description` (fixed in the business-definitions examples), and the warnings no longer depend on the declared apiVersion, so `topic` on a kafka server, which no ODCS version defines, now warns in lint as it already did in test (removed from the kafka fixture; the topic is the schema's physicalName).
This comment was marked as outdated.
This comment was marked as outdated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A misspelled key such as
qualitiinstead ofqualitypasseddatacontract lint, anddatacontract testsilently dropped the checks it held. Only--all-errorsreported it.The default path validated with fastjsonschema, which ignores the draft 2019-09
unevaluatedPropertieskeyword the ODCS schema uses to reject unknown fields. Lint now validates with jsonschema only. Fields the ODCS model would drop are reported as a warning inlintandtest(to become an error in the next major version). Fields the CLI reads beyond the schema, such asdelimiteron alocalserver, are not reported.🤖 Generated with Claude Code