How to specify a property as null or a reference?

后端 未结 2 1888
心在旅途
心在旅途 2021-02-05 02:41

I have a json document in which a part can be either null or a subobject, like this:

[{
    \"owner\":null    
},
{
    \"owner\":{
        \"id\":1
    }   
}]
         


        
2条回答
  •  借酒劲吻你
    2021-02-05 03:32

    nullable field will be supported in OpenApi (aka Swagger) Specification v3.0.0

    So with this new spec your definition would look like:

    "properties":{
        "owner":{
            "nullable": true,
             ...
        }
    },
    

提交回复
热议问题