Multiple Examples with @Response Decorator not possible anymore #1570
Labels
bug
good first issue
This issue could be an easy PR for those looking to help contribute
help wanted
Looking for a way to add multiple examples with the @response decorator, I think I found a bug.
I've gathered all the info I could find and made my assumption where and how things go not as I expected them to. But I'm not quite sure how my suggested solution would work with other examples like the @Example-ones for the @SuccessResponse. So if I misunderstood something I hope you can help me out! If my solution would fit, I would be happy to create a pull request for it!
Thanks in advance!
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
The following example shows how I would define multiple examples for a e.g. response with status code 422 by defining an array of examples of ResponseType.
I would expect this to produce a swagger.json like this:
Current Behavior
Currently this does not work and only adds the two examples as value of "Example 1".
While searching for a solution to my problem, I came across the issue (#650) and the pull request (#727) for it. As far as I understand it, this already removed the option to specify multiple examples with a @Responses Decorator.
A later commit by @WoH (WoH@9c228a4) fixed a bug with undefined examples, but the passed example, if defined, was passed as a single entry in an array.
In my opinion, this leads to the above mentioned problem that several example-objects are set as the value of the first and only example in the swagger.json.
Possible Solution
If I have understood it correctly, a possible solution to the problem would be to check whether
example
is an array and, if so, to pass it directly:Steps to Reproduce
Context (Environment)
Version of the library: v6.0.1
Version of NodeJS: 20.9.0
Detailed Description
--
Breaking change?
--
The text was updated successfully, but these errors were encountered: