API 在 Spring ROO 项目中未被 swagger 检测到

APIs not getting detected by swagger on a Spring ROO project

我已经尝试了很多东西,但由于某种原因,API 没有被 swagger 检测到。我是否必须指定一个包以便大摇大摆地扫描?或者一些 url 包含模式?

我的 Swager 配置:

@Configuration
@EnableSwagger
@EnableWebMvc
public class SwaggerConfiguration {

private final Logger log = LoggerFactory
        .getLogger(SwaggerConfiguration.class);

/**
 * Swagger Spring MVC configuration.
 */
@Bean
public SwaggerSpringMvcPlugin swaggerSpringMvcPlugin(
        SpringSwaggerConfig springSwaggerConfig) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    SwaggerSpringMvcPlugin swaggerSpringMvcPlugin = new SwaggerSpringMvcPlugin(
            springSwaggerConfig).apiInfo(apiInfo())
            .genericModelSubstitutes(ResponseEntity.class);

    swaggerSpringMvcPlugin.build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return swaggerSpringMvcPlugin;
}

/**
 * API Info as it appears on the swagger-ui page.
 */
private ApiInfo apiInfo() {
    return new ApiInfo("Title", "Description", "terms of service",
            "contact", "license", "licenseUrl");
}

}

示例控制器

@RequestMapping("/settings")
@Controller
@Api(value = "/settings", description = "Endpoint for settings management")
public class SettingsController {

@ApiOperation(value = "API Operation")
@RequestMapping(value = "/changepassword", method = RequestMethod.POST)
public @ResponseBody Map<String, Object> changePassword(@RequestParam Map<String, String> userProperties,
        Model model, HttpServletRequest httpServletRequest, Locale locale) {
    Map<String, Object> responseMap = new HashMap<String, Object>();
    return responseMap;
}

}

我得到一个空响应

{

"apiVersion": "1.0",
"swaggerVersion": "1.2",
"apis": [ ],
"authorizations": [ ],
"info": 

{
    "title": "Title",
    "description": "Description",
    "termsOfServiceUrl": "terms of service",
    "contact": "contact",
    "license": "license",
    "licenseUrl": "licenseUrl"
}

}

我正在使用 swagger-springmvc 版本 1.0.2 和 spring 版本 4.1.6.RELEASE

按照以下URL中的说明进行操作:

http://naddame.blogspot.in/2014/12/spring-roo-mvc-integration-for-swagger.html