Skip to content

Commit afdbbac

Browse files
committed
- Switched to using enumValues for fields, sorts, includes, and appends
1 parent 6560234 commit afdbbac

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

docs/generating-api-docs/adding-additional-fields.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ For those, you will need to define them as additional allowed methods by overrid
99
## apiDocAdditionalIndexQueryParameters()
1010

1111
Use this method to specify additional query parameters for `index` endpoint.
12-
Will support all properties allowed by `Knuckles\Scribe\Attributes\QueryParam` Attribute.
12+
Will support the following properties:
13+
- `description`
14+
- `type`
15+
- `required`
16+
- `example`
17+
- `enumValues`
18+
- `nullable`
1319

1420
```php
1521
// in IslandsController.php
@@ -34,7 +40,13 @@ public static function apiDocAdditionalIndexQueryParameters(): array
3440
## apiDocAdditionalShowQueryParameters()
3541

3642
Use this method to specify additional query parameters for `show` endpoint.
37-
Will support all properties allowed by `Knuckles\Scribe\Attributes\QueryParam` Attribute.
43+
Will support the following properties:
44+
- `description`
45+
- `type`
46+
- `required`
47+
- `example`
48+
- `enumValues`
49+
- `nullable`
3850

3951
```php
4052
// in IslandsController.php

docs/generating-api-docs/customizing-api-docs-metadata.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ Here are some of the methods we recommend to override.
1212

1313
## apiDocFilterMetadata()
1414

15-
Use this method to describe what each filter does. Will support all properties allowed by `Knuckles\Scribe\Attributes\QueryParam` Attribute.
15+
Use this method to describe what each filter does.
16+
Will support the following properties:
17+
- `description`
18+
- `type`
19+
- `required`
20+
- `example`
21+
- `enumValues`
22+
- `nullable`
1623

1724
```php
1825
// in ProductsController.php

src/Concerns/ApiDocHelpers.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ public static function apiDocGenerateFieldsMetadata(array $fields): array
206206
{
207207
return [
208208
'type' => 'string',
209-
'description' => static::apiFieldsDescription() .
210-
'<br><br> **Allowed values:** ' . "\n" . implode("\n", array_map(fn($field) => "- `$field`", $fields)),
211-
'enum' => $fields,
209+
'description' => static::apiFieldsDescription(),
210+
'enumValues' => $fields,
212211
'example' => implode(',', $fields),
213212
];
214213
}
@@ -229,10 +228,8 @@ public static function apiDocGenerateSortsMetadata(array $sorts, string $default
229228
{
230229
return [
231230
'type' => 'string',
232-
'description' => static::apiSortsDescription() .
233-
'<br><br>**Allowed sorts:** ' . "\n" . implode("\n", array_map(fn($field) => "- `$field`", $sorts)) . "\n\n" .
234-
'<br>**Default sort:** ' . ($default_sort ? '`' . $default_sort . '`' : 'None'),
235-
'enum' => static::apiDocAllowedSorts(),
231+
'description' => static::apiSortsDescription(),
232+
'enumValues' => static::apiDocAllowedSorts(),
236233
'example' => static::apiDocDefaultSort(),
237234
];
238235
}
@@ -254,9 +251,8 @@ public static function apiDocGenerateAppendsMetadata(array $appends): array
254251
{
255252
return [
256253
'type' => 'string',
257-
'description' => static::apiAppendsDescription() .
258-
'<br><br> **Allowed values:** ' . "\n" . implode("\n", array_map(fn($field) => "- `$field`", $appends)),
259-
'enum' => $appends,
254+
'description' => static::apiAppendsDescription(),
255+
'enumValues' => $appends,
260256
'example' => implode(',', $appends),
261257
];
262258
}
@@ -278,8 +274,8 @@ public static function apiDocGenerateIncludesMetadata(array $includes): array
278274
{
279275
return [
280276
'type' => 'string',
281-
'description' => static::apiIncludesDescription() . '<br><br> **Allowed values:** ' . "\n" . implode("\n", array_map(fn($field) => "- `$field`", $includes)),
282-
'enum' => $includes,
277+
'description' => static::apiIncludesDescription(),
278+
'enumValues' => $includes,
283279
'example' => implode(',', $includes),
284280
];
285281
}

src/Concerns/IsApiController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Illuminate\Foundation\Bus\DispatchesJobs;
1010
use Illuminate\Foundation\Validation\ValidatesRequests;
1111
use Illuminate\Http\Request;
12-
use Illuminate\Support\Arr;
1312
use Illuminate\Support\Collection;
1413
use Illuminate\Validation\ValidationException;
1514
use Javaabu\QueryBuilder\QueryBuilder;

0 commit comments

Comments
 (0)