prettyopenapi
A clean API documentation page for FastAPI. It reads your OpenAPI document and shows the parameters, fields, types, enums and errors, code samples (cURL, Python, Node.js, Go) and a Try it form that sends a real request from the browser and shows what was actually sent as cURL.
FastAPI builds the document, this package serves the page. Python 3.9 or newer.
Install
pip install prettyopenapi
Use
from fastapi import FastAPI
from prettyopenapi import setup_docs
app = FastAPI(docs_url=None) # turn off FastAPI's own Swagger UI, it uses the same /docs
# ... include your routers ...
setup_docs(app, "/docs")
Open http://localhost:8000/docs. The document itself is at /docs/openapi.json.
Call setup_docs after the routers are included, so the path check sees every route.
Not for production? Register it conditionally:
import os
if os.getenv("ENV") != "production":
setup_docs(app, "/docs")
Next to Swagger UI
You can keep FastAPI's Swagger UI and put this page on another path:
app = FastAPI() # Swagger UI stays at /docs
setup_docs(app, "/docs/v2") # this page: /docs/v2/
If the path is already taken (for example setup_docs(app, "/docs") while Swagger UI is on), setup_docs raises
PathConflictError at startup and tells you what to change. Without the check the page would silently never be
reached, because the first matching route wins.
setup_docs()
setup_docs(app, path="/docs", *, title=None, lang=None, theme=None, base_url=None)
| Argument | Default | What it does |
|---|---|---|
app |
The FastAPI application. | |
path |
"/docs" |
Where the page lives: "docs", "/docs" and "/docs/" mean the same. |
title |
info.title of the document |
The name in the sidebar and in the browser tab. |
lang |
the browser's language: Russian gives "ru", anything else "en" |
"en" or "ru". The language the page opens in. |
theme |
follows the system: flame (light) or midnight (dark) |
The theme the page opens in. An unknown name falls back to the default. |
base_url |
see below | The address Try it sends requests to. An absolute URL with http:// or https://. |
What it serves (for path="/docs"):
| URL | What |
|---|---|
/docs |
Redirects to docs/ (a relative redirect, so it works behind a proxy with a prefix). |
/docs/ |
The documentation page. |
/docs/openapi.json |
The OpenAPI document of the application. |
/docs/assets/… |
The files of the page. |
These routes are left out of the OpenAPI document itself.
lang and theme are starting values. The reader can switch them on the page; that choice is saved in their
browser and wins from then on. Themes: light flame, lavender, mint, serika, sky; dark midnight,
dracula, nord, gruvbox, catppuccin.
Where does Try it send requests?
base_url, if set. It replaces everyserversentry of the document.- The
serversof the document. Behind a proxy withroot_path(uvicorn --root-path /api), FastAPI-styleroot_pathis added there, and a relative entry is resolved against the address of the document. - The address the docs page is served from. Right when the API and the docs live in one application.
Notes
- Authorization values typed into Try it stay in the browser's memory and are not saved.
- Browsers do not allow a page to set the
Cookieheader. For a cookie scheme the browser sends the stored cookies itself when the API is at the same address as the page and you are signed in. - OAuth flows are not run: for oauth2 and OpenID Connect schemes, paste an access token you already have.
- Optional fields written the OpenAPI 3.1 way (
anyOfwithnull), which is what FastAPI with Pydantic v2 emits, are shown as ordinary optional fields.
License
Copyright 2026 laconal. Licensed under the Apache License, Version 2.0, see LICENSE. The licenses of the bundled third-party packages are in THIRD_PARTY_LICENSES.md.
Metadata
Release files for prettyopenapi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prettyopenapi-0.1.0.tar.gz | 583.1 kB | Without provenance | Details for prettyopenapi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prettyopenapi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for prettyopenapi-0.1.0-py3-none-any.whl |
Total release size: 1.2 MB
Release files / prettyopenapi-0.1.0.tar.gz
| Download URL | prettyopenapi-0.1.0.tar.gz |
|---|---|
| Size | 583.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
570adb252dcbd9689130868d56dfba4438ea90276a3b4f4b309f68fdb9dce5f2
|
|
BLAKE2b-256 checksum How to use checksums |
a6dd21b1871520ecc31433cab384b6028e8cda7b84f7aac1ff5e9e3dfedd0e59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / prettyopenapi-0.1.0-py3-none-any.whl
| Download URL | prettyopenapi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 592.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81cfbd2e8e681bb05405be821f7f7101d98e77af1603c136b26d60ead7682ca0
|
|
BLAKE2b-256 checksum How to use checksums |
1632f211989c521f27fa4d7bc4ef4e84a380a7d917610a170094415f6803098d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for prettyopenapi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.