Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Add id to schema #698

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading