Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to define the payload type (i.e array) #486

Open
PatrickHallek opened this issue May 22, 2023 · 2 comments
Open

Option to define the payload type (i.e array) #486

PatrickHallek opened this issue May 22, 2023 · 2 comments

Comments

@PatrickHallek
Copy link

PatrickHallek commented May 22, 2023

I have interfaces that respond with an array of dto's instead of a single object.

It would be nice if I could somehow define the array type like this:

@AsyncApiPub({
    channel: 'example',
    message: [
        {
            payload: ExampleDto,
            isArray: true,
        },
    ],
})

If this feature is currently available, it would be nice if the documentation could be updated accordingly.
Besides that, awesome package and thanks for your work, I really appreciate it!

@github-actions
Copy link

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.

@molfar808
Copy link

molfar808 commented Oct 22, 2023

Some more info on what i've tried.
We have some POJO (ExampleDto). Gateway function that receives/emits payload events as array: ExampleDto[].
I've tried to around ExampleDto with square brackets like i used to do with OpenAPI documentation:

@AsyncApiPub({
    channel: 'example',
    message: [
        {
            payload: [ExampleDto],
        },
    ],
})

But with no luck - Error: Input is not a corrent AsyncAPI document so it cannot be processed.

I ended up with "payload: Array<ExampleDto>", but in generated doc there was no information about my Dto - it was simply showed as "Array" with an example of "{}".

So it would be nice if format "[ExampleDto]" or additional parameter "isArray: true" (like @PatrickHallek proposed) were supported.

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

No branches or pull requests

2 participants