如何生成Map< String,...>Swagger Codegen吗? [英] How to generate Map<String, ...> with Swagger Codegen?

查看:85
本文介绍了如何生成Map< String,...>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&lt; String,...&gt;Swagger Codegen吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