Skip to content

Commit

Permalink
Update some doc on API
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminjonard committed Jun 9, 2024
1 parent 6ce45fe commit 311be50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Entity/Datum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Entity;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
Expand Down Expand Up @@ -74,11 +75,22 @@ class Datum implements VisibleInterface, \Stringable
#[Groups(['datum:read', 'datum:write'])]
#[Assert\NotBlank]
#[Assert\Choice(choices: DatumTypeEnum::TYPES)]
#[ApiProperty(
openapiContext: [
'example' => 'text, textarea, country, date, rating, number, link, list, choice-list, checkbox, image, file, sign, video'
]
)]
private ?string $type = null;

#[ORM\Column(type: Types::STRING, nullable: true)]
#[Groups(['datum:read', 'datum:write'])]
#[Assert\NotBlank]
#[ApiProperty(
openapiContext: [
'type' => 'string',
'example' => 'See wiki: https://github.com/benjaminjonard/koillection/wiki/API#example-values-for-data-fields'
]
)]
private ?string $label = null;

#[ORM\Column(type: Types::TEXT, nullable: true)]
Expand Down
1 change: 1 addition & 0 deletions src/Enum/DatumTypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DatumTypeEnum
self::TYPE_IMAGE,
self::TYPE_FILE,
self::TYPE_SIGN,
self::TYPE_VIDEO,
];

public const array TEXT_TYPES = [
Expand Down

0 comments on commit 311be50

Please sign in to comment.