Skip to content

[18.0][ADD] endpoint_spec: declare endpoints on any class - #180

Draft
simahawk wants to merge 1 commit into
OCA:18.0from
camptocamp:18-add-endpoint_spec
Draft

simahawk wants to merge 1 commit into
OCA:18.0from
camptocamp:18-add-endpoint_spec

Conversation

@simahawk

Copy link
Copy Markdown
Contributor

Motivation

Endpoints are declared on controllers today, and base_rest declares them on components. Services such as the shopfloor ones can't expose their methods without a controller per service, or a component per service. This module lets any class declare its endpoints, so routes can be generated from them (see endpoint_route_handler) and the services don't depend on a route type. The conventions are a transitional option: they cover the naming rules of base_rest, to ease the move, and are meant to go away once the endpoints are explicit.

Key features

  • endpoint decorator: declares metadata only, never wraps the method
  • EndpointSpec: HTTP methods, paths, params and any routing key of an endpoint
  • collect_endpoints: collects the specs of a class, following inheritance
  • conventions (transitional): defaults for the methods that aren't decorated
  • no dependency on a dispatcher: generated routes can use any route type (http_json, restapi...)

Declare endpoints on any class (eg: services), not only on controllers:
metadata read by routes generators (see endpoint_route_handler).

* `endpoint` decorator: metadata only, never wraps the method;
  specs are inherited, `endpoint.extend` updates them on overrides
* `EndpointSpec` / `collect_endpoints`
* `Conventions`: explicit endpoints only by default,
  subclass it to expose non decorated methods (as a transition)

No dependency on any dispatcher.
@simahawk
simahawk force-pushed the 18-add-endpoint_spec branch from 4bf6d21 to 5bda3a8 Compare October 21, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants