Skip to content

How can you generate 'properties' entry, even for Classes without fields? #433

Closed Answered by CarstenWickner
sashirestela asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @sashirestela,

While there is no standard Option for it or anything, you can achieve that of course:

// add the properties keyword to all empty object definitions
configBuilder.forTypesInGeneral().withTypeAttributeOverride((node, scope, context) -> {
    JsonNode typeValue = node.get(context.getKeyword(SchemaKeyword.TAG_TYPE));
    String objectTypeValue = context.getKeyword(SchemaKeyword.TAG_TYPE_OBJECT);
    if (typeValue == null || node.has(context.getKeyword(SchemaKeyword.TAG_PROPERTIES))) {
        // nothing to do here
    } else if (typeValue.isTextual() && objectTypeValue.equals(typeValue.textValue())) {
        node.putObject(context.getKeyword(SchemaKeyword.TAG_PROPERTIES));
…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sashirestela
Comment options

Answer selected by CarstenWickner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants