Skip to main content

fastest-asyncapi

Use pydantic model to construct asyncapi docs and serve inside your asyncapi app

Installation

Install using pip or poetry

poetry add fastest-asyncapi

Usage

  1. 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 = {}
  1. Configure fast-and-async-api app using asyncapi spec definition from above Mount fastapi-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)
  1. Enjoy your results by navigating to docs/asyncapi/v3/

alt text

PS: images generated by AI

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_asyncapi_docs-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_asyncapi_docs-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_asyncapi_docs-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.2 Darwin/22.3.0

File hashes

Hashes for fastapi_asyncapi_docs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af53949c8ba9511a8432d8550b3f2a73510ff567bc618b3f89103f8a1649050c
MD5 4a54c113594742f315f45549d0d68a13
BLAKE2b-256 a0fece96b355be6ebec2d73d5274d68a621bc5b46e0f449cb54c85eb42dbc8c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_asyncapi_docs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fa5ecc85f24f065d0c998a69d54be0dbdc91c69c413106db06f7a7b6095edc7
MD5 1af48a69d15da586ea2655ce8d2a066d
BLAKE2b-256 7d87ede663fe03ea2e3e9fcd7aad5a36eef8005674619e13fe780477ee362e86

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page