WS.validateJsonAgainstSchema is not working as expected

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

Please show the value of textResponseGet and the value of StandardSchema. For example, change your scipt

println("textResponseGET: " + textResponseGET)
println("StandardSchema:" + StandardSchema)
WS.validateJsonAgainstSchema(textResponseGET,StandardSchema)

and please copy & past the full console messages

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

Please use “Code Formatting” syntax for better readability for others.

This is ambiguous. You should provide a single set of sample codes that others can try running on their own machine. The sample should describe:

  • what exactly the input JSON looks ----- do not trim any single line
  • what exactly the JSON schema looks
  • what exactly your test case code looks

And I would ask you to add your description for

  • on your machine, what exactly the runtime log looks ---- do not trim any single line
  • what you expect to see, and what you actually see

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.