i've built a Web API in ASP.Net Core (version 1.1.2) and i use the Swashbuckle.AspNetCore for generating the swagger definition.
below is a part of the automatically generated swagger definition. i would like to change the paths so it does not include /api/ApiName but it would be included in the basePath which is now /
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "ApiName.V1"
},
"host": "ApiUrl",
"basePath": "/api/ApiName",
"paths": {
"/": {
"get": {
"tags": [
"ApiName"
],
.........
so what i would like to get is:
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "ApiName.V1"
},
"host": "ApiUrl",
"basePath": "/",
"paths": {
"/api/ApiName": {
"get": {
"tags": [
"ApiName"
],
.........
We have some other APIs which are not written in .Net Core and there it fixed the same issue by adding default routes. I tried to do the same on .Net core by removing the route at the top of the API controller
[Route("api/[Controller]")]
and adding it to the Startup.cs. however this did not work. Does anyone have any idea on how to fix this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…