Swagger2 support for FastAPI framework
Project description
fastapi_swagger2
Swagger2 support for FastAPI
Reason behind this library:
Few API GW services like Google Cloud API GW still support only Swagger 2.0 spec. Since FastAPI only supports OAS3, it is a challenge. Converting from OAS3 to Swagger 2.0 requires some manual steps which would hinder CI/CD.
Requirements
Python 3.8+
0.0.3 - FastAPI >= 0.79.0, <= 0.98.0
Installation
$ pip install fastapi_swagger2
Example
from typing import Union
from fastapi import FastAPI
from fastapi_swagger2 import FastAPISwagger2
app = FastAPI()
FastAPISwagger2(app)
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
This adds following endpoints:
- http://localhost:8000/swagger2.json
- http://localhost:8000/swagger2/docs
- http://localhost:8000/swagger2/redoc
Development
$ pip install "/path/to/fastapi_swagger2/repo[test,all]"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastapi_swagger2-0.0.3.tar.gz
(13.8 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_swagger2-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 688b3d6baa58cbebd6e43f59cac2feee067d8ce2e2339a34fdf8321894ef7f17 |
|
MD5 | 00912c372e21fa3b08e5785941796bec |
|
BLAKE2b-256 | e85eb208b93f65425b28cfdc0b20752cfa293ca757b4c862efd7e9e6833428dd |