Skip to content

Commit

Permalink
Add id to schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Jan 16, 2025
1 parent 66f1521 commit 42f089a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/OpenApi/Schema/UserInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
#[Schema(
title: 'User Information',
description: 'Information about the user',
required: ['username', 'permissions', 'isAdmin'],
required: ['id', 'username', 'permissions', 'isAdmin'],
type: 'object'
)]
final class UserInformation implements AdditionalAttributesInterface
{
use AdditionalAttributesTrait;

public function __construct(
#[Property(description: 'User ID', type: 'integer', example: 1)]
private readonly int $id,
#[Property(description: 'Username', type: 'string', example: 'admin')]
private readonly string $username,
#[Property(
Expand All @@ -49,6 +51,11 @@ public function __construct(
) {
}

public function getId(): int
{
return $this->id;
}

public function getPermissions(): array
{
return $this->permissions;
Expand All @@ -59,7 +66,7 @@ public function getUsername(): string
return $this->username;
}

public function hasIsAdmin(): bool
public function getIsAdmin(): bool
{
return $this->isAdmin;
}
Expand Down
1 change: 1 addition & 0 deletions src/User/Hydrator/UserInformationHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ final class UserInformationHydrator implements UserInformationHydratorInterface
public function hydrate(UserInterface $user): UserInformation
{
return new UserInformation(
$user->getId(),
$user->getUsername(),
$user->getPermissions(),
$user->isAdmin()
Expand Down

0 comments on commit 42f089a

Please sign in to comment.