nullable fields in swagger on node.js

前端 未结 4 661
[愿得一人]
[愿得一人] 2021-01-04 02:42

I\'ve spent a bunch of time trying to find a solution for creating swagger docs in Node.JS. The main library is swagger-node, in which you create a swagger yaml file and the

4条回答
  •  礼貌的吻别
    2021-01-04 02:56

    Instead of add null in type property, you can use default property instead.

    Swagger.json property definition example:

    "due_date": {
      "type": "string",
      "description": "Due date",
      "default": "null"
    },
    

    It's a valid Swagger type definition, and still appears as expected in Swagger UI.

提交回复
热议问题