Skip to content

Commit

Permalink
Tweak JSON schema
Browse files Browse the repository at this point in the history
This commit distinguishes package entries with and without "details" field
and ensures "base" is present in release templates, if "details" is missing.
  • Loading branch information
deathaxe committed Oct 14, 2023
1 parent 97fd0a1 commit ce72f0c
Showing 1 changed file with 126 additions and 5 deletions.
131 changes: 126 additions & 5 deletions sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@
"markdownDescription": "```json\n{\n\t\"name\": \"My Package\",\n\t\"description\": \"A Sublime Text plugin to ...\",\n\t\"author\": \"John Doe\",\n\t\"issues\": \"https://github.com/user/repo/issues\",\n\t\"releases\": []\n}\n```\n\nInformation about a package.",
"additionalProperties": false,
"properties": {
"details": { "$ref": "#/definitions/InfoValues/DetailsValue" },
"name": { "$ref": "#/definitions/InfoValues/NameValue" },
"description": { "$ref": "#/definitions/InfoValues/DescriptionValue" },
"author": { "$ref": "#/definitions/InfoValues/AuthorValue" },
Expand Down Expand Up @@ -786,7 +785,6 @@
"markdownDescription": "```json\n{\n\t\"name\": \"My Package\",\n\t\"description\": \"A Sublime Text plugin to ...\",\n\t\"author\": \"John Doe\",\n\t\"issues\": \"https://github.com/user/repo/issues\",\n\t\"releases\": []\n}\n```\n\nInformation about a package.",
"additionalProperties": false,
"properties": {
"details": { "$ref": "#/definitions/InfoValues/DetailsValue" },
"name": { "$ref": "#/definitions/InfoValues/NameValue" },
"description": { "$ref": "#/definitions/InfoValues/DescriptionValue" },
"author": { "$ref": "#/definitions/InfoValues/AuthorValue" },
Expand All @@ -798,7 +796,7 @@
"labels": { "$ref": "#/definitions/InfoValues/LabelsValue" },
"last_modified": { "$ref": "#/definitions/InfoValues/LastModifiedValue" },
"previous_names": { "$ref": "#/definitions/InfoValues/PreviousNamesValue" },
"releases": { "$ref": "#/definitions/PackageTemplateReleasesList" }
"releases": { "$ref": "#/definitions/PackageTemplateReleasesListWithBase" }
},
"required": [
"name",
Expand All @@ -825,6 +823,18 @@
]
}
},
"PackageTemplateReleasesListWithBase": {
"type": "array",
"markdownDescription": "A list of package release templates or artefacts.",
"additionalItems": false,
"uniqueItems": true,
"items": {
"oneOf": [
{"$ref": "#/definitions/PackageReleaseArtefact"},
{"$ref": "#/definitions/PackageReleaseTemplateWithBase"}
]
}
},

"PackageReleaseArtefact": {
"type": "object",
Expand Down Expand Up @@ -898,6 +908,56 @@
}
]
},
"PackageReleaseTemplateWithBase": {
"oneOf": [
{
"type": "object",
"markdownDescription": "A release template, which uses given `branch` specification to collect available releases from `base` or package's `details` url.",
"additionalProperties": false,
"properties": {
"base": { "$ref": "#/definitions/ReleaseValues/base" },
"branch": { "$ref": "#/definitions/ReleaseValues/branch" },
"dependencies": { "$ref": "#/definitions/ReleaseValues/dependencies" },
"sublime_text": { "$ref": "#/definitions/ReleaseValues/sublime_text" },
"platforms": { "$ref": "#/definitions/ReleaseValues/platforms" }
},
"required": [
"base",
"sublime_text",
"branch"
],
"defaultSnippets": [
{
"label": "branch based release template",
"bodyText": "{\n\t\"base\": \"${1:https://github.com/author/repo}\",\n\t\"branch\": ${2:true},\n\t\"sublime_text\": \"${3:*}\"${4:,\n\t\"platforms\": [\"${5:*}\"]}\n}"
}
]
},
{
"type": "object",
"markdownDescription": "A release template, which uses given `tags` specification to collect available releases from `base` or package's `details` url.",
"additionalProperties": false,
"properties": {
"base": { "$ref": "#/definitions/ReleaseValues/base" },
"tags": { "$ref": "#/definitions/ReleaseValues/tags" },
"dependencies": { "$ref": "#/definitions/ReleaseValues/dependencies" },
"sublime_text": { "$ref": "#/definitions/ReleaseValues/sublime_text" },
"platforms": { "$ref": "#/definitions/ReleaseValues/platforms" }
},
"required": [
"base",
"sublime_text",
"tags"
],
"defaultSnippets": [
{
"label": "tag based release template",
"bodyText": "{\n\t\"base\": \"${1:https://github.com/author/repo}\",\n\t\"tags\": ${2:true},\n\t\"sublime_text\": \"${3:*}\"${4:,\n\t\"platforms\": [\"${5:*}\"]}\n}"
}
]
}
]
},

