Using Swagger to document a Laravel API, I got to the point of documenting a route with two path params. However, I can’t pass both parameters in the Swagger url in any way, only the first one comes out.
Route:
Route::get('to_apply_or_unapply/{vacancy_id}/{action}', [Applications::class, 'toApplyOrUnapply'])->name('api.vacancies_user.to_apply_or_unapply');
Docs:
`/**
- @OAGet(
- path=”/api/vacancies_user/to_apply_or_unapply/{vacancy_id}/{action}”,
- operationId=”toApplyOrUnapply”,
- tags={“VacanciesUsers”},
- summary=”Apply or unapply to a vacancy”,
- description=”Apply or unapply to a specific vacancy.”,
- security={{“bearerAuth”: {}}},
- @OAParameter(
- name=”vacancy_id”,
- in=”path”,
- description=”ID of the vacancy.”,
- required=true,
- @OASchema(
- type=”integer”
- )
- ),
- @OAParameter(
- name=”action”,
- in=”path”,
- description=”Action to perform (attach or detach).”,
- required=true,
- @OASchema(
- type=”string”,
- enum={“attach”, “detach”}
- )
- ),
- @OAResponse(
- response=200,
- description=”Success message confirming the action.”,
- @OAJsonContent(
- @OAProperty(
- property=”message”,
- type=”string”,
- example=”User John applied to Vacancy XYZ”
- )
- )
- ),
- @OAResponse(
- response=404,
- description=”Invalid data or action provided.”,
- @OAJsonContent(
- @OAProperty(
- property=”error”,
- type=”string”,
- example=”Invalid data or action provided.”
- )
- )
- )
- )
*/
`
But when executing the request, it comes out with:
http://127.0.0.1:8000/api/vacancies_user/to_apply_or_unapply/2/{action} (the “2” was the first parameter entered).
I appreciate any help
Sorry my bad english. I’m brazilian.
I tried passing the parameters in the url path, hoping the build would come out correctly. But unfortunately the second parameter was “{action}” without any filling.
Erick Agostinho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.