Metadata-Version: 2.1
Name: fastapi_swagger2
Version: 0.0.1b1
Summary: Swagger2 support for FastAPI framework
Author-email: Viraj Kanwade <virajk.oib@gmail.com>
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development
Classifier: Typing :: Typed
Classifier: Environment :: Web Environment
Classifier: Framework :: AsyncIO
Classifier: Framework :: FastAPI
Classifier: Framework :: Pydantic
Classifier: Framework :: Pydantic :: 1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Dist: fastapi>=0.79.0
Requires-Dist: httpx >=0.23.0 ; extra == "all"
Requires-Dist: ruff ==0.0.272 ; extra == "dev"
Requires-Dist: pytest >=7.1.3,<8.0.0 ; extra == "test"
Requires-Dist: coverage[toml] >= 6.5.0,< 8.0 ; extra == "test"
Requires-Dist: mypy ==1.3.0 ; extra == "test"
Requires-Dist: ruff ==0.0.272 ; extra == "test"
Requires-Dist: black == 23.3.0 ; extra == "test"
Requires-Dist: isort >=5.0.6,<6.0.0 ; extra == "test"
Requires-Dist: httpx >=0.23.0,<0.24.0 ; extra == "test"
Project-URL: Documentation, https://github.com/virajkanwade/fastapi_swagger2
Project-URL: Homepage, https://github.com/virajkanwade/fastapi_swagger2
Provides-Extra: all
Provides-Extra: dev
Provides-Extra: test

# fastapi_swagger2
<p align="center">
Swagger2 support for FastAPI
</p>
<p align="center">
<a href="https://pypi.org/project/fastapi_swagger2" target="_blank">
    <img src="https://img.shields.io/pypi/v/fastapi_swagger2?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://pypi.org/project/fastapi_swagger2" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/fastapi_swagger2.svg?color=%2334D058" alt="Supported Python versions">
</a>
</p>

---

_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.

---

<b>* NOTE: THIS IS STILL WORK IN PROGRESS. CURRENTLY SUPPORTS BASIC SPEC LIKE PATHS, PARAMS, ETC. ANY HELP IS HIGHLY APPRECIATED.</b>

---

## Requirements

Python 3.8+
FastAPI 0.79.0+

## Installation

<div class="termy">

```console
$ pip install fastapi_swagger2
```

</div>

## Example

```Python
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

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

