Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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:
- Host: GitHub
- URL: https://github.com/kludex/fastapi-asyncapi
- Owner: Kludex
- License: mit
- Created: 2021-02-19T19:42:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-02T11:56:01.000Z (about 1 year ago)
- Last Synced: 2024-10-12T18:42:05.106Z (about 1 month ago)
- Topics: asyncapi, fastapi, websockets
- Language: Python
- Homepage: https://kludex.github.io/fastapi-asyncapi/
- Size: 593 KB
- Stars: 65
- Watchers: 5
- Forks: 8
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
FastAPI-AsyncAPI
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 AnyHttpUrlfrom 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.