Skip to content
Beau Barker edited this page Jul 24, 2025 · 11 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

Once everything is running, open:

http://localhost:8000/openapi/

(Replace 8000 if you’re using a different CADDY_HTTP_PORT.)

You’ll now be able to browse and test your PostgREST endpoints directly in Swagger UI.

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.

You might want to configure the following setting in the postgres service (see PGRST_OPENAPI_MODE:

compose.yaml

PGRST_OPENAPI_MODE: ignore-privileges

Clone this wiki locally