Skip to content

Commit

Permalink
Update new tests for usnistgov#383.
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-nist committed Jun 23, 2023
1 parent a5a38b3 commit 039fc05
Show file tree
Hide file tree
Showing 15 changed files with 6,715 additions and 0 deletions.
2,692 changes: 2,692 additions & 0 deletions test-suite/metaschema-xspec/json-schema-gen/json-schema-gen-report.html

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions test-suite/metaschema-xspec/json-schema-gen/json-schema-gen.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_field_constrained-sortof.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="if has a $schema directive and does not import other Metaschema modules">
<x:context href="schema_directive_no-imports.xml"/>
<x:expect label="the resulting JSON Schema does not require but optionally allows the $schema declaration in document instances."
test="$x:result => j:json-to-xml()" select="'../schema_directive_no-imports.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="if has a $schema directive and does import other Metaschema modules">
<x:context href="schema_directive_importing.xml"/>
<x:expect label="the resulting JSON Schema does not require but optionally allows the $schema declaration in document instances."
test="$x:result => j:json-to-xml()" select="'../schema_directive_importing.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
</x:scenario>
</x:scenario>
</x:description>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="metaschema-author.css"?>
<METASCHEMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../../../schema/xml/metaschema.xsd"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no">
<schema-name>JSON value testing mini metaschema</schema-name>
<schema-version>0.1</schema-version>
<short-name>schema-directive-imported1</short-name>
<namespace>http://csrc.nist.gov/ns/metaschema-tests/1.0</namespace>
<json-base-uri>http://csrc.nist.gov/ns/metaschema-tests</json-base-uri>
<import href="schema_directive_imported.xml"/>
<define-assembly name="root1">
<formal-name>Root</formal-name>
<description>Example root to test for schema directive in the imported module.</description>
<root-name>root1</root-name>
</define-assembly>
</METASCHEMA>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="metaschema-author.css"?>
<METASCHEMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../../../schema/xml/metaschema.xsd"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no">
<schema-name>JSON value testing mini metaschema</schema-name>
<schema-version>0.1</schema-version>
<short-name>schema-directive-imported2</short-name>
<namespace>http://csrc.nist.gov/ns/metaschema-tests/1.0</namespace>
<json-base-uri>http://csrc.nist.gov/ns/metaschema-tests</json-base-uri>
<import href="schema_directive_imported.xml"/>
<define-assembly name="root2">
<formal-name>Root</formal-name>
<description>Example root to test for schema directive in the imported module.</description>
<root-name>root2</root-name>
</define-assembly>
</METASCHEMA>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/schema-directive-no-imports-schema.json",
"$comment": "JSON value testing mini metaschema: JSON Schema",
"type": "object",
"definitions": {
"json-schema-directive": {
"title": "Schema Directive",
"description": "A JSON Schema directive to bind a specific schema to its document instance.",
"$id": "#json-schema-directive",
"$ref": "#/definitions/URIReferenceDatatype"
},
"schema-directive-no-imports-schema-directive-imported1:root1": {
"title": "Root",
"description": "Example root to test for schema directive in the imported module.",
"$id": "#assembly_schema-directive-imported1_root1",
"type": "object",
"additionalProperties": false
},
"schema-directive-no-imports-schema-directive-imported2:root2": {
"title": "Root",
"description": "Example root to test for schema directive in the imported module.",
"$id": "#assembly_schema-directive-imported2_root2",
"type": "object",
"additionalProperties": false
},
"URIReferenceDatatype": {
"description": "A URI Reference, either a URI or a relative-reference, formatted according to section 4.1 of RFC3986.",
"type": "string",
"format": "uri-reference"
}
},
"oneOf": [
{
"properties": {
"$schema": {
"$ref": "#json-schema-directive"
},
"root1": {
"$ref": "#assembly_schema-directive-imported1_root1"
}
},
"required": [
"root1"
],
"additionalProperties": false
},
{
"properties": {
"$schema": {
"$ref": "#json-schema-directive"
},
"root2": {
"$ref": "#assembly_schema-directive-imported2_root2"
}
},
"required": [
"root2"
],
"additionalProperties": false
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="metaschema-author.css"?>
<METASCHEMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../../../schema/xml/metaschema.xsd"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no">
<schema-name>JSON value testing mini metaschema</schema-name>
<schema-version>0.1</schema-version>
<short-name>schema-directive-no-imports</short-name>
<namespace>http://csrc.nist.gov/ns/metaschema-tests/1.0</namespace>
<json-base-uri>http://csrc.nist.gov/ns/metaschema-tests</json-base-uri>
<import href="schema_directive_imported1.xml"/>
<import href="schema_directive_imported2.xml"/>
</METASCHEMA>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "schema_directive_importing.json",
"root1": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"root2": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/schema-directive-no-imports-schema.json",
"$comment": "JSON value testing mini metaschema: JSON Schema",
"type": "object",
"definitions": {
"json-schema-directive": {
"title": "Schema Directive",
"description": "A JSON Schema directive to bind a specific schema to its document instance.",
"$id": "#json-schema-directive",
"$ref": "#/definitions/URIReferenceDatatype"
},
"schema-directive-no-imports-schema-directive-no-imports:root": {
"title": "Root",
"description": "Example root to test for schema directive in simple module.",
"$id": "#assembly_schema-directive-no-imports_root",
"type": "object",
"additionalProperties": false
},
"URIReferenceDatatype": {
"description": "A URI Reference, either a URI or a relative-reference, formatted according to section 4.1 of RFC3986.",
"type": "string",
"format": "uri-reference"
}
},
"properties": {
"$schema": {
"$ref": "#json-schema-directive"
},
"root": {
"$ref": "#assembly_schema-directive-no-imports_root"
}
},
"required": [
"root"
],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="metaschema-author.css"?>
<METASCHEMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../../../schema/xml/metaschema.xsd"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no">
<schema-name>JSON value testing mini metaschema</schema-name>
<schema-version>0.1</schema-version>
<short-name>schema-directive-no-imports</short-name>
<namespace>http://csrc.nist.gov/ns/metaschema-tests/1.0</namespace>
<json-base-uri>http://csrc.nist.gov/ns/metaschema-tests</json-base-uri>
<define-assembly name="root">
<formal-name>Root</formal-name>
<description>Example root to test for schema directive in simple module.</description>
<root-name>root</root-name>
</define-assembly>
</METASCHEMA>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "schema_directive_no-imports.json",
"root": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"root": {}
}
Loading

0 comments on commit 039fc05

Please sign in to comment.