No project description provided
Project description
django-asyncapi
Generate and host your asyncapi specification using pydantic models
Installation
Install django-asyncapi using pip or poetry:
poetry add django-asyncapi
Usage
- Create specification
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')
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 = {}
"shop.orders.v1" means topic to which our service produces(sends) message described as OrderSchemaV1 pydantic model.
- Add
djanog-asyncapitoINSTALLED_APPS
INSTALLED_APPS = [
...,
"django_asyncapi",
]
- Setup configuration inside
settings.py
DJANGO_ASYNCAPI = {
"ASYNCAPI_SPEC_CLASS": "bus.routing.MySpecialServiceAsyncAPISpecV3",
}
- Add
django-asyncapiurls
from django.urls import path, include
urlpatterns = [
path('docs/', include('django_asyncapi.urls')),
]
- Enjoy your results by opening
docs/asyncapi/v3
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_asyncapi-0.3.2.tar.gz
(1.2 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_asyncapi-0.3.2.tar.gz.
File metadata
- Download URL: django_asyncapi-0.3.2.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/22.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97beb088a6a30ff07620dc83fd51e8309027362dd44273abaa3958dace2dc76a
|
|
| MD5 |
75051751b8ce31930d931a4d5cb626e7
|
|
| BLAKE2b-256 |
f4737db039857a23a34193e41657102adde184f8d6cdc14e806d6c947a8d96e8
|
File details
Details for the file django_asyncapi-0.3.2-py3-none-any.whl.
File metadata
- Download URL: django_asyncapi-0.3.2-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/22.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66ded8e9cc688fce19c1cfbc3d6da8131b713977d342426a87ff927821ea7fe4
|
|
| MD5 |
7e0f9e1bf28422b3f4030582f0283245
|
|
| BLAKE2b-256 |
3944c57496ad37670d11ed906e2cc648f20dc2449574fb37e2cf7a818035cbeb
|