I have this Postman scenario. What I’d like to do is create an enum or the equivalent for the two or three schemas I look for in response bodies (i.e. success, fault, etc.) So far, I have one success and two failure schemas. My Java background is trying to refactor this into a ‘enum’ if that’s possible. I’m trying to avoid just “knowing” what schemas can be expected
utils.validateResponseSchema(pm, "successSchema")
My function works as such.
validateResponseSchema: (pm, expectedSchema) => {
pm.test("Response schema validation successful", () => {
pm.expect(pm.response.json()).to.have.jsonSchema(pm.collectionVariables.get(expectedSchema))
})
}
I’m trying to refactor the ‘expectedSchema’ parameter into an ‘enum’ of sorts. That’s my question in a nutshell, and where would I define it in Postman?
To define the various expected response schemas in an Enum…