Skip to content

[18.0][ADD] http_json_cerberus: Cerberus validation for http_json routes - #182

Draft
simahawk wants to merge 2 commits into
OCA:18.0from
camptocamp:18-add-http_json_cerberus
Draft

simahawk wants to merge 2 commits into
OCA:18.0from
camptocamp:18-add-http_json_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_json routes. This module brings Cerberus validation to http_json_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_json_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`.
Pending OCA#179 (http_api_dispatcher).
To be removed once merged.
@simahawk
simahawk force-pushed the 18-add-http_json_cerberus branch from 17dfd59 to c1f5a82 Compare October 21, 2026 07:25
@OCA-git-bot OCA-git-bot added mod:http_api_cerberus Module http_api_cerberus and removed mod:http_json_cerberus Module http_json_cerberus labels Oct 21, 2026
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