diff --git a/openapi.yaml b/openapi.yaml index 464096c..6493881 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1119,11 +1119,12 @@ components: - string - 'null' partner: - anyOf: - - - $ref: '#/components/schemas/Partner' - - - type: 'null' + 'owl:maxCardinality': 1 + type: + - string + - 'null' + format: iri-reference + example: 'https://example.com/' birthday: type: - string @@ -1136,6 +1137,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + imageUrl: + type: + - string + - 'null' position: type: - string @@ -1179,11 +1184,12 @@ components: - string - 'null' partner: - anyOf: - - - $ref: '#/components/schemas/Partner.jsonhal' - - - type: 'null' + 'owl:maxCardinality': 1 + type: + - string + - 'null' + format: iri-reference + example: 'https://example.com/' birthday: type: - string @@ -1196,6 +1202,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + imageUrl: + type: + - string + - 'null' position: type: - string @@ -1253,11 +1263,12 @@ components: - string - 'null' partner: - anyOf: - - - $ref: '#/components/schemas/Partner.jsonld' - - - type: 'null' + 'owl:maxCardinality': 1 + type: + - string + - 'null' + format: iri-reference + example: 'https://example.com/' birthday: type: - string @@ -1270,6 +1281,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + imageUrl: + type: + - string + - 'null' position: type: - string @@ -1362,10 +1377,10 @@ components: type: object description: '' deprecated: false + required: + - name + - type properties: - id: - readOnly: true - type: integer name: type: string type: @@ -1398,13 +1413,6 @@ components: type: - string - 'null' - createdAt: - type: string - format: date-time - contacts: - type: array - items: - $ref: '#/components/schemas/Contact' logo: 'owl:maxCardinality': 1 type: @@ -1412,10 +1420,28 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + logoUrl: + type: + - string + - 'null' + createdAt: + type: + - string + - 'null' + format: date-time + contacts: + type: array + items: + type: string + format: iri-reference + example: 'https://example.com/' Partner.jsonhal: type: object description: '' deprecated: false + required: + - name + - type properties: _links: type: object @@ -1426,9 +1452,6 @@ components: href: type: string format: iri-reference - id: - readOnly: true - type: integer name: type: string type: @@ -1461,13 +1484,6 @@ components: type: - string - 'null' - createdAt: - type: string - format: date-time - contacts: - type: array - items: - $ref: '#/components/schemas/Contact.jsonhal' logo: 'owl:maxCardinality': 1 type: @@ -1475,10 +1491,28 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + logoUrl: + type: + - string + - 'null' + createdAt: + type: + - string + - 'null' + format: date-time + contacts: + type: array + items: + type: string + format: iri-reference + example: 'https://example.com/' Partner.jsonld: type: object description: '' deprecated: false + required: + - name + - type properties: '@context': readOnly: true @@ -1503,9 +1537,6 @@ components: '@type': readOnly: true type: string - id: - readOnly: true - type: integer name: type: string type: @@ -1538,13 +1569,6 @@ components: type: - string - 'null' - createdAt: - type: string - format: date-time - contacts: - type: array - items: - $ref: '#/components/schemas/Contact.jsonld' logo: 'owl:maxCardinality': 1 type: @@ -1552,6 +1576,21 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + logoUrl: + type: + - string + - 'null' + createdAt: + type: + - string + - 'null' + format: date-time + contacts: + type: array + items: + type: string + format: iri-reference + example: 'https://example.com/' Post: type: object description: '' diff --git a/src/ApiResource/ContactApi.php b/src/ApiResource/ContactApi.php index f52e2fc..ea3dac5 100644 --- a/src/ApiResource/ContactApi.php +++ b/src/ApiResource/ContactApi.php @@ -45,6 +45,7 @@ use Symfony\Component\Validator\Constraints\NotBlank; processor: EntityClassDtoStateProcessor::class, stateOptions: new Options(entityClass: Contact::class), )] + class ContactApi { #[ApiProperty(readable: false, writable: false, identifier: true)] @@ -62,6 +63,8 @@ class ContactApi public ?MediaObject $image = null; + public ?string $imageUrl = null; + public ?string $position = null; public ?string $phone = null; diff --git a/src/ApiResource/PartnerApi.php b/src/ApiResource/PartnerApi.php index b25c8b0..39b5565 100644 --- a/src/ApiResource/PartnerApi.php +++ b/src/ApiResource/PartnerApi.php @@ -77,6 +77,8 @@ class PartnerApi public ?MediaObject $logo = null; + public ?string $logoUrl = null; + public ?\DateTimeImmutable $createdAt = null; /** diff --git a/src/Mapper/ContactEntityToApiMapper.php b/src/Mapper/ContactEntityToApiMapper.php index 6ff000a..2ce595b 100644 --- a/src/Mapper/ContactEntityToApiMapper.php +++ b/src/Mapper/ContactEntityToApiMapper.php @@ -46,6 +46,7 @@ class ContactEntityToApiMapper implements MapperInterface ); $dto->birthday = $entity->getBirthday(); $dto->image = $entity->getImage(); + $dto->imageUrl = $entity->getImage()?->getFilePath(); $dto->position = $entity->getPosition(); $dto->phone = $entity->getPhone(); $dto->email = $entity->getEmail(); diff --git a/src/Mapper/PartnerEntityToApiMapper.php b/src/Mapper/PartnerEntityToApiMapper.php index b13a767..ae23113 100644 --- a/src/Mapper/PartnerEntityToApiMapper.php +++ b/src/Mapper/PartnerEntityToApiMapper.php @@ -14,9 +14,8 @@ use Symfonycasts\MicroMapper\MicroMapperInterface; class PartnerEntityToApiMapper implements MapperInterface { public function __construct( - private MicroMapperInterface $microMapper, - ) - { + private MicroMapperInterface $microMapper + ) { } public function load(object $from, string $toClass, array $context): object @@ -46,6 +45,7 @@ class PartnerEntityToApiMapper implements MapperInterface $dto->country = $entity->getCountry(); $dto->website = $entity->getWebsite(); $dto->logo = $entity->getLogo(); + $dto->logoUrl = $entity->getLogo()?->getFilePath(); $dto->createdAt = $entity->getCreatedAt(); $dto->contacts = array_map(function(Contact $contact) { return $this->microMapper->map($contact, ContactApi::class, [ diff --git a/src/Serializer/MediaObjectNormalizer.php b/src/Serializer/MediaObjectNormalizer.php index 7cf46fb..612401a 100644 --- a/src/Serializer/MediaObjectNormalizer.php +++ b/src/Serializer/MediaObjectNormalizer.php @@ -15,7 +15,6 @@ use Symfony\Component\Serializer\SerializerAwareInterface; use Symfony\Component\Serializer\SerializerInterface; use Vich\UploaderBundle\Storage\StorageInterface; -//final class MediaObjectNormalizer #[AsDecorator('api_platform.jsonld.normalizer.item')] final class MediaObjectNormalizer implements NormalizerInterface, SerializerAwareInterface {