jambo package

Subpackages

Submodules

jambo.schema_converter module

class SchemaConverter(namespace_registry=None)[source]

Bases: object

Converts JSON Schema to Pydantic models.

This class is responsible for converting JSON Schema definitions into Pydantic models. It validates the schema and generates the corresponding Pydantic model with appropriate fields and types. The generated model can be used for data validation and serialization.

Parameters:

namespace_registry (MutableMapping[str, MutableMapping[str, ForwardRef | type | None]] | None)

static build(schema, ref_cache=None)[source]

Converts a JSON Schema to a Pydantic model. This method doesn’t use a reference cache if none is provided. :type schema: JSONSchema

param schema:

The JSON Schema to convert.

Return type:

type[BaseModel]

Parameters:
  • schema (JSONSchema)

  • ref_cache (MutableMapping[str, ForwardRef | type | None] | None :param ref_cache: An optional reference cache to use during conversion, if provided with_clean_cache will be ignored. :return: The generated Pydantic model.)

build_with_cache(schema, ref_cache=None, without_cache=False)[source]

Converts a JSON Schema to a Pydantic model. This is the instance method version of build and uses the instance’s reference cache if none is provided. Use this method if you want to utilize the instance’s reference cache.

Return type:

type[BaseModel]

Parameters:
  • schema (JSONSchema :param schema: The JSON Schema to convert.)

  • ref_cache (MutableMapping[str, ForwardRef | type | None] | None :param ref_cache: An optional reference cache to use during conversion.)

  • without_cache (bool :param without_cache: Whether to use a clean reference cache for this conversion. :return: The generated Pydantic model.)

clear_ref_cache(namespace='default')[source]

Clears the reference cache.

Return type:

None

Parameters:

namespace (str | None)

get_cached_ref(ref_name, namespace='default')[source]

Gets a cached reference from the reference cache. :type ref_name: str :param ref_name: The name of the reference to get. :rtype: type | None :return: The cached reference, or None if not found.

Parameters:
  • ref_name (str)

  • namespace (str)

Return type:

type | None

Module contents

class SchemaConverter(namespace_registry=None)[source]

Bases: object

Converts JSON Schema to Pydantic models.

This class is responsible for converting JSON Schema definitions into Pydantic models. It validates the schema and generates the corresponding Pydantic model with appropriate fields and types. The generated model can be used for data validation and serialization.

Parameters:

namespace_registry (MutableMapping[str, MutableMapping[str, ForwardRef | type | None]] | None)

static build(schema, ref_cache=None)[source]

Converts a JSON Schema to a Pydantic model. This method doesn’t use a reference cache if none is provided. :type schema: JSONSchema

param schema:

The JSON Schema to convert.

Return type:

type[BaseModel]

Parameters:
  • schema (JSONSchema)

  • ref_cache (MutableMapping[str, ForwardRef | type | None] | None :param ref_cache: An optional reference cache to use during conversion, if provided with_clean_cache will be ignored. :return: The generated Pydantic model.)

build_with_cache(schema, ref_cache=None, without_cache=False)[source]

Converts a JSON Schema to a Pydantic model. This is the instance method version of build and uses the instance’s reference cache if none is provided. Use this method if you want to utilize the instance’s reference cache.

Return type:

type[BaseModel]

Parameters:
  • schema (JSONSchema :param schema: The JSON Schema to convert.)

  • ref_cache (MutableMapping[str, ForwardRef | type | None] | None :param ref_cache: An optional reference cache to use during conversion.)

  • without_cache (bool :param without_cache: Whether to use a clean reference cache for this conversion. :return: The generated Pydantic model.)

clear_ref_cache(namespace='default')[source]

Clears the reference cache.

Return type:

None

Parameters:

namespace (str | None)

get_cached_ref(ref_name, namespace='default')[source]

Gets a cached reference from the reference cache. :type ref_name: str :param ref_name: The name of the reference to get. :rtype: type | None :return: The cached reference, or None if not found.

Parameters:
  • ref_name (str)

  • namespace (str)

Return type:

type | None