How can I exclude a field from the schema when generating schemas in Jackon?

809 Views Asked by At

I'm using Jackson's JsonSchemaGenerator to generate schemas for my beans. One of these beans have a getter that I would like to exclude from the schema generation (or alternatively, mark is as an "object" - not any).

How would I go about generating a schema but forcing the address property to be either excluded or any object?

public static class Person {

    private final String firstName;

    private final String lastName;

    private final Address address;

    public Person(
            @JsonProperty("first_name") String firstName,
            @JsonProperty("last_name") String lastName,
            @JsonProperty("address") Address address) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.address = address;
    }

    @JsonProperty("first_name")
    public String getFirstName() {
        return firstName;
    }

    @JsonProperty("last_name")
    public String getLastName() {
        return lastName;
    }

    @JsonProperty("address")
    public Address getAddress() {
        return address;
    }
}

I haven't found a way to achieve this using Jackson.

0

There are 0 best solutions below