Add Swagger UI api page on Automation page

This commit is contained in:
Björkan
2026-05-01 08:15:50 +02:00
parent f95745cb05
commit 431d4d419a
8 changed files with 590 additions and 6 deletions
+38
View File
@@ -11,3 +11,41 @@ def test_openapi_json_is_gzipped_when_client_accepts_gzip():
assert response.status_code == 200
assert response.headers["content-encoding"] == "gzip"
def test_custom_swagger_docs_page_is_served():
with TestClient(app) as client:
response = client.get("/docs")
assert response.status_code == 200
assert "RemoteTerm API" in response.text
assert "SwaggerUIBundle" in response.text
assert 'url: "openapi.json"' in response.text
assert 'href="api/health"' in response.text
assert "repeating-linear-gradient" not in response.text
assert "background-size: 32px 32px" not in response.text
def test_openapi_includes_docs_metadata():
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200
data = response.json()
assert data["info"]["description"].startswith("RemoteTerm exposes")
assert "/docs" not in data["paths"]
tags = {tag["name"]: tag["description"] for tag in data["tags"]}
assert tags["messages"].startswith("Message history")
assert tags["radio"].startswith("Radio configuration")
def test_openapi_documents_common_error_responses():
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200
data = response.json()
responses = data["paths"]["/api/messages/channel"]["post"]["responses"]
assert responses["400"]["description"] == "Bad request"
assert responses["423"]["description"] == "Radio unavailable or locked"
assert responses["500"]["description"] == "Server error"