zerocode icon indicating copy to clipboard operation
zerocode copied to clipboard

Assertions using json schema v3 or v4

Open dinesh76in opened this issue 6 years ago • 9 comments

AC1: GIVEN-The JSON schema of the API response WHEN-I assert the API response using the schema with version as parameter THEN-I should be able to get the desired result as PASS or FAIL to determine the test status. AND-If failed, it should display or log(WARN or ERROR level) list the failure reasons in a pretty format.

AC2: Have mechanism to pass the Schema file for the API response in the DSL.

Note: "responseSchema" : (* new field which you can introduce) : Keep it optional. If supplied by the user, only then validate against it(the "body" of the response).

I think only the "body" should match the Schema definition, right? Definitely not the "status" I mean. Have a look at the Schema definition file. If yes, then implement the field as "responseBodySchema" (instead of "responseSchema")

Example:

{
    ...
    ...
    "responseSchema": {
        "schemaPath": "path/to/schema/file",
        "schemaVersion": "W3 Version? 3.0 or 4.0" //<--- optional (assign a default value if not supplied by user)
    },
    "verify": {
        "status": 200,
        "body": {
            "login": "octocat",
            "id": 583231,
            "type": "User"
        }
    }
}

AC3: (Future purpose - Implement via a new ticket if there is a Usecase for this, otherwise not needed now as AC2 shd cover most usecases) GIVEN-I want to assert the API response using a given schema of v3 or v4(parameterised) WHEN-I receive the API response THEN-I should be able to get the desired result as PASS or FAIL to determine the test status

dinesh76in avatar Sep 06 '18 12:09 dinesh76in

This feature looks interesting. Do we have it already? @dinesh76in

santhoshTpixler avatar Jan 17 '19 00:01 santhoshTpixler