Added link to the REST API docs

This commit is contained in:
Donkie
2023-04-03 19:29:51 +02:00
parent a6f872bf69
commit ada139844a
2 changed files with 22 additions and 21 deletions

View File

@@ -9,6 +9,8 @@ these services can e.g. list available spools, report filament consumption, etc.
Currently, it has no client GUI, and only operates using HTTP REST commands. Currently, it has no client GUI, and only operates using HTTP REST commands.
REST API: https://donkie.github.io/Spoolman/
## Prerequisites ## Prerequisites
The data can be stored using any async SQLAlchemy supported database: The data can be stored using any async SQLAlchemy supported database:

View File

@@ -1,7 +1,7 @@
"""Functions for generating documentation.""" """Functions for generating documentation."""
from contextlib import suppress
import json import json
from contextlib import suppress
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@@ -36,7 +36,6 @@ def generate_openapi(app: FastAPI) -> dict[str, Any]:
def generate_docs() -> None: def generate_docs() -> None:
"""Generate documentation for this service in the docs/ directory.""" """Generate documentation for this service in the docs/ directory."""
with suppress(FileExistsError): with suppress(FileExistsError):
Path("docs").mkdir() Path("docs").mkdir()
@@ -45,23 +44,23 @@ def generate_docs() -> None:
with Path("docs", "index.html").open("w") as f: with Path("docs", "index.html").open("w") as f:
f.write( f.write(
f""" f"""
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Spoolson REST API v1 - ReDoc</title> <title>Spoolson REST API v1 - ReDoc</title>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
<link rel="shortcut icon" href="https://fastapi.tiangolo.com/img/favicon.png"> <link rel="shortcut icon" href="https://fastapi.tiangolo.com/img/favicon.png">
<style> body {{margin: 0; padding: 0; }} </style> <style> body {{margin: 0; padding: 0; }} </style>
</head> </head>
<body> <body>
<div id="redoc-container"></div> <div id="redoc-container"></div>
<script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"> </script> <script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"> </script>
<script> <script>
var spec = {spec}; var spec = {spec};
Redoc.init(spec, {{}}, document.getElementById("redoc-container")); Redoc.init(spec, {{}}, document.getElementById("redoc-container"));
</script> </script>
</body> </body>
</html>""", </html>""",
) )