Swagger-UI Symfony NelmioAPIDoc 添加多个 responseType 选项

Swagger-UI Symfony NelmioAPiDoc add multiple responseType options

我正在寻找一种向 swagger-ui 添加多种响应类型的方法,通过 NelmioAPIDoc

实现

我想要 image/jpeg 作为响应类型的选项 我有代码可以在控制器中工作以将 body 设置为图像,即使响应类型仍然是 application/json 但我的目标是如果选择 'application/json' 它 returns json 格式的图像 url,但是如果选择 'image/jpeg' 它 returns 图像到 body。非常感谢任何帮助。

 /**
 * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
 *
 * @Route("/api/airs/renderframe", name="get_airs_frame", methods={"GET"})
 *
 * @SWG\Response(
 *     response=200,
 *     description="Returns json image url from paramaters",
 * )
 * @SWG\Parameter(
 *     name="imageHost",
 *     in="query",
 *     type="string",
 *     description="image host"
 * )
 * @SWG\Parameter(
 *     name="imagePath",
 *     in="query",
 *     type="string",
 *     description="image path"
 * )
 *

我也试过将它添加到我的 class 的顶部,但仍然有一个下拉选项

 /**
 *  @SWG\Swagger(
 *               schemes={"http"},
 *               produces={"image/jpeg","application/json"},
 *               consumes={"application/json"}
 *  )
 */

通过将 produces{} 放入 @SWG\Get() 使其工作,但响应类型不在请求中,因为参数现在需要弄清楚如何访问值

    /**
 * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
 *
 * @Route("/api/airs/renderframe", name="get_airs_frame", methods={"GET"})
 *
 * @SWG\Get(
 *     produces={"application/xml", "application/json"},
 *     @SWG\Parameter(
 *         name="imageHost",
 *         in="query",
 *         type="string",
 *         description="image host"
 *     ),
 *     @SWG\Parameter(
 *         name="imagePath",
 *         in="query",
 *         type="string",
 *         description="image path"
 *     ),
 *     @SWG\Parameter(
 *         name="resource",
 *         in="query",
 *         type="string",
 *         default="renderframe/serveframe",
 *         description="Render picture in frame"
 *     ),
 *     @SWG\Parameter(
 *         name="maxSize",
 *         in="query",
 *         type="integer",
 *         description="image max Size"
 *     ),
 *     @SWG\Parameter(
 *         name="inchesWidth",
 *         in="query",
 *         type="integer",
 *         description="image inches WIdth"
 *     ),
 *     @SWG\Parameter(
 *         name="inchesHeight",
 *         in="query",
 *         type="integer",
 *         description="image inches Height"
 *     ),
 *     @SWG\Response(
 *         response=200,
 *         description="Returns json image url from paramaters",
 *     ),
 *     @SWG\Tag(name="Render picture in frame")
 * )