WS.validateJsonAgainstSchema(textResponseGET,StandardSchema) is not working correctly.
If I just add schema tag in my schema & provide any invalid schema in it…the above test step still returns true. Please fix it.
Reason:
com.kms.katalon.core.exception.StepFailedException: Failed to validate your JSON Object with the JSON Schema
(Root cause: com.networknt.schema.JsonSchemaException: Schema tag not present
I was sending some sample payload
textResponseGET = {
“apiVersion”: “string”,
“data”: {
“teamId”: “3fa85f64-5717-4562-b3fc-2c963f66afa6”,
“providerIdentifier”: “test”,
“teamReferenceId”: “001”,
“teamName”: “Test Teams”
}
}
StandardSchema= {“apiVersion”: “string”,
“data”: {
“teamId”: “3fa85f64-5717-4562-b3fc-2c963f66afa6”,
“providerIdentifier”: “string”,
“teamReferenceId”: “string”,
“teamName”: “string”
}
}
So now if I use this method it should return true but it returns false asking for schema tag which is not present in our schema.
WS.validateJsonAgainstSchema(textResponseGET,StandardSchema)
If I add schema tag in StandardSchema then this method returns true no matter what the textResponseGET is.
Something like this: StandardSchema= {
“$schema”: “https://json-schema.org/draft/2020-12/schema”
“apiVersion”: “string”,
“data”: {
“teamId”: “3fa85f64-5717-4562-b3fc-2c963f66afa6”,
“providerIdentifier”: “string”,
“teamReferenceId”: int
}
}
I got this schema tag & it’s value from snippets of json validation in Get Webservices Request in Object Repository
Groovy language does not support JavaScript Object Notation (JSON) syntax natively.
This is not a valid Groovy script. If this code is exactly what you tried, this will never compile. But you wrote that your script did compile but ran differently from what you expected. So I am confused.
I guess your description above is not describing exactly what you really did.
Therefore I would ask you to provide a sample code which others can copy&paste and run.