There are various reasons cause the swagger to fail to load the API definition and you will get the error shared in the below screenshot. The below are the possible reasons,
- Swagger misconfiguration
- Controller methods without HTTP verbs (HttpGet, HttpPost etc.)
- Same class name etc…
The Swagger can be launched by adding the ‘/swagger’ after your API URL which doesn’t show the error details causing the Swagger to fail to load.
If you navigate to ‘swagger/v1/swagger.json’ page you will see error details which helpful in addressing the issues.
Note: v1 is the version of your API. Change the version according to your API version.
Once all the issues are addressed then you can launch the Swagger URL to view the API definitions.