user1930591
user1930591

Reputation: 307

Swagger-UI detecting the response content-type selected

I have a route that produces a link to a image url, I am trying to have the api return json if response content-type "application/json" and return a image preview if the response content-type is "image/jpeg" everything is working except I do not know how to access this parameter from the controller to know what response type has been selected, the $request objects only parameters are the parameters I specify for swagger I do not get the select menu values. I thought about adding a hidden parameter and setting it with javascript but that does not sound like the right way. Any help greatly appreciated

 /*
 * @SWG\Get(
 *
 *     produces={"application/json", "image/jpeg"},
 *     tags={"Render frame"},
 *     @SWG\Parameter(
 *         name="imageHost",
 *         in="query",
 *         default ="https://i.vimeocdn.com",
 *         type="string",
 *         description="image host"
 *     ),
 *

Upvotes: 0

Views: 796

Answers (1)

user1930591
user1930591

Reputation: 307

I found it in the $request I did not relize swagger-ui was setting it based on the dropdown

$request->headers->get('accept');

Upvotes: 1

Related Questions