Skip to content
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

JSON Schema References are Incorrect #933

Closed
rgauss opened this issue May 19, 2021 · 8 comments
Closed

JSON Schema References are Incorrect #933

rgauss opened this issue May 19, 2021 · 8 comments
Assignees
Labels
bug Scope: Metaschema Issues targeted at the metaschema pipeline
Projects

Comments

@rgauss
Copy link
Contributor

rgauss commented May 19, 2021

Describe the bug

Many of the $ref values in the JSON schema seem to be incorrect. As just one example, the catalog metadata revision property specifies an array of items with type "$ref" : "#/definitions/oscal-metadata-revision" but I believe the definition has been renamed to oscal-catalog-oscal-metadata-revision.

These new object-specific definitions, such as oscal-catalog-oscal-metadata-revision, will also make it much more difficult to address an issue like #731 where we'd like to see common schemas for elements reused across different models, i.e. the profile model defines oscal-profile-oscal-metadata-revision.

Who is the bug affecting?

Anyone trying to resolve/leverage the JSON schema, this seems to affect all models.

What is affected by this bug?

The ability to properly parse/resolve the schema.

When does this occur?

Always

@rgauss rgauss added the bug label May 19, 2021
@butler54
Copy link

I just wanted to add a plus one on the object specific definitions - I understand the logic in that these are unique, however, I think referencing back to #731 it just spins the problem in a different way.

Today from a final data point of view is oscal-metadata-version consistent - yes. Is it defined 7 times with different labels yes.

This complexity makes it harder to use tooling like openapi efficiently. I think the ideal outcome is that the json schema object (from a json schema users perspective) can be generated as one global OSCAL schema. It does not have to be generated as a global schema, however, the names do need to be consistent such that a user could merge and do so themselves without creating a mess.

@rgauss
Copy link
Contributor Author

rgauss commented May 19, 2021

@butler54, OpenAPI is exactly one of the reasons we're pursing this.

