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?
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?
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
Refer the OpenAPI specification page on Data Types for all the supported types
Using YAML for generating code from OpenAPI 3 documentation:
components:
schemas:
User:
type: object
properties:
id:
type: string
format: uuid
username:
type: string
password:
type: string
format: password
givenName:
type: string
familyName:
type: string
address:
type: string
required:
- id
- username
- password
- givenName
- familyName
- address
Note, that type: string
is not necessary for password, since format: password
already implies it, but I like to keep there just the same.
You just use the swagger annotations: