首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >openapi-generator-maven-plugin用@QueryMap打破了旧的伪装

openapi-generator-maven-plugin用@QueryMap打破了旧的伪装
EN

Stack Overflow用户
提问于 2020-07-10 04:39:24
回答 1查看 399关注 0票数 0

feign的代码生成在swagger-codegen-maven-plugin:2.2.2上运行得很好,不幸的是我被迫转移到openapi-generator-maven-plugin:2.2.14swagger-codegen-maven-plugin:2.2.14。当此生成器使用具有可选参数的方法处理模式时,它们会使用一个带有注释@QueryMap(encoded=true)的映射参数来复制方法。

示例:

代码语言:javascript
复制
/**
   * Note, this is equivalent to the other <code>someMethod</code> method,
   * but with the query parameters collected into a single Map parameter. This
   * is convenient for services with optional query parameters, especially when
   * used with the {@link ApiV1CodesGetQueryParams} class that allows for
   * building up this map in a fluent style.
   * @param queryParams Map of query parameters as name-value pairs
   *   <p>The following elements may be specified in the query map:</p>
   *   <ul>
   *   <li>p1 - param1 (optional)</li>
   *   <li>p2 - param2 (optional)</li>
   *   </ul>

   */
  @RequestLine("GET /api/v1/someMethod?p1={p1}&p2={p2}")
  @Headers({
  "Accept: application/json",
  })
  Response  someMethod(@QueryMap(encoded=true) Map<String, Object> queryParams);

旧版本的feign lib没有@QueryMap(encoded=true),因此编译java代码失败。我没有机会升级feign lib,所以我不会禁用这个代码生成器的功能,但找不到任何开关。有谁能关掉这个烦人的功能吗?

EN

回答 1

Stack Overflow用户

发布于 2020-10-31 11:14:13

您可以定制Java Feign生成器的模板来删除QueryMap,然后使用带有-t CLI选项的定制模板生成代码,而不是使用开关禁用它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62823341

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档