Swagger 虚张声势将下划线转换为大小写

Swagger 虚张声势将下划线转换为大小写,swagger,Swagger,因此,我在使用带有Swagger(Core1.5.7)的XML对象定义时遇到了问题。以下是我的XML代码: <result status="ok"> <another> <cards/> <customer my_super_id="2349027834"/> <someothers> <someother name="who-is-this" /&g

因此,我在使用带有Swagger(Core1.5.7)的XML对象定义时遇到了问题。以下是我的XML代码:

<result status="ok">
    <another>
        <cards/>
        <customer my_super_id="2349027834"/>
        <someothers>
            <someother name="who-is-this" />
        </someothers>
    </another>
</result>
我可以毫无问题地获得
状态
,但是
myu super\u id
null
,因为Swagger在CamelCase中使用参数生成模型类,即
mySuperId
而不是
myu super\u id
。 在生成的模型类中,我有:
public ResultAnotherCustomer(@JsonProperty(“mySuperId”)最终字符串mySuperId)


有什么办法可以解决这个问题吗?

我使用Swagger编码器生成器的经验是,它可以让我得到我想要的80%的东西,然后我必须自己做其余的事情。如果您认为这是一个bug,可以将其记录在此处:


Java通常喜欢CamelCase而不是snake_case,所以我猜这是故意的。

虽然它很愚蠢,但我似乎没有使用最新版本的
swagger codegen

,因此将其更新为最新版本(2.1.5)修复了此问题。

我在生成一个招摇过市的客户端时也遇到了此问题

这些模型从蛇壳“aa_ba_ca”更名为骆驼壳“AaBaCa”

调用api_instance.method(swagger_client.model(参数))时未找到模型,因此出现错误

错误:
AttributeError swagger模块没有属性

当您说model class是服务器代码中的那个类时?具体是谁在抛出错误?是XML反序列化器吗?是的,是Swagger在构建过程中生成的模型类。我在帖子中添加了额外的信息,即生成的模型类中的CamelCase输出。也许我遗漏了什么-为什么你不能更改模型,使其显示为@JsonProperty(“my_super_id”)?模型是根据我在yml文件中的内容自动生成的。我想这是一个与大摇大摆的codegen相关的错误,但我不知道为什么。是的,我的错误是没有使用最新版本。谢谢你的帮助!你能分享更多关于你需要手动完成的其他事情吗?谢谢请通过以下方式与我们分享您的反馈
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