"InfoValues": {
"DetailsValue": {
Expand Down Expand Up @@ -1348,7 +1408,6 @@
"markdownDescription": "```json\n{\n\t\"name\": \"My Package\",\n\t\"description\": \"A Sublime Text plugin to ...\",\n\t\"author\": \"John Doe\",\n\t\"issues\": \"https://github.com/user/repo/issues\",\n\t\"releases\": []\n}\n```\n\nInformation about a package.",
"additionalProperties": false,
"properties": {
"details": { "$ref": "#/definitions/InfoValues/DetailsValue" },
"name": { "$ref": "#/definitions/InfoValues/NameValue" },
"description": { "$ref": "#/definitions/InfoValues/DescriptionValue" },
"author": { "$ref": "#/definitions/InfoValues/AuthorValue" },
Expand All @@ -1360,7 +1419,7 @@
"labels": { "$ref": "#/definitions/InfoValues/LabelsValue" },
"last_modified": { "$ref": "#/definitions/InfoValues/LastModifiedValue" },
"previous_names": { "$ref": "#/definitions/InfoValues/PreviousNamesValue" },
"releases": { "$ref": "#/definitions/PackageTemplateReleasesList" }
"releases": { "$ref": "#/definitions/PackageTemplateReleasesListWithBase" }
},
"required": [
"name",
Expand Down Expand Up @@ -1388,6 +1447,18 @@
]
}
},
"PackageTemplateReleasesListWithBase": {
"type": "array",
"markdownDescription": "A list of package release templates or artefacts.",
"additionalItems": false,
"uniqueItems": true,
"items": {
"oneOf": [
{"$ref": "#/definitions/PackageReleaseArtefact"},
{"$ref": "#/definitions/PackageReleaseTemplateWithBase"}
]
}
},

"PackageReleaseArtefact": {
"type": "object",
Expand Down Expand Up @@ -1461,6 +1532,56 @@
}
]
},
"PackageReleaseTemplateWithBase": {
"oneOf": [
{
"type": "object",
"markdownDescription": "A release template, which uses given `branch` specification to collect available releases from `base` or package's `details` url.",
"additionalProperties": false,
"properties": {
"base": { "$ref": "#/definitions/ReleaseValues/base" },
"branch": { "$ref": "#/definitions/ReleaseValues/branch" },
"libraries": { "$ref": "#/definitions/ReleaseValues/libraries" },
"sublime_text": { "$ref": "#/definitions/ReleaseValues/sublime_text" },
"platforms": { "$ref": "#/definitions/ReleaseValues/platforms" },
"python_versions": { "$ref": "#/definitions/ReleaseValues/python_versions" }
},
"required": [
"base",
"branch"
],
"defaultSnippets": [
{
"label": "branch based release template",
"bodyText": "{\n\t\"base\": \"${1:https://github.com/author/repo}\",\n\t\"branch\": ${2:true},\n\t\"sublime_text\": \"${3:*}\"${4:,\n\t\"platforms\": [\"${5:*}\"]}\n}"
}
]
},
{
"type": "object",
"markdownDescription": "A release template, which uses given `tags` specification to collect available releases from `base` or package's `details` url.",
"additionalProperties": false,
"properties": {
"base": { "$ref": "#/definitions/ReleaseValues/base" },
"tags": { "$ref": "#/definitions/ReleaseValues/tags" },
"libraries": { "$ref": "#/definitions/ReleaseValues/libraries" },
"sublime_text": { "$ref": "#/definitions/ReleaseValues/sublime_text" },
"platforms": { "$ref": "#/definitions/ReleaseValues/platforms" },
"python_versions": { "$ref": "#/definitions/ReleaseValues/python_versions" }
},
"required": [
"base",
"tags"
],
"defaultSnippets": [
{
"label": "tag based release template",
"bodyText": "{\n\t\"base\": \"${1:https://github.com/author/repo}\",\n\t\"tags\": ${2:true},\n\t\"sublime_text\": \"${3:*}\"${4:,\n\t\"platforms\": [\"${5:*}\"]}\n}"
}
]
}
]
},

"InfoValues": {
"DetailsValue": {
Expand Down

0 comments on commit ce72f0c

Please sign in to comment.