简体   繁体   中英

How can hide some parameter from swagger spring boot?

I have a Student class and I need id , name , email , dob , age parameters. These parameters are shown on swagger as below.

在此处输入图像描述

I do not want id appear on the swagger documentation. How can I do that?

I have tried

  • @Schema(hidden = true)
  • @Parameter(hidden = true) But didn't worked

I want to see only below parameters on swagger

{
  "name": "string",
  "email": "string",
  "dob": "2022-12-19",
  "age": 0
}

Can anyone help me about that, please?

For me, ApiModelProperty and ApiParam didn't exist. I found the solution on documentation . The solution is as below;

public class Student {
     @Schema(accessMode = Schema.AccessMode.READ_ONLY)
     private Long id;
}

Also thanks to @Waled Ahmad

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM