From 1e28817280f8db4e06ad3f9828b61d09fa19c623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 15 Feb 2026 15:52:27 +0100 Subject: [PATCH] Improved API docs for label endpoint --- config/reference.php | 25 ---------------------- src/ApiResource/LabelGenerationRequest.php | 20 ++++++++++------- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/config/reference.php b/config/reference.php index a1a077aa..978a82f9 100644 --- a/config/reference.php +++ b/config/reference.php @@ -1387,7 +1387,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * bubble?: bool|Param, // Default: true * interactive_only?: bool|Param, // Default: false * app_name?: scalar|Param|null, // Default: null - * fill_extra_context?: bool|Param, // Default: false * include_stacktraces?: bool|Param, // Default: false * process_psr_3_messages?: array{ * enabled?: bool|Param|null, // Default: null @@ -1407,7 +1406,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * activation_strategy?: scalar|Param|null, // Default: null * stop_buffering?: bool|Param, // Default: true * passthru_level?: scalar|Param|null, // Default: null - * excluded_404s?: list, * excluded_http_codes?: list, @@ -1421,9 +1419,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * url?: scalar|Param|null, * exchange?: scalar|Param|null, * exchange_name?: scalar|Param|null, // Default: "log" - * room?: scalar|Param|null, - * message_format?: scalar|Param|null, // Default: "text" - * api_version?: scalar|Param|null, // Default: null * channel?: scalar|Param|null, // Default: null * bot_name?: scalar|Param|null, // Default: "Monolog" * use_attachment?: scalar|Param|null, // Default: true @@ -1432,9 +1427,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * icon_emoji?: scalar|Param|null, // Default: null * webhook_url?: scalar|Param|null, * exclude_fields?: list, - * team?: scalar|Param|null, - * notify?: scalar|Param|null, // Default: false - * nickname?: scalar|Param|null, // Default: "Monolog" * token?: scalar|Param|null, * region?: scalar|Param|null, * source?: scalar|Param|null, @@ -1452,12 +1444,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * store?: scalar|Param|null, // Default: null * connection_timeout?: scalar|Param|null, * persistent?: bool|Param, - * dsn?: scalar|Param|null, - * hub_id?: scalar|Param|null, // Default: null - * client_id?: scalar|Param|null, // Default: null - * auto_log_stacks?: scalar|Param|null, // Default: false - * release?: scalar|Param|null, // Default: null - * environment?: scalar|Param|null, // Default: null * message_type?: scalar|Param|null, // Default: 0 * parse_mode?: scalar|Param|null, // Default: null * disable_webpage_preview?: bool|Param|null, // Default: null @@ -1467,7 +1453,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * topic?: int|Param, // Default: null * factor?: int|Param, // Default: 1 * tags?: list, - * console_formater_options?: mixed, // Deprecated: "monolog.handlers..console_formater_options.console_formater_options" is deprecated, use "monolog.handlers..console_formater_options.console_formatter_options" instead. * console_formatter_options?: mixed, // Default: [] * formatter?: scalar|Param|null, * nested?: bool|Param, // Default: false @@ -1478,15 +1463,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * chunk_size?: scalar|Param|null, // Default: 1420 * encoder?: "json"|"compressed_json"|Param, * }, - * mongo?: string|array{ - * id?: scalar|Param|null, - * host?: scalar|Param|null, - * port?: scalar|Param|null, // Default: 27017 - * user?: scalar|Param|null, - * pass?: scalar|Param|null, - * database?: scalar|Param|null, // Default: "monolog" - * collection?: scalar|Param|null, // Default: "logs" - * }, * mongodb?: string|array{ * id?: scalar|Param|null, // ID of a MongoDB\Client service * uri?: scalar|Param|null, @@ -1529,7 +1505,6 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * id: scalar|Param|null, * method?: scalar|Param|null, // Default: null * }, - * lazy?: bool|Param, // Default: true * verbosity_levels?: array{ * VERBOSITY_QUIET?: scalar|Param|null, // Default: "ERROR" * VERBOSITY_NORMAL?: scalar|Param|null, // Default: "WARNING" diff --git a/src/ApiResource/LabelGenerationRequest.php b/src/ApiResource/LabelGenerationRequest.php index fe59cc77..9b4462a0 100644 --- a/src/ApiResource/LabelGenerationRequest.php +++ b/src/ApiResource/LabelGenerationRequest.php @@ -23,12 +23,15 @@ declare(strict_types=1); namespace App\ApiResource; +use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Model\Operation; use ApiPlatform\OpenApi\Model\RequestBody; +use ApiPlatform\OpenApi\Model\Response; use App\Entity\LabelSystem\LabelSupportedElement; use App\State\LabelGenerationProcessor; +use App\Validator\Constraints\Misc\ValidRange; use Symfony\Component\Validator\Constraints as Assert; /** @@ -40,7 +43,12 @@ use Symfony\Component\Validator\Constraints as Assert; description: 'Generate PDF labels for parts, part lots, or storage locations using label profiles.', operations: [ new Post( + inputFormats: ['json' => ['application/json']], + outputFormats: [], openapi: new Operation( + responses: [ + "200" => new Response(description: "PDF file containing the generated labels"), + ], summary: 'Generate PDF labels', description: 'Generate PDF labels for one or more elements using a label profile. Returns a PDF file.', requestBody: new RequestBody( @@ -48,8 +56,6 @@ use Symfony\Component\Validator\Constraints as Assert; required: true, ), ), - inputFormats: ['json' => ['application/json']], - outputFormats: [], ) ], processor: LabelGenerationProcessor::class, @@ -61,17 +67,15 @@ class LabelGenerationRequest */ #[Assert\NotBlank(message: 'Profile ID is required')] #[Assert\Positive(message: 'Profile ID must be a positive integer')] - public int $profileId = 1; + public int $profileId = 0; /** * @var string Comma-separated list of element IDs or ranges (e.g., "1,2,5-10,15") */ #[Assert\NotBlank(message: 'Element IDs are required')] - #[Assert\Regex( - pattern: '/^[\d,\-\s]+$/', - message: 'Element IDs must be a comma-separated list of numbers or ranges (e.g., "1,2,5-10")' - )] - public string $elementIds = '1,2,5-10'; + #[ValidRange()] + #[ApiProperty(example: "1,2,5-10,15")] + public string $elementIds = ''; /** * @var LabelSupportedElement|null Optional: Override the element type. If not provided, uses profile's default.