doushih06137 2019-01-08 12:14
浏览 88

我正在使用NelmioApiDocBundle来记录我的API。 如何在注释中强制执行验证?

So I'm using NelmioApiDocBundle to document my API in swagger format.

When i go to mydomain.com/api/doc I can see the documentation and it's fine. But for example I'm setting the query parameter (test_query1) as required, and when I call the API without this query it ignores this parameter and responds with 200. How can I force the API to respond with an error if test_query1 is not passed, without coding in the 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"
 * )
 */
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 Revit2020下载问题
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数