saeed
5 سال پیش توسط saeed مطرح شد
12 پاسخ

آموزش swagger

سلام کسی آموزش یا ویدویی آموزش کار با swagger در لاراول رو داره


ثبت پرسش جدید
saeed
@godbavan 5 سال پیش مطرح شد
0

سلام آره منظورم در لاراول هست


مهدی
@code2code 5 سال پیش آپدیت شد
0

منظورت چیه سوگر در لاراول ؟


saeed
@godbavan 5 سال پیش مطرح شد
0

سلام آره منظورم در لاراول هست


mahdi khanzadi
تخصص : backend developer at Snapp mar...
@khanzadimahdi 5 سال پیش مطرح شد
5

@godbavan
من شیفته ی پاسخ برتر توی این سوال و جواب در راکت شدم!

@hesammousavi


میلاد-م
تخصص : توسعه‌دهنده رابط کاربری - Fron...
@milad 5 سال پیش آپدیت شد
1

@khanzadimahdi
فکر کنم بنده خدا به نشانه ی بی پاسخی از سوی سایرین، متن خودش رو به عنوان بهترین پاسخ انتخاب کرده.
کسی کمکش نکرده بوده خب.

باز این خوب بود، توی راکت ازین برتر هم دیدم من : ))


حسام موسوی
تخصص : طراح و برنامه نویس
@hesammousavi 5 سال پیش مطرح شد
1

@milad
@khanzadimahdi
از دست بعضی‌ها به فکر خودکشی هم می افتم :))
عجب داستانیه بقران


Davood
تخصص : PHP - Laravel
@dfardabasi 5 سال پیش مطرح شد
0

@khanzadimahdi
:))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

به نظرم این بهترین پاسخو از روی کامنت خود شخص بردارید بهتره جناب موسوی چون اگه شخص بهترین پاسخ رو میدونست هیچوقت سوال نمیکرد :))))

@hesammousavi


میلاد-م
تخصص : توسعه‌دهنده رابط کاربری - Fron...
@milad 5 سال پیش آپدیت شد
0

@dfardabasi
@hesammousavi
نه برداشته نشه، گاهی اوقات پیش میاد که خود فرد بهترین جواب رو پس از گفتگوی با سایرین بدست میاره و قرار میده. بارها پیش اومده این مسئله.


حسین شفیعی
تخصص : توسعه دهنده لاراول
@hshafiei374 4 سال پیش مطرح شد
0

الان این بحث شما چه ربطی به سوال این بنده خدا داشت ؟
سوال منم همینه چطوری میشه از swagger توی لاراول استفاده کرد ؟
احتمالا باید پکیجی براش باشه


مصطفی
تخصص : برنامه نویس
@mostafanori 4 سال پیش مطرح شد
0

و همچنان بعد از کلی خنده و کنایه این سوال بی جواب مونده !!!


محمد امیری
تخصص : backend coder
@mohammadeng3731 4 سال پیش آپدیت شد
0

@hshafiei374
swagger package for laravel

بعد از نصب میتونید از کدهای زیر برای هر api خودتون استفاده کنید:


//required comment for fire swagger
/**
 * @OA\Info(
 *      version="1.0.0",
 *      title="hamejore routes documantions",
 *      description="L5 Swagger OpenApi description",
 * )
 */

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

/**
 * @OA\Post(
 * path="/login/{id}",
 * summary="Sign in",
 * description="Login by email, password",
 * tags={"auth"},
 * @OA\RequestBody(
 *    required=true,
 *    description="Pass user credentials",
 *    @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\Property(property="persistent", type="boolean", example="true"),
 *    ),
 * ),
 *     @OA\parameter(
 *          name="id",
 *           in="path",
 *           required=true,
 *           description="the user id",
 *              @OA\schema(
                    type="integer",
 *
 * ),
 *     ),
 * @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"),
 *        )
 *     ),
 * )
 */

//---------------------------------------------------------------------------------------------------------------

