Skip to content

Commit 0ef3b11

Browse files
authored
update for laravel 11
1 parent fa42578 commit 0ef3b11

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Then run the following command to install the package:
5353
```bash
5454
composer require niamulhasan/api-doctor-swagger
5555
```
56-
### Step: 4 Edit your `config/app.php` file
56+
### Step: 4 Edit your `config/app.php` file (Laravel 11 `bootstrap/providers.php`)
5757
Add the following line to the `providers` array:
5858
```php
5959
NiamulHasan\ApiDoctorSwagger\Providers\ApiDoctorProvider::class,
@@ -70,6 +70,16 @@ Run the following command to publish the package's config file:
7070
];`
7171
add this in your `app/Http/Middleware/VerifyCsrfToken.php`
7272

73+
#### For Laravel 11: in `bootstrap/app.php`
74+
add `$middleware->validateCsrfTokens(except: ['api/*']);` in middleware
75+
Like this
76+
```php
77+
->withMiddleware(function (Middleware $middleware) {
78+
$middleware->validateCsrfTokens(except: ['api/*']);
79+
})
80+
```
81+
82+
7383

7484
## Usage
7585
For now this package can generate doc only for **URL parameters** and **Request body**. It will not generate doc for **Query parameters**.

src/ApiDoctor/ApiDoctorSwaggerSections.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,19 @@ public static function buildParameters($parameters)
164164
public static function buildProperties($rules)
165165
{
166166
$result = "";
167-
foreach ($rules as $rule => $value) {
168-
preg_match('/(.*?)\|/', $value, $matches);
169-
$type = $matches[1];
170-
$propertyString = "
167+
try {
168+
foreach ($rules as $rule => $value) {
169+
preg_match('/(.*?)\|/', $value, $matches);
170+
$type = $matches[1];
171+
$propertyString = "
171172
{$rule}:
172173
type: string
173174
description: {$value}
174175
";
175-
$result .= $propertyString;
176+
$result .= $propertyString;
177+
}
178+
} catch (\Exception $e) {
179+
// echo $e->getMessage();
176180
}
177181
return $result;
178182
}

0 commit comments

Comments
 (0)