Skip to content

Commit 9f41710

Browse files
committed
updated tags example
1 parent 667e778 commit 9f41710

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

openapi/frameworks/laravel.mdx

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ info:
4646
description: ''
4747
version: 1.0.0
4848
servers:
49-
-
50-
url: 'http://localhost'
49+
- url: 'http://localhost'
5150
tags:
52-
-
53-
name: Endpoints
51+
- name: Endpoints
5452
description: ''
5553
paths:
5654
/api/health:
@@ -516,37 +514,23 @@ With descriptions covered, let's properly document the stuff these descriptions
516514
517515
### Adding tags
518516
519-
In OpenAPI, `tags` are used to group related operations together. Typically, a good way to use tags is to have one tag per "resource" and then associate all the relevant operations that access and modify that resource together. We'll add a group annotation to the top of the controller.
517+
In OpenAPI, `tags` are used to group related operations together. Typically, a
518+
good way to use tags is to have one tag per "resource" and then associate all
519+
the relevant operations that access and modify that resource together.
520520

521521
```php
522-
// !focus(1)
523-
#[Group(name: 'Races', description: 'A series of endpoints that allow programatic access to managing F1 races.', authenticated: true)]
524-
final readonly class IndexController
525-
{
526-
public function __construct(
527-
private AuthManager $auth,
528-
private RaceRepository $repository,
529-
) {
530-
}
522+
use Knuckles\Scribe\Attributes\{Authenticated, Group, BodyParam, QueryParam};
531523
532-
#[Authenticated]
533-
#[ResponseFromApiResource(RaceResource::class, Race::class, collection: true)]
534-
#[Endpoint(title: 'Browse Races', description: 'Browse through the F1 races for the season.')]
535-
public function __invoke(Request $request): CollectionResponse
536-
{
537-
$races = $this->repository->forSeason(
538-
season: $request->query('season', date('Y')),
539-
);
540-
541-
return new CollectionResponse(
542-
data: RaceResource::collection(
543-
resource: $races->paginate(),
544-
),
545-
);
546-
}
547-
}
524+
#[Group(name: 'Races', description: 'A series of endpoints that allow programmatic access to managing F1 races.')]
525+
class RaceController extends Controller
526+
{
527+
// ...
548528
```
549529

530+
Now instead of seeing `tags: [Endpoints]` in this controllers endpoints, the tag will be `Races`, and the description will be included in the OpenAPI document as a tag description.
531+
532+
**Learn more about [OpenAPI tags](/openapi/tags).**
533+
550534
## Documenting parameters
551535

552536
The whole point of an API is being able to send and receive data, so describing and documenting [API parameters](/api-design/parameters.md) for an endpoint is crucial. OpenAPI supports [several types of parameters](/openapi/requests/parameters), with the most common being `path`, `query`, and `header` parameters.

0 commit comments

Comments
 (0)