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 390056de9..0dbb8f096 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 @@ -1,169 +1,38 @@ - + stylesheet="../../../toolchains/xslt-M4/nist-metaschema-MAKE-JSON-SCHEMA.xsl" run-as="external"> - - - - Unconstrained - A field whose value is constrained only by its nominal datatype, 'token'. - #field_oscal-value-testing-mini_unconstrained - object - - - Some Flag - Some flag some flag some flag. - #/definitions/StringDatatype - - - #/definitions/TokenDatatype - - - - token-value - - false - - + + - - - - Constrained closed - Because allow-other is 'no' an enumeration can be given in the JSON Schema. - #field_oscal-value-testing-mini_constrained-closed - object - - - Some Flag - Some flag some flag some flag. - #/definitions/StringDatatype - - - - - #/definitions/TokenDatatype - - - - one - two - three - four - - - - - - - token-value - - false - - + + - - - - Constrained open - Because allow-other is 'yes' no enumeration can be given in the JSON Schema. - #field_oscal-value-testing-mini_constrained-open - object - - - Some Flag - Some flag some flag some flag. - #/definitions/StringDatatype - - - - - #/definitions/TokenDatatype - - - - one - two - three - four - - - - - - - token-value - - false - - + + - - - - 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. - #field_oscal-value-testing-mini_constrained-narrow - object - - - Some Flag - Some flag some flag some flag. - #/definitions/StringDatatype - - - #/definitions/TokenDatatype - - - - token-value - - false - - + + - - - - 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. - #field_oscal-value-testing-mini_constrained-sortof - object - - - Some Flag - Some flag some flag some flag. - #/definitions/StringDatatype - - - #/definitions/TokenDatatype - - - - token-value - - false - - + + diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value-testing-mini-metaschema-COMPOSED.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value-testing-mini-metaschema-COMPOSED.xml deleted file mode 100644 index 6f0e831fe..000000000 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value-testing-mini-metaschema-COMPOSED.xml +++ /dev/null @@ -1,244 +0,0 @@ - - - Seeing assembly#oscal-value-testing-mini:root, field#oscal-value-testing-mini:unconstrained, field#oscal-value-testing-mini:constrained-open, field#oscal-value-testing-mini:constrained-closed, field#oscal-value-testing-mini:constrained-narrow, field#oscal-value-testing-mini:constrained-sortof - JSON value testing mini metaschema - 0.1 - oscal-value-testing-mini - http://csrc.nist.gov/ns/oscal/1.0 - http://csrc.nist.gov/ns/oscal - - Root - Root root root. - root - - - - - - - - - - Unconstrained - A field whose value is constrained only by its nominal datatype, 'token'. - token-value - - Some Flag - Some flag some flag some flag. - - - - 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. - - - - - - - - - - - - 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. - - - - - - - - - - - - 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. - - - - - - - - - - - - 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. - - - - - - - - - - - diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value-testing-mini-metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value-testing-mini-metaschema.xml deleted file mode 100644 index b76d841e9..000000000 --- a/test-suite/metaschema-xspec/json-schema-gen/json-value-testing-mini-metaschema.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - JSON value testing mini metaschema - 0.1 - oscal-value-testing-mini - http://csrc.nist.gov/ns/oscal/1.0 - http://csrc.nist.gov/ns/oscal - - Root - Root root root. - root - - - - - - - - - - Unconstrained - A field whose value is constrained only by its nominal datatype, 'token'. - token-value - - Some Flag - Some flag some flag some flag. - - - - 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. - - - - - - - - - - - - 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. - - - - - - - - - - - - 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. - - - - - - - - - - - - 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. - - - - - - - - - - - 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 new file mode 100644 index 000000000..60f2b2734 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed.json @@ -0,0 +1,70 @@ +{ + "$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-closed_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed_metaschema.xml new file mode 100644 index 000000000..b7cf2f044 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-closed_metaschema.xml @@ -0,0 +1,38 @@ + + + + JSON value testing mini metaschema + 0.1 + json-schema-value-test-constrained-closed + http://csrc.nist.gov/ns/metaschema-tests/1.0 + http://csrc.nist.gov/ns/metaschema-tests + + Root + Root root root. + 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. + + + + + + + + + + + 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 new file mode 100644 index 000000000..29a7bc7af --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow.json @@ -0,0 +1,58 @@ +{ + "$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-narrow_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow_metaschema.xml new file mode 100644 index 000000000..dcb921049 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-narrow_metaschema.xml @@ -0,0 +1,39 @@ + + + + JSON value testing mini metaschema + 0.1 + json-schema-value-test-constrained-narrow + http://csrc.nist.gov/ns/metaschema-tests/1.0 + http://csrc.nist.gov/ns/metaschema-tests + + Root + Root root root. + 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. + + + + + + + + + + + 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 new file mode 100644 index 000000000..9c44e32d6 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open.json @@ -0,0 +1,70 @@ +{ + "$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-open_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open_metaschema.xml new file mode 100644 index 000000000..a2760aee7 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-open_metaschema.xml @@ -0,0 +1,38 @@ + + + + JSON value testing mini metaschema + 0.1 + json-schema-value-test-constrained-open + http://csrc.nist.gov/ns/metaschema-tests/1.0 + http://csrc.nist.gov/ns/metaschema-tests + + Root + Root root root. + 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. + + + + + + + + + + + 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 new file mode 100644 index 000000000..e82778626 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof.json @@ -0,0 +1,58 @@ +{ + "$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_constrained-sortof_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof_metaschema.xml new file mode 100644 index 000000000..7b28d4f01 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_constrained-sortof_metaschema.xml @@ -0,0 +1,38 @@ + + + + JSON value testing mini metaschema + 0.1 + json-schema-value-test-constrained-sortof + http://csrc.nist.gov/ns/metaschema-tests/1.0 + http://csrc.nist.gov/ns/metaschema-tests + + Root + Root root root. + 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. + + + + + + + + + + + diff --git a/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained.json b/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained.json new file mode 100644 index 000000000..b2533606f --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://csrc.nist.gov/ns/metaschema-tests/0.1/json-schema-value-test-unconstrained-schema.json", + "$comment": "JSON value testing mini metaschema: JSON Schema", + "type": "object", + "definitions": { + "json-schema-value-test-unconstrained-json-schema-value-test-unconstrained:root": { + "title": "Root", + "description": "Root root root.", + "$id": "#assembly_json-schema-value-test-unconstrained_root", + "type": "object", + "properties": { + "unconstrained": { + "$ref": "#field_json-schema-value-test-unconstrained_unconstrained" + } + }, + "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", + "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-unconstrained_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_unconstrained_metaschema.xml b/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained_metaschema.xml new file mode 100644 index 000000000..69d7ad4ce --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-value_unconstrained_metaschema.xml @@ -0,0 +1,30 @@ + + + + JSON value testing mini metaschema + 0.1 + 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 + + + + + + Unconstrained + A field whose value is constrained only by its nominal datatype, 'token'. + token-value + + Some Flag + Some flag some flag some 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 ff22c30fe..a36d62c9a 100644 --- a/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl +++ b/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl @@ -2,49 +2,51 @@ - - - + + + + + + + + + - + - - STRVALUE RICHTEXT PROSE - - - - - + - - http://json-schema.org/draft-07/schema# { json-base-uri }/{ schema-version }/{ short-name }-schema.json { . }: JSON Schema - object @@ -95,10 +97,7 @@ - - - - + @@ -124,7 +123,6 @@ - @@ -157,8 +155,6 @@ - - @@ -256,7 +252,6 @@ string - @@ -325,16 +320,10 @@ - - - @@ -579,7 +568,6 @@ integer - @@ -600,47 +588,20 @@ - - #/definitions/{$assigned-type} + #/definitions/{$assigned-type} - - - + - - ../../../schema/json/metaschema-datatypes.json - - string - ^((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})?$ - - - string - date-time - ^((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$ - - - string - email - ^.+@.+$ -