Interactive API Explorer

GET /api/swagger-ui

Interactive API Explorer

Overview

The Swagger UI endpoint serves an interactive web-based API explorer built on the industry-standard Swagger UI framework. It consumes the auto-generated OpenAPI Specification and renders it as a browsable, testable interface where developers can explore endpoints, read documentation, construct requests, and execute them directly from the browser.

This is the primary tool for API exploration during development and integration. Every endpoint discovered by the platform scanner appears in the Swagger UI automatically, complete with parameter descriptions, request body schemas, response examples, and authentication requirements. Developers can authenticate once and then test any endpoint without switching between documentation and a separate HTTP client.

The Swagger UI is served as a single-page application bundled with the Prismatic API application. It loads the OpenAPI specification dynamically, ensuring that the explorer always reflects the current state of the API surface.

Endpoint

GET /api/swagger-ui

Serves the Swagger UI web application. Open this URL in a browser to access the interactive explorer.

Port: 4004 Content-Type: text/html

Authentication

The Swagger UI page itself is publicly accessible. However, executing API calls through the UI requires authentication. The UI provides an "Authorize" button where you can enter your Bearer token, which is then included in all subsequent requests.

Authenticating in Swagger UI

  1. Open http://localhost:4004/api/swagger-ui in your browser
  2. Click the "Authorize" button in the top right
  3. Enter your Bearer token in the bearerAuth field
  4. Click "Authorize" and then "Close"
  5. All subsequent "Try it out" requests will include the token

Request

Browser Access

http://localhost:4004/api/swagger-ui

Open this URL directly in any modern web browser. The UI is a self-contained single-page application that requires no additional setup.

Programmatic Access

While Swagger UI is designed for browser interaction, you can also fetch the HTML page programmatically:

GET /api/swagger-ui HTTP/1.1
Host: localhost:4004
Accept: text/html

For programmatic API interaction, use the OpenAPI Specification endpoint directly rather than the Swagger UI.

Response

Success Response (200 OK)

Returns an HTML page containing the Swagger UI application. The page loads the OpenAPI specification from /api/openapi and renders the interactive explorer.

The UI organizes endpoints by tags (corresponding to application domains):

TagDescriptionExample Endpoints
coreCore platform operations/health, /endpoints
perimeterExternal attack surface management/perimeter/discover, /perimeter/rating
agentsAIAD agent management/agents/list, /agents/status

UI Features

FeatureDescription
Endpoint BrowserCollapsible list of all endpoints organized by tag
Try It OutExecute real API calls from the browser
Request BuilderVisual form for constructing request parameters and bodies
Response ViewerFormatted display of response headers, body, and status
Schema ExplorerBrowse and expand JSON Schema definitions
AuthenticationPersistent token storage for the session
Deep LinkingURL fragments for linking to specific endpoints
SearchFilter endpoints by keyword

Code Examples

Accessing from Development

# Open Swagger UI in default browser (macOS)
open http://localhost:4004/api/swagger-ui

# Open Swagger UI in default browser (Linux)
xdg-open http://localhost:4004/api/swagger-ui

# Verify the page loads
curl -s -o /dev/null -w "%{http_code}" http://localhost:4004/api/swagger-ui
# Expected: 200

curl -- Testing Endpoints Found in Swagger UI

After exploring endpoints in the Swagger UI, translate them to curl commands:

# From Swagger UI: GET /api/v1/health (no auth required)
curl -s http://localhost:4004/api/v1/health | jq .

# From Swagger UI: POST /api/v1/perimeter/discover (auth required)
curl -s -X POST \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain": "example.com"}' \
  http://localhost:4004/api/v1/perimeter/discover | jq .

# From Swagger UI: GET /api/v1/agents/list (auth required)
curl -s -H "Authorization: Bearer $API_TOKEN" \
  "http://localhost:4004/api/v1/agents/list?domain=security" | jq .

Elixir -- Configuring Swagger UI

# In the API router (apps/prismatic_api/lib/prismatic_api_web/router.ex)
scope "/api" do
  pipe_through [:api]

  # OpenApiSpex routes
  get "/openapi", OpenApiSpex.Plug.RenderSpec, []

  # Swagger UI
  get "/swaggerui", OpenApiSpex.Plug.SwaggerUI,
    path: "/api/openapi",
    title: "Prismatic Platform API",
    default_model_expand_depth: 3
end

Python -- Using Swagger UI as Documentation Reference

import requests
import webbrowser

# Open Swagger UI for exploration
swagger_url = "http://localhost:4004/api/swagger-ui"
webbrowser.open(swagger_url)

# Meanwhile, use the OpenAPI spec programmatically
spec = requests.get("http://localhost:4004/api/openapi").json()

# Build a simple endpoint reference from the spec
for path, methods in spec["paths"].items():
    for method, details in methods.items():
        if method in ("get", "post", "put", "delete"):
            auth = "AUTH" if details.get("security") else "PUBLIC"
            print(f"[{auth}] {method.upper():6s} {path}")
            print(f"         {details.get('summary', 'No description')}")
            print()

Error Responses

Status CodeConditionDescription
200AlwaysThe UI page is always available when the API is running
429Rate limitedExcessive page loads

The Swagger UI endpoint itself does not produce application errors. If the API process is running, the page will load. If the OpenAPI specification fails to load within the UI, the page will display an error banner indicating the spec URL is unreachable.

Rate Limits

Limit TypeValueWindow
Per IP30 requests1 minute
Burst5 requests1 second

Rate limits apply to page loads only. API calls executed through the Swagger UI are subject to their own per-endpoint rate limits as documented in Rate Limiting.

Customization

The Swagger UI instance is configured through OpenApiSpex, the Elixir library that handles specification generation and UI serving. Configuration options include:

OptionValueDescription
path/api/openapiPath to the OpenAPI specification
titlePrismatic Platform APIPage title
default_model_expand_depth3How deep to auto-expand schema models
display_operation_idtrueShow operation IDs alongside summaries
filtertrueEnable endpoint search/filter

The UI inherits the platform's visual identity while maintaining full Swagger UI functionality. All auto-discovered endpoints from every Prismatic* facade module are visible, organized by the tags assigned during the scanning phase.

Development Workflow

The recommended workflow for API development with Swagger UI:

  1. Write a new public function on a Prismatic* facade module with @spec and @doc
  2. Restart the API application (mix phx.server in apps/prismatic_api)
  3. Open Swagger UI and verify the new endpoint appears
  4. Use "Try it out" to test the endpoint interactively
  5. Verify response schema matches the @spec return type
  6. Share the Swagger UI link with consumers for integration testing

This workflow ensures that documentation, type safety, and testability are built into the development process from the start, embodying the Quality DNA principle of quality at creation rather than quality through inspection.


Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL