Swagger:支持可选路线 [英] Swagger: support for optional routes
本文介绍了Swagger:支持可选路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有可选参数的路由:
I have a route with an optional parameter:
[Route("{categoryId?}")]
public HttpResponseMessage Get(int? categoryId=null)
但是,当我没有为 categoryId
提供值时,调用会在请求本身中包含 {categoryId?}
...
However, when I don't provide a value for categoryId
the call includes {categoryId?}
in the request itself...
http://myhost/api/%7BcategoryId%7D
推荐答案
Swagger 不支持可选路径参数.如果您希望以这种方式记录它,则必须创建两个单独的路径 - 一个没有路径参数,一个有.
Swagger has no support for optional path parameters. If you wish to document it this way, you'd have to create two separate paths - one without the path parameter and one with.
这篇关于Swagger:支持可选路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文