Skip to content

[18.0][ADD] http_api_cerberus: Cerberus validation for http_api routes - #690

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

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

Conversation

@simahawk

Copy link
Copy Markdown
Contributor

Depends on

Motivation

base_rest validates params w/ Cerberus through its own validator, which can't be reused by http_api routes. This module brings Cerberus validation to http_api_dispatcher, with the same behavior as base_rest: an existing schema keeps working and migrating an endpoint doesn't change its contract.

Key features

  • CerberusParam: an http_api_dispatcher param validating input params or results
  • unknown keys dropped, invalid input gives a 400, invalid output a 500 (as base_rest)
  • cerberus_to_json: converts Cerberus schemas to JSON schemas, used to document the APIs

Validate `http_api` params and results with Cerberus schemas.

* `CerberusParam`: schema as dict, callable or method name,
  list support, optional schema cache, non strict output mode
* `cerberus_to_json`: convert Cerberus schemas to JSON schemas for API docs

Follows the `ApiParam` contract of `http_api_dispatcher`: `from_params`
takes the `ApiCall` (named `call`) and reads `call.params`.

Behavior compatible with base_rest `restapi.CerberusValidator`.
@simahawk
simahawk force-pushed the 18-add-http_api_cerberus branch from e58230e to 81c85b8 Compare November 23, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:http_api_cerberus Module http_api_cerberus series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants