mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 11:18:51 +02:00
Improved schema infos of Manufacturer endpoints
This commit is contained in:
parent
676c8eeefb
commit
6b5c51bdc5
5 changed files with 20 additions and 8 deletions
|
@ -35,7 +35,7 @@ use App\State\PartDBInfoProvider;
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
uriTemplate: '/info.{_format}',
|
uriTemplate: '/info.{_format}',
|
||||||
description: 'Basic information about Part-DB like version, title, etc.',
|
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
|
provider: PartDBInfoProvider::class
|
||||||
)]
|
)]
|
||||||
#[ApiFilter(PropertyFilter::class)]
|
#[ApiFilter(PropertyFilter::class)]
|
||||||
|
|
|
@ -40,6 +40,11 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
#[ORM\MappedSuperclass]
|
#[ORM\MappedSuperclass]
|
||||||
abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
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
|
* @var string The address of the company
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Base;
|
namespace App\Entity\Base;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiProperty;
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Parameters\AbstractParameter;
|
use App\Entity\Parameters\AbstractParameter;
|
||||||
use App\Repository\StructuralDBElementRepository;
|
use App\Repository\StructuralDBElementRepository;
|
||||||
|
@ -31,6 +32,7 @@ use Doctrine\DBAL\Types\Types;
|
||||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||||
use App\Entity\Parameters\ParametersTrait;
|
use App\Entity\Parameters\ParametersTrait;
|
||||||
use App\Validator\Constraints\NoneOfItsChildren;
|
use App\Validator\Constraints\NoneOfItsChildren;
|
||||||
|
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
use Symfony\Component\Validator\Constraints\Valid;
|
use Symfony\Component\Validator\Constraints\Valid;
|
||||||
use function count;
|
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
|
* @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
|
public function getFullPath(string $delimiter = self::PATH_DELIMITER_ARROW): string
|
||||||
{
|
{
|
||||||
if ($this->full_path_strings === []) {
|
if ($this->full_path_strings === []) {
|
||||||
|
|
|
@ -22,10 +22,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiFilter;
|
||||||
use ApiPlatform\Metadata\ApiProperty;
|
use ApiPlatform\Metadata\ApiProperty;
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use ApiPlatform\Metadata\Link;
|
use ApiPlatform\Metadata\Link;
|
||||||
|
use ApiPlatform\Serializer\Filter\PropertyFilter;
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentTypeAttachment;
|
use App\Entity\Attachments\AttachmentTypeAttachment;
|
||||||
use App\Repository\Parts\ManufacturerRepository;
|
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_name', columns: ['name'])]
|
||||||
#[ORM\Index(name: 'manufacturer_idx_parent_name', columns: ['parent_id', 'name'])]
|
#[ORM\Index(name: 'manufacturer_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read']],
|
normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'],
|
||||||
denormalizationContext: ['groups' => ['manufacturer:write', 'company:write', 'api:basic:write']],
|
denormalizationContext: ['groups' => ['manufacturer:write', 'company:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'],
|
||||||
)]
|
)]
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
uriTemplate: '/manufacturers/{id}/children.{_format}',
|
uriTemplate: '/manufacturers/{id}/children.{_format}',
|
||||||
operations: [new GetCollection()],
|
operations: [new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a manufacturer.'])],
|
||||||
uriVariables: [
|
uriVariables: [
|
||||||
'id' => new Link(fromClass: Manufacturer::class, fromProperty: 'children')
|
'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
|
class Manufacturer extends AbstractCompany
|
||||||
{
|
{
|
||||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||||
|
|
|
@ -83,10 +83,10 @@ use Jbtronics\TFAWebauthn\Model\TwoFactorInterface as WebauthnTwoFactorInterface
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
shortName: 'User',
|
shortName: 'User',
|
||||||
operations: [
|
operations: [
|
||||||
new Get(),
|
new Get(openapiContext: ['summary' => 'Get a specific user.']),
|
||||||
new GetCollection(),
|
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(PropertyFilter::class)]
|
||||||
#[ApiFilter(SearchFilter::class, properties: ['name' => 'exact', 'email' => 'exact'])]
|
#[ApiFilter(SearchFilter::class, properties: ['name' => 'exact', 'email' => 'exact'])]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue