【问题标题】:swagger JSON produces null value it stops UI招摇 JSON 产生空值它停止 UI
【发布时间】:2015-10-20 02:46:01
【问题描述】:

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

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

【问题讨论】:

    标签: json swagger swagger-ui


    【解决方案1】:

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

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

    而添加具体的序列化选项是这样的:

    spring.jackson.serialization-inclusion:non_null
    

    【讨论】:

      猜你喜欢
      • 2018-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      相关资源
      最近更新 更多