Is it possible to build `JsonSchema` from object a...
# kotest
n
Is it possible to build
JsonSchema
from object automatically?
e
not currently 🙂
n
Ok, maybe I will create something for this. I have one more question. In
JsonObjectBuilder
are
minProperties
and
maxProperties
fields but I don't see any usages of these fields. Are there some plans for them?
e
Hmm, then that's just something that hasn't been properly implemented yet.. should be used to validate https://json-schema.org/draft/2020-12/json-schema-validation.html#name-validation-keywords-for-obj
how much have you used the schema validations? they're pretty new and I haven't heard much about how people are liking it 😄
n
It's my first time with schema validations. 🙂 I would like to check if my json have the expected number of fields.
e
Ah okay, and you don't care about the actual fields?
just the number? 😄 cause then, if minProperties and maxProperties are indeed unused, you're in a bit of a pickle I suppose..
n
I'm trying to rewrite
shouldMatchSchema
to support this. My json is generated and I would like to fail my test when someone adds a new field to the class.
e
if you serialize
actual
to JSON, you could just test it with
shouldEqualJson
(it fails if unexpected properties appear in
actual
)