Skip to content

API for determining supported schema URIs #1067

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

Closed
ikonst opened this issue Mar 23, 2023 · 2 comments
Closed

API for determining supported schema URIs #1067

ikonst opened this issue Mar 23, 2023 · 2 comments

Comments

@ikonst
Copy link
Contributor

ikonst commented Mar 23, 2023

Since 836db7c, there's no more public API for determining the supported schema URIs.

Providing an unsupported URI silently uses the latest draft, and I'd like to be able to prevent this, or alert the user in my app. That alone I can do (a bit awkwardly) with

sentinel = object()
validator = validator_for(schema, sentinel)
if validator is sentinel:
  if schema_uri := schema.get('$schema')
    raise ValueError(f"Schema had unsupported {schema_uri!r}")
  else:
    raise ValueError("Schema had no $schema, refusing to default")

What I still cannot do, is be more helpful and list the supported URIs, because meta_schemas is private now.

@Julian
Copy link
Member

Julian commented Mar 23, 2023

Thanks! This is similar to #1052 which also coincidentally was opened recently, even though this deprecation happened a while back as you found.

My answer for now is the same as #1052 (comment) -- if you want the full list just make a dict of all the current JSON Schema metaschema URIs.

But the feedback is welcome, somewhere down the line if enough people need this I'm happy to reconsider in a few versions once the old globals are gone and there's something like a registry of supported dialects where this sort of thing can live.

@Julian Julian closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2023
@ikonst
Copy link
Contributor Author

ikonst commented Mar 23, 2023

Ah, makes perfect sense at this point, and beats using a private API which is even less forward-looking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants