Skip to content

[FEATURE] Headers schema support in AsyncAPIInputProcessor #2482

Description

@matthew-inamdar

Why do we need this improvement?

We have a use-case where we need both the payload and headers of a message defined in our AsyncAPI spec to have types generated.

Currently, only message payloads have types generated.

I am proposing that the AsyncAPIInputProcessor supports optionally including headers schemas during its AsynAPI spec traversal as part of the process() function:

for (const message of messages) {
const payload = message.payload();
if (!payload) {
continue;
}
// Add each individual message payload as a separate model
addToInputModel(payload);
oneOf.push(payload.json());
}

How will this change help?

For use-cases where headers schemas need to be typed for code-gen.

Screenshots

No response

How could it be implemented/designed?

Currently, the AsyncAPI takes no specific input processor options:

export interface ProcessorOptions {
asyncapi?: ParseOptions;
openapi?: OpenAPIInputProcessorOptions;
typescript?: TypeScriptInputProcessorOptions;
jsonSchema?: JsonSchemaProcessorOptions;
/**
* @deprecated Use the `jsonSchema` options instead of `interpreter`
*/
interpreter?: InterpreterOptions;
}

A new AsyncAPIInputProcessorOptions type should be created which accepts an includeHeaders?: bool field.

When explicitly set to true, the AsyncAPIInputProcessor will also include message headers alongside message payloads.

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions