Swagger Is not able to produce documentation for HTTP quot;PATCHquot;(Swagger 无法为 HTTP“PATCH生成文档.)
问题描述
我已遵循以下
博客条目: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 中创建支持 HTTPPATCH"方法的端点依赖版本:
I Have followed the below
blog entry:
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
To create end point to support HTTP "PATCH" method in Jersey 2.6
Dependency Versions:
-Jersey: 2.6
-swagger-jersey2-jaxrs_2.10: 1.3.12
问题?为什么 Patch
端点没有被列为 swagger ui 文档的一部分?
Question?
Why Patch
end point is not getting listed as part of the swagger ui documentation?
分析:
如果我使用此注释进行注释,则会生成该端点的文档,但没有交互.
If I am annotating with this annotation, then documentation for that end point getting generated, but no interaction .
@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());
我不确定,如果我遗漏了什么,任何帮助或指南都会有所帮助.
I am not sure, if I am missing something, any help or guide will be helpful.
补丁方法文档:
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;
}
推荐答案
看看你的 index.html.控制哪些 HTTP 操作是交互式的——通过将其更改为:
Take a look at your index.html. That controls which HTTP operations are interactive--by changing it to this:
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
您将在 PATCH 方法上进行交互:
You will have interaction on the PATCH method:
这篇关于Swagger 无法为 HTTP“PATCH"生成文档.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Swagger 无法为 HTTP“PATCH"生成文档.
基础教程推荐
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01