Issue running networknt schema validator in Readyapi groovy script
Hi, I am trying to run a schema validator library, networknt, in a groovy script in Readyapi, but for some unknown reason, the factory method used to generate the schemaNode won't work. Here is the script:
@Grapes([
@Grab('com.fasterxml.jackson.core:jackson-databind:2.9.6'),
@Grab('org.slf4j:slf4j-api:1.7.30'),
@Grab('org.apache.commons:commons-lang3:3.11'),
@Grab('com.networknt:json-schema-validator:1.0.52')
])
import com.networknt.schema.JsonSchemaFactory
import com.networknt.schema.SpecVersion
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)
The error I get:
ERROR: groovy.lang.MissingMethodException: No signature of method: static com.networknt.schema.JsonSchemaFactory.getInstance() is applicable for argument types: (com.networknt.schema.SpecVersion$VersionFlag) values: [V201909]
groovy.lang.MissingMethodException: No signature of method: static com.networknt.schema.JsonSchemaFactory.getInstance() is applicable for argument types: (com.networknt.schema.SpecVersion$VersionFlag) values: [V201909]
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1518)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at Script5.run(Script5.groovy:9)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:94)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:83)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:159)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:331)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:835)
I checked if it's not an incompatibility with the version of groovy in Readyapi I am using. Readyapi 3.2.0, Groovy 2.4.17. I downgraded my groovy version installed locally to that of the groovy version in Readyapi and tried running same script in groovyConsole and it works properly. The script I am trying to run is from the validator's github documentation which i am linking here
I'll appreciate if anyone can point out what I might be doing wrong or help in resolving this issue. Thank you.