所以我使用 NelmioApiDocBundle 以招摇格式记录我的 API。
当我转到 mydomain.com/api/doc 时,我可以看到文档,这很好。但是例如,我根据需要设置查询参数(test_query1),当我在没有此查询的情况下调用 API 时,它会忽略此参数并以 200 响应。如果未通过 test_query1,如何强制 API 以错误响应,无需在 API 中编码?
/**
* Test Controller to check OpenAPI specification
*
* This call prints ID provided in path
*
* @Route("/api/{id}/print", methods={"GET"})
* @SWG\Response(
* response=200,
* description="ID found",
* @SWG\Schema(
* type="integer"
* )
* )
* @SWG\Parameter(
* name="test_query1",
* in="query",
* required=true,
* type="string",
* description="Test Query"
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="id"
* )
*/