Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kludex/fastapi-asyncapi

OpenAPI is not enough for you? 😡 Let's try AsyncAPI! :angel:
https://github.com/kludex/fastapi-asyncapi

asyncapi fastapi websockets

Last synced: 27 days ago
JSON representation

OpenAPI is not enough for you? 😡 Let's try AsyncAPI! :angel:

Awesome Lists containing this project

README

        


FastAPI-AsyncAPI




Latest Commit






Package version



FastAPI-AsyncAPI is a utility tool to write documentation for your [FastAPI](https://github.com/tiangolo/fastapi) endpoints using [AsyncAPI](https://github.com/asyncapi).

It provides support for WebSockets, which is currently missing in OpenAPI.

> This package is not completed. Help is wanted.

## Installation

``` bash
pip install fastapi-asyncapi
```

## Usage

``` python
from fastapi import FastAPI
from pydantic import AnyHttpUrl

from fastapi_asyncapi import get_asyncapi, get_asyncapi_html

app = FastAPI(title="MyAPI", version="1.0.0", docs_url=None)

@app.get("/asyncapi.json")
async def asyncapi_json():
return get_asyncapi(title=app.title, version=app.version, routes=app.routes)

@app.get("/docs")
async def asyncapi_docs():
asyncapi_url = AnyHttpUrl("asyncapi.json", scheme="http")
return get_asyncapi_html(asyncapi_url=asyncapi_url, title=app.title)
```

## License

This project is licensed under the terms of the MIT license.