当未传递此类参数时,是否有任何方法可以从招摇生成的对象中排除属性

时间:2019-07-05 12:56:03

标签: properties swagger openapi

我在spring-boot mvc CRUD项目中使用了swagger + openapi 3.0.1。 当我更新我的实体(UpdateDao)时,使用PUT方法得到一个dto,它是从我的配置文件属性中构建的。 我的updateEntity具有几个属性,例如:

我试图使提到的api.yaml中的属性可为空(真/假),但是它什么都没有影响。

UpdateDao:
    allOf:
        -   $ref: '#/components/schemas/CommonDao'
        -   type: object
            properties:
                width:
                    type: integer
                    format: int32
                    description: width, inches
                    example: 10
                length:
                    type: integer
                    format: int32
                    description: length, inches
                    example: 10
                height:
                    type: integer
                    format: int32
                    description: heught, inches
                    example: 10

我从另一个服务获取查询,并且其更新属性是自定义的。例如,我只能得到宽度和高度,而不能得到长度。

就目前而言,使用我的UpdateDao,我可以获得所有三个属性,包括未指定的属性。未指定的值为null。

我正在使用BeanUtils.copyProperties(updateDao,实体),因此它会使用更新我的当前值。

在正文中未指定属性时,有什么方法可以将它们从updateDao中排除??

0 个答案:

没有答案