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.
6. Using @ApiParam. @ApiParam is also a Swagger annotation that we can use to specify metadata related to request parameters. We can set the hidden property to true in order to hide any property.
To hide the "Models" section, add defaultModelsExpandDepth: -1 to the Swagger UI configuration code in your index.
Swagger2 is an open source project used to generate the REST API documents for RESTful web services. It provides a user interface to access our RESTful web services via the web browser. To enable the Swagger2 in Spring Boot application, you need to add the following dependencies in our build configurations file.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With