1

I have an endpoint with the following response:

{
     "id": 1,
     "status": "ACTIVE"
   }

The possible values for status are the following: ACTIVE, INACTIVE, DELETED. To check the schema I tried the following:

* def statusValues = ["ACTIVE", "INACTIVE", "DELETED" ]
* def schema = 
"""
{
  "id" : #number,
  "status" : '#(^*statusValues)'
}
"""

And to validate I use the following sentence: Then match response == schema

But it doesn't work. This is the error

actual: 'ACTIVE', expected: ["DELETED","ACTIVE","INACTIVE"], reason: actual value is not list-like

Can you help me, please?

1 Answer 1

1

This is probably the simplest option:

* def isValidStatus = function(x){ return statusValues.contains(x) }
* def schema = { id: '#number', status: '#? isValidStatus(_)' }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.