-
Notifications
You must be signed in to change notification settings - Fork 14
Schema parsing doesn't support whitespace inside keys #14
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 @TheKeeperOfPie – sorry it's taken me so long to get back to you – I'm on vacation at the moment and I've only just got a moment to myself to look at this. You're right, the JSON Schema spec allows whitespace in property names, and I thought I had allowed for this usage, but it seems my tests of this feature were not sufficiently rigourous. When I change the line that creates the URI fragment to use a function that automatically escapes spaces and special characters, the code works OK. For Kotlin, the generator encloses names that would otherwise not be allowed (e.g. reserved words, or words containing spaces) in backticks. When I tested using the VGMDB file, I got:
For Java, it replaces non-allowable characters with underscore, and adds an underscore suffix to names that clash with reserved words. There are other problems with the VGMDB file, however. The data type As I mentioned earlier, I am currently on vacation, and that means I will not be able to upload a version with the bug fix until next week. I hope you can hang on until then. Thank you for providing clear information to help me to track down the bug. |
I appreciate the response, although sorry to interrupt your vacation time. Encoding the fragment makes sense. I ended up writing my own parser here. In the Your suggested approach sounds fine to me though. Again, no rush. Once the fix is in and I get the time, I'll replace my hacked together solution. Thanks. |
I came here after trying to parse the VGMDB.info API schema here, using pwall567/json-kotlin-gradle, but it fails because some of the definitions have spaces in their keys.
Specifically if you check at https://vgmdb.info/schema/artist.json under
definitions.artistInfo
, which contains a property calledAlbum Votes
.I can't find an explicit reference in the latest JSON Schema version that keys must not contain whitespace. Only that they must be strings and properly referenced using
"key": value
. So I think this should be supported, although obviously the whitespace will have to be replaced with a_
or simply removed when converted to a Java reference. I'm also not sure if whatever JSON parser you're using would support reading the key with whitespace.For reference, this is the entire meaningful stacktrace:
It looks like it's caused by the fact that
java.net.URI
doesn't support spaces in thefragment
, which makes sense. This code would have to do regular string comparison, although I didn't dive far enough into the specifics to understand how difficult that will be.On a tangential note, the only reason I'm trying to do this is because there's no VGMDB Kotlin wrapper, and also no RAML->Kotlin generator, so if anyone has any suggestions on that front, then this issue wouldn't matter.
The text was updated successfully, but these errors were encountered: