diff --git a/src/ApiResource/PartDBInfo.php b/src/ApiResource/PartDBInfo.php index 5fb2951d..9a06f262 100644 --- a/src/ApiResource/PartDBInfo.php +++ b/src/ApiResource/PartDBInfo.php @@ -35,7 +35,7 @@ use App\State\PartDBInfoProvider; #[ApiResource( uriTemplate: '/info.{_format}', description: 'Basic information about Part-DB like version, title, etc.', - operations: [new Get()], + operations: [new Get(openapiContext: ['summary' => 'Get basic information about the installed Part-DB instance.'])], provider: PartDBInfoProvider::class )] #[ApiFilter(PropertyFilter::class)] diff --git a/src/Entity/Base/AbstractCompany.php b/src/Entity/Base/AbstractCompany.php index ae0f47c6..b552d705 100644 --- a/src/Entity/Base/AbstractCompany.php +++ b/src/Entity/Base/AbstractCompany.php @@ -40,6 +40,11 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\MappedSuperclass] abstract class AbstractCompany extends AbstractPartsContainingDBElement { + #[Groups(['company:read'])] + protected ?\DateTimeInterface $addedDate = null; + #[Groups(['company:read'])] + protected ?\DateTimeInterface $lastModified = null; + /** * @var string The address of the company */ diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 5c4103d8..59d374c8 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Entity\Base; +use ApiPlatform\Metadata\ApiProperty; use App\Entity\Attachments\Attachment; use App\Entity\Parameters\AbstractParameter; use App\Repository\StructuralDBElementRepository; @@ -31,6 +32,7 @@ use Doctrine\DBAL\Types\Types; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Parameters\ParametersTrait; use App\Validator\Constraints\NoneOfItsChildren; +use Symfony\Component\Serializer\Annotation\SerializedName; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints\Valid; use function count; @@ -261,6 +263,8 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement * * @return string the full path (incl. the name of this element), delimited by $delimiter */ + #[Groups(['api:basic:read'])] + #[SerializedName('full_path')] public function getFullPath(string $delimiter = self::PATH_DELIMITER_ARROW): string { if ($this->full_path_strings === []) { diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index 70ea1b6a..b83024ef 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -22,10 +22,12 @@ declare(strict_types=1); namespace App\Entity\Parts; +use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Link; +use ApiPlatform\Serializer\Filter\PropertyFilter; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentTypeAttachment; use App\Repository\Parts\ManufacturerRepository; @@ -49,17 +51,18 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Index(name: 'manufacturer_name', columns: ['name'])] #[ORM\Index(name: 'manufacturer_idx_parent_name', columns: ['parent_id', 'name'])] #[ApiResource( - normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read']], - denormalizationContext: ['groups' => ['manufacturer:write', 'company:write', 'api:basic:write']], + normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], + denormalizationContext: ['groups' => ['manufacturer:write', 'company:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'], )] #[ApiResource( uriTemplate: '/manufacturers/{id}/children.{_format}', - operations: [new GetCollection()], + operations: [new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a manufacturer.'])], uriVariables: [ 'id' => new Link(fromClass: Manufacturer::class, fromProperty: 'children') ], - normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read']] + normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] )] +#[ApiFilter(PropertyFilter::class)] class Manufacturer extends AbstractCompany { #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 6a778e51..7bd22924 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -83,10 +83,10 @@ use Jbtronics\TFAWebauthn\Model\TwoFactorInterface as WebauthnTwoFactorInterface #[ApiResource( shortName: 'User', operations: [ - new Get(), - new GetCollection(), + new Get(openapiContext: ['summary' => 'Get a specific user.']), + new GetCollection(openapiContext: ['summary' => 'Get all users defined in the system.']), ], - normalizationContext: ['groups' => ['user:read']], + normalizationContext: ['groups' => ['user:read'], 'openapi_definition_name' => 'Read'], )] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(SearchFilter::class, properties: ['name' => 'exact', 'email' => 'exact'])]