-
Notifications
You must be signed in to change notification settings - Fork 82
✨ Schema validation #1441
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
Closed
Closed
✨ Schema validation #1441
Conversation
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
Merged
This was referenced Apr 25, 2025
5cf6b49 to
75c6211
Compare
61538a3 to
22130fc
Compare
chrisjsewell
added a commit
that referenced
this pull request
May 15, 2025
This fixes the problem, that the `option_spec` attributes are modified on a class level for: - `NeedDirective` - `NeedextendDirective` - `NeedserviceDirective` and thus remain changed for subsequent sphinx runs in the same interpreter session. The problem was a finding of #1441. This is particularly of issue for SN test cases, which all run in the same Python interpreter, and should ideally be reproducible, independent of any preceding tests run. The PR defines a `reset_options_spec` class method for modified directives, to revert the runtime changes during the `config-inited` event. --------- Co-authored-by: Chris Sewell <[email protected]>
22130fc to
a8a8eca
Compare
Merged
Member
Author
|
Closing this in favor of #1467 |
ubmarco
added a commit
that referenced
this pull request
Jul 24, 2025
This is the implementation of the discussion #1451 and a follow-up on #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]>
PierreEtienneJ
pushed a commit
to PierreEtienneJ/sphinx-needs
that referenced
this pull request
Jul 29, 2025
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]>
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.
Experimental implementation of a schema validation, aka. ontology check.
This is based on jsonschema, but also supports network validations.
Abandoned, see my new PR #1467.