Repository navigation
Share offline validation of YAML nodes and example schemas - #343
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #343 +/- ##
==========================================
+ Coverage 98.76% 98.77% +0.01%
==========================================
Files 95 96 +1
Lines 12430 12580 +150
==========================================
+ Hits 12276 12426 +150
Misses 129 129
Partials 25 25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
daveshanley
left a comment
There was a problem hiding this comment.
Good bones on this one. The offline loader, the copy-on-write YAML walk and the sync.OnceValues cache are all things I'd want here, and -race is green locally.
But I poked at the edges with a scratch test and found four things that bite. The big one is if: pruning required inside a condition flips which branch fires, so a perfectly valid request example fails. The other three are about where the example path quietly disagrees with the rest of the library (nullable under 3.1, readOnly through allOf, and .inf killing the compile). Inline comments have repros.
None of it is hard to fix. I'd fix if before vacuum#1065 ships, because that one turns into false positives for real users.
801ad24 to
9f66d86
Compare
Add two entry points for consumers that already have parsed YAML and a JSON Schema. Validate a node against a compiled schema, or compile an example schema for a request or response. Compilation runs offline and the cache is bounded.
Vacuum uses these entry points for its packaged OpenLint rules in daveshanley/vacuum#1065. Tests cover draft selection, nullable fields, request and response requirements, YAML keys and aliases, and cache ownership.