I want somes params on swagger have its own default value. Is there anyway to give a default value ? like this this note has to be filled automatically with "stackoverflow"
Use the default keyword in the parameter schema to specify the default value for an optional parameter. The default value is the one that the server uses if the client does not supply the parameter value in the request. The value type must be the same as the parameter's data type.
By default, Swagger treats all request parameters as optional. You can add required: true to mark a parameter as required. Note that path parameters must have required: true , because they are always required. description: Numeric ID of the user to get.
You have to annotate your note
parameter with defaultValue="stackoverflow"
.
You method signature should look like this:
public ResponseEntity<?> yourMethod(@ApiParam(value = "Default value for note", required = true, defaultValue = "stackoverflow") @Valid @RequestParam final String note) { }
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