ontocast.api.parse¶
Shared HTTP query/body parsing for API server routes.
RequestParamError
¶
Bases: ValueError
A request parameter was malformed.
Carries the offending parameter name so handlers can answer 400 by type rather than by comparing exception message strings -- the previous scheme, which meant every parameter error except one well-known message surfaced as a 500, and reworded messages silently changed status codes.
Subclasses :class:ValueError so existing except ValueError callers
(and library users calling the parsers directly) keep working.
Source code in ontocast/api/parse.py
parse_document_metadata_param(value)
¶
Parse optional document_metadata from query/form/JSON.
Accepts a dict (already-parsed JSON) or a JSON object string. Empty /
missing values yield {}.
Source code in ontocast/api/parse.py
parse_document_type_hint_param(value)
¶
Parse optional document_type_hint; empty strings become None.
parse_llm_graph_format_param(value, default)
¶
Parse optional llm_graph_format override from request params.
Source code in ontocast/api/parse.py
parse_max_visits_param(value, default)
¶
Parse optional max_visits override from query/form/json metadata.
Source code in ontocast/api/parse.py
parse_ontology_context_mode_param(value, default)
¶
Parse optional ontology_context_mode override from request params.
Source code in ontocast/api/parse.py
parse_render_mode_param(value, default)
¶
Parse optional render_mode override from request params.
parse_section_schema_id_param(value)
¶
Parse optional section_schema_id; empty strings become None.
parse_sections_list_param(value, param='sections')
¶
Parse a section list from comma-separated text or JSON array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | list[str] | None
|
Raw parameter value. |
required |
param
|
str
|
Parameter name, used only in error messages. |
'sections'
|
Raises:
| Type | Description |
|---|---|
RequestParamError
|
The value started with |
Source code in ontocast/api/parse.py
parse_strip_provenance_param(value)
¶
Parse strip_provenance query/form value.
Source code in ontocast/api/parse.py
parse_summary_max_sentences_param(value, default)
¶
Parse optional summary_max_sentences (positive integer).
Source code in ontocast/api/parse.py
resolve_ontology_context_mode(requested_mode, fixed_ontology_id)
¶
Resolve effective ontology context mode for a request.
A non-empty ontology_context_fixed_ontology_id forces fixed catalog mode.
This allows clients to pick fixed ontology context per request even when the
server default mode differs.