@Target(FIELD) @Retention(RUNTIME) public @interface DefaultValue
Define 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. Note that the string value of this annotation will be parsed using JsonParser.parseString(String)

There are two common mistakes when setting a DefaultValue:
  • Using DefaultValue with @Required. This does not make sense - if a value is required, the client must always send it, and the default value is never used.
  • Using @DefaultValue to specify a sample value. This is not the intended use of @DefaultValue and can lead to unexpected behavior in some Swagger tools.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Element Details