jsonschema2pojo
jsonschema2pojo copied to clipboard
Error when `#` is inside property name (not present in the website generator)
Given this minimal json schema:
{
"type": "object",
"additionalProperties": false,
"properties": {
"foo#bar": {
"type": "string"
}
}
}
If I try to generate the code using https://www.jsonschema2pojo.org/ I obtain the right generated classes but if I try to generate with maven plugin I get the error Path not present: foo.
To see in the detail what happens this is the stack trace obtained from the cli command:
./jsonschema2pojo-1.1.2/bin/jsonschema2pojo --source example.json --target java-gen
Exception in thread "main" java.lang.IllegalArgumentException: Path not present: foo
at org.jsonschema2pojo.FragmentResolver.resolve(FragmentResolver.java:54)
at org.jsonschema2pojo.FragmentResolver.resolve(FragmentResolver.java:52)
at org.jsonschema2pojo.FragmentResolver.resolve(FragmentResolver.java:31)
at org.jsonschema2pojo.SchemaStore.create(SchemaStore.java:66)
at org.jsonschema2pojo.SchemaStore.create(SchemaStore.java:140)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:78)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:41)
at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:70)
at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:38)
at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:121)
at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:66)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:83)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:38)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:83)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:76)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:38)
at org.jsonschema2pojo.SchemaMapper.generate(SchemaMapper.java:92)
at org.jsonschema2pojo.Jsonschema2Pojo.generate(Jsonschema2Pojo.java:79)
at org.jsonschema2pojo.cli.Jsonschema2PojoCLI.main(Jsonschema2PojoCLI.java:58)
The error is caused by the # in the property name but why when I use the website the error disappear? How can I obtain the website behaviour without getting any error?
Hi
It's a duplicate of https://github.com/joelittlejohn/jsonschema2pojo/issues/1402 and is related to https://github.com/joelittlejohn/jsonschema2pojo/issues/1404.
How can I obtain the website behaviour without getting any error?
- use
jsonschema2pojoversion1.1.1or - override ref-fragment-path-delimiters by passing
-rpd "/."or similar (double check whether output is as expected)
Thank you!
Closing this as it's a duplicate of #1402. I had a fix for this but I think I want to revisit and solve it more definitively. Just clearing the decks so we can see what's what.