-
Notifications
You must be signed in to change notification settings - Fork 82
✨ Schema validation v2 #1467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Schema validation v2 #1467
Conversation
4b4057b to
26cae92
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1467 +/- ##
==========================================
+ Coverage 86.87% 88.81% +1.93%
==========================================
Files 56 67 +11
Lines 6532 8271 +1739
==========================================
+ Hits 5675 7346 +1671
- Misses 857 925 +68
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0d3e8c5 to
6e95ec0
Compare
6e95ec0 to
a08078c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial review comments
(without yet looking over the full implementation of the schema checking)
| The option will still be stored as a string in Sphinx-Needs, | ||
| but during schema validation, the value will be coerced to the given type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bad though, the values should be coerced to these from the start, if read from a (string) directive, or just checked if read from a needs.json.
This will definitely be the case in ubcode.
What is the path to change sphinx-needs, so that it can handle storing the data as the correct type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree with you that the internal types should change with the definition, my plan was to do that in a 2-step approach. Users should adopt the ontology in a non-breaking way (switch from warnings/constraints to this, transpile from SHACL, ...). This takes time and efforts. Then in the meantime we change the internal representation which affects at least filter functions, and data/schema in exported needs.json. My current feeling is changing the types is a bigger thing in the codebase that delays this PR. The adoption of the new interface and the schema feedback is already of good value for end users. We can switch the type system while adoption happens.
Make get_warnings_list a fixture.
Co-authored-by: Chris Sewell <[email protected]>
- Renamed `needs_schemas` to `needs_schema_definitions` - Fail if both config needs_schema_definitions and json is given
chrisjsewell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment, emit a warning
then ok thats it for now; this PR can be merged, but there will be changes that need to be made when I get into it
This is the implementation of the discussion useblocks#1451 and a follow-up on useblocks#1441. The PR adds schema validation to Sphinx-Needs that supports local validation and network validation. The Sphinx-Needs internal data type representation is not changed yet, all types are still strings. This will come shortly after merge. Users can already try out the new interface and provide feedback. Differences to PR 1441: - Aligning with standards in JSON schema for re-using subschemas via `$defs` and `$ref` - Fully typed implementation including runtime checks of valid schema user input - Auto inject the default string type if not given - Replace `trigger_schema` with `select` which aligns with query language terminology - Replace `trigger_schema_id` with the mentioned `$ref` mechanism - New schemas root key `validate` with sub-keys `local` and `network` for the 2 validation types - Network validation items does not allow the `select` key anymore as the selection happens by linking target needs. This cleans up an ambiguity in the other PR. - Network validation errors now bubble up to the root json schema and are displayed to see exactly why the chain fails - More network rule types for better control over debug schema output - Rewrite test cases to use a declarative definition as yaml, so all pieces can be given in one place: - conf.py - ubproject.toml - index.rst - schemas.json - expected ontology warnings - Simplified the code logic - String patterns (regex) are constrained to a basic subset that works across engines - Added docs - Examples and explanations - Comparison with `needs_warnings` and `needs_constraints` and migration path - Many more test cases - `items` with `minItems` and `maxItems` and `contains` with `minContains` and `maxContains` are now semantically equivalent to JSON schema spec --------- Co-authored-by: Chris Sewell <[email protected]>
This is a follow-up on #1441.
I plan not to merge #1441 and merge this PR instead.
Differences:
$defsand$reftrigger_schemawithselectwhich aligns with query language terminologytrigger_schema_idwith the mentioned$refmechanismvalidatewith sub-keyslocalandnetworkfor the 2 validation typesselectkey anymore as the selection happens by linking target needs.This cleans up an ambiguity in the other PR.
needs_warningsandneeds_constraintsand migration pathitemswithminItemsandmaxItemsandcontainswithminContainsandmaxContainsare now semantically equivalent to JSON schema spec