2017-07-13 37 views
0

假设有一个具有可选参数的URL路径的API:如何在API蓝图中记录路径中的可选参数?

## Get FooBar [/foo/bar/{type}] 

+ Parameters 
    + type (optional, string, `widget`) ... Filter for a specific bar type 

当然的type参数确实应该查询参数,但API实现,因为它是和不能优化。

type可以在URI模板中表示这种可选性吗?

回答

1

是的,你可以显示可选参数,只需在问号前添加它们的块。

## Get FooBar [/foo/bar/{?type} 

+Parameters 

    +type (optional) The widget type you want back, if any. 
相关问题