---
title: Swagger Post Method in Laravel – Jaeves Codelab
description: In previous two articles we Create Laravel Swagger API and Create Swagger Configuration in Laravel. Now we will add Swagger Post Method in Laravel. /**
---

[Skip to content](https://jaeves.com/codelab/swagger-post-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:57:12 PM1 min read

# Swagger Post Method in Laravel

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

<https://jaeves.com/codelab>

[Next](https://jaeves.com/codelab/boost-website-seo-security-score-by-add-noopener-noreferrer-to-external-links)

In previous two articles we [Create Laravel Swagger API](https://jaeves.com/codelab/create-laravel-swagger-api/) and [Create Swagger Configuration in Laravel](https://jaeves.com/codelab/create-swagger-configuration-in-laravel/). Now we will add Swagger Post Method in Laravel.

```

     /**
     * @OA\Post(
     *      path="/update-user/{id}",
     *      operationId="updatePassword",
     *      tags={"User"},
     *      summary="Update Password",
     *      description="Update Password",
     *      @OA\RequestBody(
     *      required=true,
     *      description="Update Password parameters",
     *		@OA\Parameter(
     *      name="id",
     *      in="path",
     *      required=true,
     *      description= "user id",
     *      example="10",
     *      @OA\Schema(
     *           type="integer"
     *      )
     *      ),
     *      @OA\MediaType(
     *            mediaType="multipart/form-data",
     *            @OA\Schema(
     *               type="object",
     *       @OA\Property(property="full_name", type="string", format="string", example="Chetan", description ="Your full name"),
     *       @OA\Property(property="last_name", type="string", format="string")
     *            )
     *        ),
     *      ),
     *       @OA\Response(
     *      response=200,
     *      description="Success response",
     *      @OA\JsonContent(
     *      @OA\Property(property="status", type="number", example="200"),
     *      @OA\Property(property="message", type="string", example="User updated successfully."),
     *        )
     *     ),
     *        @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 updateUser($id,Request $request)
    {
    	try {
	    	$user = User::where('id', $id)->update(['full_name' => $request->input('full_name')]);

	    	if($user){
	    		return response()->json(['status' => 200, 'message' => 'User updated successfully'], 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.

Check [Laravel swagger GET Method](https://jaeves.com/codelab/swagger-get-method-in-laravel/).

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-post-method-in-laravel"
}
```

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "abstract" : "In previous two articles we Create Laravel Swagger API and Create Swagger Configuration in Laravel. Now we will add Swagger Post Method in Laravel. /**",
  "author" : {
    "@type" : "Person",
    "name" : "Admin"
  },
  "dateModified" : "",
  "datePublished" : "",
  "headline" : "Swagger Post Method in Laravel",
  "image" : "",
  "inLanguage" : "en",
  "keywords" : "[]",
  "mainEntityOfPage" : {
    "@type" : "WebPage"
  },
  "name" : "Swagger Post 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" : "In previous two articles we Create Laravel Swagger API and Create Swagger Configuration in Laravel. Now we will add Swagger Post Method in Laravel. /** * @OA\\Post( * path=\"/update-user/{id}\", * operationId=\"updatePassword\", * tags={\"User\"}, * summary=\"Update Password\", * description=\"Update Password\", * @OA\\RequestBody( * required=true, * description=\"Update Password parameters\", * @OA\\Parameter( * name=\"id\", * in=\"path\", * required=true, * description= \"user id\", * example=\"10\", * @OA\\Schema( * type=\"integer\" * ) * ), * @OA\\MediaType( * mediaType=\"multipart/form-data\", * @OA\\Schema( * type=\"object\", * @OA\\Property(property=\"full_name\", type=\"string\", format=\"string\", example=\"Chetan\", description =\"Your full name\"), * @OA\\Property(property=\"last_name\", type=\"string\", format=\"string\") * ) * ), * ), * @OA\\Response( * response=200, * description=\"Success response\", * @OA\\JsonContent( * @OA\\Property(property=\"status\", type=\"number\", example=\"200\"), * @OA\\Property(property=\"message\", type=\"string\", example=\"User updated successfully.\"), * ) * ), * @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 updateUser($id,Request $request) { try { $user = User::where('id', $id)-&gt;update(['full_name' =&gt; $request-&gt;input('full_name')]); if($user){ return response()-&gt;json(['status' =&gt; 200, 'message' =&gt; 'User updated successfully'], 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. Check Laravel swagger GET Method. Read laravel swagger documentation here.",
  "url" : "https://jaeves.com/codelab/swagger-post-method-in-laravel",
  "wordCount" : "330"
}
```

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Admin",
    "url" : "https://jaeves.com/codelab/author/admin"
  },
  "dateModified" : "2023-10-12T19:37:36.032Z",
  "datePublished" : "2023-10-02T22:57:12.000Z",
  "headline" : "Swagger Post Method in Laravel – Jaeves Codelab",
  "mainEntityOfPage" : {
    "@id" : "https://jaeves.com/codelab/swagger-post-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"
}
```