Skip to content

Commit 95c4f1d

Browse files
committed
write schema to sphinx to make it usable in editors
1 parent 09aef9a commit 95c4f1d

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ build:
2424
- uv sync --group dev --group rtd
2525
pre_build:
2626
- ./fetch_swagger.sh
27-
- uv run generate-schema.py
27+
- uv run generate-schema.py -o > docs/_static/schema.json
2828
build:
2929
html:
3030
- uv run sphinx-build -T -b html docs/ $READTHEDOCS_OUTPUT/html

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ChangeLog
77
***********
88

99
* Alternatives now allow specific context and environment variables.
10+
* The JSON schema is now available `here <_static/schema.json>`_ and can be used in IDEs such as PyCharm.
1011

1112
******************
1213
0.3.0 (2025-12-26)

docs/quickstart.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ To render your tutorials in Sphinx, add the extension and, optionally, where you
2727
# Location where your tutorials are stored (default: same directory as conf.py).
2828
#structured_tutorials_root = Path(__file__).parent / "tutorials"
2929
30+
Editor integration
31+
==================
32+
33+
The JSON schema is can be found `here <_static/schema.json>`_ and can be used in IDEs for auto-completion
34+
and validation. For example:
35+
36+
* `PyCharm <https://www.jetbrains.com/help/pycharm/yaml.html#json_schema>`_
37+
3038

3139
*******************
3240
Your first tutorial

generate-schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ def generate_openapi_schema(
6767
fh.write(swagger_js)
6868

6969
if args.output:
70-
print(json.dumps(openapi, indent=4, sort_keys=True))
70+
schema = TutorialModel.model_json_schema()
71+
del schema["properties"]["path"]
72+
schema["required"].remove("path")
73+
print(json.dumps(schema, indent=4, sort_keys=True))

0 commit comments

Comments
 (0)