Forum Discussion

harish3314's avatar
harish3314
Occasional Contributor
7 years ago

How to assert the Json schema complaince As I have file only not the URL.

Hello, I want to assert the json schema present in a file but in assertions I can only can Json schema URL which I currently don't have.Please let me know if there is any way to assert for Json sch...
  • aaronpliu's avatar
    7 years ago

    Hi harish3314,

     

    Add json schema assertion in your REST step and then points to your local Json file.

    If you want to add all Json Schema via groovy scripts, then you can try

    def addSchemaAssertion(testCase){
        testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.class).each{teststep ->
    def url = org.apache.xmlbeans.XmlObject.Factory.parse("<swaggerUrl>YourJsonFilePath</swaggerUrl>")
    def assertionName = teststep.addAssertion("Swagger Compliance Assertion")
    assertionName.setName("Swagger Compliance Assertion")
    assertionName.setConfiguration(url)
    
    }
    }

     

    Regards,

    /Aaron