如何指定/引用 JSON Schema 的版本?

How to specify / reference version of JSON Schema?

我正在尝试为项目定义编码标准,我想指定使用 JSON 架构版本 4。

然而,来自the offical JSON Schema website, if you follow the links for the Specifications, takes you to the github page, then into the Version 4 Draft at the IETF。该文档明确声明它是 Internet-Draft 文档,并表示:

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

由于 JSON 架构的任何版本似乎都不是 Internet 草案状态,我应该如何引用它?

编辑:这是在书面项目文档中,而不是在 JSON 文件本身中。我目前有这样的文字:

Python Standards and Style

  • All Python Source Files MUST be written in Python 3.x, specifically targeting Python 3.5.1 as the default Python 3 installation with Ubuntu 16.04 LTS.
  • All Python Source Files MUST conform to the PEP 8 standard [footnote: https://www.python.org/dev/peps/pep-0008/ ].
  • All Python Source Files MUST pass a flake8 [footnote: https://pypi.python.org/pypi/flake8/3.2.1 ] check before each delivery. The checker MUST be set up to be ultra-pedantic and it MUST be considered a unit test failure if the checker needs to change anything on the checked in Source Files.
  • All Python Source Files SHOULD use Docstrings conforming to the PEP 257 standard [footnote: https://www.python.org/dev/peps/pep-0257/ ].
    JSON Standards and Style
  • All JSON Source Files MUST be written in JSON Schema version 4 [footnote: https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-04 ].
  • All JSON Source Files MUST conform to the Google JSON Style Guide 0.9 [footnote: https://google.github.io/styleguide/jsoncstyleguide.xml ]
  • All JSON Source Files MUST pass a jsonschema [footnote: https://python-jsonschema.readthedocs.io/en ] check before each delivery. The checker MUST be set up to be ultra-pedantic and it MUST be considered a unit test failure if the checker needs to change anything on the checked in Source Files.
    TOML Standards and Style
  • All TOML Source Files MUST adhere to v0.4.0 of the TOML standard [footnote: https://github.com/toml-lang/toml ].
  • All TOML Source Files MUST be loadable with the pytoml parser v0.1.11 [footnote: https://github.com/bryant/pytoml ], without error.
  • All TOML Source Files SHOULD be aligned at the left margin – i.e. do not indent sub-sections.

对我来说,JSON 架构参考的斜体脚注将被视为引用互联网草案文档,我在上面给出的摘录中明确指出该文档不合适。

Since there don't seem to be any versions of the JSON Schema that are anything other than Internet-Draft status, how should I reference this?

你这样做:

{
    "$schema":"http://json-schema.org/draft-04/schema#",
    ... // the rest of your schema
}

仅仅因为标准是草案格式并不意味着它不是标准。

现在,您还可以选择在没有 $schema 声明的情况下创作模式,它仍然完全有效。如果您这样做并使用正确的 JSON schema draft v4 定义,那么所有支持 draft v4 的解析器都可以使用它。但是,惯例是使用 $schema 声明。

  • All JSON Source Files MUST be written in JSON Schema version 4

您不希望所有 JSON 文件都基于模式 - 这太可笑了。但是,除了参考标准的 版本 之外,从文档的角度来看,您确实需要任何模式文件。那个版本应该是草稿 4,即使它是草稿。

另一种方法是完全删除对 JSON 模式的任何引用,这可能是我会采用的方法。