def expected_spec(fake_jsonschema_asdataclass): message = asyncapi.Message( name='Fake Message', title='Faked', summary='Faked message', content_type='application/json', payload=fake_jsonschema_asdataclass.return_value, ) return asyncapi.Specification( info=asyncapi.Info( title='Fake API', version='0.0.1', description='Faked API', ), servers={ 'development': asyncapi.Server( name='development', url='fake.fake', protocol=asyncapi.ProtocolType.KAFKA, description='Fake Server', ) }, channels={ 'fake': asyncapi.Channel( name='fake', description='Fake Channel', subscribe=asyncapi.Operation( operation_id='fake_operation', message=message, ), publish=asyncapi.Operation(message=message), ) }, components=asyncapi.Components( messages={'FakeMessage': message}, schemas={ 'FakePayload': { 'type': 'object', 'properties': { 'faked': { 'type': 'integer' } }, } }, ), )
import dataclasses from typing import Optional import asyncapi @dataclasses.dataclass class UserUpdatePayload: id: str name: Optional[str] = None age: Optional[int] = None dev_server = asyncapi.Server( url='localhost', protocol=asyncapi.ProtocolType.REDIS, description='Development Broker Server', ) message = asyncapi.Message( name='userUpdate', title='User Update', summary='Inform about users updates', payload=UserUpdatePayload, ) user_update_channel = asyncapi.Channel( description='Topic for user updates', subscribe=asyncapi.Operation( operation_id='receive_user_update', message=message, ), publish=asyncapi.Operation(message=message),
import typing import asyncapi from . import success_task_name, failure_task_name, SagaErrorPayload fake_asyncapi_servers = { 'development': asyncapi.Server( url='localhost', protocol=asyncapi.ProtocolType.REDIS, description= "Don't look at this server description, it's just some fake needed to generate AsyncAPI docs" ) } def message_to_channel( message: asyncapi.Message, response: asyncapi.Message = None, publish_made_first=False, description: str = None) -> typing.Tuple[str, asyncapi.Channel]: if publish_made_first: first_action, second_action = 'publish', 'subscribe' else: first_action, second_action = 'subscribe', 'publish' channel_kwargs = { 'description': description, first_action: asyncapi.Operation(message=message, ) }
import dataclasses from typing import Optional import asyncapi @dataclasses.dataclass class UserUpdatePayload: id: str name: Optional[str] = None age: Optional[int] = None dev_server = asyncapi.Server( url='asyncapi-local', protocol=asyncapi.ProtocolType.GCLOUD_PUBSUB, description='Development Broker Server', ) message = asyncapi.Message( name='userUpdate', title='User Update', summary='Inform about users updates', payload=UserUpdatePayload, ) user_update_channel = asyncapi.Channel( description='Topic for user updates', publish=asyncapi.Operation(message=message), ) spec = asyncapi.Specification( info=asyncapi.Info(