# Step 1 composer require "darkaonline/l5-swagger:6.*" # Step 2 php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" # Step 3 artisan l5-swagger:generate
原本 POST 是寫成 parameter 且屬性為 in="query",後來發現要寫在 body 裡。 (參考資料)
example:
@OA\RequestBody( @OA\MediaType( mediaType="application/json", @OA\Schema( @OA\Property( property="id", type="string" ), @OA\Property( property="name", type="string" ), example={"id": "a3fb6", "name": "Jessica Smith"} ) ) )
參考資料
@OA\Parameter( name="_sort_field", description="排序欄位", required=false, in="query", @OA\Schema( type="string", enum={ "id", "number" "created_at", "updated_at", }, example={""}, ), ),
步驟 1~3 僅需在專案開發初始時執行,步驟 4 為日後查看 API 文件的地址。
composer require "darkaonline/l5-swagger:6.*"
/** * @OA\SecurityScheme( * type="http", * description="Login with email and password to get the authentication token", * name="Token based Based", * in="header", * scheme="bearer", * bearerFormat="JWT", * securityScheme="apiAuth", * ) */
/** * @OA\Get( * path="/resources", * summary="Get the list of resources", * tags={"Resource"}, * @OA\Response(response=200, description="Return a list of resources"), * security={{ "apiAuth": {} }} * ) */
API
Swagger
Laravel
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up