0

Any help or hint would be greatly appreciated it!!

I am using SpringDoc to do the swagger generation. I am trying to use more than one "ExampleObject". But it doesn't seem to work for the below syntax.

            @ApiResponses( value = {
                @ApiResponse(responseCode = "200",
                        description = "OK"

                ),
                @ApiResponse(responseCode = "400",
                        description = "BAD REQUEST",
                        content= @Content(
                                mediaType = "application/json",
                                examples = {
                                        @ExampleObject(
                                                value="{\"code\":400,\"Message\":\"Permission and Role type doesn't match\"}"
                                        )
    //                                  ,@ExampleObject(
    //                                          value="{\"code\":400,\"Message\":\"Permission must be UUID value\"}"
    //                                  )
                                }
                        )),
                @ApiResponse(responseCode = "404",
                        description = "Permission not found",
                        content= @Content(
                                mediaType = "application/json",
                                examples = {
                                        @ExampleObject(
                                                value="{\"code\":404,\"Message\":\"Permission not found\"}"
                                        ),
                                }
                        ))
        })
Albert Lam
  • 9
  • 1
  • 3

1 Answers1

0

Please use the name field of @ExampleObject.

            @ApiResponse(responseCode = "400",
              description = "BAD REQUEST",
              content= @Content(
                  mediaType = "application/json",
                  examples = {
                      @ExampleObject(
                         name="RoleNoMatch",
                          value="{\"code\":400,\"Message\":\"Permission and Role type doesn't match\"}"
                      )
                      ,@ExampleObject(
                          name="MustUUID",
                          value="{\"code\":400,\"Message\":\"Permission must be UUID value\"}"
                      )
                  }
              )),
YutaSaito
  • 387
  • 6