Skip to content

Commit 0b897c7

Browse files
authored
Merge pull request #359 from handrews/comment
Add "$comment" as a keyword
2 parents 02c076a + 93d312f commit 0b897c7

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

hyper-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
"submissionSchema": {
5959
"description": "Schema describing the data to submit along with the request",
6060
"allOf": [ { "$ref": "#" } ]
61+
},
62+
"$comment": {
63+
"type": "string"
6164
}
6265
}
6366
}

jsonschema-core.xml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@
395395
</t>
396396
</section>
397397

398-
<section title="Schema references with $ref">
398+
<section title='Schema references with "$ref"'>
399399
<t>
400400
The "$ref" keyword is used to reference a schema, and provides the ability to
401401
validate recursive structures through self-reference.
@@ -588,6 +588,38 @@
588588
</section>
589589
</section>
590590

591+
<section title='Comments with "$comment"'>
592+
<t>
593+
This keyword is reserved for comments from schema authors to readers or
594+
maintainers of the schema.
595+
596+
The value of this keyword MUST be a string. Implementations MUST NOT present this
597+
string to end users. Tools for editing schemas SHOULD support displaying and
598+
editing this keyword. The value of this keyword MAY be used in debug or error
599+
output which is intended for developers making use of schemas.
600+
601+
Schema vocabularies SHOULD allow "$comment" within any object containing
602+
vocabulary keywords. Implementations MAY assume "$comment" is allowed
603+
unless the vocabulary specifically forbids it. Vocabularies MUST NOT
604+
specify any effect of "$comment" beyond what is described in this
605+
specification.
606+
607+
Tools that translate other media types or programming languages
608+
to and from application/schema+json MAY choose to convert that media type or
609+
programming language's native comments to or from "$comment" values.
610+
The behavior of such translation when both native comments and "$comment"
611+
properties are present is implementation-dependent.
612+
613+
Implementations SHOULD treat "$comment" identically to an unknown extension
614+
keyword. They MAY strip "$comment" values at any point during processing.
615+
In particular, this allows for shortening schemas when the size of deployed
616+
schemas is a concern.
617+
618+
Implementations MUST NOT take any other action based on the presence, absence,
619+
or contents of "$comment" properties.
620+
</t>
621+
</section>
622+
591623
<section title="Usage for hypermedia">
592624

593625
<t>
@@ -738,6 +770,16 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
738770
Individual JSON Schema vocabularies are liable to also have their own security
739771
considerations. Consult the respective specifications for more information.
740772
</t>
773+
<t>
774+
Schema authors should take care with "$comment" contents, as a malicious
775+
implementation can display them to end-users in violation of a spec, or
776+
fail to strip them if such behavior is expected.
777+
</t>
778+
<t>
779+
A malicous schema author could place executable code or other dangerous
780+
material within a "$comment". Implementations MUST NOT parse or otherwise
781+
take action based on "$comment" contents.
782+
</t>
741783
</section>
742784

743785
<section title="IANA Considerations">

schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
"type": "string",
5151
"format": "uri-reference"
5252
},
53+
"$comment": {
54+
"type": "string"
55+
},
5356
"title": {
5457
"type": "string"
5558
},

0 commit comments

Comments
 (0)