I know I’ve seen someone describe how to do this, ...
# singer-tap-development
j
I know I’ve seen someone describe how to do this, but I can’t find examples. I need to create a custom composite type using the SDK typing helper. For example I want a config item to be either a
th.ObjectType
or a
th.StringType
. How do I get a
th.Property
to accept that type?
a
You should be able to create a
th.CustomType()
with any arbitrary JSON Schema definition, and then wrap that in a
Property
declaration.
j
Like this?:
Copy code
stream_properties.append(
        th.Property(
            "schema",
            th.CustomType({"anyOf": [{"type": "string"}, {"type": "null"}, {"type:": "object"}]}),
            required=False,
            description="A valid Singer schema or a path-like string that provides "
                        "the path to a `.json` file that contains a valid Singer "
                        "schema. If provided, the schema will not be inferred from "
                        "the results of an api call."
        ),
    )
a
Yeah, that looks right to me!
I've logged an issue because I realized in responding that we don't have a good docs reference as of now: Add typing helper classes to auto-generated Reference docs (#332) · Issues · Meltano / Meltano SDK for Singer Taps and Targets · GitLab