3

我有一个使用 spring 注释和 Spring MVC 公开 RESTful 操作的应用程序。

看起来像

@RequestMapping(value = "/example/{someId}", 
    method = RequestMethod.GET, consumes=MediaType.APPLICATION_JSON_VALUE, 
    produces=MediaType.APPLICATION_JSON_VALUE)
@ResponseBody 
public void isRegisteredToThread(@PathVariable long someId, HttpServletResponse response) {

    [something]
}

我想要的是一个自动生成的所有 URL、方法和可用参数的列表——可能在一个 WSDL 中。有插件还是可用的?

4

2 回答 2

0

您可以查看RequestMappingEndpointSpring Boot 提供的源代码,了解 Spring Boot 如何报告映射。

通过该代码可以看到映射(处理程序和方法映射)可以很容易地从 applicationContext 获得

(使用

applicationContext.getBeansOfType(AbstractUrlHandlerMapping.class)

applicationContext.getBeansOfType(AbstractHandlerMethodMapping.class)

分别)。获得映射后,您可以随意处理它们。您可能想要创建一个库,该库可以包含在您的所有项目中,这些项目处理您的组织所需形式的映射

于 2014-04-09T09:31:20.170 回答
0

WSDL 不是为休息而完成的,它是为 SOAP 使用的。

您可能会使用 WADL,但我真的不建议这样做。

在我的项目中,我总是使用 swagger(有一个 spring 版本)。您可以在这里找到更多信息https://github.com/martypitt/swagger-springmvc和这里http://blog.zenika.com/index.php?post/2013/07/11/Documenting-a-REST-API -with-Swagger-and-Spring-MVC

试试看。

作为替代方案,如果您不需要基于 Web 的东西,您可以尝试使用 rest-shell ( https://github.com/spring-projects/rest-shell )

于 2014-04-09T09:16:43.343 回答