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?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue?
Yes I am willing to submit a PR!
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
AsyncAPIInputProcessorsupports optionally including headers schemas during its AsynAPI spec traversal as part of theprocess()function:modelina/src/processors/AsyncAPIInputProcessor.ts
Lines 131 to 141 in 9af5b60
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:
modelina/src/models/ProcessorOptions.ts
Lines 9 to 18 in 9af5b60
A new
AsyncAPIInputProcessorOptionstype should be created which accepts anincludeHeaders?: boolfield.When explicitly set to
true, theAsyncAPIInputProcessorwill also include message headers alongside message payloads.🚧 Breaking changes
No
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue?
Yes I am willing to submit a PR!