From 13cde791af0dc8682f7dd1532e36205ce968e20d Mon Sep 17 00:00:00 2001 From: "A.J. Stein" Date: Mon, 26 Jun 2023 17:51:25 -0400 Subject: [PATCH] Update tests to support corrected JSON Schema Generation PR (#380) * Correct field and flag enumerations in JSON schemas. Previously in usnistgov/metaschema#360, @kylelaker reported a needed improvement to fix a regression for usnistgov/OSCAL#1773. While I had been completing testing in #360 and properly expanding test coverage to address how we handle enumerations based on allow-other and target attributes for field and flag elements in Metaschema (both act similarly but subtly different with more scenarios for field), I observed my test data instances needed further correction in a way that cannot be address in the PR by Kyle. This merges the changes from the commit reffed by the URL below, adds my enhancement, tests, and all examples that helped me uncover missing code. https://github.com/usnistgov/metaschema/pull/360/commits/6fb8a7457ef1148589fda1de9ccc0d51d9986a97 * Surpress bottlecaps.de link fail More info below: https://github.com/usnistgov/metaschema/actions/runs/5228171226/jobs/9440341454 Co-authored-by: Kyle Laker --- build/config/.markdown-link-check/config.json | 3 + .../json-schema-gen/json-schema-gen.xspec | 70 ++++++++++-------- .../json-value_constrained-closed.json | 70 ------------------ .../json-value_constrained-narrow.json | 58 --------------- .../json-value_constrained-open.json | 70 ------------------ .../json-value_constrained-sortof.json | 58 --------------- .../json-value_field_constrained-closed.json | 53 ++++++++++++++ ...field_constrained-closed_example_FAIL.json | 5 ++ ...field_constrained-closed_example_PASS.json | 5 ++ ...e_field_constrained-closed_metaschema.xml} | 22 +++--- .../json-value_field_constrained-narrow.json | 41 +++++++++++ ...field_constrained-narrow_example-FAIL.json | 5 ++ ...ield_constrained-narrow_example-PASS1.json | 5 ++ ...ield_constrained-narrow_example-PASS2.json | 5 ++ ...e_field_constrained-narrow_metaschema.xml} | 23 +++--- .../json-value_field_constrained-open.json | 53 ++++++++++++++ ...e_field_constrained-open_example-FAIL.json | 5 ++ ..._field_constrained-open_example-PASS1.json | 5 ++ ..._field_constrained-open_example-PASS2.json | 5 ++ ...lue_field_constrained-open_metaschema.xml} | 22 +++--- .../json-value_field_constrained-sortof.json | 41 +++++++++++ ...field_constrained-sortof_example-FAIL.json | 5 ++ ...ield_constrained-sortof_example-PASS1.json | 5 ++ ...ield_constrained-sortof_example-PASS2.json | 5 ++ ...e_field_constrained-sortof_metaschema.xml} | 22 +++--- .../json-value_field_unconstrained.json | 41 +++++++++++ ...alue_field_unconstrained_example-FAIL.json | 5 ++ ...alue_field_unconstrained_example-PASS.json | 5 ++ ...n-value_field_unconstrained_metaschema.xml | 26 +++++++ .../json-value_flag_constrained-closed.json | 72 +++++++++++++++++++ ..._flag_constrained-closed_example-FAIL.json | 8 +++ ..._flag_constrained-closed_example-PASS.json | 8 +++ ...lue_flag_constrained-closed_metaschema.xml | 38 ++++++++++ .../json-value_flag_constrained-open.json | 72 +++++++++++++++++++ ...ue_flag_constrained-open_example-FAIL.json | 8 +++ ...e_flag_constrained-open_example-PASS1.json | 8 +++ ...e_flag_constrained-open_example-PASS2.json | 8 +++ ...value_flag_constrained-open_metaschema.xml | 38 ++++++++++ ...son => json-value_flag_unconstrained.json} | 36 +++++----- ...value_flag_unconstrained_example-FAIL.json | 8 +++ ...value_flag_unconstrained_example-PASS.json | 8 +++ ...n-value_flag_unconstrained_metaschema.xml} | 22 +++--- .../schema-gen/make-json-schema-metamap.xsl | 16 ++++- 43 files changed, 720 insertions(+), 368 deletions(-) delete mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed.json delete mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow.json delete mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open.json delete mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_PASS.json rename test-suite/metaschema-xspec/json-schema-gen/{json-value_constrained-closed_metaschema.xml => json-value_field_constrained-closed_metaschema.xml} (61%) create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS1.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS2.json rename test-suite/metaschema-xspec/json-schema-gen/{json-value_constrained-narrow_metaschema.xml => json-value_field_constrained-narrow_metaschema.xml} (58%) create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS1.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS2.json rename test-suite/metaschema-xspec/json-schema-gen/{json-value_constrained-open_metaschema.xml => json-value_field_constrained-open_metaschema.xml} (61%) create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS1.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS2.json rename test-suite/metaschema-xspec/json-schema-gen/{json-value_constrained-sortof_metaschema.xml => json-value_field_constrained-sortof_metaschema.xml} (58%) create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-PASS.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_metaschema.xml create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-PASS.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_metaschema.xml create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS1.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS2.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_metaschema.xml rename test-suite/metaschema-xspec/json-schema-gen/{json-value_unconstrained.json => json-value_flag_unconstrained.json} (52%) create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-FAIL.json create mode 100644 test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-PASS.json rename test-suite/metaschema-xspec/json-schema-gen/{json-value_unconstrained_metaschema.xml => json-value_flag_unconstrained_metaschema.xml} (60%) diff --git a/build/config/.markdown-link-check/config.json b/build/config/.markdown-link-check/config.json index 34d5646ae..15376ad33 100644 --- a/build/config/.markdown-link-check/config.json +++ b/build/config/.markdown-link-check/config.json @@ -8,6 +8,9 @@ }, { "pattern": "https://help.github.com" + }, + { + "pattern": "https://www.bottlecaps.de/rex/" } ], "replacementPatterns": [ diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-schema-gen.xspec b/test-suite/metaschema-xspec/json-schema-gen/json-schema-gen.xspec index 0dbb8f096..9482a3897 100644 --- a/test-suite/metaschema-xspec/json-schema-gen/json-schema-gen.xspec +++ b/test-suite/metaschema-xspec/json-schema-gen/json-schema-gen.xspec @@ -3,36 +3,50 @@ xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0" xmlns:j="http://www.w3.org/2005/xpath-functions" stylesheet="../../../toolchains/xslt-M4/nist-metaschema-MAKE-JSON-SCHEMA.xsl" run-as="external"> - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed.json deleted file mode 100644 index 60f2b2734..000000000 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-schema-value-test-constrained-closed-schema.json", - "$comment": "JSON value testing mini metaschema: JSON Schema", - "type": "object", - "definitions": { - "json-schema-value-test-constrained-closed-json-schema-value-test-constrained-closed:root": { - "title": "Root", - "description": "Root root root.", - "$id": "#assembly_json-schema-value-test-constrained-closed_root", - "type": "object", - "properties": { - "constrained-closed": { - "$ref": "#field_json-schema-value-test-constrained-closed_constrained-closed" - } - }, - "additionalProperties": false - }, - "json-schema-value-test-constrained-closed-json-schema-value-test-constrained-closed:constrained-closed": { - "title": "Constrained closed", - "description": "Because allow-other is 'no' an enumeration can be given in the JSON Schema.", - "$id": "#field_json-schema-value-test-constrained-closed_constrained-closed", - "type": "object", - "properties": { - "some": { - "title": "Some Flag", - "description": "Some flag some flag some flag.", - "$ref": "#/definitions/StringDatatype" - }, - "token-value": { - "allOf": [ - { - "$ref": "#/definitions/TokenDatatype" - }, - { - "enum": [ - "one", - "two", - "three", - "four" - ] - } - ] - } - }, - "required": [ - "token-value" - ], - "additionalProperties": false - }, - "StringDatatype": { - "type": "string", - "pattern": "^\\S(.*\\S)?$" - }, - "TokenDatatype": { - "type": "string", - "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" - } - }, - "properties": { - "root": { - "$ref": "#assembly_json-schema-value-test-constrained-closed_root" - } - }, - "required": [ - "root" - ], - "additionalProperties": false, - "maxProperties": 1 -} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow.json deleted file mode 100644 index 29a7bc7af..000000000 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-schema-value-test-constrained-narrow-schema.json", - "$comment": "JSON value testing mini metaschema: JSON Schema", - "type": "object", - "definitions": { - "json-schema-value-test-constrained-narrow-json-schema-value-test-constrained-narrow:root": { - "title": "Root", - "description": "Root root root.", - "$id": "#assembly_json-schema-value-test-constrained-narrow_root", - "type": "object", - "properties": { - "constrained-narrow": { - "$ref": "#field_json-schema-value-test-constrained-narrow_constrained-narrow" - } - }, - "additionalProperties": false - }, - "json-schema-value-test-constrained-narrow-json-schema-value-test-constrained-narrow:constrained-narrow": { - "title": "Constrained narrow", - "description": "Although allow-other is 'no' an enumeration can't be given in the JSON Schema since it targets a qualified set (only a subset) of the elements in scope.", - "$id": "#field_json-schema-value-test-constrained-narrow_constrained-narrow", - "type": "object", - "properties": { - "some": { - "title": "Some Flag", - "description": "Some flag some flag some flag.", - "$ref": "#/definitions/StringDatatype" - }, - "token-value": { - "$ref": "#/definitions/TokenDatatype" - } - }, - "required": [ - "token-value" - ], - "additionalProperties": false - }, - "StringDatatype": { - "type": "string", - "pattern": "^\\S(.*\\S)?$" - }, - "TokenDatatype": { - "type": "string", - "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" - } - }, - "properties": { - "root": { - "$ref": "#assembly_json-schema-value-test-constrained-narrow_root" - } - }, - "required": [ - "root" - ], - "additionalProperties": false, - "maxProperties": 1 -} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open.json deleted file mode 100644 index 9c44e32d6..000000000 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-schema-value-test-constrained-open-schema.json", - "$comment": "JSON value testing mini metaschema: JSON Schema", - "type": "object", - "definitions": { - "json-schema-value-test-constrained-open-json-schema-value-test-constrained-open:root": { - "title": "Root", - "description": "Root root root.", - "$id": "#assembly_json-schema-value-test-constrained-open_root", - "type": "object", - "properties": { - "constrained-open": { - "$ref": "#field_json-schema-value-test-constrained-open_constrained-open" - } - }, - "additionalProperties": false - }, - "json-schema-value-test-constrained-open-json-schema-value-test-constrained-open:constrained-open": { - "title": "Constrained open", - "description": "Because allow-other is 'yes' no enumeration can be given in the JSON Schema.", - "$id": "#field_json-schema-value-test-constrained-open_constrained-open", - "type": "object", - "properties": { - "some": { - "title": "Some Flag", - "description": "Some flag some flag some flag.", - "$ref": "#/definitions/StringDatatype" - }, - "token-value": { - "anyOf": [ - { - "$ref": "#/definitions/TokenDatatype" - }, - { - "enum": [ - "one", - "two", - "three", - "four" - ] - } - ] - } - }, - "required": [ - "token-value" - ], - "additionalProperties": false - }, - "StringDatatype": { - "type": "string", - "pattern": "^\\S(.*\\S)?$" - }, - "TokenDatatype": { - "type": "string", - "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" - } - }, - "properties": { - "root": { - "$ref": "#assembly_json-schema-value-test-constrained-open_root" - } - }, - "required": [ - "root" - ], - "additionalProperties": false, - "maxProperties": 1 -} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof.json deleted file mode 100644 index e82778626..000000000 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-schema-value-test-constrained-sortof-schema.json", - "$comment": "JSON value testing mini metaschema: JSON Schema", - "type": "object", - "definitions": { - "json-schema-value-test-constrained-sortof-json-schema-value-test-constrained-sortof:root": { - "title": "Root", - "description": "Root root root.", - "$id": "#assembly_json-schema-value-test-constrained-sortof_root", - "type": "object", - "properties": { - "constrained-sortof": { - "$ref": "#field_json-schema-value-test-constrained-sortof_constrained-sortof" - } - }, - "additionalProperties": false - }, - "json-schema-value-test-constrained-sortof-json-schema-value-test-constrained-sortof:constrained-sortof": { - "title": "Constrained, sort of", - "description": "Although allow-other is 'no' an enumeration can't be given in the JSON Schema since it targets a qualified set (only a subset) of the elements in scope.", - "$id": "#field_json-schema-value-test-constrained-sortof_constrained-sortof", - "type": "object", - "properties": { - "some": { - "title": "Some Flag", - "description": "Some flag some flag some flag.", - "$ref": "#/definitions/StringDatatype" - }, - "token-value": { - "$ref": "#/definitions/TokenDatatype" - } - }, - "required": [ - "token-value" - ], - "additionalProperties": false - }, - "StringDatatype": { - "type": "string", - "pattern": "^\\S(.*\\S)?$" - }, - "TokenDatatype": { - "type": "string", - "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" - } - }, - "properties": { - "root": { - "$ref": "#assembly_json-schema-value-test-constrained-sortof_root" - } - }, - "required": [ - "root" - ], - "additionalProperties": false, - "maxProperties": 1 -} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed.json new file mode 100644 index 000000000..3cde39864 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-value_field_constrained-closed-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-value_field_constrained-closed-json-value_field_constrained-closed:test-root": { + "title": "Root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-value_field_constrained-closed_test-root", + "type": "object", + "properties": { + "test-field": { + "$ref": "#field_json-value_field_constrained-closed_test-field" + } + }, + "additionalProperties": false + }, + "json-value_field_constrained-closed-json-value_field_constrained-closed:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-value_field_constrained-closed_test-field", + "allOf": [ + { + "$ref": "#/definitions/TokenDatatype" + }, + { + "enum": [ + "one", + "two", + "three", + "four" + ] + } + ] + }, + "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type": "string", + "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" + } + }, + "properties": { + "test-root": { + "$ref": "#assembly_json-value_field_constrained-closed_test-root" + } + }, + "required": [ + "test-root" + ], + "additionalProperties": false, + "maxProperties": 1 +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_FAIL.json new file mode 100644 index 000000000..76fbd17d3 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_FAIL.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "anything" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_PASS.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_PASS.json new file mode 100644 index 000000000..3d6d76e7c --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_example_PASS.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "four" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_metaschema.xml similarity index 61% rename from test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed_metaschema.xml rename to test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_metaschema.xml index b7cf2f044..a9cda9493 100644 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed_metaschema.xml +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-closed_metaschema.xml @@ -5,27 +5,23 @@ xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no"> JSON value testing mini metaschema 0.1 - json-schema-value-test-constrained-closed + json-value_field_constrained-closed http://csrc.nist.gov/ns/metaschema-tests/1.0 http://csrc.nist.gov/ns/metaschema-tests - + Root - Root root root. - root + The root assembly of this example module. + test-root - + - Constrained closed - Because allow-other is 'no' an enumeration can be given in the JSON Schema. - token-value - - Some Flag - Some flag some flag some flag. - + name="test-field"> + Test Field + A test field. + test-json-key-value diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow.json new file mode 100644 index 000000000..5f6e78046 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-value_field_constrained-narrow-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-value_field_constrained-narrow-json-value_field_constrained-narrow:test-root": { + "title": "Root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-value_field_constrained-narrow_test-root", + "type": "object", + "properties": { + "test-field": { + "$ref": "#field_json-value_field_constrained-narrow_test-field" + } + }, + "additionalProperties": false + }, + "json-value_field_constrained-narrow-json-value_field_constrained-narrow:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-value_field_constrained-narrow_test-field", + "$ref": "#/definitions/TokenDatatype" + }, + "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type": "string", + "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" + } + }, + "properties": { + "test-root": { + "$ref": "#assembly_json-value_field_constrained-narrow_test-root" + } + }, + "required": [ + "test-root" + ], + "additionalProperties": false, + "maxProperties": 1 +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-FAIL.json new file mode 100644 index 000000000..20eb8b1d8 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-FAIL.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": false + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS1.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS1.json new file mode 100644 index 000000000..76fbd17d3 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS1.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "anything" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS2.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS2.json new file mode 100644 index 000000000..890813576 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_example-PASS2.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "three" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_metaschema.xml similarity index 58% rename from test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow_metaschema.xml rename to test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_metaschema.xml index dcb921049..9588dddb6 100644 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow_metaschema.xml +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-narrow_metaschema.xml @@ -5,28 +5,23 @@ xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no"> JSON value testing mini metaschema 0.1 - json-schema-value-test-constrained-narrow + json-value_field_constrained-narrow http://csrc.nist.gov/ns/metaschema-tests/1.0 http://csrc.nist.gov/ns/metaschema-tests - + Root - Root root root. - root + The root assembly of this example module. + test-root - + - - Constrained narrow - Although allow-other is 'no' an enumeration can't be given in the JSON Schema since it targets a qualified set (only a subset) of the elements in scope. - token-value - - Some Flag - Some flag some flag some flag. - + name="test-field"> + Test Field + A test field. + test-json-key-value diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open.json new file mode 100644 index 000000000..dbd0de8d8 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-value_field_constrained-open-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-value_field_constrained-open-json-value_field_constrained-open:test-root": { + "title": "Root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-value_field_constrained-open_test-root", + "type": "object", + "properties": { + "test-field": { + "$ref": "#field_json-value_field_constrained-open_test-field" + } + }, + "additionalProperties": false + }, + "json-value_field_constrained-open-json-value_field_constrained-open:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-value_field_constrained-open_test-field", + "anyOf": [ + { + "$ref": "#/definitions/TokenDatatype" + }, + { + "enum": [ + "one", + "two", + "three", + "four" + ] + } + ] + }, + "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type": "string", + "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" + } + }, + "properties": { + "test-root": { + "$ref": "#assembly_json-value_field_constrained-open_test-root" + } + }, + "required": [ + "test-root" + ], + "additionalProperties": false, + "maxProperties": 1 +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-FAIL.json new file mode 100644 index 000000000..20eb8b1d8 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-FAIL.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": false + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS1.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS1.json new file mode 100644 index 000000000..76fbd17d3 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS1.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "anything" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS2.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS2.json new file mode 100644 index 000000000..d038cbe3e --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_example-PASS2.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "two" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_metaschema.xml similarity index 61% rename from test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open_metaschema.xml rename to test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_metaschema.xml index a2760aee7..74571dfe9 100644 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open_metaschema.xml +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-open_metaschema.xml @@ -5,27 +5,23 @@ xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no"> JSON value testing mini metaschema 0.1 - json-schema-value-test-constrained-open + json-value_field_constrained-open http://csrc.nist.gov/ns/metaschema-tests/1.0 http://csrc.nist.gov/ns/metaschema-tests - + Root - Root root root. - root + The root assembly of this example module. + test-root - + - Constrained open - Because allow-other is 'yes' no enumeration can be given in the JSON Schema. - token-value - - Some Flag - Some flag some flag some flag. - + name="test-field"> + Test Field + A test field. + test-json-key-value diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof.json new file mode 100644 index 000000000..1244edd60 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-value_field_constrained-sortof-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-value_field_constrained-sortof-json-value_field_constrained-sortof:test-root": { + "title": "Root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-value_field_constrained-sortof_test-root", + "type": "object", + "properties": { + "test-field": { + "$ref": "#field_json-value_field_constrained-sortof_test-field" + } + }, + "additionalProperties": false + }, + "json-value_field_constrained-sortof-json-value_field_constrained-sortof:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-value_field_constrained-sortof_test-field", + "$ref": "#/definitions/TokenDatatype" + }, + "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type": "string", + "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" + } + }, + "properties": { + "test-root": { + "$ref": "#assembly_json-value_field_constrained-sortof_test-root" + } + }, + "required": [ + "test-root" + ], + "additionalProperties": false, + "maxProperties": 1 +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-FAIL.json new file mode 100644 index 000000000..20eb8b1d8 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-FAIL.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": false + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS1.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS1.json new file mode 100644 index 000000000..76fbd17d3 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS1.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "anything" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS2.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS2.json new file mode 100644 index 000000000..d038cbe3e --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_example-PASS2.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "two" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_metaschema.xml similarity index 58% rename from test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof_metaschema.xml rename to test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_metaschema.xml index 7b28d4f01..76c8b695b 100644 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof_metaschema.xml +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_constrained-sortof_metaschema.xml @@ -5,27 +5,23 @@ xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" abstract="no"> JSON value testing mini metaschema 0.1 - json-schema-value-test-constrained-sortof + json-value_field_constrained-sortof http://csrc.nist.gov/ns/metaschema-tests/1.0 http://csrc.nist.gov/ns/metaschema-tests - + Root - Root root root. - root + The root assembly of this example module. + test-root - + - Constrained, sort of - Although allow-other is 'no' an enumeration can't be given in the JSON Schema since it targets a qualified set (only a subset) of the elements in scope. - token-value - - Some Flag - Some flag some flag some flag. - + name="test-field"> + Test Field + A test field. + test-json-key-value diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained.json new file mode 100644 index 000000000..64734582e --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-value_field_unconstrained-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-value_field_unconstrained-json-value_field_unconstrained:test-root": { + "title": "Root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-value_field_unconstrained_test-root", + "type": "object", + "properties": { + "test-field": { + "$ref": "#field_json-value_field_unconstrained_test-field" + } + }, + "additionalProperties": false + }, + "json-value_field_unconstrained-json-value_field_unconstrained:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-value_field_unconstrained_test-field", + "$ref": "#/definitions/TokenDatatype" + }, + "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type": "string", + "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" + } + }, + "properties": { + "test-root": { + "$ref": "#assembly_json-value_field_unconstrained_test-root" + } + }, + "required": [ + "test-root" + ], + "additionalProperties": false, + "maxProperties": 1 +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-FAIL.json new file mode 100644 index 000000000..20eb8b1d8 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-FAIL.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": false + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-PASS.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-PASS.json new file mode 100644 index 000000000..76fbd17d3 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_example-PASS.json @@ -0,0 +1,5 @@ +{ + "test-root": { + "test-field": "anything" + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_metaschema.xml new file mode 100644 index 000000000..8f77ea819 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_field_unconstrained_metaschema.xml @@ -0,0 +1,26 @@ + + + + JSON value testing mini metaschema + 0.1 + json-value_field_unconstrained + http://csrc.nist.gov/ns/metaschema-tests/1.0 + http://csrc.nist.gov/ns/metaschema-tests + + Root + The root assembly of this example module. + test-root + + + + + + Test Field + A test field. + test-json-key-value + + diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed.json new file mode 100644 index 000000000..b4fcc949f --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-value_flag_constrained-closed-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-value_flag_constrained-closed-json-value_flag_constrained-closed:test-root": { + "title": "Root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-value_flag_constrained-closed_test-root", + "type": "object", + "properties": { + "test-field": { + "$ref": "#field_json-value_flag_constrained-closed_test-field" + } + }, + "additionalProperties": false + }, + "json-value_flag_constrained-closed-json-value_flag_constrained-closed:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-value_flag_constrained-closed_test-field", + "type": "object", + "properties": { + "test-flag": { + "title": "Test Flag", + "description": "A test flag.", + "allOf": [ + { + "$ref": "#/definitions/StringDatatype" + }, + { + "enum": [ + "one", + "two", + "three", + "four" + ] + } + ] + }, + "test-json-key-value": { + "$ref": "#/definitions/TokenDatatype" + } + }, + "required": [ + "test-json-key-value" + ], + "additionalProperties": false + }, + "StringDatatype": { + "description": "A non-empty string with leading and trailing whitespace disallowed. Whitespace is: U+9, U+10, U+32 or [ \n\t]+", + "type": "string", + "pattern": "^\\S(.*\\S)?$" + }, + "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type": "string", + "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" + } + }, + "properties": { + "test-root": { + "$ref": "#assembly_json-value_flag_constrained-closed_test-root" + } + }, + "required": [ + "test-root" + ], + "additionalProperties": false, + "maxProperties": 1 +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-FAIL.json new file mode 100644 index 000000000..e5bf71426 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-FAIL.json @@ -0,0 +1,8 @@ +{ + "test-root": { + "test-field": { + "test-flag": "anything1", + "test-json-key-value": "anything2" + } + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-PASS.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-PASS.json new file mode 100644 index 000000000..212166af4 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_example-PASS.json @@ -0,0 +1,8 @@ +{ + "test-root": { + "test-field": { + "test-flag": "four", + "test-json-key-value": "anything2" + } + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_metaschema.xml new file mode 100644 index 000000000..86ba99869 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-closed_metaschema.xml @@ -0,0 +1,38 @@ + + + + JSON value testing mini metaschema + 0.1 + json-value_flag_constrained-closed + http://csrc.nist.gov/ns/metaschema-tests/1.0 + http://csrc.nist.gov/ns/metaschema-tests + + Root + The root assembly of this example module. + test-root + + + + + + Test Field + A test field. + test-json-key-value + + Test Flag + A test flag. + + + + + + + + + + + diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open.json new file mode 100644 index 000000000..b47eff488 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-value_flag_constrained-open-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-value_flag_constrained-open-json-value_flag_constrained-open:test-root": { + "title": "Root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-value_flag_constrained-open_test-root", + "type": "object", + "properties": { + "test-field": { + "$ref": "#field_json-value_flag_constrained-open_test-field" + } + }, + "additionalProperties": false + }, + "json-value_flag_constrained-open-json-value_flag_constrained-open:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-value_flag_constrained-open_test-field", + "type": "object", + "properties": { + "test-flag": { + "title": "Test Flag", + "description": "A test flag.", + "anyOf": [ + { + "$ref": "#/definitions/StringDatatype" + }, + { + "enum": [ + "one", + "two", + "three", + "four" + ] + } + ] + }, + "test-json-key-value": { + "$ref": "#/definitions/TokenDatatype" + } + }, + "required": [ + "test-json-key-value" + ], + "additionalProperties": false + }, + "StringDatatype": { + "description": "A non-empty string with leading and trailing whitespace disallowed. Whitespace is: U+9, U+10, U+32 or [ \n\t]+", + "type": "string", + "pattern": "^\\S(.*\\S)?$" + }, + "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type": "string", + "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" + } + }, + "properties": { + "test-root": { + "$ref": "#assembly_json-value_flag_constrained-open_test-root" + } + }, + "required": [ + "test-root" + ], + "additionalProperties": false, + "maxProperties": 1 +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-FAIL.json new file mode 100644 index 000000000..caf5f01e7 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-FAIL.json @@ -0,0 +1,8 @@ +{ + "test-root": { + "test-field": { + "test-flag": false, + "test-json-key-value": false + } + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS1.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS1.json new file mode 100644 index 000000000..e5bf71426 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS1.json @@ -0,0 +1,8 @@ +{ + "test-root": { + "test-field": { + "test-flag": "anything1", + "test-json-key-value": "anything2" + } + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS2.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS2.json new file mode 100644 index 000000000..5cf66abe1 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_example-PASS2.json @@ -0,0 +1,8 @@ +{ + "test-root": { + "test-field": { + "test-flag": "one", + "test-json-key-value": "anything2" + } + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_metaschema.xml new file mode 100644 index 000000000..bc94acd28 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_constrained-open_metaschema.xml @@ -0,0 +1,38 @@ + + + + JSON value testing mini metaschema + 0.1 + json-value_flag_constrained-open + http://csrc.nist.gov/ns/metaschema-tests/1.0 + http://csrc.nist.gov/ns/metaschema-tests + + Root + The root assembly of this example module. + test-root + + + + + + Test Field + A test field. + test-json-key-value + + Test Flag + A test flag. + + + + + + + + + + + diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained.json similarity index 52% rename from test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained.json rename to test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained.json index b2533606f..863cb11cf 100644 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained.json +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained.json @@ -4,54 +4,56 @@ "$comment": "JSON value testing mini metaschema: JSON Schema", "type": "object", "definitions": { - "json-schema-value-test-unconstrained-json-schema-value-test-unconstrained:root": { + "json-schema-value-test-unconstrained-json-schema-value-test-unconstrained:test-root": { "title": "Root", - "description": "Root root root.", - "$id": "#assembly_json-schema-value-test-unconstrained_root", + "description": "The root assembly of this example module.", + "$id": "#assembly_json-schema-value-test-unconstrained_test-root", "type": "object", "properties": { - "unconstrained": { - "$ref": "#field_json-schema-value-test-unconstrained_unconstrained" + "test-field": { + "$ref": "#field_json-schema-value-test-unconstrained_test-field" } }, "additionalProperties": false }, - "json-schema-value-test-unconstrained-json-schema-value-test-unconstrained:unconstrained": { - "title": "Unconstrained", - "description": "A field whose value is constrained only by its nominal datatype, 'token'.", - "$id": "#field_json-schema-value-test-unconstrained_unconstrained", + "json-schema-value-test-unconstrained-json-schema-value-test-unconstrained:test-field": { + "title": "Test Field", + "description": "A test field.", + "$id": "#field_json-schema-value-test-unconstrained_test-field", "type": "object", "properties": { - "some": { - "title": "Some Flag", - "description": "Some flag some flag some flag.", + "test-flag": { + "title": "Test Flag", + "description": "A test flag.", "$ref": "#/definitions/StringDatatype" }, - "token-value": { + "test-json-key-value": { "$ref": "#/definitions/TokenDatatype" } }, "required": [ - "token-value" + "test-json-key-value" ], "additionalProperties": false }, "StringDatatype": { + "description": "A non-empty string with leading and trailing whitespace disallowed. Whitespace is: U+9, U+10, U+32 or [ \n\t]+", "type": "string", "pattern": "^\\S(.*\\S)?$" }, "TokenDatatype": { + "description": "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", "type": "string", "pattern": "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" } }, "properties": { - "root": { - "$ref": "#assembly_json-schema-value-test-unconstrained_root" + "test-root": { + "$ref": "#assembly_json-schema-value-test-unconstrained_test-root" } }, "required": [ - "root" + "test-root" ], "additionalProperties": false, "maxProperties": 1 diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-FAIL.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-FAIL.json new file mode 100644 index 000000000..caf5f01e7 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-FAIL.json @@ -0,0 +1,8 @@ +{ + "test-root": { + "test-field": { + "test-flag": false, + "test-json-key-value": false + } + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-PASS.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-PASS.json new file mode 100644 index 000000000..e5bf71426 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_example-PASS.json @@ -0,0 +1,8 @@ +{ + "test-root": { + "test-field": { + "test-flag": "anything1", + "test-json-key-value": "anything2" + } + } +} \ No newline at end of file diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_metaschema.xml similarity index 60% rename from test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained_metaschema.xml rename to test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_metaschema.xml index 69d7ad4ce..226dcd1d7 100644 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained_metaschema.xml +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_flag_unconstrained_metaschema.xml @@ -8,23 +8,23 @@ json-schema-value-test-unconstrained http://csrc.nist.gov/ns/metaschema-tests/1.0 http://csrc.nist.gov/ns/metaschema-tests - + Root - Root root root. - root + The root assembly of this example module. + test-root - + - Unconstrained - A field whose value is constrained only by its nominal datatype, 'token'. - token-value - - Some Flag - Some flag some flag some flag. + name="test-field"> + Test Field + A test field. + test-json-key-value + + Test Flag + A test flag. diff --git a/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl b/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl index 55abc1e33..89ca6d865 100644 --- a/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl +++ b/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl @@ -194,8 +194,18 @@ - - + + + + + + + + + + + + @@ -596,4 +606,4 @@ - + \ No newline at end of file