-
Notifications
You must be signed in to change notification settings - Fork 136
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
Incomplete type definition for array/Collection properties #45
Comments
What's the status of this? From my experience, it looks like I can successfully create a schema from an object and then turn that into a json string, but then if I use an ObjectMapper to turn that back into a JsonSchema, all of my arrays get messed up. That's a big problem for me. Is there anything I can do to help fix this or make the fix happen sooner? |
I haven't had time to work on Schema module lately, so any help would be appreciated. |
I'm afraid I'm not familiar enough with the code to fix it myself :-( Best guess is that the problem is in the com.fasterxml.jackson.module.jsonSchema.types.ArraySchema file, in Items.jsonCreator. I see a comment in there about another bug too. |
@mariepaulsen-sersol I'll go and have a look at the updated tests; sometimes there are easy fixes to be found. |
Oh . . . you were talking about serializing, I think the problem is in the deserialization of a schema json string into a JsonSchema object. My sequence: ObjectMapper mapper = new ObjectMapper();
SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
mapper.acceptJsonFormatVisitor(mapper.constructType(Foo.class), visitor);
JsonSchema schema = visitor.finalSchema();
String schemaString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);
log.debug(schemaString);
"foo" : {
"type" : "array",
"items" : {
"type" : "object",
"id" : "urn:jsonschema:com:company:project:stuff:Bar",
"properties" : {
"baz" : {
"type" : "string"
}
}
}
}
ObjectMapper objectMapper = new ObjectMapper();
JsonSchema secondSchema = objectMapper.readValue(Experiment.class.getResource("/schema.json"), JsonSchema.class);
ObjectMapper secondMapper = new ObjectMapper();
String secondSchemaString = secondMapper.writerWithDefaultPrettyPrinter().writeValueAsString(secondSchema);
log.debug(secondSchemaString);
"foo" : {
"type" : "array",
"items" : {
"type" : "object",
}
} |
Ah. This may be different from the original problem then, which was wrt to generation of schema. |
Any news on this problem? I run into the same issue if it try to parse a ArraySchema all getItems() property fields are null. I am using version 2.6.1 |
Hi, any progress with this? It's a notable gap in functionality. |
@dazraf This modules does not have maintainer, and unless someone steps up it will probably be dropped from FasterXML repo for 3.0. There are better generators out there. But if anyone wants to do a PR I can help merge. |
NOTE: cleaved off of #34
This bug seems not to be completely fixed. It doesn't throw a NPE anymore, but it doesn't generate the schema correctly either. It just generates:
I extended the test to use a collection of nested beans, and expected to see the schema of the nested items, e.g.:
See updated test: greyfairer@2a9b859
The text was updated successfully, but these errors were encountered: