singer_sdk.typing.ObjectType#
- class singer_sdk.typing.ObjectType#
Object type, which wraps one or more named properties.
- __init__(*properties: Property, additional_properties: W | type[W] | bool | None = None, pattern_properties: Mapping[str, W | type[W]] | None = None) None #
Initialize ObjectType from its list of properties.
- Parameters:
properties – Zero or more attributes for this JSON object.
additional_properties – A schema to match against unnamed properties in this object, or a boolean indicating if extra properties are allowed.
pattern_properties – A dictionary of regex patterns to match against property names, and the schema to match against the values.
Examples
>>> t = ObjectType( ... Property("name", StringType, required=True), ... Property("age", IntegerType), ... Property("height", NumberType), ... additional_properties=False, ... ) >>> print(t.to_json(indent=2)) { "type": "object", "properties": { "name": { "type": [ "string" ] }, "age": { "type": [ "integer", "null" ] }, "height": { "type": [ "number", "null" ] } }, "required": [ "name" ], "additionalProperties": false } >>> t = ObjectType( ... Property("name", StringType, required=True), ... Property("age", IntegerType), ... Property("height", NumberType), ... additional_properties=StringType, ... ) >>> print(t.to_json(indent=2)) { "type": "object", "properties": { "name": { "type": [ "string" ] }, "age": { "type": [ "integer", "null" ] }, "height": { "type": [ "number", "null" ] } }, "required": [ "name" ], "additionalProperties": { "type": [ "string" ] } }
- property type_dict: dict#
Get type dictionary.
- Returns:
A dictionary describing the type.