【问题标题】:Swagger ui dose not work when @RequestParam annotation dose not set to method parameter当@RequestParam 注解未设置为方法参数时,Swagger ui 不起作用
【发布时间】:2016-07-09 18:07:23
【问题描述】:

我在 spring mvc 控制器中有方法 .method 参数不需要设置 @RequestParam 并正常工作。我想为 api doc 使用 swagger 和 spring fox 。但是当不设置 @RequestParam 它参数 swagger 不起作用。我我的项目中有 100 个控制器,无法为控制器中的所有方法设置此注释。不添加 @RequestParam 注释如何解决这个问题?

@RequestMapping(value = "/listGrid", method = RequestMethod.GET)
public QueryResult<ActionViewModel> list(
            @RequestParam String searchFilter,
            @RequestParam String order, 
            @RequestParam int pageNumber/* swagger ok*/,
            int pageSize /* swagger problem*/) {
    // body
}

【问题讨论】:

    标签: spring-mvc swagger swagger-ui springfox


    【解决方案1】:

    在你招摇的配置中,在案卷上

    enableUrlTemplating(false)
    

    决定是否对路径使用 URL 模板。当您的搜索 API 可能对每个搜索用例有多个请求映射时,这尤其有用。

    https://github.com/springfox/springfox/issues/909

    【讨论】:

      猜你喜欢
      • 2016-01-27
      • 1970-01-01
      • 2015-08-13
      • 2018-08-08
      • 2022-08-24
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      相关资源
      最近更新 更多