Leandro
6 years agoNew Contributor
Required parameter in function comments don't throw exception ?
/**
* @SWG\Get(
* path="/chargeability/{entity_type}/{id}/{weekStart}/{weekEnd}",
* summary="Get chargeability data for a team",
* tags={"Chargeability"},
* @SWG\Parameter(name="entity_type", type="string", required=true, in="path"),
* @SWG\Parameter(name="id", type="string", required=true, in="path"),
* @SWG\Parameter(name="weekStart", type="string", required=true, in="path"),
* @SWG\Parameter(name="weekEnd", type="string", required=true, in="path"),
* @SWG\Response(response=200,description="Chargeability detail"),
* )
*/
public function run() {
...
foo($this->params['weekStart']);
}
I get the exception "weekStart is undefined", but in the comments I put a required=true to this param.
Should swagger throw an exception for this ? Or I have to check manually if parameters are set even if it is specified in the comment ?
Hello
Yes I am using php-swagger.
One of my coleague explained to me that it was just to generate a documentation and it does no validation.So required parameter in function comments don't throw an exception
Have a nice day