How can view the swagger ui for Azure API app
In the configuration of your WebAPI project (SwaggerConfig.cs
in the folder App_Start
), you have to enable the Swagger UI. It is commented out as default behavior.
Just open the configuration, search for:
/* }) .EnableSwaggerUi(c => { */
and disable the comments in the lines above and under it
Pedro, above, has provided a perfect answer for enabling SwaggerUi.As for your question regarding the URL "swagger/docs/v1
"
This is the default URL used by Swashbuckle to return Swagger 2.0 JSON metadata for the API
The SwaggerConfig.cs
file is created when you install the Swashbuckle package in a project. You can find it in the folder "App_Start" . It provides a number of ways to configure Swashbuckle. I haven't checked if you can change that default URL or do URL rerouting for it.
Edited:
The default route templates for the Swagger docs and swagger-ui are "swagger/docs/{apiVersion}" and "swagger/ui/{*assetPath}" respectively. You can change these so long as the provided templates include the relevant route parameters - {apiVersion} and {*assetPath}.For example: the URL to swagger-ui will be myswag/index.
httpConfiguration .EnableSwagger("docs/{apiVersion}/swagger", c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi("myswag/{*assetPath}");
You can read more about it here in the GitHub repo: https://github.com/domaindrivendev/Swashbuckle
If you are creating API using Template Azure API App in visual studio, you just need to un-comment few lines from SwaggerConfig.cs file to activate Swagger for your API application.
In your solution look for the file 'SwaggerConfig.cs'
'VSSolution' > App_Start > SwaggerConfig.cs
Look for EnableSwaggerUi and remove comments for below line of code
/* }) .EnableSwaggerUi(c => { */
That's it, No Other Configuration Required.
Just run the application :http://localhost:57452/swagger