aazsamir / temrest
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/aazsamir/temrest
Requires
- tempest/framework: dev-main
Requires (Dev)
- carthage-software/mago: dev-main
This package is auto-updated.
Last update: 2025-10-18 20:48:03 UTC
README
Temrest is a package for building RESTful APIs with Tempest framework.
It's still in early FAFO development stage.
Usage
composer require aazsamir/temrest:dev-main
Temrest reads route definitions directly from your types.
Given this example code:
<?php class ListRequest implements Request { use IsRequest; public int $limit = 30; public ?int $page = null; } class ListResponse implements ApiResponse { use IsApiResponse; /** @return Pet[] */ public function toResponse(): array; { return $this->pets; } } class PetController { #[Get('/owner/{ownerId}/pets')] #[ApiInfo(description: 'List pets by their owner')] public function listPets(string $ownerId, ListRequest $request): ListResponse { // ... } } class Pet { use ToArray; public string $id; public string $name; public PetType $type; /** @var string[] */ public array $tags; } enum PetType: string { case Dog = 'dog'; case Cat = 'cat'; }
When you run ./tempest openapi:generate
it will generate an OpenAPI specifilaction
openapi: 3.0.0 servers: [] info: title: Temrest API version: '1.0' paths: /owner/{ownerId}/pets: get: description: List pets by their owner responses: '200': description: Successful Response content: application/json: schema: type: array items: $ref: '#/components/schemas/Pet' nullable: false parameters: - name: ownerId in: path required: true schema: type: string - name: limit in: query schema: type: integer nullable: true - name: page in: query schema: type: integer nullable: true components: schemas: Pet: type: object properties: id: type: string nullable: false name: type: string nullable: false type: $ref: '#/components/schemas/PetType' nullable: false PetType: type: string enum: - dog - cat nullable: false