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 new file mode 100644 index 00000000..0dbb8f09 --- /dev/null +++ b/test-suite/metaschema-xspec/json-schema-gen/json-schema-gen.xspec @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 00000000..60f2b273 --- /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 00000000..b7cf2f04 --- /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 00000000..29a7bc7a --- /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 00000000..dcb92104 --- /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 00000000..9c44e32d --- /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 00000000..a2760aee --- /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 00000000..e8277862 --- /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 00000000..7b28d4f0 --- /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 00000000..b2533606 --- /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 00000000..69d7ad4c --- /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 adf16626..55abc1e3 100644 --- a/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl +++ b/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl @@ -2,60 +2,43 @@ - - - + + + - + + + - + - - STRVALUE RICHTEXT PROSE - - - - - - + - - - http://json-schema.org/draft-07/schema# { json-base-uri }/{ schema-version }/{ short-name }-schema.json { . }: JSON Schema - object @@ -106,10 +89,7 @@ - - - - + @@ -135,7 +115,6 @@ - @@ -168,9 +147,6 @@ - - - @@ -200,8 +176,6 @@ - - @@ -250,13 +224,10 @@ - - - - + @@ -273,7 +244,6 @@ string - @@ -310,24 +280,6 @@ - - - @@ -360,65 +312,48 @@ - - - - - - - - - - string - - - - - - - - - { @_in-json-name } @@ -432,7 +367,6 @@ - @@ -626,7 +560,6 @@ integer - @@ -647,101 +580,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 - ^.+@.+$ - - -