question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ApiModelProperty "hidden" attribute has no effect

See original GitHub issue

I’m including this annotation in my model, and there is one attribute there that I want to hide from the API, cause it’s not relevant.

As far as I know, “hidden” attribute of @ApiModelProperty does it, but it’s not working. I tried defining it in the class attribute and in the getter/setter, but Swagger always includes it in the API.

@ApiModel(value = "DTO description")
public class ESType {
    @ApiModelProperty(value = "The type", position = -1, required = true)
    private String type;

    @ApiModelProperty(hidden = true)
    private Class<DTO> clazz;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @ApiModelProperty(hidden = true)
    public Class<DTO> getClazz() {
        return clazz;
    }

    @ApiModelProperty(hidden = true)
    public void setClazz(Class<DTO> clazz) {
        this.clazz = clazz;
    }
}

How can I hide it?

Thanks! Marc

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:38 (13 by maintainers)

github_iconTop GitHub Comments

10reactions
raspacorpcommented, Jun 9, 2017

One of the comments above that suggests to create different classes for requests responses that have or not the required properties. IMHO a documentation tool shouldn’t drive the design of the class hierarchy for requests or responses. It is very common and fair to reuse classes that contain a global set of properties. Developers want to be able to use for example a class ‘User’ that has an id, that is normally not known in the moment of the call to the ‘POST /user’ service as it is going to be generated in the backend, in addition to other possible properties e.g. createdDate, modifiedDate… But we want to have those in the response of that or other operations. It would be great if Swagger had an annotation for allowing the field to appear or not in the documentation, but it would be even more useful if we could choose if it should be documented for request or for response.

For example: @ApiModelProperty(responseOnly = true)

8reactions
Marzacommented, Jan 14, 2015

We would like to have the hidden attribute. For our use case we don’t want to show it in the documentation since it is deprecated and should not be used but we cannot remove it yet since it is still used by some clients and therefor cannot use @JsonIgnore from Jackson.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does @ApiModelProperty "name" attribute has no effect?
@ApiModelProperty "name" attribute has no effect. We don't want ever to have a case ... There is a workaround with @JsonProperty annotation:
Read more >
ApiModelProperty (swagger-annotations 1.5.0 API)
Allows a model property to be hidden in the Swagger model definition. ... Specifies if the parameter is required or not.
Read more >
Hide a Request Field in Swagger API - Baeldung
A quick and practical guide to hiding a request field in Swagger UI.
Read more >
How to hide some APIs from swagger UI? - Google Groups
This had no effect :( After a couple iterations, I found out that support for this attribute has not yet been implemented yet....
Read more >
docs/release-notes.md · serv/springfox - Gitee.com
... (#2132) @ApiModelProperty has no effect on some variables (name starting with one ... [#554] @ApiModelProperty "hidden" attribute has no effect ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found