Skip to content

@JsonAnyGetter property gets included in generated schema since 2.19.0 #5393

@victor-noel-pfx

Description

@victor-noel-pfx

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

Hi,

When upgrading from 2.18.5 to 2.19.0+ (I tested up to latest 2.20.1), I noticed that while before, generating the schema (using JsonSchemaGenerator but I suspect with anything using ObjectWriter.acceptJsonFormatVisitor()?), would omit the property annotated with @JsonAnyGetter from the schema, now it will include it.

I don't know if it's on purpose but it feels wrong in the sense that the serialization of an object would not include that property but only its keys instead (which can't be discovered during schema generation of course, but it's a separate matter IMO).

Version Information

2.20.1

Reproduction

    public final class Test {
        @JsonAnyGetter
        Map<String, Object> getMyProperties() {
            return Map.of();
        }

        public static void main(String[] args) throws Exception {
            // 2.18.5 gives {}
            // 2.19.0+ gives {getMyProperties=com.fasterxml.jackson.module.jsonSchema.types.ObjectSchema@34123d65}
            System.out.println(
                ((ObjectSchema) new JsonSchemaGenerator(new ObjectMapper()).generateSchema(Test.class))
                    .getProperties()
            );
        }
    }

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.19Issues planned at 2.19 or laterto-evaluateIssue that has been received but not yet evaluated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions