aam*_*rad 1 java spring swagger-ui swagger-2.0 cuba-platform
我在 cuba 平台上创建了一个自定义的 rest 控制器,并按照文档https://doc.cuba-platform.com/restapi-7.1/#rest_api_v2_custom_auth 中的说明进行操作
我的“rest-dispatcher-spring.xml”
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:component-scan base-package="com.company.test.web.resource"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
将“rest-dispatcher-spring.xml”添加到“web-app.properties”
cuba.restSpringContextConfig = +com/company/test/rest-dispatcher-spring.xml
Run Code Online (Sandbox Code Playgroud)
我的控制器看起来像这样
package com.company.test.web.resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@RestController
@RequestMapping("/test")
public class TestResource {
@RequestMapping(value = "/testAPI", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity testAPI() {
return new ResponseEntity<>(HttpStatus.OK);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以从 Postman 调用 API,但该 API 未使用 URL 在 Swagger-ui 中显示
http://localhost:8080/app/rest/v2/docs/swaggerDetailed.yaml
Run Code Online (Sandbox Code Playgroud)