Skip to content

feat: add support for AsyncAPI headers#2484

Open
matthew-inamdar wants to merge 7 commits into
asyncapi:masterfrom
matthew-inamdar:master
Open

feat: add support for AsyncAPI headers#2484
matthew-inamdar wants to merge 7 commits into
asyncapi:masterfrom
matthew-inamdar:master

Conversation

@matthew-inamdar

@matthew-inamdar matthew-inamdar commented Mar 11, 2026

Copy link
Copy Markdown

Description

This PR adds opt-in support for header schemas in AsyncAPI specifications.

The ProcessorOptions type now accepts a new AsyncAPIInputProcessorOptions type for the asyncapi field.

The AsyncAPIInputProcessorOptions type has a single boolean option for includeMessageHeaders.

When includeMessageHeaders is set to true the following logic applies:

  1. During AsyncAPI traversal, models are generated for headers along with the existing logic of payloads.
  2. For operations with multiple messages:
    1. The payload union model name is suffixed with Payload
    2. The header union model is added and suffixed with Headers

N.B. I expect both the change in behavior for 2.i., and also the suffix naming convention to possibly be contentious and are therefore looking for guidance on these approaches.

Related Issue

#2482

Checklist

  • The code follows the project's coding standards and is properly linted (npm run lint).
  • Tests have been added or updated to cover the changes.
  • Documentation has been updated to reflect the changes.
  • All tests pass successfully locally.(npm run test).

Additional Notes

There is a further consideration about having a type generated for each message which is composed of headers and payload types – this would allow for discriminating once for the entire message instead of separately for both the headers and the payload.

This seems to require further changes to the behavior and I'm not confident if there is an appetite for it. If there is, I'll be happy to look into this approach.

@netlify

netlify Bot commented Mar 11, 2026

Copy link
Copy Markdown

Deploy Preview for modelina canceled.

Name Link
🔨 Latest commit 734b258
🔍 Latest deploy log https://app.netlify.com/projects/modelina/deploys/69fef78e5686470007702ea9

@matthew-inamdar matthew-inamdar changed the title Add support for AsyncAPI headers feat: Add support for AsyncAPI headers Mar 11, 2026
@matthew-inamdar matthew-inamdar changed the title feat: Add support for AsyncAPI headers feat: add support for AsyncAPI headers Mar 11, 2026
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented May 9, 2026

Copy link
Copy Markdown

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 25596816485

Coverage decreased (-1.0%) to 91.034%

Details

  • Coverage decreased (-1.0%) from the base build.
  • Patch coverage: 17 of 17 lines across 1 file are fully covered (100%).
  • 50 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

50 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
src/models/XsdSchema.ts 30 59.87%
src/helpers/XsdToMetaModel.ts 20 68.56%

Coverage Stats

Coverage Status
Relevant Lines: 7433
Covered Lines: 6955
Line Coverage: 93.57%
Relevant Branches: 2772
Covered Branches: 2335
Branch Coverage: 84.24%
Branches in Coverage %: Yes
Coverage Strength: 369.78 hits per line

💛 - Coveralls

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants