Posts gin-swagger 파라미터 유형에 따른 주석 변경
Post
Cancel

gin-swagger 파라미터 유형에 따른 주석 변경

개요

  • gin-swagger로 API 문서 만들때, 파라미터 받는 방식마다
    gin-swagger 주석이 다른데 자주 까먹어서 기록한다.

파라미터 종류

  • Query Parameter
    • method: GET, URL: /base/url?param=123
  • Path Variable
    • method: GET, URL: /base/url/123

Gin-swagger 문서 주석

  • 위치
  • 파라미터 주석 명세
    • @Param [param name] [param type] [data type] [is mandatory] [comment] [attribute(optional)]
  • Query Parameter
    • param type이 query
      • ex) // @Param id query int true “ID”
  • Path Variable
    • param type이 path
      • ex) // @Param id path int true “ID”
    • Router 명세에 path variable을 넣어줘야 한다.
      • ex) // @Router /base/url/{id} [get]

참고

This post is licensed under CC BY 4.0 by the author.