swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Default value for Parameter annotation

Open eduhAgostinho opened this issue 3 years ago • 4 comments

I'm trying to set a default value for one of my query params, but the Parameter annotation doesn't have defaultValue. I tried using the prop schema and pass the value but it doesn't work. Is it a bug or am I doing something wrong? This is the example of what I'm trying to do: When I was using Swagger version 2, It was working with ApiImplicitParams annotation.

@GetMapping(path = "/user", produces = JSON_FORMAT)
    public ResponseEntity<PagedListDto<List<UserOutputDto>>> getUsers(
            @Parameter(description = DEFAULT_PAGE_DESCRIPTION, schema = @Schema(defaultValue = DEFAULT_PAGE))
            @RequestParam(defaultValue = DEFAULT_PAGE) Integer page,
            @Parameter(description = DEFAULT_LIMIT_DESCRIPTION, schema = @Schema(defaultValue = DEFAULT_LIMIT))
            @RequestParam(defaultValue = DEFAULT_LIMIT) Integer limit) {
       ...
    }

eduhAgostinho avatar May 05 '22 14:05 eduhAgostinho

+1, This seems like a weird oversight

thattolleyguy avatar Sep 24 '22 20:09 thattolleyguy

+1

glau2 avatar Mar 22 '23 02:03 glau2

+1

ThomasAndreSix avatar Jul 25 '23 15:07 ThomasAndreSix

+1

scintilla932 avatar Sep 25 '23 05:09 scintilla932