swagger JSON 产生空值,它停止 UI [英] swagger JSON produces null value it stops UI

查看:36
本文介绍了swagger JSON 产生空值,它停止 UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 swaggerspring mvc -1.0.2 和 jackson-databind 2.6.3.为什么它产生空值.如何停止它?它停止 swagger UI.JSON

I am using swaggerspring mvc -1.0.2 and jackson-databind 2.6.3.why it produce null value.how stop it?.it stopping swagger UI. JSON

                    {
                        "parameterType": {
                            "absoluteType": "array"
                        },
                        "name": "file",
                        "description": "Pass File as input",
                        "defaultValue": "",
                        "required": true,
                        "allowMultiple": false,
                        "allowableValues": null,
                        "paramType": "query",
                        "paramAccess": null
                    }

推荐答案

您需要将 JSON 映射器配置为不写入空值:

You need to configure your JSON mapper to not write null values:

http://docs.spring.io/spring-boot/docs/current/reference/html/howto-spring-mvc.html#howto-customize-the-jackson-objectmapper

并添加特定的序列化选项是这样的:

And adding the specific serialization option is like such:

spring.jackson.serialization-inclusion:non_null

这篇关于swagger JSON 产生空值,它停止 UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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