diff --git a/Taskfile.yml b/Taskfile.yml index f595828da..716e3e7b3 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -25,16 +25,9 @@ dotenv: - .env - .dev.env tasks: - docs:gen: - desc: runs the API documentation generator - cmds: - - uv run python dev/code-generation/gen_docs_api.py - docs: desc: runs the documentation server dir: docs - deps: - - docs:gen cmds: - uv run python -m mkdocs serve @@ -81,7 +74,6 @@ tasks: desc: run code generators cmds: - uv run python dev/code-generation/main.py {{ .CLI_ARGS }} - - task: docs:gen - task: py:format dev:services: @@ -350,4 +342,4 @@ tasks: vars: { WAIT_UNTIL_HEALTHY: true } - defer: { task: e2e:stop-server } - task: e2e:test - vars: { PREVENT_REPORT_OPEN: true } \ No newline at end of file + vars: { PREVENT_REPORT_OPEN: true } diff --git a/dev/code-generation/gen_docs_api.py b/dev/code-generation/gen_docs_api.py deleted file mode 100644 index 4a300fecb..000000000 --- a/dev/code-generation/gen_docs_api.py +++ /dev/null @@ -1,80 +0,0 @@ -import json -from datetime import UTC, datetime -from typing import Any - -from fastapi import FastAPI - -from mealie.app import app -from mealie.core.config import determine_data_dir - -DATA_DIR = determine_data_dir() - -"""Script to export the ReDoc documentation page into a standalone HTML file.""" - -HTML_TEMPLATE = """ -{% extends "main.html" %} -{% block tabs %} -{{ super() }} - - - - -
- - - - -{% endblock %} -{% block content %}{% endblock %} -{% block footer %}{% endblock %} -""" - -HTML_PATH = DATA_DIR.parent.parent.joinpath("docs/docs/overrides/api.html") -CONSTANT_DT = datetime(2025, 10, 24, 15, 53, 0, 0, tzinfo=UTC) - - -def normalize_timestamps(s: dict[str, Any]) -> dict[str, Any]: - field_format = s.get("format") - is_timestamp = field_format in ["date-time", "date", "time"] - has_default = s.get("default") - - if not is_timestamp: - for k, v in s.items(): - if isinstance(v, dict): - s[k] = normalize_timestamps(v) - elif isinstance(v, list): - s[k] = [normalize_timestamps(i) if isinstance(i, dict) else i for i in v] - - return s - elif not has_default: - return s - - if field_format == "date-time": - s["default"] = CONSTANT_DT.isoformat() - elif field_format == "date": - s["default"] = CONSTANT_DT.date().isoformat() - elif field_format == "time": - s["default"] = CONSTANT_DT.time().isoformat() - - return s - - -def generate_api_docs(my_app: FastAPI): - openapi_schema = my_app.openapi() - openapi_schema = normalize_timestamps(openapi_schema) - - with open(HTML_PATH, "w") as fd: - text = HTML_TEMPLATE.replace("MY_SPECIFIC_TEXT", json.dumps(openapi_schema)) - fd.write(text) - - -if __name__ == "__main__": - generate_api_docs(app)