https://github.com/the-codegen-project/asyncapi-python-parser
An AsyncAPI Python parser that is always up to date with the specification!
https://github.com/the-codegen-project/asyncapi-python-parser
asyncapi asyncapi-python parser python python3
Last synced: 5 months ago
JSON representation
An AsyncAPI Python parser that is always up to date with the specification!
- Host: GitHub
- URL: https://github.com/the-codegen-project/asyncapi-python-parser
- Owner: the-codegen-project
- Created: 2024-02-14T14:51:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-13T18:04:02.000Z (over 1 year ago)
- Last Synced: 2025-08-22T04:46:29.736Z (5 months ago)
- Topics: asyncapi, asyncapi-python, parser, python, python3
- Language: Python
- Homepage:
- Size: 495 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Python AsyncAPI Parser
## Parsing options
These are the options that can be provided when parsing AsyncAPI documents;
### Reference resolvement
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.
```py
parse(data, ParserOptions({'resolve_references': True}))
```
### Validating input
By default, the input is validated against the [official AsyncAPI JSON Schema documents](https://github.com/asyncapi/spec-json-schemas/), however, if wanted you can turn this off by providing the option `validate_input` when parsing a document.
```py
parse(data, ParserOptions({'validate_input': True}))
```
### Applying traits
By default, traits are applied when parsed, however, if wanted you can turn this off by providing the option `apply_traits`.
```py
parse(data, ParserOptions({'apply_traits': True}))
```
## Serializing parsed documents
All parts of the parsed AsyncAPI document can be serialized back into JSON.
```py
document = {}
parsedDocument = parse(data)
serializedDocument = parsedDocument.json()
```
> NOTICE: If `traits` or `references` have been applied, `document` and `serializedDocument` will never be the same.
## Creating new AsyncAPI documents
Through the AsyncAPI Python models, you can create AsyncAPI documents directly in your code instead of parsing existing documents.
```py
document = AsyncApi2Dot0Dot0SchemaDot({'asyncapi': '3.0.0', 'info': {'title': 'smartylighting', 'version': '1.0.0'}})
```
## Reading and Overwriting values
You can also overwrite existing functions
```py
document = AsyncApi2Dot0Dot0SchemaDot({'asyncapi': '3.0.0', 'info': {'title': 'smartylighting', 'version': '1.0.0'}})
document.id('urn:example:com:smartylighting:streetlights:server')
```
# Restrictions
These are the current known restrictions;
- Private reference