描述:在DB中,某些列具有空值。我在Spring-boot应用程序中获取了直到控制器层的空数据。但是作为响应,空值字段被过滤了。我认为这是由ResponseEntity Class(org.springframework.http.ResponseEntity)完成的。 OpenSpec API的默认响应类为:ResponseEntity。不确定如何更改此设置。 我正在这样定义我的openspec以返回响应:
我尝试使用nullable:真正的属性级别
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/MyPojoClass'
components:
schemas:
MyPojoClass:
description: PrimeBroker Short lending availability
type: object
properties:
field1:
description: xyz
title: xyz
type: string
field2:
description: xyz
title: xyz
type: string
field3:
description: xyz
title: xyz
type: string
我正在获取响应,但是在响应构建过程中会跳过空值。我还需要null值,这也是我的JSON响应的一部分。请告诉我是否有解决方法或它的局限性?
我需要具有空值的JSON响应。令人惊讶的是,直到控制器级别的响应都带有空值。在使用ResponseEntity建立响应期间,将忽略null。请帮帮我。