You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a requirement where I want to make if/else conditions for subtypes (annotated via jackson's JsonSubType.class). It could be either EXTERNAL_PROPERTY or WRAPPER_OBJECT which decides the conditionals block.
I read #130 but it is adding constants to conditionals.
I wanted some control to resolve subtype in an if condition.
I tried advanced configurations but couldn't figure out a way.
EXTERNAL_PROPERTY is a tricky one to handle generically, that's why it's not yet supported by the JacksonModule out-of-the-box. I'm open for pull requests though. 😉
However, it seems you're handling it yourself already and the main question is about not having to manually build the nested schemas once you're inside of a CustomDefinition.
I've tried to document the most important methods here: https://victools.github.io/jsonschema-generator/#custom-type-definitions
For this particular use-case, it sounds like createDefinitionReference()/createStandardDefinitionReference() would be an approriate choice.
As an additional reference, you could look into the JacksonModule implementation (or its JsonSubTypesResolver in particular), where the WRAPPER_OBJECT alongside some other Jackson subtype strategies are being handled.
I have a requirement where I want to make if/else conditions for subtypes (annotated via jackson's
JsonSubType.class
). It could be eitherEXTERNAL_PROPERTY
orWRAPPER_OBJECT
which decides the conditionals block.I want someway to get if/then blocks without traversing the final JsonNode.
My expected output is:
Is it possible to generate this using the jsonschema generator, without traversing the final
JsonNode
?The text was updated successfully, but these errors were encountered: