-
Notifications
You must be signed in to change notification settings - Fork 13
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
jschon and OpenAPI support (surprisingly simple... probably) #99
Comments
Doing this properly will require something much like #82 and its related PRs, and in OAS 3.1 #87. The subschema iteration idea in #77 would also help, as the notion of "subschema" gets interesting if you regard the entire OAS document as a kind of pseudo-JSON Schema. @marksparkza this module has my (currently somewhat messy) work-in-progress on OAS support. I'll have to see if OAI/Linux Foundation would want to split that out to a separate installable module of just |
An alternative approach to #101 could involve I'm not quite sure how that would work, but it would be different from what I'm doing with a #101-ish approach, where my This alternative might involve defining |
Closing in favor of the more general discussion #108 |
@marksparkza I'm using jschon in some contract work for OpenAPI / the Linux Foundation, and it turns out to be very difficult to work with a document that embeds JSON Schema in various locations, but is not overall a JSON Schema.
The issue is that the
JSON
/JSONSchema
classes' mechanism (withSubschemaMixin.jsonify()
) for choosing a subclass for list and dict values works one level at a time, and assumes that everything on the same level will use the same subclass (e.g.JSON
vsJSONSchema
).My suggestion (and I'll post a PR since it's simple) is to make the list and dict instantiations methods that can be overridden in a subclass. An OAS-aware subclassof
JSON
can select the correct subclass (itself orJSONSchema
) based on the position in the OAS document. Once aJSONSchema
subclass is chosen, everything works normally as everything within an OAS Schema Object behaves like a schema keyword.This is a very simple change that lets the OAS extension I'm working on hold the complexity, rather than trying to build support for arbitrarily complex JSON Schema-embedding formats into
jschon
itself. (There are other use cases for this, most notaby AsyncAPI which is still on draft-07, but also the W3C's Web of Things groups' Thing Description format - I believe they plan to update to 2020-12).If possible, this and one other PR I am posting momentarily would make a very helpful 0.10.3 for me.
BTW, it was not hard to implement OAS 3.0's schema dialect in
jschon
even though it is draft-04 base, because it only uses keywords that have the same behavior in 2020-12; OAS 3.1's schema dialect is fully 2020-12 compatible, just with an extra vocabulary, so this project that I'm doing will end up providng OAS 3.x support forjschon
if this issue is solved.The text was updated successfully, but these errors were encountered: