aipng/apitte-mapping
Composer 安装命令:
composer require aipng/apitte-mapping
包简介
Custom type mappers for contributte/apitte
README 文档
README
Custom parameter type mappers for contributte/apitte.
Installation
composer require aipng/apitte-mapping
Registration
Register the mappers manually in your Nette configuration:
api: plugins: Apitte\Core\DI\Plugin\CoreMappingPlugin: types: date: AipNg\ApitteMapping\Parameter\DateTypeMapper email: AipNg\ApitteMapping\Parameter\EmailTypeMapper int_array: AipNg\ApitteMapping\Parameter\IntegerArrayTypeMapper
Mappers
DateTypeMapper
Type name: date
Accepts a date string in Y-m-d format and returns a DateTimeImmutable with time set to 00:00:00.
Invalid input throws Apitte\Core\Exception\Runtime\InvalidArgumentTypeException.
EmailTypeMapper
Type name: email
Accepts an email address string and returns an AipNg\ValueObjects\Web\Email value object. The address is normalized to lowercase.
Invalid input throws Apitte\Core\Exception\Runtime\InvalidArgumentTypeException.
IntegerArrayTypeMapper
Type name: int_array
Accepts a comma-separated string of integers (e.g. 1,2,3) and returns array<int>. Whitespace around items is trimmed. Empty string or comma-only input returns an empty array.
Invalid input (non-string, non-integer values, floats) throws Apitte\Core\Exception\Runtime\InvalidArgumentTypeException.
Usage
use Apitte\Core\Annotation\Controller\Path; use Apitte\Core\Annotation\Controller\RequestParameter; use Apitte\Core\Annotation\Controller\Method; use Apitte\Core\Http\ApiRequest; use Apitte\Core\Http\ApiResponse; use AipNg\ValueObjects\Web\Email; #[Path('/users')] final class UserController implements \Apitte\Core\UI\Controller\IController { #[Path('/search')] #[Method('GET')] public function search( ApiRequest $request, ApiResponse $response, #[RequestParameter(name: 'email', type: 'email')] Email $email, #[RequestParameter(name: 'since', type: 'date')] \DateTimeImmutable $since, #[RequestParameter(name: 'ids', type: 'int_array', required: false)] array $ids = [], ): ApiResponse { // $email is AipNg\ValueObjects\Web\Email // $since is DateTimeImmutable at 00:00:00 // $ids is array<int> ... } }
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-16