I am currently using a Swagger schema which defines enums for several values. I would like to know how I can assert my response against my swagger document. I would like to make sure that the response values that come back are only one of the values specified in the schema (think enum in Swagger). If anything else is returned in the response which is not defined in the array within the schema, then the test should fail.
How can I achieve this using the following:
Schema.json
{
"itemType":{
"hardware":[
"VIDEO CARD",
"SOLID STATE DRIVE",
"HARD DRIVE"
]
}
}
All values are optional and will respond with a string value.
Response:
{
"itemType": {
"hardware": "HARD DRIVE"
}
}
My guess is that it may be something along the lines of * match response.itemType.hardware == "##string? _ == 'VIDEO CARD' || _ == 'SOLID STATE DRIVE' || _ == 'HARD DRIVE'"
but I may have my syntax incorrect.