Answer the question
In order to leave comments, you need to log in
What's wrong with generating the Swagger Documentation API?
I'm not familiar with swagger, I'm just learning. The task is to generate documentation for api controllers. Put the @OA\Info annotation on the main controller class
namespace App\Http\Controllers;
/**
* @OA\Info(
* version="1.0.0",
* title="Documentation",
* description="Документация",
* )
*/
class Controller extends BaseController
namespace App\Http\Controllers;
/**
* @OA\Schema(
* title="UserController",
* description="UserController",
* @OA\Xml(
* name="UserController"
* )
* )
*/
class UserController extends Controller
{
/**
* @OA\Post(
* path="/api/users/add",
* tags={"add"},
* summary="add",
* operationId="add",
*
* @OA\Parameter(
* name="name",
* in="query",
* required=true,
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="email",
* in="query",
* required=true,
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="password",
* in="query",
* required=true,
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="Success",
* @OA\MediaType(
* mediaType="application/json",
* )
* )
*)
**/
/**
* @param Request $request
* @return bool
*/
public function create(Request $request){
return $this->serviceUser->create($request);
}
....
}
Answer the question
In order to leave comments, you need to log in
because of the two annotations in a row, the last one will be selected. solved by merging them into one
/**
* @OA\Post(
* path="/api/users/add",
* tags={"add"},
* summary="add",
* operationId="add",
*
* @OA\Parameter(
* name="name",
* in="query",
* required=true,
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="email",
* in="query",
* required=true,
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="password",
* in="query",
* required=true,
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="Success",
* @OA\MediaType(
* mediaType="application/json",
* )
* )
*)
* @param Request $request
* @return bool
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question