【发布时间】:2015-02-18 14:15:03
【问题描述】:
我已遵循以下
博客条目:
http://kingsfleet.blogspot.co.uk/2014/02/transparent-patch-support-in-jax-rs-20.html
https://github.com/jersey/jersey/tree/2.6/examples/http-patch
在 Jersey 2.6 中创建支持 HTTP“PATCH”方法的端点
依赖版本:
-Jersey: 2.6
-swagger-jersey2-jaxrs_2.10: 1.3.12
问题?
为什么 Patch 端点没有被列为 swagger ui 文档的一部分?
分析:
如果我使用此注释进行注释,则会生成该端点的文档,但没有交互。
@com.wordnik.swagger.jaxrs.PATCH
配置
JerssyApplicationInitializer
packages(true, "com.test.account.endpoint", "com.wordnik.swagger.jaxrs.json");
//Swagger Configuration
register(new ApiListingResourceJSON(), 10);
register(JerseyApiDeclarationProvider.class);
register(JerseyResourceListingProvider.class);
//Genson Converter
register(GensonJsonConverter.class, 1);
register(createMoxyJsonResolver());
我不确定,如果我遗漏了什么,任何帮助或指南都会有所帮助。
补丁方法文档:
public static final String PATCH_MEDIA_TYPE = "application/json-patch+json";
@PATCH
//@com.wordnik.swagger.jaxrs.PATCH
@PreAuthorize(userAuthenticationRequire=true)
@Consumes(PATCH_MEDIA_TYPE)
@Path("{id: .\\d+}")
@ApiOperation(value = "Update Client Details in UIM System."
, response = State.class
, notes="Requesting User, should be the owner of the Client."
, consumes = PATCH_MEDIA_TYPE)
@ApiResponses({
@ApiResponse(code = _401, message = "If the access token is invalid.", response = String.class),
@ApiResponse(code = _498, message = "If the access token is expired.", response = String.class),
@ApiResponse(code = _420, message = "If Provided Input is not valid according to requirment specification."),
@ApiResponse(code = _404, message = "If no client/app Found."),
@ApiResponse(code = _200, message = "If Client Account has been Updated successfully. ", response=String.class)
})
public State updateClientDetails(@ApiParam(value="Client Id to be Updated.", required=true) @PathParam(CLIENT_ID) String clientId
, @ApiParam(value = "Updated field and Value.", required = true) final State newState){
//LOG.info("[ENTRY]- Received requst for updating Client {} from System.", clientId);
System.out.println("----->" + someBean.test());
//LOG.info("[EXIT]- Client Id {} Updation has been completed.", clientId);
Test t = new Test();
t.name = "Hello Test";
System.out.println(t.name);
return newState;
}
【问题讨论】:
-
你说没有生成,是看UI还是生成的Swagger JSON?
-
你能用包含注释的示例方法签名来编辑问题吗?
-
@Ron Hmm 已编辑,请查看...感谢您抽出宝贵时间 :)
-
另外两个问题 - 资源是否使用 @Api 注释?你用的是哪个版本的 swagger-core?
-
@Ron: 是的,它有 @Api(value = CLIENT_PATH, description = "客户端管理,例如注册、读取、更新和删除") 完整的生成文档,用于其他方法,如 GET、DELETE 内部存在.版本=1.3.12 artifactId=swagger-core_2.10
标签: java swagger swagger-ui