Debugging Swashbuckle Error - Failed to load API Definition
Agree that the UI debugging isn't really useful, however the full exception trace can be scraped by opening up your browser's debugging tools (e.g. F12 on Chrome), refreshing your /swagger
endpoint, and then examining the swagger.json
payload - this is an XHR request which will fail with a 500
status code.
(I would suggest on a big project that you bookmark the link, so that in future you can just go straight to the json file, e.g. https://MyHost/swagger/v1/swagger.json
)
e.g. in the below contrived error, I've duplicated the same route between two methods:
[HttpGet]
[Route("parseenum")]
public ActionResult CheckEnum([FromQuery] MyEnum someEnum)
...
[HttpGet]
[Route("parseenum")]
public ActionResult CheckEnum2([FromQuery] MyEnum someEnum)
...
Which produces the error:
Which you should now be able to track down and fix.
If your api have same two or more [HttpGet]
its not working swagger.
You should be specify [HttpGet] , [HttpGet ("{id}")]
[HttpGet]
`[HttpGet ("{id}")]`