jambo.parser package

Submodules

jambo.parser.allof_type_parser module

class AllOfTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:
json_schema_type: ClassVar[str] = 'allOf'
mapped_type(iterable, /)

Return True if bool(x) is True for any x in the iterable.

If the iterable is empty, return False.

jambo.parser.anyof_type_parser module

class AnyOfTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'anyOf'
mapped_type

alias of Union

jambo.parser.array_type_parser module

class ArrayTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:array'
mapped_type

alias of list

type_mappings: dict[str, str] = {'maxItems': 'max_length', 'minItems': 'min_length'}

jambo.parser.boolean_type_parser module

class BooleanTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:boolean'
mapped_type

alias of bool

type_mappings: dict[str, str] = {'default': 'default'}

jambo.parser.const_type_parser module

class ConstTypeParser[source]

Bases: GenericTypeParser

default_mappings = {'const': 'default', 'description': 'description', 'examples': 'examples'}
from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'const'

jambo.parser.enum_type_parser module

class EnumTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:
json_schema_type: ClassVar[str] = 'enum'

jambo.parser.float_type_parser module

class FloatTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:number'
mapped_type

alias of float

type_mappings: dict[str, str] = {'default': 'default', 'exclusiveMaximum': 'lt', 'exclusiveMinimum': 'gt', 'maximum': 'le', 'minimum': 'ge', 'multipleOf': 'multiple_of'}

jambo.parser.int_type_parser module

class IntTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:integer'
mapped_type

alias of int

type_mappings: dict[str, str] = {'default': 'default', 'exclusiveMaximum': 'lt', 'exclusiveMinimum': 'gt', 'maximum': 'le', 'minimum': 'ge', 'multipleOf': 'multiple_of'}

jambo.parser.null_type_parser module

class NullTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:null'
mapped_type

alias of None

jambo.parser.object_type_parser module

class ObjectTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :rtype: tuple[type[BaseModel], dict] :return: A tuple containing the type and its properties.

Parameters:
Return type:

tuple[type[BaseModel], dict]

json_schema_type: ClassVar[str] = 'type:object'
mapped_type

alias of object

classmethod to_model(name, properties, required_keys, description=None, **kwargs)[source]

Converts JSON Schema object properties to a Pydantic model. :type name: str :param name: The name of the model. :type properties: dict[str, JSONSchema] :param properties: The properties of the JSON Schema object. :type required_keys: list[str] :param required_keys: List of required keys in the schema. :rtype: type[BaseModel] :return: A Pydantic model class.

Parameters:
Return type:

type[BaseModel]

jambo.parser.oneof_type_parser module

class OneOfTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'oneOf'
mapped_type

alias of Union

jambo.parser.ref_type_parser module

class RefTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :rtype: tuple[type | ForwardRef, dict] :return: A tuple containing the type and its properties.

Parameters:
Return type:

tuple[type | ForwardRef, dict]

json_schema_type: ClassVar[str] = '$ref'

jambo.parser.string_type_parser module

class StringTypeParser[source]

Bases: GenericTypeParser

format_pattern_mapping = {'hostname': '^[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*$'}
format_type_mapping = {'date': <class 'datetime.date'>, 'date-time': <class 'datetime.datetime'>, 'duration': <class 'datetime.timedelta'>, 'email': <class 'pydantic.networks.EmailStr'>, 'hostname': <class 'str'>, 'ipv4': <class 'ipaddress.IPv4Address'>, 'ipv6': <class 'ipaddress.IPv6Address'>, 'time': <class 'datetime.time'>, 'uri': <class 'pydantic.networks.AnyUrl'>, 'uuid': <class 'uuid.UUID'>}
from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:string'
mapped_type

alias of str

type_mappings: dict[str, str] = {'maxLength': 'max_length', 'minLength': 'min_length', 'pattern': 'pattern'}

Module contents

class AllOfTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:
json_schema_type: ClassVar[str] = 'allOf'
mapped_type(iterable, /)

Return True if bool(x) is True for any x in the iterable.

If the iterable is empty, return False.

class AnyOfTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'anyOf'
mapped_type

alias of Union

class ArrayTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:array'
mapped_type

alias of list

type_mappings: dict[str, str] = {'maxItems': 'max_length', 'minItems': 'min_length'}
class BooleanTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:boolean'
mapped_type

alias of bool

type_mappings: dict[str, str] = {'default': 'default'}
class ConstTypeParser[source]

Bases: GenericTypeParser

