This article is the beginning of a series on how to use FastAPI to build an API with Python. Additionally, I'll attach some tools that help to design, develop, and manage the API.
The API will use the OpenAPI specification to help with design, documentation, and testing. Its purpose is to help me find and store related articles on my blog.
Consequently, I'm not sure—yet—how much detail I will go into with the actual code. Furthermore, I won't be available to share the code in a repository. I will share the code that is in each article that may be relevant.
FastAPI framework, high performance, easy to learn, fast to code, ready for production
I heard about FastAPI about a month ago. I'm curious about the framework and want to use this project as an excuse to get to know it better.
Contrary to the features of FastAPI, I decided to use SwaggerHub to create the OpenAPI specification from scratch (basically).
I think in the future, I will opt to generate the specification using FastAPI and Python. That will help autogenerate a lot of the syntax.
Below is a link to the OpenAPI Specification YAML file.
Part of the reason that I created this file before creating the Python project is to follow more of an API-first approach. Although, as mentioned, doing these tasks in tandem is a benefit of FastAPI.
Ideally, the OpenAPI specification would be used immediately by the front-end development team to develop the user interface with a mock API. The mock API can easily be generated from the OpenAPI spec.
Additionally, integration and quality assurance teams could start setting up integration and functional tests based on the mock values.
This isn't permanent because the specification will change, but it creates an asynchronous approach to developing the API as a whole.
In the next article, we'll possibly look at:
- Testing our mock server
- Setting up the FastAPI project