← Back to Pull requests

[18.0][ADD] http_api_dispatcher: generic dispatcher for JSON APIs #179

Closed
unknown closed this pull request without merging on Nov 13, 2026 16:04 UTC
View on GitHub
unknown unknown commented on Oct 16, 2026 13:49 UTC
Author

Motivation

base_rest ties every API to its components and to the restapi route type, so an API can't leave base_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 with base_rest .

Key features

  • http_json route type: params parsed once from the query string and the body (JSON or forms)

  • language set from the Accept-Language header

  • input and output validated/converted by pluggable params declared on the route (see http_json_cerberus)

  • results serialized as JSON (dates as ISO strings, decimals as floats)

  • exceptions turned into JSON error responses w/ the proper status codes

  • hooks on each step, extensible via standard Odoo inheritance
  • 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:

  • it is a monolith: dispatcher, service layer, validation,

  • documentation and routing are bound together
    and you cannot use one piece without the others
  • services must be components, a second registry

  • with its own inheritance and boot lifecycle,
    which is often used only to look up a class by name
  • controllers are generated at boot from the services,

  • making routing hard to follow and to customize

    The fastapi stack 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: the http_json route type (parsing, validation hooks, JSON errors)

  • usable by plain Odoo controllers
  • endpoint_spec: declare endpoints on services, for routes generators

  • http_json_cerberus: Cerberus validation

  • openapi_doc_base: API docs from the actual routes

  • endpoint_route_handler generators: routes computed from the code

  • without storing a row per route

    Goals:

  • simplify the base_rest stack without moving to fastapi

  • keep modules small and reusable

  • drop the dependency on component, staying highly customizable

  • (routing keys per route, ir.http hooks per database)
  • stay compatible with base_rest clients (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:

    Diff: 386 lines (+289 / -97) across 4 files Reviewer: simahawk Review duration: 40455m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43% (MEDIUM) · Higher = larger blast radius
    43%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17% · Safe to merge
    17%
    Repository