{"id":3645,"date":"2018-12-28T14:35:04","date_gmt":"2018-12-28T06:35:04","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3645"},"modified":"2018-12-28T14:35:04","modified_gmt":"2018-12-28T06:35:04","slug":"%e8%af%a6%e8%a7%a3-swagger2-%e4%b8%ad%e5%b1%8f%e8%94%bd%e6%8e%a5%e5%8f%a3-apiignore-%e6%b3%a8%e8%a7%a3%e7%9a%84%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3645","title":{"rendered":"\u8be6\u89e3 swagger2 \u4e2d\u5c4f\u853d\u63a5\u53e3 @ApiIgnore \u6ce8\u89e3\u7684\u7528\u6cd5"},"content":{"rendered":"<p>\n\t\u6d3b\u5230\u8001\uff0c\u5b66\u5230\u8001\u3002\u4eca\u5929\u6709\u540c\u4e8b\u95ee\u6211\uff0c\u4e3a\u4ec0\u4e48\u6709\u7684\u63a5\u53e3\u4e0a\u52a0\u7684\u6709 @ApiIgnore \u6ce8\u89e3\uff0c\u6709\u7684\u6ca1\u6709\uff1f\u672c\u6587\u6211\u4eec\u4e00\u8d77\u6765\u89e3\u91ca\u89e3\u91ca\u4e3a\u4ec0\u4e48\uff1f\n<\/p>\n<p>\n\tIgnore \u8fd9\u4e2a\u5355\u8bcd\uff0c\u7ffb\u8bd1\u8fc7\u6765\u5c31\u662f\u5ffd\u7565\u7684\u610f\u601d\u3002api Ignore \u548c\u8d77\u6765\u5c31\u662f\u5ffd\u7565 api \u7684\u610f\u601d\u3002\n<\/p>\n<p>\n\t@ApiIgnore \u6ce8\u89e3\u662f springfox \u4e2d\u7684\u4e00\u4e2a\u6ce8\u89e3\u3002\u5bf9\u5e94\u6e90\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\npackage springfox.documentation.annotations;\r\nimport java.lang.annotation.ElementType;\r\nimport java.lang.annotation.Retention;\r\nimport java.lang.annotation.RetentionPolicy;\r\nimport java.lang.annotation.Target;\r\n@Retention(RetentionPolicy.RUNTIME)\r\n@Target({ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER})\r\npublic @interface ApiIgnore {\r\n  \/**\r\n   * \u7b80\u8981\u63cf\u8ff0\u4e3a\u4f55\u5ffd\u7565\u6b64\u53c2\u6570\/\u64cd\u4f5c\r\n   *\/\r\n  String value() default &quot;&quot;;\r\n}<\/pre>\n<p>\n\t\u4ece\u8fd9\u4e2a\u6e90\u7801\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u3002@ApiIgnore \u6ce8\u89e3\u4e3b\u8981\u4f5c\u7528\u5728\u65b9\u6cd5\u4e0a\uff0c\u7c7b\u4e0a\uff0c\u53c2\u6570\u4e0a\u3002\n<\/p>\n<p>\n\t\u5f53\u4f5c\u7528\u5728\u65b9\u6cd5\u4e0a\u65f6\uff0c\u65b9\u6cd5\u5c06\u88ab\u5ffd\u7565\uff1b\u4f5c\u7528\u5728\u7c7b\u4e0a\u65f6\uff0c\u6574\u4e2a\u7c7b\u90fd\u4f1a\u88ab\u5ffd\u7565\uff1b\u4f5c\u7528\u5728\u53c2\u6570\u4e0a\u65f6\uff0c\u5355\u4e2a\u5177\u4f53\u7684\u53c2\u6570\u4f1a\u88ab\u5ffd\u7565\u3002\n<\/p>\n<p>\n\t\u5177\u4f53\u7528\u6cd5\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n\/\/ \u771f\u4e2a\u7c7b\u88ab Swagger \u5ffd\u7565\r\n@ApiIgnore\r\n@RestController\r\n@RequestMapping(value = &quot;\/xttblog&quot;)\r\npublic class XttblogController {}\r\n\r\n@RestController\r\n@RequestMapping(value = &quot;\/xttblog&quot;)\r\npublic class XttblogController {\r\n\r\n  \/\/ \u6574\u4e2a\u65b9\u6cd5\u88ab\u5ffd\u7565\r\n  @ApiIgnore\r\n  public String hello(){\r\n    return &quot;hello&quot;;\r\n  }\r\n\r\n  \/\/ Swagger \u4e0a \u5ffd\u7565 User \u53c2\u6570\r\n  public String sayHello(@ApiIgnore User user){\r\n    return &quot;hello &quot; + user.getName();\r\n  }\r\n}<\/pre>\n<p>\n\t\u5ffd\u7565\u7684\u610f\u601d\u5c31\u662f swagger-ui.html \u4e0a\u4e0d\u4f1a\u663e\u793a\u5bf9\u5e94\u7684\u63a5\u53e3\u4fe1\u606f\u3002\u7f51\u4e0a\u5173\u4e8e @ApiIgnore \u7528\u6cd5\u7684\u89e3\u91ca\u975e\u5e38\u7684\u5c11\uff0c\u7b80\u5355\u7684\u90fd\u6ca1\u4eba\u613f\u610f\u5199\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3645\">\u8be6\u89e3 swagger2 \u4e2d\u5c4f\u853d\u63a5\u53e3 @ApiIgnore \u6ce8\u89e3\u7684\u7528\u6cd5<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6d3b\u5230\u8001\uff0c\u5b66\u5230\u8001\u3002\u4eca\u5929\u6709\u540c\u4e8b\u95ee\u6211\uff0c\u4e3a\u4ec0\u4e48\u6709\u7684\u63a5\u53e3\u4e0a\u52a0\u7684\u6709 @ApiIgnore \u6ce8\u89e3\uff0c\u6709\u7684\u6ca1\u6709\uff1f\u672c\u6587\u6211\u4eec\u4e00\u8d77\u6765\u89e3 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1857,607,992,603,1045],"class_list":["post-3645","post","type-post","status-publish","format-standard","hentry","category-java","tag-apiignore","tag-enableswagger2","tag-shiro-","tag-swagger2","tag-1045"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3645"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3645\/revisions"}],"predecessor-version":[{"id":3646,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3645\/revisions\/3646"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}