Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Api - Swagger documentation error 500

When I access to the swagger url: http://localhost:28483/swagger/ui/index, it generates this error:

500 : undefined http://localhost:28483/swagger/docs/v1

Any ideas?

UPDATED: See this detail error in firebug:

Not supported by Swagger 2.0: Multiple operations
 with path 'api/BimModel' and method 'GET'. See the config setting - \"ResolveConflictingActions\" for
 a potential workaround
like image 724
Minh Nguyen Avatar asked Oct 06 '15 15:10

Minh Nguyen


3 Answers

Swagger might be considering two actions as one operation (like in the case of this common scenario)...

GET api/Products
GET api/Products/{id}

It seems you can use attribute routing to fix this and use these attributes above your actions so swagger will recognize them separately.

[Route("api/Products")]

[Route("api/Products/{id:guid}")]
like image 177
Evan Avatar answered Oct 12 '22 13:10

Evan


Have you tried enable this in you swagger config?

c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
like image 9
Adi Widodo Avatar answered Oct 12 '22 14:10

Adi Widodo


In the controller, it got two different GET operations and it is disallowed by Swagger. I suggest to either have only single GET operation for each controller or modify the router in WebApiConfig

like image 1
Minh Nguyen Avatar answered Oct 12 '22 14:10

Minh Nguyen