Hi All, I am trying to write a spec for something that looks like this (similar to openapi schema)
responses:
200:
description: "foo"
content:
text/plain:
schema:
type: boolean
404:
description: "bar"
and I want to have a rule for both validating that the keys are valid http status codes, as well as the shape of the structure under the keys, and I am confounded on how to express it.
I have tried an approach like this
(defn http-status?
[status]
(and (int? status) (>= status 100) (< status 600)))
(s/def ::response (s/keys :opt-un [::description]))
(s/def ::responses (s/coll-of (s/and http-status? ::response)))
But it doesn’t quite work. Any suggestions appreciated.Disregard…I figured it out. Needed to use s/cat