2017-06-20 48 views
1

我正在尋找一種方式來添加多個響應類型招搖的UI通過NelmioAPiDoc實施揚鞭-UI的Symfony NelmioAPiDoc添加多個responseTyp的選項

enter image description here

我想爲圖像/ JPEG作爲一個選項響應類型我有代碼工作在控制器設置身體的圖像,即使響應類型仍然說的應用程序/ JSON但我的目標是如果'應用程序/ JSON'被選中它返回圖像的JSON格式的網址,但是如果選擇'image/jpeg',它會將圖像返回到主體。任何幫助不勝感激。

/** 
* @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" 
*) 
* 

我自己也嘗試添加該到我班上的第一名,但仍然有一個下拉選項

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

回答

0

得到它通過將產生{}的@SWG \進去工作( )但響應類型不在請求中作爲參數需要計算出現在如何訪問該值

/** 
* @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") 
*)