Skip to content
Advertisement

Plugin jsonschema2pojo: Properties are shown as required but they should be optional

i have a personschema which has e.g. those two fields:

JavaScript

Then I have another schema which extends the person schema. In this schema, I want those two properties (birthCountry and birthday) to be optional and only the name to be mandatory. I’ve tried it like that:

JavaScript

But unfortunately, in the API-Docs they are still remarked as mandatory.

Advertisement

Answer

The issue was that properties can only be added in child classes and not modified, so I rearranged the class structure to modify the decision whether a value is mandatory will only be decided in the child classes themselves. Also please note, that sibling values alongsid $refs are ignored. To add properties to a $ref, you need to wrap it into an allOf.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement