-
-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow selecting schema from URI #1052
Comments
Hi -- thanks. Can you elaborate a bit more on what you mean by:
Override what specifically? Or, what would you do with this mapping? You can create such a mapping yourself via e.g.
though yeah would still love to hear what you'd use it for. |
Thanks for the quick reply. I'm just looking to get a validator by the id string, essentially overriding the default validator specified in the $id field (without modifying the document). I could construct the dictionary as above, but that means importing and rebuilding the list of validators myself. I could also directly use the private _META_SCHEMAS or its deprecated access via the |
I'm afraid I still don't follow this -- do you mean the But essentially this is unlikely to come back -- it's not encouraged to override the builtin versions, it's instead a way better idea to create your own dialect with its own |
Sorry, yes I did mean By "override" I mean which validator to use, not anything specific about the validator itself. It's just a tiny bit of syntactic sugar to be able to take the draft specification URI and retrieve the appropriate validator, using the same code that
By default, use the schema in the |
That looks more or less like why |
Sure, but I have to use the class itself, not a lookup based on a string value, which is easier for client code. Again, it's just a minor convenience function to have a way to use the _META_SCHEMAS lookup to get the validator type - if you don't think it's generally useful or a good idea it's not that hard for me to create the map myself. Overall I really like the library and appreciate the work that has gone into it. |
Thanks for the kind words, definitely appreciated. I think for now I'd like to err on the side of not adding more here -- it's possible down the line once some of the global state has disappeared (i.e. after some of the deprecated things are removed) that something like this could be in the cards, but for now I don't want to commit to more global state until we have some notion of a dialect registry. FWIW in case I didn't mention it before, yet another way if you really have a string dialect URI is to simply use Going to close, but certainly appreciate the report (and again the kind words!) |
Not sure if this is related to #451, but it would be convenient to access the map of schema URIs to validators (e.g. https://json-schema.org/draft/2020-12/schema -> Draft2012). It looks like this used to be exposed via
meta_schemas
invalidators.py
but was deprecated - getting a validator for the schema is useful but sometimes you want to override that and it would be helpful to do that with a string or enum value.The text was updated successfully, but these errors were encountered: