因此,我在Swagger(Core 1.5.7)中使用XML对象定义时遇到了麻烦。这是我的XML代码:
<result status="ok">
<another>
<cards/>
<customer my_super_id="2349027834"/>
<someothers>
<someother name="who-is-this" />
</someothers>
</another>
</result>
这是我的yml代码:
result:
type: object
description: Some random description
properties:
status:
type: string
xml:
attribute: true
another:
type: object
properties:
customer:
type: object
properties:
superId:
type: string
xml:
name: my_super_id
attribute: true
我可以status
毫无问题地得到,但是my_super_id
是null
因为Swagger使用CamelCase中的参数(即mySuperId
而不是)生成了模型类my_super_id
。在我生成的模型类中,我有以下内容:public ResultAnotherCustomer(@JsonProperty("mySuperId") final String mySuperId)
有什么办法解决这个问题?
尽管很愚蠢,但似乎我没有使用的最新版本swagger-codegen
,因此将其更新为最新版本(2.1.5)可以解决此问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句