@ApiModelProperty(hidden = true) seems not work
See original GitHub issueHi, I am using ‘io.swagger:swagger-jersey2-jaxrs:1.5.10’. The @ApiModelProperty(hidden = true) seems not hide those properties from ‘definitions’! Could you please have a look? Thanks!
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@JsonInclude(JsonInclude.Include.NON_EMPTY)
//@JsonFilter("attributeFilter")
public final class User extends Resource {
public static final String SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:User";
@ApiModelProperty(value = "MUST be same as work type email address", required = true)
private String userName; // unique user-friendly identifier
@ApiModelProperty(required = true)
private Name name;
@ApiModelProperty(hidden = true)
private String displayName;
@ApiModelProperty(hidden = true)
private String nickName;
@ApiModelProperty(hidden = true)
private String profileUrl;
@ApiModelProperty(hidden = true)
private String title;
@ApiModelProperty(hidden = true)
private String userType; // used to identify the relationship between the organization and the user
@ApiModelProperty(hidden = true)
private String preferredLanguage;
@ApiModelProperty(hidden = true)
private String locale; // https://tools.ietf.org/html/rfc5646
@ApiModelProperty(hidden = true)
private String timezone; // https://tools.ietf.org/html/rfc6557
@ApiModelProperty("user status")
private Boolean active; // active/disabled/suspended
@ApiModelProperty(hidden = true)
private String password;
@ApiModelProperty(required = true)
private List<Email> emails;
private List<PhoneNumber> phoneNumbers;
@ApiModelProperty(hidden = true)
private List<Im> ims;
@ApiModelProperty(hidden = true)
private List<Photo> photos;
private List<Address> addresses;
@ApiModelProperty(hidden = true)
private List<GroupRef> groups;
@ApiModelProperty(hidden = true)
private List<Entitlement> entitlements;
@ApiModelProperty(hidden = true)
private List<Role> roles;
@ApiModelProperty(hidden = true)
private List<X509Certificate> x509Certificates;
@JsonProperty(EnterpriseUser.SCHEMA)
private EnterpriseUser enterpriseUser;
@Builder
@JsonCreator
private User(@JsonProperty(value = "schemas", required = true) List<String> schemas,
@JsonProperty("id") String id,
@JsonProperty("externalId") String externalId,
@JsonProperty("meta") Meta meta,
@JsonProperty("userName") String userName,
@JsonProperty("name") Name name,
@JsonProperty("displayName") String displayName,
@JsonProperty("nickName") String nickName,
@JsonProperty("profileUrl") String profileUrl,
@JsonProperty("title") String title,
@JsonProperty("userType") String userType,
@JsonProperty("preferredLanguage") String preferredLanguage,
@JsonProperty("locale") String locale,
@JsonProperty("timezone") String timezone,
@JsonProperty("active") Boolean active,
@JsonProperty("password") String password,
@JsonProperty("emails") List<Email> emails,
@JsonProperty("phoneNumbers") List<PhoneNumber> phoneNumbers,
@JsonProperty("ims") List<Im> ims,
@JsonProperty("photos") List<Photo> photos,
@JsonProperty("addresses") List<Address> addresses,
@JsonProperty("groups") List<GroupRef> groups,
@JsonProperty("entitlements") List<Entitlement> entitlements,
@JsonProperty("roles") List<Role> roles,
@JsonProperty("x509Certificates") List<X509Certificate> x509Certificates,
@JsonProperty(EnterpriseUser.SCHEMA) EnterpriseUser enterpriseUser) {
super(schemas == null ? Lists.newArrayList(SCHEMA) : schemas, id, externalId, meta);
this.userName = userName;
this.name = name;
this.displayName = displayName;
this.nickName = nickName;
this.profileUrl = profileUrl;
this.title = title;
this.userType = userType;
this.preferredLanguage = preferredLanguage;
this.locale = locale;
this.timezone = timezone;
this.active = active;
this.password = password;
this.emails = emails;
this.phoneNumbers = phoneNumbers;
this.ims = ims;
this.photos = photos;
this.addresses = addresses;
this.groups = groups;
this.entitlements = entitlements;
this.roles = roles;
this.x509Certificates = x509Certificates;
setEnterpriseUser(enterpriseUser);
}
public void setEnterpriseUser(EnterpriseUser enterpriseUser) {
if (enterpriseUser != null) {
this.enterpriseUser = enterpriseUser;
addSchema(EnterpriseUser.SCHEMA);
}
}
}
@Api(tags = "User")
@Produces({MediaType.APPLICATION_JSON, SCIMConstants.SCIM_CONTENT_TYPE})
@Consumes({MediaType.APPLICATION_JSON, SCIMConstants.SCIM_CONTENT_TYPE})
@Path("/Users")
public class UserEndpoint extends ResourceEndpoint<User> {
@Inject
UserService userService;
@Inject
UserPatchService userPatchService;
@ApiOperation(value = "get an user by id", response = User.class)
@ApiResponses({
@ApiResponse(code = 401, message = "authorization failure", response = ErrorResponse.class),
@ApiResponse(code = 403, message = "license limit", response = ErrorResponse.class),
@ApiResponse(code = 404, message = "not found", response = ErrorResponse.class),
@ApiResponse(code = 429, message = "too many requests", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "internal server error", response = ErrorResponse.class)
})
@GET
@Path("/{id}")
public Response getUserById(@ApiParam("user id") @PathParam("id") String id) {
User user = userService.getById(id);
return buildResponseWithLocation(user);
}
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ApiModelProperty(hidden = true) is ignored on join columns
My problem is that it expands too much and a leaf field becomes required. Is there a way to make it work? Or...
Read more >@APiModelProperty annotation (hidden = true) don't work with ...
This displays value as "check" in swagger doc, but doesn't hide the variable. Any idea/solution? Ron's profile photo ...
Read more >Schema (swagger-annotations 2.0.8 API)
The annotation may be used to define a Schema for a set of elements of the OpenAPI spec, and/or to define additional properties...
Read more >Hide a Request Field in Swagger API - Baeldung
A quick and practical guide to hiding a request field in Swagger UI. ... @ApiModelProperty(hidden = true) private int id;
Read more >OpenAPI 3 Library for spring-boot
All the path springdoc-openapi properties are not applicable when springdoc.use-management-port=true . If you want to reach the application ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @webron, it’s working when annotating
@ApiModelProperty(hidden = true)
on getter. Looking over the source codes ofio.swagger.jackson.ModelResolver#resolve(com.fasterxml.jackson.databind.JavaType, io.swagger.converter.ModelConverterContext, java.util.Iterator<io.swagger.converter.ModelConverter>)
andio.swagger.jackson.ModelResolver#ignore
, it doesn’t handle the@ApiModelProperty(hidden = true)
on field.Hidden parameter also does not seem to work on scala case classes.