Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
FastAPI Cookbook

You're reading from   FastAPI Cookbook Develop high-performance APIs and web applications with Python

Arrow left icon
Product type Paperback
Published in Aug 2024
Publisher Packt
ISBN-13 9781805127857
Length 358 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Giunio De Luca Giunio De Luca
Author Profile Icon Giunio De Luca
Giunio De Luca
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Chapter 1: First Steps with FastAPI 2. Chapter 2: Working with Data FREE CHAPTER 3. Chapter 3: Building RESTful APIs with FastAPI 4. Chapter 4: Authentication and Authorization 5. Chapter 5: Testing and Debugging FastAPI Applications 6. Chapter 6: Integrating FastAPI with SQL Databases 7. Chapter 7: Integrating FastAPI with NoSQL Databases 8. Chapter 8: Advanced Features and Best Practices 9. Chapter 9: Working with WebSocket 10. Chapter 10: Integrating FastAPI with other Python Libraries 11. Chapter 11: Middleware and Webhooks 12. Chapter 12: Deploying and Managing FastAPI Applications 13. Index 14. Other Books You May Enjoy

Documenting your API with Swagger and Redoc

FastAPI automatically generates documentation for your API using Swagger UI and Redoc, when spinning the server.

This documentation is derived from your route functions and Pydantic models, making it incredibly beneficial for both development and consumption by frontend teams or API consumers.

In this recipe, we will see how to customize the documentation’s specific needs.

Getting ready…

By default, FastAPI provides two documentation interfaces:

  • Swagger UI: Accessible at /docs endpoint (e.g., http://127.0.0.1:8000/docs)
  • Redoc: Accessible at /redoc endpoint (e.g., http://127.0.0.1:8000/redoc)

These interfaces offer dynamic documentation where users can see and test the API endpoints and their details. However, both pieces of documentation can be modified.

How to do it...

FastAPI allows the customization of Swagger UI. You can add metadata, customize the look, and add additional documentation...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime