---
title: Swagger GET Method in Laravel – Jaeves Codelab
description: "In previous article we Create Swagger Post Method in Laravel. Now we will create Swagger GET Method in Laravel. /**\n     * @OA\\Get(\n     *      path=\"/get-"
---

[Skip to content](https://jaeves.com/codelab/swagger-get-method-in-laravel#main-content)

 Close

SEARCH

[Discover Jaeves for Free](https://app.jaeves.com/login)

[![jaeves-2025-logo](https://jaeves.com/hubfs/logos/jaeves-2025-logo.svg)![jaeves-2025-logo](https://jaeves.com/hubfs/logos/jaeves-2025-logo.svg)](https://jaeves.com/)

[Discover Jaeves for Free](https://app.jaeves.com/login)

Quick results for "{search\_term}"

TABLE OF CONTENTS

loading...

[Admin](https://jaeves.com/codelab/author/admin)Oct 2, 2023, 6:55:19 PM< 1 min read

# Swagger GET Method in Laravel

[Previous](https://jaeves.com/codelab/swagger-authenticate-the-api-in-laravel)

<https://jaeves.com/codelab>

[Next](https://jaeves.com/codelab/swagger-post-method-in-laravel)

After successfully implementing the [Swagger Post Method in Laravel](https://jaeves.com/codelab/swagger-post-method-in-laravel), it's time to explore the Swagger GET Method in Laravel.

```
/**
     * @OA\Get(
     *      path="/get-user/{id}",
     *      operationId="getUser",
     *      tags={"User"},
     *      summary="Get User",
     *      description="Get User",
     *      @OA\Parameter(
     *      name="id",
     *      in="path",
     *      required=true,
     *      description= "user id",
     *      example="10",
     *      @OA\Schema(
     *           type="integer"
     *      )
     *      ),
     *       @OA\Response(
     *      response=200,
     *      description="Success response",
     *      @OA\JsonContent(
     *      @OA\Property(property="status", type="number", example="200"),
     *      @OA\Property(property="user", type="string", example="{'full_name':'Chetan','email_id':'chetan1234@gmail.com','created_at':'2022-05-27T07:16:57.000000Z','updated_at':'2022-05-27T07:16:57.000000Z'}"),
     *        )
     *     ),
     *        @OA\Response(
     *      response=400,
     *      description="Bad Request",
     *      @OA\JsonContent(
     *      @OA\Property(property="status", type="number", example="400"),
     *      @OA\Property(property="message", type="string", example="Error in processing request")
     *        )
     *     )
     * )
     *      
     * )
     */

    public function getUser($id)
    {
    	try {
	    	$user = User::where('id', $id)->get();

	    	if($user){
	    		return response()->json(['status' => 200, 'user' => $user], 200);
	    	}
    	}catch (\Exception $e) {
            return response()->json(['status' => 400, 'message' => 'Error in processing request'], 400);
        }
    }
```

Now, run php artisan l5-swagger:generate and check api at https://mywebsite.com/api/documentation.

Read [laravel swagger documentation here](https://github.com/DarkaOnLine/L5-Swagger).

COMMENTS

## RELATED ARTICLES

[![logo](https://jaeves.com/hs-fs/hubfs/jaeves-logo-230917.png?width=140&height=45&name=jaeves-logo-230917.png "logo")](https://jaeves.com/)

Jaeves is a trailblazing AI-powered content generation tool that revolutionizes your content creation journey. Its user-friendly interface, extensive customization options, and innovative approach make it an invaluable asset for all your content needs. Transform your content strategy with Jaeves today.

All rights reserved

- [Privacy Policy](https://jaeves.com/privacy-policy)

```json
{
  "@context" : "https://schema.org",
  "@type" : "Organization",
  "address" : {
    "@type" : "PostalAddress",
    "addressCountry" : "Germany",
    "addressLocality" : "Speyer",
    "addressRegion" : "Rheinland-Pfalz",
    "postalCode" : "67346",
    "streetAddress" : "Gerhart-hauptmann-Str"
  },
  "knowsLanguage" : "en",
  "logo" : {
    "@type" : "ImageObject",
    "url" : "https://139767802.fs1.hubspotusercontent-eu1.net/hubfs/139767802/logo-2024-less-points.svg"
  },
  "name" : "Jaeves AI",
  "url" : "https://jaeves.com/codelab/swagger-get-method-in-laravel"
}
```

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "abstract" : "In previous article we Create Swagger Post Method in Laravel. Now we will create Swagger GET Method in Laravel. /** * @OA\\Get( * path=\"/get-",
  "author" : {
    "@type" : "Person",
    "name" : "Admin"
  },
  "dateModified" : "",
  "datePublished" : "",
  "headline" : "Swagger GET Method in Laravel",
  "image" : "",
  "inLanguage" : "en",
  "keywords" : "[]",
  "mainEntityOfPage" : {
    "@type" : "WebPage"
  },
  "name" : "Swagger GET Method in Laravel",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://139767802.fs1.hubspotusercontent-eu1.net/hubfs/139767802/jaeves-logo-230917.png"
    },
    "name" : "Jaeves AI"
  },
  "text" : "After successfully implementing the Swagger Post Method in Laravel, it's time to explore the Swagger GET Method in Laravel. /** * @OA\\Get( * path=\"/get-user/{id}\", * operationId=\"getUser\", * tags={\"User\"}, * summary=\"Get User\", * description=\"Get User\", * @OA\\Parameter( * name=\"id\", * in=\"path\", * required=true, * description= \"user id\", * example=\"10\", * @OA\\Schema( * type=\"integer\" * ) * ), * @OA\\Response( * response=200, * description=\"Success response\", * @OA\\JsonContent( * @OA\\Property(property=\"status\", type=\"number\", example=\"200\"), * @OA\\Property(property=\"user\", type=\"string\", example=\"{'full_name':'Chetan','email_id':'chetan1234@gmail.com','created_at':'2022-05-27T07:16:57.000000Z','updated_at':'2022-05-27T07:16:57.000000Z'}\"), * ) * ), * @OA\\Response( * response=400, * description=\"Bad Request\", * @OA\\JsonContent( * @OA\\Property(property=\"status\", type=\"number\", example=\"400\"), * @OA\\Property(property=\"message\", type=\"string\", example=\"Error in processing request\") * ) * ) * ) * * ) */ public function getUser($id) { try { $user = User::where('id', $id)-&gt;get(); if($user){ return response()-&gt;json(['status' =&gt; 200, 'user' =&gt; $user], 200); } }catch (\\Exception $e) { return response()-&gt;json(['status' =&gt; 400, 'message' =&gt; 'Error in processing request'], 400); } } Now, run php artisan l5-swagger:generate and check api at https://mywebsite.com/api/documentation. Read laravel swagger documentation here.",
  "url" : "https://jaeves.com/codelab/swagger-get-method-in-laravel",
  "wordCount" : "248"
}
```

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Admin",
    "url" : "https://jaeves.com/codelab/author/admin"
  },
  "dateModified" : "2023-12-20T12:18:21.481Z",
  "datePublished" : "2023-10-02T22:55:19.000Z",
  "headline" : "Swagger GET Method in Laravel – Jaeves Codelab",
  "mainEntityOfPage" : {
    "@id" : "https://jaeves.com/codelab/swagger-get-method-in-laravel",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://jaeves.com/hubfs/logo-2024-less-points.svg"
    },
    "name" : "Jaeves AI"
  }
}
```

```json
{
  "@context" : "http://schema.org",
  "@type" : "Organization",
  "description" : "Unlock the Power of AI for Content Creation. Explore Insights, Tips, and Trends on the Jaeves.com Blog. Empower Your Writing Journey Today!",
  "logo" : "https://jaeves.com/hubfs/untitled%20(4).png",
  "name" : "Jaeves AI",
  "sameAs" : [ "https://www.instagram.com/jaeves.ai", "https://www.linkedin.com/company/jaeves-ai", "https://www.youtube.com/@Jaeves_ai", "https://www.tiktok.com/@jaeves_ai" ],
  "url" : "https://jaeves.com"
}
```