Declarable HTTP resources #10
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No project
No assignees
1 participant
Notifications
Total time spent: 2 hours
Due date
c.fahner
2 hours
No due date set.
Blocks
#14 Public API for Resource behavior metadata
slendium/framework
Reference
slendium/framework!10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issues/3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #3.
Declarable HTTP resourcesto WIP: Declarable HTTP resources@ -0,0 +20,4 @@* @copyright Slendium 2026*/#[Attribute(Attribute::TARGET_PARAMETER)]class NonEmpty implements ArgumentValidator {Add tests
@ -0,0 +9,4 @@* @author C. Fahner* @copyright Slendium 2026*/final class ArgumentCasts {Add tests
@ -0,0 +136,4 @@'float' => ArgumentCasts::toFloat($arg->value),'string' => ArgumentCasts::toString($arg->value),Field::class => ArgumentCasts::toField($arg->value),default => ResourceException::forUnsupportedType($param->name, $type)ResourceExceptionshould not be part of the return type, they should not happen during normal operation. Just throw.@ -0,0 +113,4 @@$type === null => ResourceException::forMissingType($param->name),$type instanceof ReflectionNamedType => self::castArgumentTyped($param, $arg, $type->getName()),$type instanceof ReflectionUnionType => self::castArgumentUnion($param, $type, $arg),$type instanceof ReflectionIntersectionType => ResourceException::forUnsupportedType($param->name, $type),Throw and remove from return type.
@ -0,0 +18,4 @@** To define an HTTP-method for the resource, simply add a class-method with the same name as the* HTTP-method. The class-method must be `public` and must declare a return type that is covariant* with `?Method`. To ensure the method's possible responses can be properly documented (eg. for OpenAPI),Return type can also be
Response@ -0,0 +4,4 @@use Exception;/**Add an explanation that this exception should be returned instead of thrown.
@ -0,0 +6,4 @@/*** Indicates a problem with the way the resource has been declared.*Add explanation that this indicates a developer error and that this exception is thrown.
@ -0,0 +5,4 @@use Slendium\Framework\Builders\ResponseBuilder;/*** Modifies a resource method's response before it is sent back."HTTP response modifier for a declared resource method."
@ -0,0 +22,4 @@$this->assertSame(2, $result);}public function test_parameters_shouldHaveExpectedCount_whenEvaluatingImpliedHeadMethod(): void {"whenEvaluatingHeadMethod" (since the head method is a forced wrapper, not really implied)
WIP: Declarable HTTP resourcesto Declarable HTTP resources