L5-Swagger
L5-Swagger copied to clipboard
Issue with optional parameter
- L5-Swagger Version: 8.0.7
- PHP Version: 8.0.12
- OS: Ubuntu
I would like to add an optional parameter to my GET API and I'm able to disable the required field, but when I passed an empty value to {item_per_page}, the URL is didn't remove {item_per_page} from the URL.
This is my CURL and request URL.
This is my Swagger Annotation
/**
* @OA\Get(
* path="/api/product-categories/{id}/products/{item_per_page}",
* summary="Retrieve products based on product category",
* description="Retrieve products",
* tags={"Product Categories [Public]"},
* @OA\Parameter(
* name="id",
* description="Product Category ID",
* example=1,
* required=true,
* in="path",
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Parameter(
* name="item_per_page",
* description="Number of item per page",
* example=15,
* in="path",
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Response(
* response=200,
* description="Success response",
* @OA\JsonContent(
* @OA\Property(
* property="status",
* type="string",
* example="success"
* ),
* @OA\Property(
* property="message",
* type="string",
* example=""
* ),
* @OA\Property(
* property="data",
* type="string",
* ref="#/components/schemas/ProductCategory"
* )
* )
* ),
* )
*/
Do you guys have to meet this problem before? I need some helps with it.
Wouldn't that be a question for swagger-ui?
hi you should use location in query for your optional parameters.
- @OA\Parameter(
-
name="id",
-
description="Product Category ID",
-
example=1,
-
required=true,
-
in="path", =>>>>>>>>>>>>>>>>>>>>>> in="query"
-
@OA\Schema(
-
type="integer"
-
)
- ),
-