如何生成Map< String,...>Swagger Codegen吗? [英] How to generate Map<String, ...> with Swagger Codegen?
问题描述
我正在研究一个API,我们在swagger.yaml文件中定义API定义.我正在使用的API返回包含地图的输出对象.
I'm working on an API where we define the API definition in the swagger.yaml file. The API which I am working on returns an output object which contains a map.
输出对象:OutputClass
Output Object : OutputClass
public class OutputClass {
private Map<String, MapValue> map;
}
现在,我使用:
OutputClass:
type: object
additionalProperties:
$ref: '#/definitions/MapValue'
但是Swagger Codegen会生成以下Java代码:
But Swagger Codegen generates the following Java code:
public class OutputClass extends HashMap<String, MapValue> implements Serializable {
}
有什么办法可以满足我的需求?
Is there any way to achieve what I need?
推荐答案
您的地图定义正确.Swagger Codegen关于将OpenAPI映射转换为Java代码的方式存在一个未解决的问题:https://github.com/swagger-api/swagger-codegen/issues/5187
Your map definition is correct. There's an open issue with Swagger Codegen about the way it translates OpenAPI maps to Java code: https://github.com/swagger-api/swagger-codegen/issues/5187
这篇关于如何生成Map< String,...>Swagger Codegen吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!