-
-
Notifications
You must be signed in to change notification settings - Fork 15
Question regarding usage of generics #124
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
Comments
Hi there!
Depending on what you mean by "parsing" schemas, though I suppose that's besides the point of your question! ( For the question itself -- firstly, there's certainly a possibility the types are wrong, but:
It depends on what draft of JSON Schema. On earlier ones, there's no union, it's just Presumably if you have multiple different kind of resources you get a larger union type there (e.g. if this project ever gets some OpenAPI support, which I still hopefully plan on). But honestly as I started with, there's still a possibility something is wrong, I did some small level of thinking but not fully, mostly since I unfortunately usually find |
Thanks for the quick answer!
Basically what I'm trying to do is provide the user a list of "json paths" (format TBD, can be JSON Pointer, lodash style, etc) from a JSON Schema, so having a structured Python representation of the schema could help. I think this can be pretty straightforward to do manually (i.e. iterating over the
Ok good to know, I guess this will be discovered more once more resources types are being used!
I can agree with this in certain situations -- |
Cool -- the monkey wrench in modern JSON Schema is Going to close this then but more feedback definitely welcome! |
I should say a general "structured schema walker" is indeed a specific tool I have in mind, but there are other things I want to get to first... To quote the great, "so much time, and so little to do...". |
I feel the same every day.
As my current task is work related, I might have some time working on this. Hopefully I'll be able to have it generic enough to be implemented as part of this library, or in a separated one, or as a reusable gist |
Hello,
thanks for this library. I'm looking for a way to parse JSON Schema into something that can be used in Python but couldn't find anything suitable.
jsonschema
can validate JSON "instances" against a schema, but does not seem to provide such parsing abilities.As I'm probably going to parse the schemas "by hand",
referencing
looks interesting for my task as I will not have to resolve references manually.That said, I just wanted to raise something that feels inconsistent regarding typing. The
Registry
is currently defined as aMapping[URI, Resource[D]]
, simplified asMapping[str, D]
. Does this mean aRegistry
should hold only one type of resources?This
D
type variable seems to be kept when iterating over subresources and anchors as well, e.g.subresources
returns anIterable[Resource[D]]
.My understanding is for JSON schemas, this
D
type variable should always resolve toUnion[bool, ObjectSchema]
, even when iterating over the subresources. But I don't know if this is the case if not dealing with JSON schemas?The text was updated successfully, but these errors were encountered: