Swagger: support for optional routes

假如想象 提交于 2020-01-03 13:07:48

问题


I have a route with an optional parameter:

    [Route("{categoryId?}")]
    public HttpResponseMessage Get(int? categoryId=null)

However, when I don't provide a value for categoryId the call includes {categoryId?} in the request itself...

http://myhost/api/%7BcategoryId%7D

回答1:


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.



来源:https://stackoverflow.com/questions/30182657/swagger-support-for-optional-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!