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
- 0.1.1 - FastAPI >= 0.99.0, <= 0.99.1
- 0.2.1 - FastAPI >= 0.100.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.2.3.tar.gz
(12.6 kB
view details)
Built Distribution
File details
Details for the file fastapi_swagger2-0.2.3.tar.gz
.
File metadata
- Download URL: fastapi_swagger2-0.2.3.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 798fedd7ba85760ec518a929c8dff1caffeb3146fd73bf476db67afac3b01997 |
|
MD5 | 09bccd9b9570ab8085da4d08e827d044 |
|
BLAKE2b-256 | 7077cbb39071f7f6f201841c765de46c19d80d1be284f0ef8e5e45c2fabd72f9 |
File details
Details for the file fastapi_swagger2-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: fastapi_swagger2-0.2.3-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca70c774bba2e13f4be94f2ccc3827d046343e247ebcc56fad83ec55c79719ed |
|
MD5 | 680b4056ae3aea7e0c4ffdc8edf6c53e |
|
BLAKE2b-256 | 8fcaacd5c94054d7ca4fa3ff951ba904cb34c29c8853818139cdb4f82e3f1d45 |