I'm trying to use karate.match() to check the schema on a request in the Scenario.
Here's a sample schema I'm declaring in my Background:
* def mySchema = {place: { id: '#string',},id: '#string',number: '#number'}
I asked here about how to to match the full schema: Schema validation in the Scenario
It was suggested that this was a duplicate, and that this reference for matching would do the trick: Is it possible to use karate 'match' inside conditional statement?
I'm still having trouble, and I don't think that the reference suggested applied in my case, because it seems to talk only about using match in a test, but the syntax seems to be different when used in a Scenario.
For instance, I decided to try to only match one part of my schema to just make sure I was using the correct syntax. I sent this request:
{"place": {"id": "someID"},"id": "someOtherID","number": 10}
I decided to try to match on the number
value.
This is my Scenario:
Scenario: pathMatches('my/api/path') && !karate.match("request contains { number: '#number'}").pass
I also tried
!karate.match("each number =='#number'}").pass
bit neither work as intended. I think in my request the number
key value is a number. That being the case, I'd expect the !
to cause this scenario to be skipped, but it's not, which leads me to believe my schema match syntax isn't correct.
I appreciate any help.