PEP 633: add JSON schema (#1601)
This commit is contained in:
parent
0c1b259034
commit
5722db2e98
194
pep-0633.rst
194
pep-0633.rst
|
@ -223,6 +223,200 @@ performed):
|
|||
reqs += optional_reqs
|
||||
return reqs, extras
|
||||
|
||||
JSON schema
|
||||
-----------
|
||||
|
||||
For initial validation, a JSON-schema can be used. Not only does this help
|
||||
tools have a consistent validation, but it allows code editors to highlight
|
||||
validation errors as users are building the dependencies list.
|
||||
|
||||
.. code-block::
|
||||
|
||||
{
|
||||
"$id": "http://sitesee.com.au/schemas/equipment/v3.json",
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Project metadata",
|
||||
"type": "object",
|
||||
"definitions": {
|
||||
"requirementTable": {
|
||||
"title": "Full project dependency specification",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"extras": {
|
||||
"title": "Dependency extras",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"title": "Dependency extra",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"markers": {
|
||||
"title": "Dependency environment markers",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"oneOf": [
|
||||
{
|
||||
"title": "Version requirement",
|
||||
"properties": {
|
||||
"version": {
|
||||
"title": "Version",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "URL requirement",
|
||||
"properties": {
|
||||
"url": {
|
||||
"title": "URL",
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"url"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "VCS requirement",
|
||||
"properties": {
|
||||
"revision": {
|
||||
"title": "VCS repository revision",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"oneOf": [
|
||||
{
|
||||
"title": "Git repository",
|
||||
"properties": {
|
||||
"git": {
|
||||
"title": "Git URL",
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"git"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Mercurial repository",
|
||||
"properties": {
|
||||
"hg": {
|
||||
"title": "Mercurial URL",
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"hg"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Bazaar repository",
|
||||
"properties": {
|
||||
"bzr": {
|
||||
"title": "Bazaar URL",
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"bzr"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Subversion repository",
|
||||
"properties": {
|
||||
"svn": {
|
||||
"title": "Subversion URL",
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"svn"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"requirementVersion": {
|
||||
"title": "Version project dependency specification",
|
||||
"type": "string"
|
||||
},
|
||||
"requirement": {
|
||||
"title": "Project dependency specification",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/definitions/requirementVersion"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/requirementTable"
|
||||
},
|
||||
{
|
||||
"title": "Multiple specifications",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/requirementTable"
|
||||
},
|
||||
"minLength": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"optionalRequirement": {
|
||||
"title": "Project optional dependency specification",
|
||||
"allOf": [
|
||||
{
|
||||
"title": "Base requirement",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/definitions/requirementTable"
|
||||
},
|
||||
{
|
||||
"title": "Multiple specifications",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/requirementTable"
|
||||
},
|
||||
"minLength": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"for-extra": {
|
||||
"title": "Dependency's extra",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"for-extra"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"dependencies": {
|
||||
"title": "Project dependencies",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/requirement"
|
||||
}
|
||||
},
|
||||
"optional-dependencies": {
|
||||
"title": "Project dependencies",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/optionalRequirement"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Examples
|
||||
========
|
||||
|
|
Loading…
Reference in New Issue