//------------get method documantion in Api-----------------
     /**
     * @OA\Get(
     *     path="/pet/{petId}",
     *     summary="Find pet by ID",
     *     description="Returns a single pet",
     *     tags={"pet"},
     *     @OA\Parameter(
     *         description="ID of pet to return",
     *         in="path",
     *         name="petId",
     *         required=true,
     *         @OA\Schema(
     *           type="integer"
     *         )
     *     ),
   * @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"),
 *        )
 *     ),
 * )
     */

یا بدون api به صورت زیر میتونید استفاده کنید:


//neccesary comment for starting the swagger

/**
 * @OA\Info(
 *      version="1.0.0",
 *      title="hamejore routes documantions",
 *      description="L5 Swagger OpenApi description",
 * )
 */

----------------------------------------------------------------------------------------------
//----------post method documantion without Api----------

/**
 * @OA\Post(
 *   path="/pet/{petId}",
 *   tags={"pet"},
 *   summary="Updates a pet in the store with form data",
 *   description="testing the post in swagger",
 *   @OA\RequestBody(
 *       required=false,
 *       @OA\MediaType(
 *           mediaType="application/x-www-form-urlencoded",
 *           @OA\Schema(
 *               type="object",
 *               @OA\Property(
 *                   property="name",
 *                   description="Updated name of the pet",
 *                   type="string"
 *               ),
 *               @OA\Property(
 *                   property="status",
 *                   description="Updated status of the pet",
 *                   type="string"
 *               ),
 *           )
 *       )
 *   ),
 *   @OA\Parameter(
 *     name="petId",
 *     in="path",
 *     description="ID of pet that needs to be updated",
 *     required=true,
 *     @OA\Schema(
 *         type="integer",
 *         format="int64"
 *     )
 *   ),
 *   @OA\Response(response="405",description="Invalid input"),
 * )
 */

//---------------------------------------------------------------------------------------------------------------

//------------get method documantion without Api-----------------

/**
 * @OA\get(
 *     path="/users/{id}",
 *     summary="get users",
 *     tags={"users"},
 *     description="get users informations",
 *     @OA\parameter(
 *          name="id",
 *          required=true,
 *          in="path",
 *          description="userId",
 *              @OA\schema(
 *                  type="integer",
 *                         ),
 *      ),
 *       @OA\parameter(
 *          name="family",
 *          required=true,
 *          in="query",
 *          description="user family",
 *              @OA\schema(
 *                  type="string",
 *                         ),
 *       ),
 *
 *     @OA\Response(
 *              response=200,
 *              description="the success"
 * ),
 *     )
 *
 *
 */

//---------------------------------------------------------------------------------------------------------------

//------------post method for fileUploading documantion without Api-----------------

/**
 * @OA\Post(
 *     path="/pet/{petId}/uploadImage",
 *     description="",
 *     summary="uploads an image",
 *     @OA\RequestBody(
 *         required=true,
 *         @OA\MediaType(
 *             mediaType="multipart/form-data",
 *             @OA\Schema(
 *                 @OA\Property(
 *                     description="Additional data to pass to server",
 *                     property="additionalMetadata",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     description="file to upload",
 *                     property="file",
 *                     type="string",
 *                     format="file",
 *                 ),
 *                 required={"file"}
 *             )
 *         )
 *     ),
 *     @OA\Parameter(
 *         description="ID of pet to update",
 *         in="path",
 *         name="petId",
 *         required=true,
 *         @OA\Schema(
 *             type="integer",
 *             format="int64"
 *         ),
 *     ),
 *     @OA\Response(
 *         response="200",
 *         description="successful operation",
 *     ),
 * )
 * */

در انتها دستور زیر رو وارد میکنید:
php artisan l5-swagger:generate
و برای مشاهده userinterface مستندات ایجاد شده به آدرس زیر در سرور خودتون برید:
http://yourdomain.com/api/documantions
که این مسیر رو در کانفیگ این پکیج میتونید تغییر بدید در routes/api


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

سلام خوبین
سوال من اینه که چطور میتونم از طریق swagger یک selector بسازم که یسری داده رو از دیتابیس بکشه بیرون و داخل selector نمایش بده


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

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