Skip to content

Warn about unknown fields that lint and test silently ignored - #1711

Merged
jschoedl merged 5 commits into
mainfrom
fix/lint-unevaluated-properties
Oct 7, 2026
Merged

jschoedl merged 5 commits into
mainfrom
fix/lint-unevaluated-properties

Conversation

@simonharrer

Copy link
Copy Markdown
Contributor

A misspelled key such as qualiti instead of quality passed datacontract lint, and datacontract test silently dropped the checks it held. Only --all-errors reported it.

The default path validated with fastjsonschema, which ignores the draft 2019-09 unevaluatedProperties keyword 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 in lint and test (to become an error in the next major version). Fields the CLI reads beyond the schema, such as delimiter on a local server, are not reported.

🤖 Generated with Claude Code

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>
@jschoedl

jschoedl commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

I pushed a few changes on top:

  • Unknown fields are now found by walking the ODCS model instead of through unevaluatedProperties, which made jsonschema exponentially slower with nesting depth (10 nested properties took 36 s, now 0.06 s). The walk also catches typos in objects the schema leaves open. It found limitation in our business-definitions example and topic on the kafka fixture's server, both fixed.
  • With a custom --schema, the unknown fields that schema rejects are errors again.
  • oneOf/anyOf errors now point at the actual typo, e.g. data.team[0]: Additional properties are not allowed ('rol' was unexpected), instead of printing the whole object and every schema branch.

… 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).
@simonharrer

This comment was marked as outdated.

@jschoedl
jschoedl merged commit 7d9dfc8 into main Oct 7, 2026
17 checks passed
@jschoedl
jschoedl deleted the fix/lint-unevaluated-properties branch October 7, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants