Skip to content

Commit

Permalink
docs: Wrap schema input configuration under a python property
Browse files Browse the repository at this point in the history
Issue-246: #246
  • Loading branch information
pawamoy committed Feb 9, 2025
1 parent 6c16172 commit 24afd5d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/mkdocs_hooks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Generate a JSON schema of the Python handler configuration."""

import json
from dataclasses import fields
from dataclasses import dataclass, fields
from os.path import join
from typing import Any

Expand All @@ -25,7 +25,12 @@ def on_post_build(config: MkDocsConfig, **kwargs: Any) -> None: # noqa: ARG001
if TypeAdapter is None:
logger.info("Pydantic is not installed, skipping JSON schema generation")
return
adapter = TypeAdapter(PythonInputConfig)

@dataclass
class PythonHandlerSchema:
python: PythonInputConfig

adapter = TypeAdapter(PythonHandlerSchema)
schema = adapter.json_schema()
schema["$schema"] = "https://json-schema.org/draft-07/schema"
with open(join(config.site_dir, "schema.json"), "w") as file:
Expand Down

0 comments on commit 24afd5d

Please sign in to comment.