cancel
Showing results for 
Search instead for 
Did you mean: 

Required parameter in function comments don't throw exception ?

SOLVED
Highlighted
New 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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
New Contributor

Re: Required parameter in function comments don't throw exception ?

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

2 REPLIES 2
Moderator

Re: Required parameter in function comments don't throw exception ?

Hi there,

 

It looks like you're using swagger-php, or possibly another php library. We don't manage any of the php libraries and don't know them well enough to provide support for them. It's best to file a ticket directly with the project.

 

That said, keep in mind that many Swagger/OAS annotation libraries are meant to document behavior but not enforce it. The enforcement would be done either directly by you, or through the framework you're using.

New Contributor

Re: Required parameter in function comments don't throw exception ?

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

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors