Skip to content

Commit 997fe60

Browse files
feat: Add github-discussion schema
Add github-discussion schema from schemastore. Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
1 parent 05eecae commit 997fe60

File tree

10 files changed

+129
-0
lines changed

10 files changed

+129
-0
lines changed

.pre-commit-hooks.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,20 @@
165165
)$
166166
types: [yaml]
167167

168+
# this hook is autogenerated from a script
169+
# to modify this hook, update `src/check_jsonschema/catalog.py`
170+
# and run `make generate-hooks` or `tox run -e generate-hooks-config`
171+
- id: check-github-discussion
172+
name: Validate GitHub discussion
173+
description: 'Validate GitHub discussion against the schema provided by SchemaStore'
174+
entry: check-jsonschema --builtin-schema vendor.github-discussion
175+
language: python
176+
files: >
177+
(?x)^(
178+
^\.github/DISCUSSION_TEMPLATE/.+\.ya?ml$
179+
)$
180+
types: [yaml]
181+
168182
# this hook is autogenerated from a script
169183
# to modify this hook, update `src/check_jsonschema/catalog.py`
170184
# and run `make generate-hooks` or `tox run -e generate-hooks-config`

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Unreleased
1212
1313
- Update vendored schemas: buildkite, gitlab-ci, mergify, renovate, snapcraft
1414
(2025-11-23)
15+
- Add GitHub Discussion category forms schema and pre-commit hook. Thanks :user:`edgarrmondragon`! (:pr:`626`)
1516

1617
0.35.0
1718
------

docs/precommit_usage.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,20 @@ Validate GitHub Actions against the schema provided by SchemaStore
211211
- id: check-github-actions
212212
213213
214+
``check-github-discussion``
215+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
216+
217+
Validate GitHub discussion against the schema provided by SchemaStore
218+
219+
.. code-block:: yaml
220+
:caption: example config
221+
222+
- repo: https://github.com/python-jsonschema/check-jsonschema
223+
rev: 0.35.0
224+
hooks:
225+
- id: check-github-discussion
226+
227+
214228
``check-github-issue-config``
215229
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216230

docs/usage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ SchemaStore and other sources:
9898
- ``vendor.dependabot``
9999
- ``vendor.drone-ci``
100100
- ``vendor.github-actions``
101+
- ``vendor.github-discussion``
101102
- ``vendor.github-issue-config``
102103
- ``vendor.github-issue-forms``
103104
- ``vendor.github-workflows``
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://json.schemastore.org/github-discussion.json",
4+
"$comment": "https://docs.github.com/en/discussions/managing-discussions-for-your-community/syntax-for-discussion-category-forms",
5+
"additionalProperties": false,
6+
"properties": {
7+
"title": {
8+
"description": "A default title that will be pre-populated in the discussion submission form.",
9+
"type": "string"
10+
},
11+
"labels": {
12+
"description": "Labels that will automatically be added to discussions created with this template.",
13+
"oneOf": [
14+
{
15+
"type": "string"
16+
},
17+
{
18+
"type": "array",
19+
"items": {
20+
"type": "string"
21+
}
22+
}
23+
]
24+
},
25+
"body": {
26+
"description": "Definition of the input types in the discussion form",
27+
"type": "array",
28+
"items": {
29+
"type": "object",
30+
"properties": {
31+
"type": {
32+
"type": "string",
33+
"enum": ["markdown", "textarea", "input", "dropdown", "checkboxes"]
34+
},
35+
"attributes": {
36+
"type": "object",
37+
"properties": {
38+
"label": {
39+
"type": "string"
40+
},
41+
"description": {
42+
"type": "string"
43+
},
44+
"placeholder": {
45+
"type": "string"
46+
}
47+
}
48+
},
49+
"validations": {
50+
"type": "object",
51+
"properties": {
52+
"required": {
53+
"type": "boolean"
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
},
61+
"required": ["body"],
62+
"type": "object"
63+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14cf1562338184fa10109cfb4c7855e7070ea6339e5bc3bc83bdb6e1088aca4f

src/check_jsonschema/catalog.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
166166
"types": "yaml",
167167
},
168168
},
169+
"github-discussion": {
170+
"url": "https://www.schemastore.org/github-discussion.json",
171+
"hook_config": {
172+
"name": "Validate GitHub discussion",
173+
"files": [
174+
r"^\.github/DISCUSSION_TEMPLATE/.+\.ya?ml$",
175+
],
176+
"types": "yaml",
177+
},
178+
},
169179
"github-issue-config": {
170180
"url": "https://www.schemastore.org/github-issue-config.json",
171181
"hook_config": {

tests/acceptance/test_hook_file_matches.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ def get_hook_config(hookid):
144144
),
145145
"bad": (".github/actions/foo/other.yaml",),
146146
},
147+
"check-github-discussion": {
148+
"good": (
149+
".github/DISCUSSION_TEMPLATE/announcements.yaml",
150+
".github/DISCUSSION_TEMPLATE/office-hours.yml",
151+
),
152+
"bad": (
153+
".github/discussion.yml",
154+
".github/DISCUSSION_TEMPLATE/not-a-discussion.txt",
155+
),
156+
},
147157
"check-github-issue-config": {
148158
"good": (".github/ISSUE_TEMPLATE/config.yml",),
149159
"bad": (
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: "Office Hours"
2+
not-a-valid-field: "This field is not allowed."
3+
labels:
4+
- "office-hours"
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: "The agenda for this week's office hours is as follows: ..."
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
title: "Office Hours"
2+
labels:
3+
- "office-hours"
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: "The agenda for this week's office hours is as follows: ..."

0 commit comments

Comments
 (0)