Repository navigation
Closed
Milestone
Description
Hi,
I am having troubles to generate POJOS for a JSON schema that contains a reference with pound (#). E.g.
{
"$schema": "http://json-schema.org/draft-04/schema",
"id": "test.json",
"properties": {
"id": {
"$ref": "basic_types.json#/definitions/positive_int"
}
}
}
I am using recently installed CLI with Brew under Mac OS X.
Here is the complete trace:
Exception in thread "main" java.lang.IllegalArgumentException: Path not present: definitions
at org.jsonschema2pojo.FragmentResolver.resolve(FragmentResolver.java:54)
at org.jsonschema2pojo.FragmentResolver.resolve(FragmentResolver.java:31)
at org.jsonschema2pojo.SchemaStore.create(SchemaStore.java:61)
at org.jsonschema2pojo.SchemaStore.create(SchemaStore.java:128)
at org.jsonschema2pojo.rules.PropertyRule.resolveRefs(PropertyRule.java:160)
at org.jsonschema2pojo.rules.PropertyRule.resolveRefs(PropertyRule.java:162)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:81)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43)
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:119)
at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:66)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:75)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43)
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:119)
at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30)
at org.jsonschema2pojo.rules.ArrayRule.apply(ArrayRule.java:81)
at org.jsonschema2pojo.rules.ArrayRule.apply(ArrayRule.java:37)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:113)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:75)
at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43)
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:119)
at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90)
at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:66)
at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30)
at org.jsonschema2pojo.SchemaMapper.generate(SchemaMapper.java:92)
at org.jsonschema2pojo.Jsonschema2Pojo.generate(Jsonschema2Pojo.java:77)
at org.jsonschema2pojo.cli.Jsonschema2PojoCLI.main(Jsonschema2PojoCLI.java:48)
Thanks!
Metadata
Metadata
Assignees
Labels
No labels
Activity
joelittlejohn commentedon Oct 11, 2017
Does the basic_types.json that is alongside test.json have a property called
definitions? It looks like jsonschema2pojo does not see it in there.xaviarias commentedon Oct 11, 2017
No it is not a JSON Schema property but a JSON property, i.e:
By reading the docs that seems to be a valid alternative for structuring complex schemas.
xaviarias commentedon Oct 11, 2017
My minimal example generates valid code though. The
idfield is properly generated as a Java integer. I would need to find an extended example to reproduce the error.joshiste commentedon Dec 16, 2020
the same happens when trying to generate the schemas from oci: https://github.com/tianon/oci-runtime-spec/tree/master/schema
unkish commentedon Dec 18, 2020
A simplified reproducible case would be:
selfRef.json:Referencing schema:
Looks like #322 would fix this (though given PR does not conform to contribution rules)
[-]Exception while resolving reference with #[/-][+]IllegalArgumentException while resolving reference to reference with #[/+]joelittlejohn commentedon Apr 2, 2021
Thanks for the minimal example @unkish, that helped a lot 😃
Ensure to uses the correct document to resolve