No project description provided
Project description
fastapi-asyncapi
Use pydantic model to construct asyncapi docs and serve inside your asyncapi app
Installation
Install using pip
or poetry
poetry add fastapi-asyncapi
Usage
- Describe your specification using pydantic models
from asyncapi_container.asyncapi.spec.v3.info import Info
from asyncapi_container.containers.v3.simple_spec import SimpleSpecV3
from asyncapi_container.custom_types import RoutingMap
from pydantic import BaseModel, Field
class Customer(BaseModel):
first_name: str = Field(..., title='First Name')
last_name: str = Field(..., title='Last Name')
email: str = Field(..., title='Email', format="email", description="Person's email to deliver order info")
country: str = Field(..., title='Country')
zipcode: str = Field(..., title='Zipcode')
city: str = Field(..., title='City')
street: str = Field(..., title='Street')
apartment: str = Field(..., title='Apartment')
class OrderSchemaV1(BaseModel):
product_id: int = Field(..., title='Product Id')
quantity: int = Field(..., title='Quantity')
customer: Customer
class MySpecialServiceAsyncAPISpecV3(SimpleSpecV3):
info: Info = Info(
title="My special Service",
version="1.0.0",
description="Service for making orders"
)
sends: RoutingMap = {
"shop.orders.v1": [
OrderSchemaV1,
]
}
receives: RoutingMap = {}
- Configure
fast-and-async-api
app using asyncapi spec definition from above Mountfastapi-asyncapi
urls.
from fastapi import FastAPI
from fastest_asyncapi.views.sync.v3.asyncapi import fastest_asyncapi_app
app = FastAPI()
fastest_asyncapi_app.configure(asyncapi_spec_classes=[MySpecialServiceAsyncAPISpecV3])
app.mount("/docs/", fastest_asyncapi_app)
- Enjoy your results by navigating to
docs/asyncapi/v3/
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
Built Distribution
File details
Details for the file fastest_asyncapi-0.1.0.tar.gz
.
File metadata
- Download URL: fastest_asyncapi-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a49219462b0dcda5ed32672c0a4709ee163c65bc53c29dd6f1852674943b6dc |
|
MD5 | 85e9aef6a24d97afe62e7bd2e216ac49 |
|
BLAKE2b-256 | d3ba09bab37f868d7f9a8130cc1b2f0d9b043218ae877693c187f71e18a14d85 |
File details
Details for the file fastest_asyncapi-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: fastest_asyncapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 022831351577c1f541422e9fa94a2b2f3c71c84512eae124d146eea46b4f5029 |
|
MD5 | ae053aa3ca7e893dd9a08ab7cbc28b68 |
|
BLAKE2b-256 | ee74a4dc7ef75fc610cd6916dfd90486c2f20fe5981f7becd6450d7e7095b590 |