default_mappings = {'const': 'default', 'description': 'description', 'examples': 'examples'}
from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'const'
class EnumTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:
json_schema_type: ClassVar[str] = 'enum'
class FloatTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:number'
mapped_type

alias of float

type_mappings: dict[str, str] = {'default': 'default', 'exclusiveMaximum': 'lt', 'exclusiveMinimum': 'gt', 'maximum': 'le', 'minimum': 'ge', 'multipleOf': 'multiple_of'}
class GenericTypeParser[source]

Bases: ABC, Generic[T]

default_mappings = {'default': 'default', 'deprecated': 'deprecated', 'description': 'description', 'examples': 'examples', 'title': 'title'}
from_properties(name, properties, **kwargs)[source]

Converts properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :rtype: tuple[TypeVar(T, bound= type), dict] :return: A tuple containing the type and its properties.

Parameters:
Return type:

tuple[T, dict]

abstractmethod from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :rtype: tuple[TypeVar(T, bound= type), dict] :return: A tuple containing the type and its properties.

Parameters:
Return type:

tuple[T, dict]

json_schema_type: ClassVar[str]
mappings_properties_builder(properties, **kwargs)[source]
Return type:

dict[str, Any]

Parameters:

kwargs (Unpack[TypeParserOptions])

classmethod type_from_properties(name, properties, **kwargs)[source]

Factory method to fetch the appropriate type parser based on properties and generates the equivalent type and fields. :type name: str :param name: The name of the type to be created. :type properties: JSONSchema :param properties: The properties that define the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :rtype: tuple[type, dict] :return: A tuple containing the type and its properties.

Parameters:
Return type:

tuple[type, dict]

type_mappings: dict[str, str] = {}
class IntTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:integer'
mapped_type

alias of int

type_mappings: dict[str, str] = {'default': 'default', 'exclusiveMaximum': 'lt', 'exclusiveMinimum': 'gt', 'maximum': 'le', 'minimum': 'ge', 'multipleOf': 'multiple_of'}
class NullTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:null'
mapped_type

alias of None

class ObjectTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :rtype: tuple[type[BaseModel], dict] :return: A tuple containing the type and its properties.

Parameters:
Return type:

tuple[type[BaseModel], dict]

json_schema_type: ClassVar[str] = 'type:object'
mapped_type

alias of object

classmethod to_model(name, properties, required_keys, description=None, **kwargs)[source]

Converts JSON Schema object properties to a Pydantic model. :type name: str :param name: The name of the model. :type properties: dict[str, JSONSchema] :param properties: The properties of the JSON Schema object. :type required_keys: list[str] :param required_keys: List of required keys in the schema. :rtype: type[BaseModel] :return: A Pydantic model class.

Parameters:
Return type:

type[BaseModel]

class OneOfTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'oneOf'
mapped_type

alias of Union

class RefTypeParser[source]

Bases: GenericTypeParser

from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: str :param name: The name of the type. :type properties: JSONSchema :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :rtype: tuple[type | ForwardRef, dict] :return: A tuple containing the type and its properties.

Parameters:
Return type:

tuple[type | ForwardRef, dict]

json_schema_type: ClassVar[str] = '$ref'
class StringTypeParser[source]

Bases: GenericTypeParser

format_pattern_mapping = {'hostname': '^[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*$'}
format_type_mapping = {'date': <class 'datetime.date'>, 'date-time': <class 'datetime.datetime'>, 'duration': <class 'datetime.timedelta'>, 'email': <class 'pydantic.networks.EmailStr'>, 'hostname': <class 'str'>, 'ipv4': <class 'ipaddress.IPv4Address'>, 'ipv6': <class 'ipaddress.IPv6Address'>, 'time': <class 'datetime.time'>, 'uri': <class 'pydantic.networks.AnyUrl'>, 'uuid': <class 'uuid.UUID'>}
from_properties_impl(name, properties, **kwargs)[source]

Abstract method to convert properties to a type and its fields properties. :type name: :param name: The name of the type. :type properties: :param properties: The properties of the type. :type kwargs: Unpack[TypeParserOptions] :param kwargs: Additional options for type parsing. :return: A tuple containing the type and its properties.

Parameters:

kwargs (Unpack[TypeParserOptions])

json_schema_type: ClassVar[str] = 'type:string'
mapped_type

alias of str

type_mappings: dict[str, str] = {'maxLength': 'max_length', 'minLength': 'min_length', 'pattern': 'pattern'}