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
Metadata
Release files for django-asyncapi 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_asyncapi-0.3.2.tar.gz | 1.2 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_asyncapi-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.3 MB
Release files / django_asyncapi-0.3.2.tar.gz
| Download URL | django_asyncapi-0.3.2.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97beb088a6a30ff07620dc83fd51e8309027362dd44273abaa3958dace2dc76a
|
|
BLAKE2b-256 checksum How to use checksums |
f4737db039857a23a34193e41657102adde184f8d6cdc14e806d6c947a8d96e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Darwin/22.3.0
|
Release files / django_asyncapi-0.3.2-py3-none-any.whl
| Download URL | django_asyncapi-0.3.2-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66ded8e9cc688fce19c1cfbc3d6da8131b713977d342426a87ff927821ea7fe4
|
|
BLAKE2b-256 checksum How to use checksums |
3944c57496ad37670d11ed906e2cc648f20dc2449574fb37e2cf7a818035cbeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Darwin/22.3.0
|
Security for django-asyncapi 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.