robby_robinson
06/22/2023, 8:17 PMint or str
or str or object
?Reuben (Matatika)
06/23/2023, 8:24 AMJSONTypeHelper
to create your own type with a JSON schema definition - this is what a lot of the inbuilt types do:
https://github.com/meltano/sdk/blob/c6a893372d036a99da81ee9131b8b6e17f50e670/singer_sdk/typing.py#L423-L442
from singer_sdk.typing import JSONTypeHelper
class StrOrIntType(JSONTypeHelper):
# provide an implementation
def type_dict(cls):
return {"type": ["string", "integer"]}
robby_robinson
06/23/2023, 3:50 PMReuben (Matatika)
06/23/2023, 6:39 PMjson.loads
the value - if no exception, then you've got your data already; otherwise you can assume it's a file path and load the file.
Having said that, the above logic would lie in the tap code rather than in the config schema. If you really want to validate from JSON schema, the spec does support regex pattern matching if you wanted to validate a JSON-formatted string (e.g. starts and ends with []
or {}
) - I know there is some URI type that is built into the SDK currently which could maybe work for a local path, but I'm not sure about that. If it turns out it's not so straightforward to implement, I would just do the first solution personally.Reuben (Matatika)
06/23/2023, 6:47 PM