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

Generated JSON Schema does not enforce root element #11

Closed
david-waltermire opened this issue Dec 10, 2019 · 2 comments · Fixed by #118
Closed

Generated JSON Schema does not enforce root element #11

david-waltermire opened this issue Dec 10, 2019 · 2 comments · Fixed by #118
Assignees
Labels
bug Something isn't working

Comments

@david-waltermire
Copy link
Collaborator

The toolchains/oscal-m2 implementation does not properly generate a JSON schema.

A current generated schema looks like this:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  ... snip ...
  "type": "object",
  "definitions": {
    "parent": {
      ... snip ...
    }
  },
  "properties": {
    "parent": {"$ref": "#/definitions/parent"}
    }
  }
}

But it's missing a definition of the required properties for the root object.

The following illustrates the addition of a "required" property at the end to fix this.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  ... snip ...
  "type": "object",
  "definitions": {
    "parent": {
      ... snip ...
    }
  },
  "properties": {
    "parent": {"$ref": "#/definitions/parent"}
    }
  },
  "required": [ "parent" ]
}

Unit tests that illustrate this bug are included in PR #10, which has been integrated into master.

@wendellpiez
Copy link
Collaborator

See the PR at #13

wendellpiez added a commit to wendellpiez/metaschema that referenced this issue Feb 5, 2020
david-waltermire added a commit that referenced this issue Feb 5, 2020
* integrated schema generation unit tests with new build scripting
* Work in progress on metaschema-related updates towards OSCAL SSP conversion roundtrips.
* added required top-level property to all unit-test JSON schema files
* Added XSD targets for unit testing
* oXygen project file for metaschema testing
* Updated project file
* Test coverage and planning docs
* added unit test for collapse
* fixed a bug in the test script causing expected schema files to not be compared.
* Addressing Issue #11: JSON Schema missing constraint at root
* Adding metaschema documentation. #16 usnistgov/OSCAL#596
* Added CI/CD files for website.
* Added Github issue templates.
* Addressing #12, supporting collapsibility of fields.
* Fixed website build error.
* Updating website contents and CI/CD configuration.
* Patch to catch up metaschema implementation to latest changes in the OSCAL repo.
* fixed broken links in documentation
* updated repository documentation to fix broken links
* added configuration support to build scripts
* Implemented content converter generation in build scripts
* Removed references to local files for usnistgov/OSCAL#566
* integrated schema generation unit tests with new build scripting
* Now accounting for json-value-key/json-key combination
* removed extra files

Co-authored-by: Wendell Piez <[email protected]>
david-waltermire added a commit that referenced this issue Feb 5, 2020
)

* Work in progress on metaschema-related updates towards OSCAL SSP conversion roundtrips.
* added required top-level property to all unit-test JSON schema files
* Added XSD targets for unit testing
* oXygen project file for metaschema testing
* Updated project file
* Test coverage and planning docs
* added unit test for collapse
* fixed a bug in the test script causing expected schema files to not be compared.
* Addressing Issue #11: JSON Schema missing constraint at root
* Adding metaschema documentation. #16 usnistgov/OSCAL#596
* Added CI/CD files for website.
Added Github issue templates.
* Addressing #12, supporting collapsibility of fields.
* Fixed website build error.
* Updating website contents and CI/CD configuration.
* Patch to catch up metaschema implementation to latest changes in the OSCAL repo.
* fixed broken links in documentation
* updated repository documentation to fix broken links
* added configuration support to build scripts
* Implemented content converter generation in build scripts
* Removed references to local files for usnistgov/OSCAL#566
* integrated schema generation unit tests with new build scripting
* Now accounting for json-value-key/json-key combination

Co-authored-by: David Waltermire <[email protected]>
david-waltermire added a commit that referenced this issue Feb 5, 2020
* integrated schema generation unit tests with new build scripting
* Work in progress on metaschema-related updates towards OSCAL SSP conversion roundtrips.
* added required top-level property to all unit-test JSON schema files
* Added XSD targets for unit testing
* oXygen project file for metaschema testing
* Updated project file
* Test coverage and planning docs
* added unit test for collapse
* fixed a bug in the test script causing expected schema files to not be compared.
* Addressing Issue #11: JSON Schema missing constraint at root
* Adding metaschema documentation. #16 usnistgov/OSCAL#596
* Added CI/CD files for website.
* Added Github issue templates.
* Addressing #12, supporting collapsibility of fields.
* Fixed website build error.
* Updating website contents and CI/CD configuration.
* Patch to catch up metaschema implementation to latest changes in the OSCAL repo.
* fixed broken links in documentation
* updated repository documentation to fix broken links
* added configuration support to build scripts
* Implemented content converter generation in build scripts
* Removed references to local files for usnistgov/OSCAL#566
* integrated schema generation unit tests with new build scripting
* Now accounting for json-value-key/json-key combination
* removed extra files

Co-authored-by: Wendell Piez <[email protected]>
@wendellpiez
Copy link
Collaborator

This is now working. Additionally, at the top we have

"additionalProperties" : false,
"maxProperties" : 1

which forces only a single, designated property at the root, and nothing else.

wendellpiez added a commit to wendellpiez/metaschema that referenced this issue May 5, 2020
wendellpiez added a commit to wendellpiez/metaschema that referenced this issue Jun 11, 2020
wendellpiez added a commit to wendellpiez/metaschema that referenced this issue Jun 22, 2020
david-waltermire pushed a commit that referenced this issue Sep 17, 2020
wendellpiez added a commit to wendellpiez/metaschema that referenced this issue Nov 10, 2020
david-waltermire pushed a commit that referenced this issue Nov 13, 2020
david-waltermire pushed a commit that referenced this issue Dec 21, 2020
@david-waltermire david-waltermire linked a pull request Feb 26, 2021 that will close this issue
11 tasks
@david-waltermire david-waltermire added this to the Metaschema 0.9.0 milestone Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants