No project description provided
Project description
django-asyncapi
Generate and host your asyncapi specification using pydantic models
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 = {}
- Add
djanog-asyncapi
to `INSTALLED_APPS
INSTALLED_APPS = [
...,
"django_asyncapi",
]
- Setup configuration inside
settings.py
DJANGO_ASYNCAPI = {
"ASYNCAPI_SPEC_CLASS": "bus.routing.MySpecialServiceAsyncAPISpecV3",
}
- Add
django-asyncapi
urls
from django.urls import path, include
urlpatterns = [
path('docs/', include('django_asyncapi.urls')),
]
- Enjoy your result
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.1.1.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file django_asyncapi-0.1.1.tar.gz
.
File metadata
- Download URL: django_asyncapi-0.1.1.tar.gz
- Upload date:
- Size: 3.4 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 | 7d0a142dc843c5051fb1949826679e473fba7eeed57d0072f673294278aa9b6c |
|
MD5 | 674010e31358bffbe98b0c4f20abb239 |
|
BLAKE2b-256 | faab08c387ea9868a7159cd36d24d59cd14d0083ee4e1b6f13e7ba5c88464776 |
File details
Details for the file django_asyncapi-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: django_asyncapi-0.1.1-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 | 2e8769859882199715a18efedbb5ab8cd9df82f88092dda6be24c45ea8cbb797 |
|
MD5 | 41a813e88eeaf692e4a90bd388df5f5e |
|
BLAKE2b-256 | 6ce10f39b643a1f7afc0ea1a3369d829820eb2ac1102a6686c472c0d65681aa6 |