SmartBear / readyapi-swagger-plugin

Ready! API Plugin for importing Swagger definitions as REST Services
36 stars 27 forks source link

Error when importing JSON based swagger definition #31

Closed klam1 closed 8 years ago

klam1 commented 8 years ago

I get the following error when I try adding a JSON based swagger definition to a new Rest Project:

Ready API Log ERROR:An error occurred [Cannot get property 'properties' on null object], see error log for details

Error Log: ERROR:java.lang.NullPointerException: Cannot get property 'properties' on null object java.lang.NullPointerException: Cannot get property 'properties' on null object at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:172) at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296) at com.smartbear.swagger.Swagger2Importer$_addOperation_closure2_closure7.doCall(Swagger2Importer.groovy:214) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at groovy.lang.Closure.call(Closure.java:426) at groovy.lang.Closure.call(Closure.java:442) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056) at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:87) at com.smartbear.swagger.Swagger2Importer$_addOperation_closure2.doCall(Swagger2Importer.groovy:205) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at groovy.lang.Closure.call(Closure.java:426) at groovy.lang.Closure.call(Closure.java:442) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056) at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at com.smartbear.swagger.Swagger2Importer.addOperation(Swagger2Importer.groovy:177) at com.smartbear.swagger.Swagger2Importer$addOperation.callCurrent(Unknown Source) at com.smartbear.swagger.Swagger2Importer.importPath(Swagger2Importer.groovy:142) at sun.reflect.GeneratedMethodAccessor423.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182) at com.smartbear.swagger.Swagger2Importer$_importSwagger_closure1.doCall(Swagger2Importer.groovy:105) at sun.reflect.GeneratedMethodAccessor422.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at groovy.lang.Closure.call(Closure.java:426) at groovy.lang.Closure.call(Closure.java:442) at org.codehaus.groovy.runtime.DefaultGroovyMethods.callClosureForMapEntry(DefaultGroovyMethods.java:5228) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2107) at org.codehaus.groovy.runtime.dgm$163.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at com.smartbear.swagger.Swagger2Importer.importSwagger(Swagger2Importer.groovy:104) at com.smartbear.swagger.SwaggerImporter$importSwagger.call(Unknown Source) at com.smartbear.swagger.SwaggerUtils$1.construct(SwaggerUtils.groovy:85) at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:48) at com.eviware.soapui.support.swing.SwingWorker.run(SwingWorker.java:88)

Software: ReadyAPI v1.6.0 Swagger Plugin v2.3.0 Swagger 2.0

rick23ro commented 8 years ago

I have the same problem, it works fine on swagger plugin version 2.2, but not on 2.3 or on 2.4 and now I can't update my project or create a new one. I tried to put version 2.1.3 from git but it doesn't build, it's missing a file....I'm stuck right now.

olensmar commented 8 years ago

Hi - hm... which ReadyAPI version are you using?

rick23ro commented 8 years ago

Tried on 1.6 and 1.8, both using plugin version 2.3, same error. The problem seems to be the plugin itself, 2.2 works fine for create and update project.

olensmar commented 8 years ago

hm... could you share the Swagger definition that you're using? would love to fix this in the plugin itself...

olensmar commented 8 years ago

also - could you please check your -home-/.readyapi/plugins folder that it doesn't contain multiple versions of the plugin (which sometimes happens)... ?

rick23ro commented 8 years ago

There's no plugins folder in my C:\Program Files\SmartBear\ReadyAPI-1.8.0 path, even with /bin, maybe it's only on the old soapui product. I don't think I can give the swagger definition, it is from my job. :) Can we do somehow else the debugging?

olensmar commented 8 years ago

ok - I think I can see the cause for this in the code - if I create a branch from master with a fix, can you build and give that a try?

olensmar commented 8 years ago

branch is at https://github.com/SmartBear/readyapi-swagger-plugin/tree/NP-on-missing-schema

rick23ro commented 8 years ago

Yes, I'll install it and reply with results.

rick23ro commented 8 years ago

Yey, it worked with the new version. :D Thanks for your help!

olensmar commented 8 years ago

awesome - thanks for confirming! I'll merge this into master and it will be in the next release