bex 无法在swagger生效
环境版本:
<koca.base.version>3.2.0</koca.base.version>
<kace.base.version>3.2.0</kace.base.version>
![|554x203](file:///C:\Users\user\AppData\Local\Temp\ksohtml924\wps1.jpg)
详细描述:在-Bex.xml写的接口,无法在swagger正常显示。
Debug模式下详细信息:
java.lang.NullPointerException: null
at java.util.TreeMap.compare(TreeMap.java:1294)
at java.util.TreeMap.put(TreeMap.java:538)
at java.util.TreeSet.add(TreeSet.java:255)
at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
at java.util.TreeSet.addAll(TreeSet.java:312)
at springfox.documentation.builders.OperationBuilder.tags(OperationBuilder.java:308)
at com.szkingdom.koca.bex.swagger.config.BexSwaggerScanner.apply(BexSwaggerScanner.java:133)
at springfox.documentation.spring.web.plugins.DocumentationPluginsManager.additionalListings(DocumentationPluginsManager.java:199)
at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:127)
at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:67)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.scanDocumentation(AbstractDocumentationPluginsBootstrapper.java:96)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82)
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:445)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
at com.szkingdom.oms.OmsApplication.main(OmsApplication.java:39)
原因:实际报错位置是L 133行,tags为空,把TreeSet添加null报错。
来分析bex.xml的 写法如下:
<java-bex method="manageCalendar" type="com.szkingdom.koca.ace.dac.right.system.service.impl.CalendarServiceImpl" name="管理[系统-交易日历]" id="100340" api="100340">
<request>
<param type="com.szkingdom.koca.ace.dac.right.core.bean.BexParam">
<param code="param" type="map">
<param code="action" name="操作 A-清算 D-非清算" required="true" type="string" length="1"/>
<param code="markets" name="日历类型" required="true" type="string" length="128"/>
<param code="phydate" name="日期" required="true" type="string"/> </param>
</param>
</request>
</java-bex>
CalendarServiceImpl 的写法没问题
分析:发现他是根据spring的类型查找,没有写bean的属性,导致apiBexMap中的Bex对象中没有bean属性。
解决方案是:
-
在Line 93行,对tags进行增强,如果tags为空,截取bean的实际类型赋值给tags,还是为空的时候把他归到“其他”,也就是tags = “orther”;
-
在Line:124- 133行部分,用try-catch进行处理,这部分由于个别bex接口编写的不规范,但不应该导致整个bex 接口文档的输出,正常接口还得正常输出。
这些都需要koca基础包修复此bug