Mask input (example - password) in Swagger UI?

Viewed 3982

I have three path variables for an API. I want to mask one input on Swagger UI with *****.

How can I do this when using Springdoc OpenAPI?

2 Answers

You just use the swagger annotations:

@Parameter(schema = @Schema(type = "string", format = "password")) 

As already shown by jenkinsme in their answer, set the format to password. Also, the type field is not needed as it defaults to string (hopefully all passwords are strings).

@Parameter(schema = @Schema(format = "password"))

The above will show up as shown in the below image

enter image description here

Refer the OpenAPI specification page on Data Types for all the supported types

Related