servicecomb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yhs0092 <yhs0...@163.com>
Subject [Discuss] Do we need to add some reminder logs on SwaggerGeneratorContext selection?
Date Wed, 24 Oct 2018 08:14:02 GMT
Hi guys.
Yesterday, a user asked me about a 404 error. He packed his JavaChassis project into a jar
file and ran it on his laptop. But when he invoked the rest interface by Postman, a 404 error
was returned, while if he ran the project in Eclipse, this problem did not occur.


Finally we found out there was something wrong with maven. On his laptop, if maven packaging
command was run in Windows CMD, the output jar file lacked swagger-generator-springmvc dependency
jar.
As the implementations of SwaggerGeneratorContext are loaded by SPI mechanism, there is no
error when some classes are abscent. When the expected SpringmvcSwaggerGeneratorContext is
abscent, the PojoSwaggerGeneratorContext will be used as default. As a result, the @RequestMapping
tagged on REST interface class is ignored, and the name of the class is used as basePath instead
of the value specified in @RequestMapping.


After cleaning local maven repo, the problem disappeared. But in this case, there is almost
no log for helping locate the problem cause.


So do we need to add some log to indicate the potential problem?
Currently I think we can add log to show which SwaggerGeneratorContext is selected to generate
swagger schema. And if PojoSwaggerGeneratorContext is selected, we can add some extra logic
to check whether there is @Path or @RequestMapping and remind developer to be aware of the
dependency jar files.
Any ideas?




Yours sincerely


Yao Haishi
yhs0092@163.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message