与Swashbuckle有一些问题,主要是路由。
所以我正在使用一个API,该API具有为某些路由器定义的控制器特定路由以及所有其他路由器的通用默认路由。两者都有路由规范中包含的默认值。
具体路线示例:
config.Routes.MapHttpRoute(
name: "Infobutton",
routeTemplate: "api/Infobutton/{clientId}",
defaults: new
{
controller = "Infobutton",
maxresults = 0,
firstresult = 0,
format = "xhtml",
urlType = "x",
alphaSort = "",
showAll = "false",
spellcheck = "true",
showCategories = "false",
showSnippet = "false",
showGroups = "false",
disableAltSearch = "false",
requireCode = "false",
forceRelevance = "true",
searchtype="",
showSearchedTerms = "true",
searchId = "",
omitBlanks = "false"
}
);
默认路由示例:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new
{
id = RouteParameter.Optional,
query = "",
category = "",
cpt = "",
diagnosis = "",
group = "",
icd10 = "",
icd9 = "",
keyword = "",
title = "",
language = "en",
maxresults = 0,
firstresult = 0,
fields = "",
format = "xml",
encoding = "",
printsize = "",
images = "",
snomed = "",
age = 0,
gender = "",
loinc = "",
ndc = "",
rxnorm = "",
browse = "",
urlType = "",
alphaSort = "",
showAll = "false",
spellcheck = "true",
resultLanguage = "en",
showGroups = "false",
disableAltSearch = "false",
requireCode = "false",
forceRelevance = "false",
showSearchedTerms = "false",
omitBlanks = "false"
}
);
我遇到的问题:
由于通用路由处理程序是一个“全能”swagger选择更具体的路由(在这种情况下为Infobutton)和通用路由,这导致两个函数显示在Swagger UI中。
使用默认值中显示的参数进行Get调用会导致UI中的Get调用完全显示。
任何想法都将不胜感激!