[18.0][ADD] http_api_dispatcher: generic dispatcher for JSON APIs #179
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 386 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #179"
general
weight: 0.35
simahawk
Motivation
base_restties every API to its components and to therestapiroute type, so an API can't leavebase_rest(shopfloor included) without a replacement. This module provides the common plumbing of an API endpoint as a route type of its own,http_json, independent of components. APIs can then move to it one endpoint at a time. The error format and the params stay compatible withbase_rest.Key features
http_jsonroute type: params parsed once from the query string and the body (JSON or forms)Accept-Languageheaderhttp_json_cerberus)A bit more of context in comparison to base_rest/fastapi (from module's readme)
base_rest(OCA/rest-framework) has been the foundation of many APIs,including the Shopfloor apps. Over time it showed some limits:
documentation and routing are bound together
and you cannot use one piece without the others
components, a second registrywith its own inheritance and boot lifecycle,
which is often used only to look up a class by name
making routing hard to follow and to customize
The
fastapistack is a way to go for new standalone APIs,but moving existing APIs to it means rewriting every service and schema and endpoints are not extendable models.
Plus, it pulls in more external dependencies that for many cases are not needed.
This module is the base of a lighter stack, made of small modules
that can be used separately and extended via standard Odoo inheritance:
http_json_dispatcher: thehttp_jsonroute type (parsing, validation hooks, JSON errors)usable by plain Odoo controllers
endpoint_spec: declare endpoints on services, for routes generatorshttp_json_cerberus: Cerberus validationopenapi_doc_base: API docs from the actual routesendpoint_route_handlergenerators: routes computed from the codewithout storing a row per route
Goals:
base_reststack without moving tofastapicomponent, staying highly customizable(routing keys per route,
ir.httphooks per database)base_restclients (error format, validation behavior)to allow a gradual migration
The only doubt that I have ATM is: should this stay here or go to rest-framework repo? (even though is not strictly bound to "REST" stuff.
@lmignon would be nice to have your feedback :pray:
One last thing: as this work it's a derivation of base_rest, I've tried to keep the copyright where it made sense, but please let me know if I left something behind :wink: