۵۰٪ تخفیف فقط تا پایان جشنواره؛ بعدش همه‌چیز به قیمت قبل برمی‌گرده!

مشاهده دوره‌ها
ثانیه
دقیقه
ساعت
روز
راکت
حل شده

آموزش swagger

12 پاسخ

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

ثبت پرسش جدید

پاسخ‌ها

12
saeed
saeed
@godbavan
بهترین پاسخ

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

مهدی
مهدی
@code2code

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

mahdi khanzadi
mahdi khanzadi
@khanzadimahdi

تخصص: Software engineer

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

@hesammousavi

شاید پاسخ شما همین‌جا باشد

میلاد-م
میلاد-م
@milad

تخصص: توسعه‌دهنده رابط کاربری - Front-End

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

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

حسام موسوی
حسام موسوی
@hesammousavi

تخصص: طراح و برنامه نویس

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

Davood
Davood
@dfardabasi

تخصص: PHP - Laravel

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

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

@hesammousavi

میلاد-م
میلاد-م
@milad

تخصص: توسعه‌دهنده رابط کاربری - Front-End

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

حسین شفیعی
حسین شفیعی
@hshafiei374

تخصص: توسعه دهنده لاراول

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

مصطفی
مصطفی
@mostafanori

تخصص: برنامه نویس

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

محمد امیری
محمد امیری
@mohammadeng3731

تخصص: backend coder

@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

تخصص: برنامه نویس

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

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

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