Schema-Specific Keywords as Property Names #554
DarioViva42
started this conversation in
General
Replies: 1 comment
-
|
HI @DarioViva42, Thanks for the kind words. I'm convinced this is an IntelliJ bug. Don't hesitate to raise new issues, just accept that I may be busy with work and/or private life, and I may not respond anytime soon. 😉 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey All
Let me start by stating that this is a really nice project. It offers pretty much everything that I could wish from a JSON schema generation tool.
One small issue I have is about schema specific keywords.
Say I would like to create a schema for JSON files that have schema specific keywords as property names.
{ "name": "Dario Viva", "title": "Application Developer" }I would create the following schema / this is also what your generator creates for a corresponding POJO:
{ "$schema" : "https://json-schema.org/draft/2020-12/schema", "type" : "object", "properties" : { "name" : { "type" : "string" }, "title" : { "type" : "string" } } }Now that seems fine, but intelliJ tells me, that the JSON schema file does not conform to the JSON schema specification.
Now I am honestly not sure, if that is an error of intelliJ, or if schema specific keywords are not allowed as property names, if strictly following the JSON schema rules. I bet you know the rules much better than I do. What is clear to me, is that inside a schema node of course title should be of type string. https://www.learnjsonschema.com/2020-12/meta-data/title/
On SO someone also asked this question. But the answer does not seem to be 100 % sure about it. https://stackoverflow.com/a/16432960
If its an error of intelliJ I will gladly create an Issue on https://github.com/JetBrains/intellij-community.
In manually created JSON schema files I use a workaround that I am not sure is very elegant, but it works.
{ "$schema" : "https://json-schema.org/draft/2020-12/schema", "type" : "object", "properties" : { "name": { "type": "string" } }, "patternProperties": { "^title$" : { "type" : "string" } } }What is your opinion about this. And in case if these keywords really are not allowed as properties, is there maybe an
com.github.victools.jsonschema.generator.Optionfor this?I hope this message finds you well and you are not being overwhelmed by issues like other OSS projects. So that’s why I only created this discussion by now.
I would first kindly ask you if it was OK, If I created more discussions or issues on some of the pain points I still have with JSON schema generation.
What I can promise is, is that all my issues / discussions will be written by me (not AI) and that all them will be about me trying to solve real world issues I and have, where I already tried some stuff out myself.
With kind regards and happy to hear from you
Dario
Beta Was this translation helpful? Give feedback.
All reactions