Open asm0dey opened 1 year ago
Hi – you see that dash at the end of the "Exception" line? There is in fact a JSON Pointer following that dash, but the JSON Pointer for the root of an object is an empty string! I realise that's not very helpful, and I'll improve that error message.
The fact that the pointer is a root reference is a clue to the problem; it means that a schema contains a reference to the root of the schema object itself. Looking at your file feed.schema.json
I see that it includes (by reference) the schema file https://readium.org/webpub-manifest/schema/subcollection.schema.json
, and that file contains several recursive references to itself. Similarly, the file https://readium.org/webpub-manifest/schema/link.schema.json
contains multiple references to itself.
The code generator currently does not handle recursive references, and in any case, the JSON Schema specification does not allow the use of $ref
recursively; Draft 2019-09 defined $recursiveRef
for this purpose, and Draft 2020-12 replaces this with $dynamicRef
.
I can't help you with your recursive references, but at least I plan to improve the error reporting!
-Peter
Thank you! Yes, the only thing I'm asking for is to display the actual loop: it would help to report the actual issue in the schema to developers
I mean sure , it would be cool if you supported recursive references, but if it's impossible for now - better messages would be cool too!
@pwall567 I think that you might be wrong that the JSON Schema specification prohibits recursive referencing: http://json-schema.org/understanding-json-schema/structuring.html#recursion
@asm0dey - that document is an introductory guide, written for JSON Schema Draft 7. Draft 2019-09 changed the handling of recursion (as is alluded to in that document) and Draft 2020-12 made further changes (see Schema References).
My implementation is something of a hybrid – it was written mostly to the Draft 2019-09 standard, but because it does not include some of the features of the later drafts (such as vocabularies), the team managing the standard asked me to label it as implementing Draft 7. The Draft 7 specification clearly mentions recursion, so it's a fair criticism to say that my implementation is not complete in that regard, but I had planned to cover recursion using the $recursiveRef
and $dynamicRef
constructs.
I have a new version in development that will cover all of Draft 2020-12, but that is a long-term project, and I can't offer any completion date at this stage.
@asm0dey If that still has any relevance for you, you may try out my PR: https://github.com/pwall567/json-kotlin-schema-codegen/pull/43 Feedback welcome!
It is an interesting excercise indeed, but not too simple when the jar is not published :)
mvn install
is your friend. :wink:
Here you go, if you don't mind using jitpack as additional artifact source: https://jitpack.io/#milux/json-kotlin-schema-codegen/0.108.2
With the following code
I get the following exception:
I do understand that maybe there are loops somewhere in refs, but I don't understand where. It would be very helpful to add the information about the loop into the error