Skip to main content

Enhanced Swagger UI for FastAPI with tag-based filtering and download links

Project description

FastAPI Swagger Splitter

Enhanced Swagger UI for FastAPI applications with tag-based filtering, download links, and search functionality.

Features

  • 🎨 Custom Styled UI - Beautiful, modern Swagger UI with custom CSS
  • 📥 Download Links - Download complete or tag-specific OpenAPI JSON schemas
  • 🔍 Tag Search - Search and filter tags in real-time
  • 🏷️ Tag-based Filtering - Generate OpenAPI schemas filtered by specific tags
  • 🚀 Easy Integration - Simple setup with just one function call

Installation

pip install fastapi-swagger-splitter

Quick Start

from fastapi import FastAPI
from fastapi_swagger_splitter import setup_swagger_splitter

# Create your FastAPI app
app = FastAPI(
    title="My API",
    description="API documentation",
    version="1.0.0",
    docs_url=None,  # Disable default docs - we'll use custom one
    openapi_url="/openapi.json",
)

# Setup custom Swagger UI
setup_swagger_splitter(app, swagger_path="/docs")

@app.get("/")
async def root():
    return {"message": "Hello World"}

That's it! Now visit http://localhost:8000/docs to see your enhanced Swagger UI.

Features in Detail

Download Complete OpenAPI JSON

Click the "Complete OpenAPI JSON" link to download the full OpenAPI schema for your API.

Download Tag-Specific OpenAPI JSON

Each tag in your API gets its own download link. Click any tag name to download an OpenAPI JSON file containing only endpoints and schemas related to that tag.

Search Tags

Use the search input to quickly find tags by name. The search is case-insensitive and filters tags in real-time as you type.

API Endpoints

The package automatically creates these endpoints:

  • GET /docs - Custom Swagger UI (or your custom path)
  • GET /docs/json - Complete OpenAPI JSON schema
  • GET /docs/json/{tag} - Tag-specific OpenAPI JSON schema
  • GET /docs/tags - List of all available tags

Customization

Custom Swagger Path

You can customize the Swagger UI path:

setup_swagger_splitter(app, swagger_path="/api-docs")

Now your Swagger UI will be available at /api-docs instead of /docs.

Requirements

  • Python 3.8+
  • FastAPI 0.68.0+
  • Starlette 0.14.0+

Development

# Clone the repository
git clone https://github.com/yourusername/fastapi-swagger-splitter.git
cd fastapi-swagger-splitter

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

0.1.0 (2024-01-XX)

  • Initial release
  • Custom Swagger UI with download links
  • Tag-based filtering
  • Search functionality

fastapi-swagger-splitter

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_swagger_splitter-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_swagger_splitter-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_swagger_splitter-0.1.0.tar.gz.

File metadata

File hashes

Hashes for fastapi_swagger_splitter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 673416b2e41af531e9a4e86aa44df441506eac5c8dc201b87d46f54c4273c5ee
MD5 816bc4fab56ab6bf9c2e95a0b5589229
BLAKE2b-256 d7c21c0f5ecc6858146533ac778c92b87ccc46d49ca51f808727171ae8d5665f

See more details on using hashes here.

File details

Details for the file fastapi_swagger_splitter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_swagger_splitter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bed860b0d0ff03482443153a97adf4d4f6be610e8fd48a69024b42f2a17723bf
MD5 395c02ae94f57144465b618bea0615e7
BLAKE2b-256 518351595442a2ba3319f4631f7c7db0c6a17dcf22bf3fe180e17c2781558365

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page