An AsyncAPI python parser, that supports all versions
These are the options that can be provided when parsing AsyncAPI documents;
By default, all references are resolved when the document is parsed, however, if wanted you can turn this off by providing the option resolve_references
when parsing a document.
parse(data, ParserOptions({'resolve_references': True}))
By default, the input is validated against the official AsyncAPI JSON Schema documents, however, if wanted you can turn this off by providing the option validate_input
when parsing a document.
parse(data, ParserOptions({'validate_input': True}))
By default, traits are applied when parsed, however, if wanted you can turn this off by providing the option apply_traits
.
parse(data, ParserOptions({'apply_traits': True}))
All parts of the parsed AsyncAPI document can be serialized back into JSON.
document = {}
parsedDocument = parse(data)
serializedDocument = parsedDocument.json()
NOTICE: If
traits
orreferences
have been applied,document
andserializedDocument
will never be the same.
Through the AsyncAPI Python models, you can create AsyncAPI documents directly in your code instead of parsing existing documents.
document = AsyncApi2Dot0Dot0SchemaDot({'asyncapi': '3.0.0', 'info': {'title': 'smartylighting', 'version': '1.0.0'}})
You can also overwrite existing functions
document = AsyncApi2Dot0Dot0SchemaDot({'asyncapi': '3.0.0', 'info': {'title': 'smartylighting', 'version': '1.0.0'}})
document.id('urn:example:com:smartylighting:streetlights:server')
These are the current known restrictions;