Swagerの簡単な理解


SwagerもRestDocsと同様によく使われるAPIドキュメント化ツールです.
よく使うが欠点もある
  • 生産コードは、文書化のためのコードと混合される.
  • 操作コード解析困難
  • メンテナンスが悪い
  • @ApiOperation(value = "해당 게시판 조회") // documentation을 위한 annotation
     @ApiImplicitParams({
         @ApiImplicitParam(name = "id", value = "게시판 고유키", required = true, dataType = "string", paramType = "path", defaultValue = ""),
      })
      @RequestMapping(value = "/board/{id}", method = RequestMethod.GET)
      public ResultJson selectOneBoard(@PathVariable("id") Integer id) {
          ResultJson resultJson = new ResultJson();
          resultJson.setObject(boardService.selectOneBoard(id));
          resultJson.setResultCode(ResultCodeType.SUCCESS.getCode());
          resultJson.setMsg(ResultCodeType.SUCCESS.getMsg());
          return resultJson;
      }
  • RestDocsのように、テストを行わなくてもドキュメント化されるため、api検証を自動的に行うことはできません.
  • ソース

  • Spring Rest APIドキュメントをSwaggerにする