-
Notifications
You must be signed in to change notification settings - Fork 42
Refactor JSON schema generation for consistency #946
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
Conversation
Squashed commits: [b936166] add first pass schema override methods
…rent `SCHEMA_VERSION` values per class while still allowing us to centralize setting `obj.schemaVersion` and processing schema `$id` generation
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.
Pull Request Overview
This PR refactors JSON schema generation for SSVC objects to improve consistency and maintainability. The main changes consolidate schema version logic into a central mixin, update schema files to use new naming conventions with standardized metadata, and simplify schema generation tooling.
- Moved schema version handling from individual classes to the
_SchemaVersionedmixin - Updated schema files to use consistent naming pattern (
ClassName_X_Y_Z.schema.json) and added standard metadata - Simplified schema dumping in
doctools.pyto automatically handle all SSVC classes using new utilities
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/ssvc/_mixins.py |
Added schema filename, path, and URL generation methods to _SchemaVersioned mixin |
src/ssvc/selection.py |
Removed custom schema metadata generation, now uses mixin functionality |
src/ssvc/registry/base.py |
Removed custom schema version validator, uses mixin's _schema_version |
src/ssvc/dp_groups/base.py |
Removed custom schema version validator, added deprecation warning to schema description |
src/ssvc/decision_tables/base.py |
Removed custom schema version validator, uses mixin's _schema_version |
src/ssvc/decision_points/base.py |
Added _schema_version class variable for consistency |
src/ssvc/doctools.py |
Refactored to use new schema utilities, simplified schema dumping logic |
src/ssvc/utils/misc.py |
Added filename_friendly function for consistent filename generation |
src/ssvc/utils/defaults.py |
Added SCHEMA_BASE_URL constant |
data/schema/v2/*.schema.json |
Renamed files and updated with standard metadata ($schema, $id, description) |
| Test files | Updated to use new schema filenames and import structure |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
$schemaand$idmissing #901I took the opportunity to refactor much of what we added to the
SelectionListobject into the_SchemaVersionedmixin.Warning
Breaking Change
This PR changes the file names of
data/schema/v2/*.schema.json. That likely means that the calculator and other UI things might need to change the URLs they're drawing from. However, this seemed to be a worthwhile tradeoff to allow us to move forward with automatically generating schemas consistently.If desired, we could leave filesystem links behind from the old names. I have not done that as of creating this PR though.
Copilot Summary
This pull request refactors schema handling and generation for SSVC objects, improving consistency, maintainability, and future extensibility. The main changes include consolidating schema version logic into a mixin, updating schema files to use new naming conventions and metadata, and simplifying schema dumping in documentation tooling.
Schema handling and generation improvements:
_schema_versionclass variable and related schema filename, path, and URL generation methods to the_SchemaVersionedmixin insrc/ssvc/_mixins.py, centralizing schema version logic and enabling consistent schema metadata and file naming for all SSVC models. (src/ssvc/_mixins.py) [1] [2]DecisionPoint,DecisionTable,DecisionPointGroup,SsvcObjectRegistry) to use the new_schema_versionlogic and removed redundant schema version validators, ensuring a single source of truth for schema versioning. (src/ssvc/decision_points/base.py,src/ssvc/decision_tables/base.py,src/ssvc/dp_groups/base.py,src/ssvc/registry/base.py) [1] [2] [3] [4]Schema file and metadata updates:
data/schema/v2/to use a consistent naming convention and updated their contents to include$schema,$id, and a standardizeddescription, improving schema discoverability and standards compliance. (data/schema/v2/DecisionPoint_2_0_0.schema.json,data/schema/v2/DecisionTable_2_0_0.schema.json,data/schema/v2/DecisionPointGroup_2_0_0.schema.json,data/schema/v2/SsvcObjectRegistry_2_0_0.schema.json) [1] [2] [3] [4]Documentation and tooling simplification:
src/ssvc/doctools.pyto use the new schema filename/path utilities, removed legacy filename helpers, and streamlined schema dumping logic to automatically handle all relevant SSVC classes. (src/ssvc/doctools.py) [1] [2] [3]General codebase consistency:
src/ssvc/_mixins.py) [1] [2]These changes collectively modernize SSVC schema management and make it easier to maintain and extend in the future.