When using the current version of metaschema-xslt as of commit 0010340, when I use the current kabob-case data types [in documentation]() and not [the legacy data types (no longer documented), the JSON Schemas, some $refs double the name after the path, rendering the JSON Schemas invalid.
Who is the bug affecting?
Developer using metaschema-xslt for JSON Schema generation of models in a Metaschema module.
What is affected by this bug?
JSON Schema generation
When does this occur?
Consistently
How do we replicate the issue?
{What are the steps to reproduce the behavior?
Use ./bin/metaschema-xslt schema-gen 'choice-example_metaschema.xml' '.' 'choice-example' to generate schema
Open JSON Schema and observe refs like { "$ref" : "#/definitions/PositiveIntegerDatatype PositiveIntegerDatatype" }, int the outputted schema
Metaschema module:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://raw.githubusercontent.com/usnistgov/metaschema/develop/schema/xml/metaschema.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
<schema-name>Model for Testing usnistgov/metaschema-xslt#105</schema-name>
<schema-version>0.1.0</schema-version>
<short-name>choice-bug-issue-105</short-name>
<namespace>https://github.com/usnistgov/metaschema-xslt/issues/105</namespace>
<json-base-uri>https://github.com/usnistgov/metaschema-xslt/issues/105</json-base-uri>
<define-assembly name="root">
<formal-name>Root Assembly for Choice</formal-name>
<description>This root assembly should only an instance to have a field of a or b, but not both.</description>
<root-name>root</root-name>
<model>
<choice>
<define-field name="a" as-type="positive-integer" min-occurs="1" max-occurs="1"/>
<define-field name="b" as-type="positive-integer" min-occurs="1" max-occurs="1"/>
</choice>
</model>
</define-assembly>
</METASCHEMA>
Outputted JSON Schema:
{ "$schema" : "http://json-schema.org/draft-07/schema#",
"$id" : "https://github.com/usnistgov/metaschema-xslt/issues/105/0.1.0/choice-bug-issue-105-schema.json",
"$comment" : "Model for Testing usnistgov/metaschema-xslt#105: 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" : "#/definitions/json-schema-directive",
"$ref" : "#/definitions/URIReferenceDatatype" },
"choice-bug-issue-105-choice-bug-issue-105:root" :
{ "title" : "Root Assembly for Choice",
"description" : "This root assembly should only an instance to have a field of a or b, but not both.",
"$id" : "#/definitions/choice-bug-issue-105-choice-bug-issue-105:root",
"type" : "object",
"properties" :
{ "a" :
{ "$ref" : "#/definitions/PositiveIntegerDatatype PositiveIntegerDatatype" },
"b" :
{ "$ref" : "#/definitions/PositiveIntegerDatatype PositiveIntegerDatatype" } },
"additionalProperties" : false },
"IntegerDatatype" :
{ "description" : "A whole number value.",
"type" : "integer" },
"PositiveIntegerDatatype" :
{ "description" : "An integer value that is greater than 0.",
"allOf" :
[
{ "$ref" : "#/definitions/IntegerDatatype" },
{ "type" : "number",
"minimum" : 1 } ] },
"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" : "#/definitions/json-schema-directive" },
"root" :
{ "$ref" : "#/definitions/choice-bug-issue-105-choice-bug-issue-105:root" } },
"required" :
[ "root" ],
"additionalProperties" : false }
If applicable, add screenshots to help explain your problem.}
Expected behavior (i.e. solution)
Whether using datatype=positive-integer, I would want the correct schema rendered like so below.
{ "$schema" : "http://json-schema.org/draft-07/schema#",
"$id" : "https://github.com/usnistgov/metaschema-xslt/issues/105/0.1.0/choice-bug-issue-105-schema.json",
"$comment" : "Model for Testing usnistgov/metaschema-xslt#105: 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" : "#/definitions/json-schema-directive",
"$ref" : "#/definitions/URIReferenceDatatype" },
"choice-bug-issue-105-choice-bug-issue-105:root" :
{ "title" : "Root Assembly for Choice",
"description" : "This root assembly should only an instance to have a field of a or b, but not both.",
"$id" : "#/definitions/choice-bug-issue-105-choice-bug-issue-105:root",
"type" : "object",
"properties" :
{ "a" :
{ "$ref" : "#/definitions/PositiveIntegerDatatype" },
"b" :
{ "$ref" : "#/definitions/PositiveIntegerDatatype" } },
"additionalProperties" : false },
"IntegerDatatype" :
{ "description" : "A whole number value.",
"type" : "integer" },
"PositiveIntegerDatatype" :
{ "description" : "An integer value that is greater than 0.",
"allOf" :
[
{ "$ref" : "#/definitions/IntegerDatatype" },
{ "type" : "number",
"minimum" : 1 } ] },
"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" : "#/definitions/json-schema-directive" },
"root" :
{ "$ref" : "#/definitions/choice-bug-issue-105-choice-bug-issue-105:root" } },
"required" :
[ "root" ],
"additionalProperties" : false }
Describe the bug
When using the current version of metaschema-xslt as of commit
0010340
, when I use the currentkabob-case
data types [in documentation]() and not [the legacy data types (no longer documented), the JSON Schemas, some$refs
double the name after the path, rendering the JSON Schemas invalid.Who is the bug affecting?
Developer using metaschema-xslt for JSON Schema generation of models in a Metaschema module.
What is affected by this bug?
JSON Schema generation
When does this occur?
Consistently
How do we replicate the issue?
{What are the steps to reproduce the behavior?
./bin/metaschema-xslt schema-gen 'choice-example_metaschema.xml' '.' 'choice-example'
to generate schema{ "$ref" : "#/definitions/PositiveIntegerDatatype PositiveIntegerDatatype" },
int the outputted schemaMetaschema module:
Outputted JSON Schema:
If applicable, add screenshots to help explain your problem.}
Expected behavior (i.e. solution)
Whether using
datatype=positive-integer
, I would want the correct schema rendered like so below.Other Comments
N/A