-
-
Notifications
You must be signed in to change notification settings - Fork 316
Conversation
@Relequestual, @handrews : Any interest in reviewing this? |
@mdboom I had somehow missed this! Will take a look soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks great! Most of the comments are ideas that you don't necessarily need to incorporate. I never know how much detail to put into tutorials and references so I'll leave that call to you!
} | ||
|
||
Unfortunately, this approach above doesn't scale to more than two countries. You | ||
can, however, wrap pairs of ``if`` and ``then`` inside an ``allOf`` to create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can never figure out whether allOf
, anyOf
, or oneOf
makes sense here. For mutually exclusive conditions, the effect is the same for all of them. For overlapping conditions, it makes a difference.
I don't think you need to change this, I'm just kind of musing on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. In any case allOf
/anyOf
/oneOf
are discussed in detail elsewhere -- this is just intended to show the combination of conditionals with the set notation operators. I think I'll not confuse this here now, but we can always revisit later.
source/reference/generic.rst
Outdated
practice, and can make your schema "self-documenting". | ||
|draft7| ``$comment`` | ||
|
||
The ``title``, ``description``, and ``$comment`` keywords must be strings. A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't put $comment
with title
and description
.
$comment
, like $defs
, is a placeholder keyword. It reserves that keyword for a particular syntax, but doesn't do anything like an assertion or annotation does. $comment
is specifically reserved for strings that you're not allowed to do anything with, and $defs
is reserved as a place to put re-usable schemas.
title
and description
are annotations and actually attach their values to the instance during processing (assuming you are collecting annotations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is $defs
a thing from a newer version of the standard? I still see definitions
here and that's what I've used in this doc.
That makes sense about $comment
-- I'll move it to its own section and be clearer about how explicitly limited its use is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah, $defs
replaces definitions
in the next draft. Although you can keep using definitions
, it just didn't fit the core keyword naming. Less seriously, I also can't type it accurately half the time- "definitoins" is what I write more often than not 😛
Anyway, ignore $defs
for draft-07, pretend I wrote definitions
source/reference/non_json_data.rst
Outdated
really only two options useful for modern usage: | ||
|
||
- If the string contains a binary MIME type (``image/png``, for example), set | ||
``contentEncoding`` to ``base64`` and encode the contents using `Base64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth noting that we're adding RFC 4648 encodings to the set of legal values in the next draft, so you can use base64url
explicitly. I'm not sure if that's confusing to add or not- maybe as a footnote?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since it's not in draft 7, I'll defer mentioning it to later updates. Since many users I've come across are stuck on earlier drafts for various "reasons", I've tried to be really specific about when certain features are and aren't available.
source/reference/non_json_data.rst
Outdated
``contentEncoding`` to ``base64`` and encode the contents using `Base64 | ||
<https://tools.ietf.org/html/rfc4648>`_. | ||
|
||
- If the string contains a text MIME type (usually indicated with the ``text/`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it needs to be mentioned, but a text-based application media type such as application/xml
would also not need an encoding (I guess unless there's some weird character set issue? I'm a little vague on that sort of thing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm a little vague, on that too, but I think it's worth clarifying -- not all text-based formats have the text/
prefix. I think the important distinction for this tutorial is probably -- if the content has the same encoding as the enclosing JSON document (which, in practice, is almost always utf-8) then leave contentEncoding
unspecified. If it's some kind of binary data, the best choice, as of draft 7, is base64
. I'll simplify/clarify this.
|
||
Built-in formats | ||
^^^^^^^^^^^^^^^^ | ||
|
||
The following is the list of formats specified in the JSON Schema | ||
specification. | ||
|
||
- ``"date-time"``: Date representation, as defined by `RFC 3339, section |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still reference RFC 3339, not ISO 8601
source/reference/string.rst
Outdated
Dates and times | ||
*************** | ||
|
||
Dates and times are represented in `ISO8601 format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RFC 3339 is a simpler reference, and easier to get than a full ISO spec that you have to buy.
|
||
Hostnames | ||
********* | ||
|
||
- ``"hostname"``: Internet host name, see `RFC 1034, section 3.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth noting here that an international hostname that has been punycoded is valid under {"format": "hostname"}
? (and also "idn-hostname"
of course)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only have a vague understanding of the specs involved. I'm struggling to describe the difference between hostname
and idn-hostname
in that case. Is the punycoded hostname
limited to ascii letters/digits/hyphens like a "classic" hostname? (I see the spec says "punycode" is supported for hostname, but not "internationalized" like in your comment).
I suspect in practice this makes very little difference in terms of what implementations are doing. Any suggestions about how to word this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, punycode is an algorithm mapping full Unicode strings into the limited ASCII character set which is valid for hostnames in DNS. Note that I said "international", not "internationalized". I really should have just said "non-ascii" as that is not directly related to I18N or pertaining to multiple nations anyway.
This is a valid "format": "idn-hostname"
which is not a valid "format": "hostname"
:
見.香港
This is the same hostname, punycoded so that it is a valid "format": "hostname"
, which, since all valid hostnames are valid idn-hostnames, is also a valid "format": "idn-hostname"
:
xn--nw2a.xn--j6w193g
If you paste either into chrome's address bar (and presumably other browsers), it will assume HTTP and take you to the same web site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. That makes sense now. I'll work on incorporating that into the language.
source/reference/string.rst
Outdated
of JSON Pointer within JSON Schema in `structuring`. Note that this should be | ||
used only when the entire string contains only JSON Pointer content, e.g. | ||
``/foo/bar``. JSON Pointer URI fragments, e.g. ``#/foo/bar/`` should us e | ||
``"uri"`` or ``"uri-reference"``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#/foo/bar
would definitely be "uri-reference"
, not "uri"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Good catch.
This updates the document for what feel like the "core" parts of Draft 7. In the interest of not letting the details bog down the most important updates, I'm going to file separate issues and PRs for the remaining Draft 7 things.
Direct link to the Draft 7 release notes