Replies: 4 comments 9 replies
-
This is an important discussion - thanks for opening it. In answer to your first few questions:
Yes, absolutely. Although the project tagline refers to jschon as a JSON Schema implementation, I generally think of it more as a JSON + schema toolkit, that may grow indefinitely to support any number and variety of JSON + schema use cases. And I think the development of capabilities to support well-established and emerging standards is especially valuable - both in terms of utility to the wider JSON-* community and in terms of increasing the robustness of the library's internal architecture.
I'm not sure that there is a definitive answer to this question, but the use case that originally motivated the development of jschon does provide some insight. This derived package implements a custom (and not yet properly documented) vocabulary, with implementations for a hierarchy of keywords along with custom schema processing. The rules for keyword validation and schema processing are not defined by any specification explicitly supported by jschon, and so do not belong in the jschon library itself. However, extensive changes were made to jschon to support the development of this package - including the addition of a JSON Patch implementation along with generalizing of some aspects of keyword construction and schema processing.
Any generic capability in support of an external use case is fair game for inclusion in jschon, as long as it does not introduce limitations on existing functionality. Specific / custom rules not defined by an explicitly supported specification should be left out. Having said that, the list of explicitly supported JSON-* specifications may grow - as with the addition of JSON Patch. |
Beta Was this translation helpful? Give feedback.
-
Subclass interdependency thoughtsI've spent some time working with the approach in #111 in the
Some intermediate ideasGiven the above, this problem would benefit from stepping back and looking at why different classes need subclassing, and whether they could just be made more flexible instead. I have been playing with refactoring the
A more comprehensive re-thinkI don't have time right this moment, but I do have thoughts on a more comprehensive design than the above, and will add a reply to this comment thread when I have a moment to write it up. The short version: Right now I have I think it might be possible to reduce the need for subclassing down to just I still need to think this through, but reducing the need for subclassing in order to make a useful extension might be a more robust solution that enabling subclassing across the board and managing complex interdependencies. |
Beta Was this translation helpful? Give feedback.
-
EDIT — sub-thread RESOLVED: URI management is outside of the scope of URI hashingOne thing I've realized is that, within a The correct rules are:
While it's not necessary to use the technically correct rules, it is necessary to be consistent, and Python URI libraries are not remotely consistent. For example, So either everything has to use the same URI implementation (which in my codebase became a nightmare of translating between three different URI libraries depending on what code was talking to what library), or the URI protocol/interface/whatever has to be very clear on the hashing expectations. |
Beta Was this translation helpful? Give feedback.
-
@handrews, I've given this a lot more thought and have settled on an outlook for jschon that I'm feeling more comfortable with (in terms of my fluctuating availability and interest in the domain) and that I believe is aligned with the spirit of open source software development. I've updated the project description and contributing guidelines accordingly. With respect to the more complex modifications that you've proposed in support of the OASComply project, it's unlikely that these will be merged any time soon, if at all. I have some ideas that might substantially alter the jschon internals and API, but which might only begin taking shape in conjunction with further development of use cases in my work environment. My suggestion would be to rename your fork of jschon to any name of your choosing (there's no need to include jschon in the name), and to publish and manage it as you see fit. This may lead to a divergence in the structure and mechanics of our respective forks, but I believe that diversity in implementation is a good thing and may ultimately promote wider adoption of the relevant specifications. I do apologise for any uncertainty and inconvenience I've caused with my evolving perspective on the direction of jschon. My sincere thanks for your valuable insights and contributions to the project. |
Beta Was this translation helpful? Give feedback.
-
I'm filing this issue to take a step back and look at the big-picture questions of extensibility:
jschon
? Both yes and no are totally reasonable answers here.jschon
and other packages built on it?jschon
expect to be able to do or not do?The idea of extending
JSONPointer
andRelativeJSONPointer
with subclasses has already been accepted and mostly implemented, but we decided to only do that so far in #103.Deciding this will help me avoid taking up time with out-of-scope suggestions. And if this is in-scope, help with producing a comprehensive and consistent solution.
Use cases
"$ref"
-handling tools exist, ranging from pure"$ref"
replacement to full support of all JSON Schema draft 2020-12 referencing and identification keywordsThis discussion is primarily motivated by my work building OpenAPI support for
oascomply
on top ofjschon
.The current version in the main repo ended up paralleling a lot of
jschon
functionality for non-schema documents. My own fork has a work-in-progress version leveraging a lot more ofjschon
, but with some awkward workarounds to make it viable.Functional areas
jschon
, in my view, covers three cohesive major areas and two less cohesive minor areas:JSON
,JSONPointer
,RelativeJSONPointer
, andJSONPatch
classes)Catalog
plusSource
and its subclasses- I'll refer to this as the Catalog system)JSONSchema
,Metaschema
,Vocabulary
,Keyword
, etc.)URI
)jschon.utils
)Side note: the maintainer of
jsonschema
has made areferencing
library covering a similar area as the Catalog system, although I prefer the boundaries drawn by the Catalog system for several reasons.Extensibility challenges
if parent == root:
orif parent:
won't work, althoughif parent is None:
will)JSON
subclassesJSON
subclass (e.g. a file line and column number map)JSONPointer
andRelativeJSONPointer
jschon
and myoascomply
package do thisrfc3986
vsrfc3987
) due to different requiremetnsoascomply.resourceid.*
,jschon.uri.URI
,rdflib.URIRef
, just plainstr
, and maybe one other package I'm forgetting, has been very challenging and a huge source of bugsPaths forward?
In another month or two, I should have
oascomply
in good enough shape that it's worth looking at for lessons learned, assuming there's interest in havingjschon
support this sort of thing in some way. This is particularly relevant for the document structure stuff, which is the most complex (hence a couple of PRs that I've submitted but retracted or moved to draft as I work with it more).The most difficult is the URI thing. Which feels a bit petty to complain about, particularly as it's more of a Python ecosystem problem than a
jschon
problem. But I've spent a lot of effort on it recently. This is an area where the question of setting expectations on what is and is not flexible injschon
is pretty relevant.I think the rest of the above is reasonably straightforward to fix. What I'm doing in my
oascomply
fork has worked out a lot of it, although sometimes with less-than-elegant workarounds.Deciding how much extensibility is in-scope would help me figure out what workarounds to try to harden for robustness in
oascomply
, vs what could be contributed upstream tojschon
.Beta Was this translation helpful? Give feedback.
All reactions