Swagger - spring fox - hide password
Asked Answered
S

3

8

Swagger - spring fox - hide password.

In one of our API I need to return alphanumeric code after verifying user id and password.

We are using springfox-swagger-ui-2.3.1.I have a field "password" where I do not want to show password (instead i want to show "XXXX") when user types in swagger ui.

password is defined as @RequestParam(value = "password") String password.

any suggestion is highly appreciated.

Slop answered 14/9, 2017 at 22:25 Comment(1)
have you tried @RequestParam(value = "password", type = "string", format = "password") to see if it supports swagger format?Frederickson
T
2

Unfortunately springfox does not provide support for swagger-core's password format.

It was introduced in swagger-core 1.5.11 #469

Issue #2366 is still open in springfox.

Trella answered 6/11, 2019 at 13:8 Comment(0)
S
1

To use password as a parameter type, you can simply override the format like this:

@ApiParam(value = "your password", type = "string", format = "password") 
@QueryParam(/* normal stuff */)

hidden password for APiParam

Spica answered 5/11, 2019 at 15:31 Comment(0)
F
0

Issue is fixed in 2020 release of 3.0.0

https://github.com/springfox/springfox/issues/3002

https://github.com/springfox/springfox/issues/3386

Frias answered 7/4, 2022 at 16:32 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.