محسن
3 سال پیش توسط محسن مطرح شد
1 پاسخ

اضلفه کردن header به swagger در لاراول

سلام.من برای استفاده از swagger برای روت خاصی به صورت زیر مستندات نوشتم.

<?php
//required comment for fire swagger
/**
* @OA\Info(
*      version="1.0.0",
*      title="mafia api documantion ",
* )
*/

//----------------------------------------------------------------------------------------------
//----------post method documantion in Api----------

/**
* @OA\Post(
* path="/api/admin/auth/login",
* summary="admin login",
* description="Login by email, password",
* tags={"admin login"},
* @OA\RequestBody(
*    required=true,
*    @OA\JsonContent(
*       required={"email","password"},
*       @OA\Property(property="email", type="string", format="email", example="user1@mail.com"),
*       @OA\Property(property="password", type="string", format="password", example="PassWord12345"),
*    ),
* ),

* @OA\Response(
*    response=422,
*    description="Wrong credentials response",
*    @OA\JsonContent(
*       @OA\Property(property="users", type="object", example="{name:'mohammad',family:'amiri'}"),
*       @OA\Property(property="status", type="integer", example="200"),
*        )
*     ),
* )
*/

مشکلم اینه که نمیتونم header رو به سرور پاس بدم.میشه راهنمایی کنید؟


ثبت پرسش جدید
مجید
تخصص : برنامه‌نویس
@kashefymajid1992 2 سال پیش مطرح شد
0

با سلام..//
فایل l5-swagger.php در تنظیمات ، میتونید کلید header رو به آرایه اضافه کنید

'headers'   => [

                /*
                |--------------------------------------------------------------------------
                | Uncomment to add response headers when swagger is generated
                |--------------------------------------------------------------------------
                */

                //'view' => [
                //  'Content-Type' => 'text/plain',
                //],

                /*
                |--------------------------------------------------------------------------
                | Uncomment to add request headers when swagger performs requests
                |--------------------------------------------------------------------------
                */

                'request' => [
                    'Content-Type' => 'application/vnd.api+json',
                    'Accept'       => 'application/json',
                ],

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام