swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.37k stars 2.17k forks source link

@ApiParam(hidden = true) on property with object as type is ignored #2413

Open alexpeelman opened 7 years ago

alexpeelman commented 7 years ago

I use Spring MVCs ModelAttribute to map query parameters to an object encapsulating the fields.

public String getTargets(@ModelAttribute TargetRequest request, Model model) throws Exception {
...
}

But the TargetRequest class contains a field with an object as type, which is never used in the parameter mappings and may be ignored

public class TargetRequest {

    //bug in swagger? it is still shown
    @ApiParam(hidden = true)
    ErsEntity ersEntity;

}

Swagger introspects the object and for each primitive property in the top-down hierarchy, query parameter documentation is generated. I explicitly annotated the field to be hidden but no luck.

screen shot 2017-08-31 at 16 19 22
sinboun commented 7 years ago

I met you, too

willcain commented 6 years ago

If you are using SpringFox, a work-around is:

import springfox.documentation.spring.web.plugins.Docket;
...
docket.ignoredParameterTypes(ErsEntity.class);

Credit: https://github.com/springfox/springfox/issues/1139#issuecomment-171005465

leonardocsc commented 3 years ago

@ApiIgnore It'll get you where you want it。