https://github.com/roblesdotdev/fastapi-starter
Example API
https://github.com/roblesdotdev/fastapi-starter
Last synced: 8 months ago
JSON representation
Example API
- Host: GitHub
- URL: https://github.com/roblesdotdev/fastapi-starter
- Owner: roblesdotdev
- Created: 2023-06-10T01:36:18.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-11T03:10:11.000Z (about 3 years ago)
- Last Synced: 2025-09-09T13:51:28.768Z (9 months ago)
- Language: Python
- Size: 35.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Getting started with fastapi
### Setup Python Environment
```
pipenv --python 3.10
pipenv shell
pipenv install pytest pylint black --dev
```
### Create makefile with useful commands.
- install
- format
- lint
- test
### Create Open Api Specification
[The Swagger Editor](https://editor.swagger.io) provides a user-friendly interface
that allows you to efficiently add and edit the components of your OAS. You can
specify detailed information such as descriptions, examples, and validation
constraints for each element of your API.
### Generate schema from oas
```
mkdir todo
pipenv install datamodel-code-generator --dev
datamodel-codegen --input oas.yaml output todo/schema.py
```
### Setup fastapi
```
pipenv install fastapi uvicorn
```
```
# todo/server.py
from fastapi import FastApi
server = FastApi(debug=True)
from todo import api
```
```
# todo/api.py
from todo.server import server
@server.get("/hello")
def hello():
return {
'message': 'Hello World'
}
```