httk.serve.http.openapi.schemas

Offline JSON Schema registries for OpenAPI applications.

Exceptions

OpenAPISchemaError

Report an unavailable or invalid JSON Schema document.

Classes

OpenAPISchemaRegistry

Validate caller-supplied JSON Schema documents without network retrieval.

Module Contents

exception httk.serve.http.openapi.schemas.OpenAPISchemaError[source]

Bases: ValueError

Report an unavailable or invalid JSON Schema document.

class httk.serve.http.openapi.schemas.OpenAPISchemaRegistry(documents)[source]

Validate caller-supplied JSON Schema documents without network retrieval.

The registry deep-copies supplied documents, so later caller mutations do not alter validation or offline reference resolution.

Parameters:

documents (collections.abc.Iterable[collections.abc.Mapping[str, Any]]) – JSON Schema documents, each with a non-empty $id.

lookup(identifier)[source]

Return a schema document by its canonical identifier.

Parameters:

identifier (str) – Schema $id.

Returns:

Independent copy of the registered schema mapping.

Raises:

OpenAPISchemaError – If no supplied schema has that identifier.

Return type:

collections.abc.Mapping[str, Any]

validate(identifier, value)[source]

Validate a JSON-compatible value against an offline schema.

Parameters:
  • identifier (str) – Schema $id.

  • value (Any) – JSON-compatible value to validate.

Raises:

OpenAPISchemaError – If the schema is unavailable or validation fails.

property identifiers: tuple[str, Ellipsis][source]

Return supplied schema identifiers in caller order.