{"id":1420,"date":"2018-10-30T11:02:35","date_gmt":"2018-10-30T02:02:35","guid":{"rendered":"https:\/\/esoro.jp\/?p=1420"},"modified":"2020-10-20T07:38:21","modified_gmt":"2020-10-19T22:38:21","slug":"swagger-spring-%e3%81%a7-api%e3%82%b5%e3%82%a4%e3%83%88%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"https:\/\/esoro.jp\/?p=1420","title":{"rendered":"Swagger + SpringBoot \u3067 API\u30b5\u30a4\u30c8\u3092\u4f5c\u3063\u3066\u307f\u308b"},"content":{"rendered":"<p> \u65e2\u5b58\u30b7\u30b9\u30c6\u30e0\u306eDB\u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3059\u308b\u3088\u3046\u306aAPI\u3092\u3001\u3063\u3066\u4e8b\u3067\u3001<br \/>\nSwagger\u3067API\u3092\u5b9a\u7fa9\u3057\u3001Swagger\u304b\u3089\u81ea\u52d5\u751f\u6210\u3057\u305f\u30bd\u30fc\u30b9\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u306a\u304a\u3001\u4eca\u56de\u5bfe\u8c61\u3068\u3057\u3066\u3044\u308b\u306e\u306f\u53c2\u7167\u7cfb\u304c\u30e1\u30a4\u30f3\u3067REST\u3063\u3066\u96f0\u56f2\u6c17\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u5bfe\u8c61\u304c\u65e2\u5b58\u30b7\u30b9\u30c6\u30e0\u306eDB\u306a\u306e\u3067\u3002\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u3056\u3063\u304f\u308a\u3068\u3057\u305f\u8981\u6c42\u3068\u5fdc\u7b54\u306e\u4ed5\u69d8\u3092\u6574\u7406\u3057\u3001Swagger Editor\u306byaml\u3092\u66f8\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2018\/10\/swagger-e1540852896269.png\" alt=\"\" width=\"599\" height=\"317\" class=\"aligncenter size-full wp-image-1424\" \/><\/p>\n<p>\u306a\u304a\u3001Swagger Editor\u306f\u3001\u5225\u4ef6\u3067\u4f7f\u3063\u3066\u3044\u305f\u7aef\u672b\u5185\u306exampp\/htdocs\u306bGitHub\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305fZIP\u3092\u89e3\u51cd\u3057\u3066\u4f7f\u3063\u3066\u307e\u3059\u3002<br \/>\n\u3042\u308b\u7a0b\u5ea6\u3001\u5b9a\u7fa9\u3092\u66f8\u3044\u305f\u5f8c\u3001Swagger Editor\u304b\u3089Generate Server\u3067Spring\u306e\u30b5\u30fc\u30d0\u30bd\u30fc\u30b9\u3092\u51fa\u529b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u81ea\u52d5\u751f\u6210\u3055\u308c\u305fJava\u30bd\u30fc\u30b9\u306f\u3053\u3093\u306a\u69cb\u6210\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/esoro.jp\/wordpress\/wp-content\/uploads\/2018\/10\/generate-e1540852977919.png\" alt=\"\" width=\"600\" height=\"227\" class=\"aligncenter size-full wp-image-1421\" \/><\/p>\n<p>Controller\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u306e\u30e2\u30c7\u30eb\u304c\u63c3\u3063\u3066\u307e\u3059\u3002\u5168\u4f53\u7684\u306a\u30bd\u30fc\u30b9\u69cb\u6210\u306f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u5c64\u3001\u30b5\u30fc\u30d3\u30b9\u5c64\u3001\u30c7\u30fc\u30bf\u30a2\u30af\u30bb\u30b9\u5c64\u3068\u3044\u3046\uff13\u69cb\u6210\u306b\u306a\u308a\u307e\u3059\u304b\u306d\u3002<br \/>\n\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u5c64\u306f\u6982\u306dSwagger\u3067\u751f\u6210\u3057\u305f\u306e\u3067\u3001\u30c7\u30fc\u30bf\u30a2\u30af\u30bb\u30b9\u5c64\u3082\u81ea\u52d5\u751f\u6210\u3057\u3088\u3046\u3068\u3001Doma2\u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<br \/>\ndoma-gen-build.xml\u306b\u63a5\u7d9a\u5148DB\u60c5\u5831\u3068\u51fa\u529b\u5148\u30bd\u30fc\u30b9\u306e\u8a2d\u5b9a\u7b49\u3092\u8a18\u8ff0\u3057\u3001\u3053\u3061\u3089\u3082Generate!<\/p>\n<p>\u7d50\u679c\u3001\u30bd\u30fc\u30b9\u3092\u624b\u66f8\u304d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u306f\u3001<\/p>\n<p>\u30fb\u30b5\u30fc\u30d3\u30b9\u5c64\u5168\u4f53<\/p>\n<p>\u30fbSwagger\u3067\u81ea\u52d5\u751f\u6210\u3055\u308c\u305fSpringBootApplication\u30af\u30e9\u30b9\u306eComponentScan\u306b\u30b5\u30fc\u30d3\u30b9\u5c64\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u8ffd\u8a18<br \/>\n\u3000\u3000@ComponentScan(basePackages = { &#8220;io.swagger&#8221;, &#8220;io.swagger.api&#8221;,&#8221;jp.esoro.api&#8221; })<\/p>\n<p>\u30fbSwagger\u3067\u81ea\u52d5\u751f\u6210\u3055\u308c\u305fController\u306bService\u3092\u30b3\u30fc\u30eb\u3059\u308b\u7b87\u6240\u3092\u8ffd\u8a18<\/p>\n<p>\u30fbDAO\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306b\u4e0b\u8a18\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u8a18<br \/>\n@ConfigAutowireable<br \/>\n@Repository<\/p>\n<p>\u30fb\u81ea\u52d5\u751f\u6210\u4e0d\u53ef\u80fd\u306aSQL\u6587\u306e\u4f5c\u6210\u3057\u3001\u305d\u308c\u306b\u5408\u308f\u305b\u3066DAO\u306b\u30e1\u30bd\u30c3\u30c9\u8ffd\u52a0<\/p>\n<p>\u3068\u3044\u3063\u305f\u3068\u3053\u308d\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u306e\u52d5\u4f5c\u78ba\u8a8d\u304c\u51fa\u6765\u307e\u3057\u305f\u3002<\/p>\n<p>\u305f\u3060\u3001\u5b9f\u7528\u3059\u308b\u306b\u306f\u8a8d\u8a3c\u3084\u30da\u30fc\u30b8\u30f3\u30b0\u7b49\u3082\u5fc5\u8981\u306a\u306e\u3067\u3001\u3053\u3093\u306a\u5358\u7d14\u306a\u8a71\u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3057\u3001API\u306e\u4ed5\u69d8\u3092\u3061\u3083\u3093\u3068\u6574\u7406\u3057\u3066\u304b\u3089Swagger\u3067\u30bd\u30fc\u30b9\u3092\u751f\u6210\u3057\u3066\u7740\u624b\u3057\u306a\u3044\u3068\u5f8c\u304c\u9762\u5012\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65e2\u5b58\u30b7\u30b9\u30c6\u30e0\u306eDB\u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3059\u308b\u3088\u3046\u306aAPI\u3092\u3001\u3063\u3066\u4e8b\u3067\u3001 Sw &hellip; <a href=\"https:\/\/esoro.jp\/?p=1420\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,17],"tags":[],"_links":{"self":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1420"}],"collection":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1420"}],"version-history":[{"count":0,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1420\/revisions"}],"wp:attachment":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}