Public API for Resource behavior metadata #14

Closed
opened 2026-05-27 08:32:40 +02:00 by c.fahner · 1 comment
Owner

Currently the actual behavior of a Resource is inaccessible from outside of the Handler black box. It is not possible to:

  • Get a list of HTTP methods for a resource
  • Get a list of parameters for a resource method
  • Get the extractors and validators of a specific resource method parameter

While it would be possible to use reflection on the Resource class to obtain this information, this would only show the information as declared and not how it actually behaves. For example, every resource has implied HEAD and OPTIONS methods and every parameter has an implied FromQuery extractor. Future versions may further introduce new implied, edge-case, documentation, or security-related behavior.

There should be a public API that standardizes this "behavioral metadata" about resources. Implementing OpenAPI would be impossible otherwise. The Handler itself should also be refactored to use these API's instead of its own internal methods, to keep the metadata in sync with the actual behavior.

Suggestion: a final class Resource\Endpoint and a namespace with the same name that contains all the helpers (Resource\Endpoint\{ Method, Parameter, StringParameter, ... }.

Currently the actual behavior of a `Resource` is inaccessible from outside of the `Handler` black box. It is not possible to: * Get a list of HTTP methods for a resource * Get a list of parameters for a resource method * Get the extractors and validators of a specific resource method parameter While it would be possible to use reflection on the `Resource` class to obtain this information, this would only show the information as declared and not how it actually behaves. For example, every resource has implied `HEAD` and `OPTIONS` methods and every parameter has an implied `FromQuery` extractor. Future versions may further introduce new implied, edge-case, documentation, or security-related behavior. There should be a public API that standardizes this "behavioral metadata" about resources. Implementing OpenAPI would be impossible otherwise. The `Handler` itself should also be refactored to use these API's instead of its own internal methods, to keep the metadata in sync with the actual behavior. Suggestion: a final class `Resource\Endpoint` and a namespace with the same name that contains all the helpers (`Resource\Endpoint\{ Method, Parameter, StringParameter, ... }`.
c.fahner added this to the v0.1 milestone 2026-05-27 08:32:40 +02:00
Author
Owner

Merging this with #3.

Merging this with #3.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Depends on
Reference
slendium/framework#14
No description provided.