Closed okeydoke closed 2 years ago
I'm running into the same problem. Using open api I don't know what I did but somehow it is now working again...3.0.0
, jest-openapi@0.14.1
and jest@27.3.1
.
thanks for raising this!
I think the validator is working correctly though - {}
actually does satisfy your schema, because by default, properties are optional. If your schema marks the accounts
property as required
, does it validate as you expect? (And you may want to mark account_type
and account_name
as required
too in the sub-schema)
I think required
is a JSON schema thing - see some examples in the OpenAPI spec
Let me know if that works 🙂
Ah thanks I didn't realise I could/needed to add required to the response. It's working once I add that. Many thanks!
Are you using jest or chai? Jest 27.0.6
Are you using OpenAPI 2, 3.0.X, or 3.1.0? 3.0.1
Describe the bug clearly Not sure if I'm doing something wrong but
expect({}).toSatisfySchemaInApiSpec("AccountResponse")
doesn't seem to validate very well/strictly. And seems to think that an empty object is valid when using the following schema.AccountResponse looks like below
It seems like
toSatisfySchemaInApiSpec
is true as long as the response is an object. Is there anyway to ensure that the response matches exactlySteps to reproduce the bug: See above
What did you expect to happen instead? Would of thought
toSatisfySchemaInApiSpec()
would require the passed response to exactly match the specAre you going to resolve the issue? Probably not