我正在使用 swagger ui,我有一个 Get api,它采用可选参数,但我无法为该 api 提供注释,下面是我尝试过的 make 代码:
/**
* @SWG\Get(
* path="/basics/checkDataNameAvailability/{type}/{name}{/id}",
* tags={"Emergency"},
* description="Return data useful for userGroup, deviceGroups and deviceTags",
* produces={"application/json", "application/xml", "text/xml", "text/html"},
* @SWG\Parameter(name="type",in="path",description="return useful data by type",required=true,type="integer", @SWG\Items(type="integer"),collectionFormat="csv",format="int32"),
* @SWG\Parameter(name="name",in="path",description="return useful data by name",required=true,type="integer", @SWG\Items(type="integer"),collectionFormat="csv",format="int32"),
* @SWG\Parameter(name="id",in="path",description="optional, useful data by id",required=true,type="integer", @SWG\Items(type="integer"),collectionFormat="csv",format="int32"),
* @SWG\Response(response=200,description="Dashboard Response",
* @SWG\Schema(type="array",@SWG\Items(ref="#/definitions/Pet"))
* ),
* @SWG\Response(response="default",description="unexpected error",
* @SWG\Schema(ref="#/definitions/ErrorModel")
* ),
* @SWG\ExternalDocumentation(description="find more info here", url="https://swagger.io/about")
* )
*/
我的 Get api 结构是这样的:
$app->get('/checkDataNameAvailability/:type/:name(/:id)', function($type, $name, $id = '') use($app){
//here is my api code
});
但是当我尝试这样做时,swagger ui 不采用id可选参数,它采用必需参数,帮助我..