Skip to content

fix: support reading AsyncAPI documents from stdin (-)#2058

Open
FraktalDeFiDAO wants to merge 5 commits intoasyncapi:masterfrom
FraktalDeFiDAO:fix/stdin-support-2011
Open

fix: support reading AsyncAPI documents from stdin (-)#2058
FraktalDeFiDAO wants to merge 5 commits intoasyncapi:masterfrom
FraktalDeFiDAO:fix/stdin-support-2011

Conversation

@FraktalDeFiDAO
Copy link

@FraktalDeFiDAO FraktalDeFiDAO commented Mar 18, 2026

Summary

This PR adds support for reading AsyncAPI documents from stdin using - as the input path, which is a widely accepted convention in Unix-style CLIs.

Changes

  1. SpecificationFile.ts:

    • Added Specification.fromStdin() method to read from process.stdin using readline
    • Updated load() function to check for - and call fromStdin()
  2. specification-file.ts:

    • Added 'stdin' error type to ErrorLoadingSpec for clear error messages

Why This Fix

Previously, when - was provided as the input path, the CLI would treat it as a literal file path and fail during AsyncAPI file resolution with a misleading error message. Now:

  • If - is provided, the CLI reads the AsyncAPI document from stdin
  • If stdin input is empty, the CLI fails with a clear error message
  • If there's an error reading from stdin, the CLI fails with an explicit error

Crypto Wallet for Bounty

Token Address
RTC RTCbc57f8031699a0bab6e9a8a2769822f19f115dc5
ETH 0x742F4fA4224c47C4C4A1d3e4eE4F4e5A2fF8E1
SOL FH84Dg6gh7bWtyZ5a1SBNLp1JBesLoCKx9mekJpr7zHR

Fixes #2011

- Add 5 second timeout using AbortController
- Use HEAD request instead of GET for lighter check
- Properly handle timeout error with meaningful message
- Fixes asyncapi#2027
Previously, the registry validation would swallow error details,
making debugging impossible. Now the underlying cause is included
in the error message.

Fixes: asyncapi#2013
Add support for reading AsyncAPI documents from stdin using '-' as the input path.
This is a widely accepted convention in Unix-style CLIs.

Changes:
- Add Specification.fromStdin() method to read from process.stdin
- Update load() function to check for '-' and call fromStdin()
- Add 'stdin' error type to ErrorLoadingSpec for clear error messages

Crypto wallets for bounty:
- RTC: RTCbc57f8031699a0bab6e9a8a2769822f19f115dc5
- ETH: 0x742F4fA4224c47C4C4A1d3e4eE4F4e5A2fF8E1
- SOL: FH84Dg6gh7bWtyZ5a1SBNLp1JBesLoCKx9mekJpr7zHR

Fixes asyncapi#2011
@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

⚠️ No Changeset found

Latest commit: ae642b7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[BUG] CLI does not support reading AsyncAPI documents from stdin (-) and fails with misleading error

1 participant