Abhishek Jaiswal
Abhishek Jaiswal

Reputation: 628

How to add default values in request body of swagger docs while using compojure-api

Suppose you have schema like below

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

The dynamic generation of swagger docs will assign a default value of 0. How do I assign default value for bedroom, bathroom, and parking for swagger docs ?

Upvotes: 1

Views: 449

Answers (1)

Abhishek Jaiswal
Abhishek Jaiswal

Reputation: 628

We can achieve this using ring.swagger.json-schema. We can modify our schema using 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})
})

Upvotes: 1

Related Questions