在swagger UI中测试休息服务时如何将查询参数传递给url

时间:2019-05-17 10:34:53

标签: swagger-ui

我正在使用swagger UI测试spring boot rest服务,但是我必须将查询参数传递给URL,例如 http://localhost:8080/v1.0/media/?user=dcisupportevg&client=20

如何传递这些参数?

谢谢。

@Bean 
public Docket productApi() { 
    return new Docket(DocumentationType.SWAGGER_2)
                  .apiInfo(DEFAULT_API_INFO)
                  .select()
                  .apis(RequestHandlerSelectors
                  .basePackage("com.dci.rest.controller"))
                  .paths(regex("/.*"))
                  .build(); 
}

控制器:

@RestController
@RequestMapping({"/v1.0/media"})
public class MediaController {

@RequestMapping(value = "/" method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public Response<Object> getAllMedia(@PathVariable Map<String, String> pathVariablesMap,HttpServletRequest request){

        Response<Object> responseVO = new Response<Object>();
        try {
            responseVO = mediaService.getAllMedia(request,pathVariablesMap);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return responseVO;      
    }
}

但是实际上,我必须使用URL:http://localhost:8080/v1.0/media/?user=xxxxx&client=xxxx才能从上述方法中获得响应。

0 个答案:

没有答案