Swagger-core: @ApiModel has no way to hide inherited properties

Created on 26 Oct 2016  路  2Comments  路  Source: swagger-api/swagger-core

This is a repeat of issue #730 because, to my understanding, it wasn't implemented. This would be used when extending third party classes.

@bthule already showed an example:

Here is sample model for super+inherited classes:

// A super class provided by third-party
public class Animal {
    String uselessAnnoyingProperty;
}
// A sub class whose api-model should not have uselessAnnoyingProperty
public class Dog extends Animal {
    int numberOfLegs;
}

swagger-ui would show:

{
    "numberOfLegs": 0,
    "uselessAnnoyingProperty": "",
}

The solution he suggested is:
@ApiModel(hideProperties = {"uselessAnnoyingProperty", ...})

All 2 comments

Feels like an edge case. If you can add a PR with a generalized solution, would be happy to add it.

@aciganj I had the same exact issue using Ebean and the swagger annotations were adding _ebean_intercept to my documentation. I solved this by adding a getter to my model

@ApiModelProperty(hidden = true)
    public boolean get_ebean_intercept() {
        return false;
    }

You can also use @JsonIgnore

Was this page helpful?
0 / 5 - 0 ratings