A Sphinx extension that integrates RapiDoc to render beautiful, customizable, and interactive API documentation from OpenAPI/Swagger specifications.
- 🚀 Quick and easy integration with Sphinx documentation
- 🎨 Customizable themes (light/dark)
- 🔄 Multiple rendering styles (read/view/focused)
- 🔒 Support for authentication
- ⚡ Interactive API testing interface
- 📱 Responsive design
- 🔍 Search functionality
- 📖 Support for OpenAPI v2.0 (Swagger) and v3.0
Install the package using pip:
pip install sphinx-rapidocOr install directly from GitHub for the latest version:
pip install git+https://github.com/TirthS24/sphinx_rapidoc-
Add
sphinx_rapidocto your Sphinx extensions inconf.py:extensions = [ # ... your other extensions 'sphinx_rapidoc' ]
-
Create a new RST file (e.g.,
api.rst) with the RapiDoc directive:API Documentation ================ .. rapidoc:: :spec-url: https://api.example.com/openapi.json :theme: light :render-style: view
-
Include your RST file in
index.rst:.. toctree:: :maxdepth: 2 :caption: Contents: api
-
Build your documentation:
make html
| Option | Description | Default | Values |
|---|---|---|---|
spec-url |
URL to OpenAPI/Swagger specification | None | Valid URL |
theme |
UI theme | light |
light, dark |
render-style |
Documentation rendering style | view |
view, read, focused |
.. rapidoc::
:spec-url: http://127.0.0.1:5500/src/petstore.yml
:theme: light
:render-style: view.. rapidoc::
:spec-url: http://127.0.0.1:5500/src/petstore.yml
:theme: dark
:render-style: read- Python 3.9 or higher
- Sphinx 7.2.5 or higher
- Valid OpenAPI/Swagger specification (JSON or YAML format)
- Web browser with JavaScript enabled
If you encounter CORS errors, ensure that:
- Your API specification URL is accessible from the hosted server
- The server hosting your API specification has appropriate CORS headers
- You're using HTTPS if your documentation is hosted on HTTPS
- Verify that your specification URL is publicly accessible
- Check if the URL returns valid JSON/YAML in OpenAPI/Swagger format
- Ensure your specification follows OpenAPI standards
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
- Check the Common Issues section
- Open an issue on GitHub
- Contact the maintainers

