Skip to main content

st_swagger_ui

Streamlit component for embedding Swagger UI to display OpenAPI/Swagger specifications.

Features

  • Display OpenAPI/Swagger specifications from URL or local file
  • Configurable operation expansion (doc_expansion)
  • Enable/disable "Try it out" functionality (try_it_out_enabled)
  • Show/hide operation IDs (display_operation_id)
  • Control model rendering (default_model_rendering)
  • Custom CSS overrides for reduced indentation

Installation

uv add st_swagger_ui

or

pip install st_swagger_ui

Usage

Basic Usage

import streamlit as st
from st_swagger_ui import st_swagger_ui

# Load from URL
st_swagger_ui(url="https://petstore.swagger.io/v2/swagger.json")

Load from Local File

import json

with open("openapi.json") as f:
    spec = json.load(f)

st_swagger_ui(spec=spec)

Configuration Options

st_swagger_ui(
    url="https://petstore.swagger.io/v2/swagger.json",
    doc_expansion="list",           # "list" | "full" | "none"
    try_it_out_enabled=True,        # True | False | None
    display_operation_id=False,     # True | False | None
    default_model_rendering="example",  # "example" | "model" | None
)

Parameters

Parameter Type Default Description
url str None URL to fetch OpenAPI specification from
spec dict None OpenAPI specification as a Python dict
doc_expansion str None Default expansion: "list", "full", or "none"
try_it_out_enabled bool None Enable "Try it out" functionality
display_operation_id bool None Show operation IDs next to operation names
default_model_rendering str None Model display: "example" or "model"

Note: Either url or spec must be provided (mutually exclusive).

Examples

Full Expansion with Model View

st_swagger_ui(
    url="https://petstore.swagger.io/v2/swagger.json",
    doc_expansion="full",
    default_model_rendering="model"
)

Read-Only Mode (No "Try it out")

st_swagger_ui(
    url="https://api.example.com/openapi.json",
    try_it_out_enabled=False,
    display_operation_id=True
)

Load from FastAPI App

from fastapi import FastAPI
import fastapi.openapi.utils

app = FastAPI()

spec = fastapi.openapi.utils.get_openapi(
    title="My API",
    version="1.0.0",
    openapi_version="3.0.0",
    routes=app.routes,
)

st_swagger_ui(spec=spec, doc_expansion="list")

License

MIT

Release files for st_swagger_ui 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for st_swagger_ui 0.1.1
File Size Uploaded
st_swagger_ui-0.1.1.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for st_swagger_ui 0.1.1
File Interpreter ABI Platform
st_swagger_ui-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size:531.0 kB

Release files / st_swagger_ui-0.1.1.tar.gz

Download URL st_swagger_ui-0.1.1.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2bf1dca60b4110e5ff57e2693efe73fd06df730c85621d5bdc901079fb2083d8
BLAKE2b-256 checksum
How to use checksums
f410638b7ad5a33e0289bf1504c9bff133d0ee2acb2112729bf77f381e1bdcf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release files / st_swagger_ui-0.1.1-py3-none-any.whl

Download URL st_swagger_ui-0.1.1-py3-none-any.whl
Size 520.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46cd6810a210b992452188d2bb7ccd2f3f153869e834e9c5b21d8cd00d807c8e
BLAKE2b-256 checksum
How to use checksums
825072c5db916df5928c2766822e2db4caadafc6cfd82baf616f5ecff2673a87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page