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.
* NOTE: THIS IS STILL WORK IN PROGRESS. CURRENTLY SUPPORTS BASIC SPEC LIKE PATHS, PARAMS, ETC. ANY HELP IS HIGHLY APPRECIATED.
Requirements
Python 3.8+ FastAPI 0.79.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.1b2.tar.gz
(12.3 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_swagger2-0.0.1b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 683e0f7df6d2a3105f75aceb4e1e4c12cdbf5e003b9138a04359bc1277dc3d7d |
|
MD5 | 9d5ba5f83ef08c7bfd9b8b518f1c8a9a |
|
BLAKE2b-256 | f75dc3f9e22c1e677bae48d4a017efb07eabeb281b07722bc1fcc2d11c7d117c |