[BUG] CLI crashes with TypeError when AsyncAPI document file is empty
- Dominant language
- TypeScript
- Stars
- 272
- Forks
- 375
- Avg merge
- 3h 22m
- Merged PRs (30d)
- 8
Description
### Describe the bug.
When running the AsyncAPI CLI with an empty AsyncAPI file, the CLI crashes with a raw JavaScript TypeError instead of showing a user-friendly validation error.
### Expected behavior
The CLI should detect that the AsyncAPI file is empty and return a clear error message, such as:
`The provided AsyncAPI file is empty or invalid.`
### Screenshots
### How to Reproduce
1. Create an empty AsyncAPI file:
```
touch empty.yaml
```
2. Create a minimal valid generator template:
```
mkdir -p test-template/template
cat > test-template/package.json <=2.0.0"
}
EOF
echo "test" > test-template/template/test.txt
```
3. Run the AsyncAPI CLI:
```
asyncapi generate fromTemplate empty.yaml ./test-template -o out
```
### 🖥️ Device Information [optional]
- Operating System (OS): Windows(WSL)
- Browser:
- Browser Version:
### 👀 Have you checked for similar open issues?
- [x] I checked and didn't find similar issue
### 🏢 Have you read the Contributing Guidelines?
- [x] I have read the [Contributing Guidelines](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)
### Are you willing to work on this issue ?
yes
Contributor guide
Assessment
This issue has not been assessed yet.