Skip to main content

Swagger2 support for FastAPI framework

Project description

fastapi_swagger2

Swagger2 support for FastAPI

Package version Supported Python versions


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.2 - FastAPI >= 0.79.0, <= 0.98.0 0.1.0 - FastAPI >= 0.99.0, <= 0.99.1

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:

Development

$ pip install "/path/to/fastapi_swagger2/repo[test,all]"

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.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

fastapi_swagger2-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_swagger2-0.1.0.tar.gz.

File metadata

  • Download URL: fastapi_swagger2-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.3

File hashes

Hashes for fastapi_swagger2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 51c7b95e9673246644d3d294ec737e7fa83422046d1251488117988265ecd23d
MD5 807a07b99de1d86526d11d2bd7a5c71b
BLAKE2b-256 704600d576c94d8cc894df5547101efdb2e6b2baac0a7914834d7985684e95d3

See more details on using hashes here.

File details

Details for the file fastapi_swagger2-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_swagger2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 026dbcb53d62490a39fdc8f4d724fcfac1a5d8ab3ad97c1e1792f5d1a39e761e
MD5 1b7a9a622b29c0256c7a28027b38c2aa
BLAKE2b-256 29df48c7604ce1095ce2001e2356865062eb0717316b61e1df42cb237c6ecff0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page