reinert / JJSchema

A generator from Java Types to JSON-Schema using Jackson.
Other
117 stars 56 forks source link

Restrict depth of properties #58

Closed rdgupt closed 7 years ago

rdgupt commented 7 years ago

Hi, it is a question, not an issue. Is it possible to restrict how deep Json Schema should be generated? For example, there is a class User, which has a custom class as it's property called Organisation. Now Organisation has further more CustomClasses as it's properties. Can we restrict the generated Schema to list only properties of User, and not list Properties of Organisation in Json schema of User? Just list Organisation as type:object+some other details, but not go in the iteration of properties of all nth great grand children. Hope question is clear. :)

Thanks, Rishi

reinert commented 7 years ago

Yeah, that's possible. Just put @SchemaIgnore on top of the field you want to bypass. See this test.

rdgupt commented 7 years ago

I don't want to completely bypass the field object. I only want to bypass it's properties. For example, let us extend the Product example and add a property catalog to it, which is a class (with some props). @Attributes(required = true) private Catalog catalog;

When we generate Json schema of Product class, it should list catalog in properties of Product, but should not show properties of catalog in json schema of Prodct. like this : "catalog":{"type":"object"}" and not like this : "catalog":{"type":"object","properties":{"..."}}

Let me know if that is possible or any plans for the enhancement.

reinert commented 7 years ago

I see. That's not possible yet. But I believe it's not difficult to implement. I could take a look at it this week to tell you if I can work on it. But I really prefer contributions, as this is a collaborative project. If you think you can contribute, please don't hesitate.

rdgupt commented 7 years ago

Thanks Danilo.

reinert commented 7 years ago

This issue is solved by the new annotation @SchemaIgnoreProperties.