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

SwaggerResponseAttribute - Type of IEnumerable #372

Closed
JohnYoungers opened this issue Jun 4, 2015 · 2 comments
Closed

SwaggerResponseAttribute - Type of IEnumerable #372

JohnYoungers opened this issue Jun 4, 2015 · 2 comments

Comments

@JohnYoungers
Copy link

I just started playing around with this library today, so I may be missing something, but is this attribute compatible with IEnumerable?

If I set it to something like this, in the UI it correctly shows the model/schema:
[SwaggerResponse(System.Net.HttpStatusCode.BadRequest, "Validation Failed", typeof(ValidationResult))]

However, if I try to say it's an enumeration of some kind, the UI shows nothing for the response model:
[SwaggerResponse(System.Net.HttpStatusCode.BadRequest, "Validation Failed", typeof(ValidationResult[]))]
[SwaggerResponse(System.Net.HttpStatusCode.BadRequest, "Validation Failed", typeof(List<ValidationResult>))]
[SwaggerResponse(System.Net.HttpStatusCode.BadRequest, "Validation Failed", typeof(IEnumerable<ValidationResult>))]

If I set the ResponseType to the same enumerable, the "Response Class (Status 200)" section at the top does populate correctly. I tried to fork the project to determine if these two sections were following different logic, but I couldn't really tell either way.

The project looks great! And I saw the thread about questioning whether to include this SwaggerResponse attribute, and I think it was a good choice adding it in! Thanks!

edit
Looking at the data that is getting sent to the browser, it does appear everything is getting setup correctly:
image

There must just be an issue on the display side

@domaindrivendev
Copy link
Owner

I believe this is actually an issue with the swagger-ui as opposed to SB itself.

First and foremost, SB is a Swagger JSON generator. For convenience though, it does include an embedded version of swagger-ui, which consumes the generated JSON, so that you can seamlessly provide a rich documentation UI with a one-line Nuget install.

Can you view the raw JSON directly (browse to swagger/docs/v1) and check if the responses are being added correctly?. I suspect this to be the case but it would be great if you can confirm.

This means that SB is doing it's job correctly. However, I've noticed the support in swagger-ui for error model descriptions is somewhat limited and I think this may be what you're experiencing. If this is the case, then the swagger-ui repo may be a better place to find some answers or post an issue:)

Let me know ...

@JohnYoungers
Copy link
Author

Yep, after originally posting I edited it to note it appears the JSON seems to be correct.

Sorry, I didn't realize the actual ui piece was a separate project; I'll post this scenario over there and we'll see what we can find.

Thanks!

Looks like it's related to these:
swagger-api/swagger-ui#1297
swagger-api/swagger-ui#1248

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