We hope to put forward a proposal for the beginnings of an OSCAL REST OpenAPI definition (in a time frame closely aligned with OSCAL's 1.0 final release) that starts to explore how real world systems could map the relationships within and between the different OSCAL models.

As part of this discussion though, we need to have clear schema definitions of which objects are in fact shared vs unique, not just based on name. For example, a component-definition's component's control-implementation objects and the implemented-requirement objects contained within them are identically named and extremely similar to a system-security-plan's control-implementation objects and the implemented-requirement objects contained within them, but they are intentionally distinct objects.

@butler54
Copy link

If you are interested (or okay with) python this may be of interest (I won't claim it's perfect but we did get to an object model and at least you are able to build APIs quickly): https://github.com/IBM/compliance-trestle-flask-demo

(Could not help the little plug for https://github.com/IBM/compliance-trestle)

@david-waltermire david-waltermire added this to To do in Sprint 42 via automation May 20, 2021
@david-waltermire david-waltermire added the Scope: Metaschema Issues targeted at the metaschema pipeline label May 20, 2021
david-waltermire added a commit to usnistgov/metaschema that referenced this issue Jun 6, 2021
* Rework of docs focusing on JSON docs and model pipeline
* Improvements to composition toolchain
* Fixed a few small bugs in the metaschema-check. Improved performance of the compose pruning using an accumulator.
* Moved edge-case samples into testing directory
* Made shadowing warning a warning
* Initial commit of an Oxygen Metaschema framework.
* Creation of new compose schematron unit tests.
* Cross-linking XML and JSON syntax pages and other improvements to links
* Now building XML and JSON indexes to reference pages, with links to steps
* Reconfigured docs pipeline (XSLT entry points); adding new files including pipeline steps
* Migrating schema generation tools to new/improved composition pipeline
* Addressing usnistgov/OSCAL#902 thanks for finding this bug
* Enhancements to JSON Schema definition (with better performance too)
* Adding support for json-base-uri as a metaschema property
* Updated JSON schema $id; factoring out common docs XSLT
* Fixing IDs in JSON schema per issue usnistgov/OSCAL#933.
* Addressing datatype validation issues: whitespace collapsing; non-empty values; ncname-workalike in JSON Schema - see usnistgov/OSCAL#911  usnistgov/OSCAL#805 also #33 #67 #68
* Improvements to XSD production; fully aligning 'token' datatype across XSD and JSON Schema implementations.
* Updating bidirectional XML/JSON converter generators (#143)
* Committing a version that handles test data correctly (so far) from rebuilt metaschema composition addressing #51 #53 #76
* Now displaying constraints in documentation at point of definition;
* Docs generation revamp Reworked reference and other pages to sketch - #128 and others

Co-authored-by: Wendell Piez <wendell.piez@nist.gov>
@david-waltermire
Copy link
Contributor

This was addressed by PR #948, which has added support for a combined XML and JSON schema, along with model specific schema views.

Sprint 42 automation moved this from To do to Done Jun 7, 2021
@rgauss
Copy link
Contributor Author

rgauss commented Jun 9, 2021

While this fix looks correct after a quick 'manual' spot check of the changes it unfortunately won't solve our issue since $ref by $id rather than path seems to only be supported in OpenAPI v3.1 (and Swagger UI hasn't caught up to that yet).

It would be nice if $ref in the schemas could point to a path rather than by $id, but I understand it that might be difficult with the pipeline/tooling being used to generate the schema.

@wendellpiez
Copy link
Contributor

@rgauss would you be able to open a new ticket in the usnistgov/metaschema repo for this, possibly with a (tiny) mockup? We would gladly consider options and feasibility. There is a possibility that the Metaschema design would preclude doing this, but alternatively, maybe it is actually super-easy or could be made to be. We have to look. Thanks!

@rgauss
Copy link
Contributor Author

rgauss commented Jun 9, 2021

@wendellpiez, submitted usnistgov/metaschema#160. Thanks!

@rgauss
Copy link
Contributor Author

rgauss commented Jul 20, 2021

(tiny) mockup?

Here's an example of what the result might look like (and works with Swagger UI).

nikitawootten-nist pushed a commit to nikitawootten-nist/metaschema-xslt that referenced this issue Jul 21, 2023
* Rework of docs focusing on JSON docs and model pipeline
* Improvements to composition toolchain
* Fixed a few small bugs in the metaschema-check. Improved performance of the compose pruning using an accumulator.
* Moved edge-case samples into testing directory
* Made shadowing warning a warning
* Initial commit of an Oxygen Metaschema framework.
* Creation of new compose schematron unit tests.
* Cross-linking XML and JSON syntax pages and other improvements to links
* Now building XML and JSON indexes to reference pages, with links to steps
* Reconfigured docs pipeline (XSLT entry points); adding new files including pipeline steps
* Migrating schema generation tools to new/improved composition pipeline
* Addressing usnistgov/OSCAL#902 thanks for finding this bug
* Enhancements to JSON Schema definition (with better performance too)
* Adding support for json-base-uri as a metaschema property
* Updated JSON schema $id; factoring out common docs XSLT
* Fixing IDs in JSON schema per issue usnistgov/OSCAL#933.
* Addressing datatype validation issues: whitespace collapsing; non-empty values; ncname-workalike in JSON Schema - see usnistgov/OSCAL#911  usnistgov/OSCAL#805 also usnistgov#33 usnistgov#67 usnistgov#68
* Improvements to XSD production; fully aligning 'token' datatype across XSD and JSON Schema implementations.
* Updating bidirectional XML/JSON converter generators (#143)
* Committing a version that handles test data correctly (so far) from rebuilt metaschema composition addressing usnistgov#51 usnistgov#53 usnistgov#76
* Now displaying constraints in documentation at point of definition;
* Docs generation revamp Reworked reference and other pages to sketch - #128 and others

Co-authored-by: Wendell Piez <wendell.piez@nist.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Scope: Metaschema Issues targeted at the metaschema pipeline
Projects
No open projects
Development

No branches or pull requests

4 participants