It it possible to have shared schemas referenced w...
# singer-tap-development
p
It it possible to have shared schemas referenced within schemas for different streams when using the SDK? I tried doing something like this but the jsonschema library was throwing an
unknown URL type
error. I’m guessing that isn’t something that just works out of the box.
a
I like where you are going with this! We currently default to the Draft4 spec. Do you know if that's a supported feature in the Draft4 JSON Schema spec? If so, there certainly should be a way to accomplish this and we'd welcome a PR if you have time and interest in developing it. Another manner of schema reuse would be to declare the structure in python, either using the
typing
helper classes or your own custom code (as long as it generates valid json schema structures). What do you think of these approaches? If what you want to accomplish is not supported, do you mind opening up an issue for tracking? I can see others having similar requests in the future.
p
This changelog seems to suggest Draft4 does support `$ref`s, but I’ll do some more research. And yes I’d be happy to contribute a PR - I’ve had success with the pattern outlined here. Re: declaring the structure in Python - has there been any talk about potentially using Pydantic to declare and validate data against schemas? As a bonus, it was also give you the ability to easily convert back-and-forth with jsonschema.
e
@prratek_ramchandani there has been some discussion about using Pydantic: https://gitlab.com/meltano/singer-sdk/-/issues/10#note_519595958.
a
@prratek_ramchandani and @edgar_ramirez_mondragon - We resolved the issue referenced above with a minimal implementation but if either of you want to open a new issue for the next iteration(s), that would be much appreciated. I just reread that thread and the only potential issue I saw (apart from bandwidth at the time 😉) was the question of nullable types that might expect “anyOf” with “null” as an option if used in downstream SCHEMA messages.
@prratek_ramchandani - Regarding the compatibility with
$ref
, it sounds like that may be a bug or something we could add support for. Feel free to log a ticket and we can dive deep there in the Issue.
p
okay i tried writing this up to the best of my ability - https://gitlab.com/meltano/singer-sdk/-/issues/109
a
@prratek_ramchandani - Thanks for logging. I put a couple comments there for further discussion.
e
Alright @aaronsteers. Finally got to open the issue for pydantic: https://gitlab.com/meltano/singer-sdk/-/issues/110
a
I saw that. Thanks! 😁