Skip to content
Beau Barker edited this page Jul 24, 2025 · 9 revisions

Swagger UI lets users visually explore and interact with your API.

1. Compose File

Add a new service:

compose.yaml

swagger-ui:
  image: swaggerapi/swagger-ui:v5.20.1
  environment:
    SWAGGER_JSON_URL: http://localhost:${CADDY_HTTP_PORT:?}/rest/
  depends_on:
    - postgrest

2. Caddyfile

Add a route to serve Swagger UI:

caddy/Caddyfile

# Swagger UI

handle_path /openapi/\* {
  reverse_proxy swagger-ui:8080
}

3. Open Swagger UI

Restart Caddy, then open:

http://localhost:8000/openapi/

(Assuming 8000 is your Caddy port.)

Endpoints not showing?

PostgREST exposes its OpenAPI spec, but it only documents the "default schema", which is public by default, or the first schema listed in PGRST_DB_SCHEMAS. To see everything, you might want to set PGRST_OPENAPI_MODE in the postgres service:

compose.yaml

PGRST_OPENAPI_MODE: ignore-privileges
Clone this wiki locally