Search code examples
laravelrestparametersswaggerdocumentation

Swagger parameter query without question mark


I'm ussing Swagger to documentate my api-rest and i found a problem that i can't fix. When i start to documentate my api i create this comments before the function:

/**
 * @OA\Get(
 *     path="/api/my-route/",
 *     tags={"My-tag1","My-tag2"},
 *     description="Get data from user profile",
 *     @OA\Parameter(
 *          name="name_parameter",
 *          in="query",
 *          description="description parameter",
 *          required=true,
 *     ),
 *     @OA\Response(response="200", description="Data from user profile"),
 *     security={ {"api_key": {}} }
 * )
 */

The code generate a good documentation but... When i go to test the route i found my problem:

http://127.0.0.1:8000/api/my-route/?name_parameter=value

How can set a parameter without question mark?

Something like this:

http://127.0.0.1:8000/api/my-route/value


Solution

  • You should use :

    in="path"
    

    And modify your path :

    path="/api/my-route/{name_parameter}"
    

    You can find more informations here : https://swagger.io/docs/specification/describing-parameters/#path-parameters