feign的代码生成在swagger-codegen-maven-plugin:2.2.2上运行得很好,不幸的是我被迫转移到openapi-generator-maven-plugin:2.2.14或swagger-codegen-maven-plugin:2.2.14。当此生成器使用具有可选参数的方法处理模式时,它们会使用一个带有注释@QueryMap(encoded=true)的映射参数来复制方法。
示例:
/**
* 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,所以我不会禁用这个代码生成器的功能,但找不到任何开关。有谁能关掉这个烦人的功能吗?
发布于 2020-10-31 11:14:13
您可以定制Java Feign生成器的模板来删除QueryMap,然后使用带有-t CLI选项的定制模板生成代码,而不是使用开关禁用它。
https://stackoverflow.com/questions/62823341
复制相似问题