【问题标题】:How to add default values in request body of swagger docs while using compojure-api如何在使用 compojure-api 时在 swagger 文档的请求正文中添加默认值
【发布时间】:2021-03-28 18:54:09
【问题描述】:

假设您有如下架构

(s/defschema House
  {:bedroom s/Int
   :bathroom s/Int 
   :parking s/Int
})

swagger 文档的动态生成将分配一个默认值 0。 如何为 swagger docs 分配卧室、浴室和停车场的默认值?

【问题讨论】:

    标签: clojure swagger swagger-2.0 compojure-api


    【解决方案1】:

    我们可以使用ring.swagger.json-schema 来实现这一点。我们可以使用 json-schema 修改我们的模式

    (s/defschema House
      {:bedroom (ring.swagger.json-schema/field s/Int {:example 3})
       :bathroom (ring.swagger.json-schema/field s/Int {:example 2})
       :parking (ring.swagger.json-schema/field s/Int {:example 1})
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-14
      • 1970-01-01
      • 1970-01-01
      • 2021-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多