Better Programming

Advice for programmers.

Follow publication

Member-only story

Metadata and Additional Responses in FastAPI

Ng Wai Foong
Better Programming
Published in
6 min readAug 26, 2020
Photo by the author.

Building on top of our previous guide (Migrate From Flask to FastAPI Smoothly), we are going to explore the API documentation a little more today.

By now, you should realize that the generated interactive API documentation and ReDoc of a newly created FastAPI server are not that intuitive and lack proper examples of the input and output schema. Let’s have a look at the following examples.

Swagger UI:

Image by Author

From a quick glance, we can deduce that there are two APIs available. The first route is to create a user, while the second route is to get a new user. The information is definitely not sufficient for someone who is new to this API. Besides, the naming is based on the actual name of the function. It can get really confusing later on when more APIs are added to it.

It would be a lot more convenient and self-explanatory if the API documentation looked something like this:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Ng Wai Foong
Ng Wai Foong

Written by Ng Wai Foong

Senior AI Engineer@Yoozoo | Content Writer #NLP #datascience #programming #machinelearning | Linkedin: https://www.linkedin.com/in/wai-foong-ng-694619185/

Write a response