Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>swaggoNew to Visual Studio Code? Get it now.
swaggo

swaggo

narubrown

|
1 install
| (0) | Free
GoSwagger Genie - virtual annotation helper for Go Swagger comments
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

swaggo

GoSwagger Genie for VS Code. @Tag(...) 또는 #Tag(...) 형태의 가상 어노테이션을 입력하면, 자동으로 Go Swagger 주석(// @Tag ...)으로 변환합니다.

핵심 기능

  • 가상 어노테이션 문법 지원: @Summary("..."), #Param(...) 등.
  • 자동 변환: 입력 즉시 // @Tag ... 형식으로 변환.
  • 기본 패턴 진단: package.Type 또는 package.Function 형태를 정규식으로 검사.
  • 스니펫 제공: 자주 쓰는 GET/POST 템플릿.

사용 방법

1) 입력 예시

@Summary("클래스 생성")
@Description("클래스 생성 API")
@Tags("classroom", "admin")
@Accept("json")
@Produce("json")
@Param("body", "body", "dto.CreateClassroomRequest", true, "클래스 생성 요청")
@Success(200, "dto.ClassroomResponse", "클래스 생성 성공")
@Failure(400, "echo.HTTPError", "잘못된 요청")
@Router("/classrooms", "post")

2) 변환 결과

// @Summary 클래스 생성
// @Description 클래스 생성 API
// @Tags classroom,admin
// @Accept json
// @Produce json
// @Param body body dto.CreateClassroomRequest true "클래스 생성 요청"
// @Success 200 {object} dto.ClassroomResponse "클래스 생성 성공"
// @Failure 400 {object} echo.HTTPError "잘못된 요청"
// @Router /classrooms [post]

지원하는 어노테이션 문법

아래는 현재 지원하는 가상 어노테이션 태그와 기본 변환 규칙입니다.

기본 텍스트 계열

  • @Summary("텍스트") → // @Summary 텍스트
  • @Description("텍스트") → // @Description 텍스트
  • @ID("operationId") → // @ID operationId
  • @Tags("tag1", "tag2") → // @Tags tag1,tag2
  • @Accept("json", "xml") → // @Accept json xml
  • @Produce("json") → // @Produce json
  • @Schemes("http", "https") → // @Schemes http https
  • @Security("ApiKeyAuth") → // @Security ApiKeyAuth
  • @Deprecated() → // @Deprecated

Param

형식:

@Param("in", "name", "type", required, "description")

변환:

// @Param name in type required "description"

예시:

@Param("query", "id", "string", true, "사용자 ID")
// @Param id query string true "사용자 ID"

Success / Failure

형식:

@Success(code, "typePath", "description")
@Failure(code, "typePath", "description")

변환:

// @Success code {object} typePath "description"
// @Failure code {object} typePath "description"

스키마 타입을 직접 지정할 수도 있습니다.

@Success(200, "array", "dto.User", "OK")
// @Success 200 {array} dto.User "OK"

지원하는 스키마 타입: object, array, string, number, integer, boolean

Header

형식:

@Header(code, "type", "name", "description")

변환:

// @Header code {type} name "description"

예시:

@Header(200, "string", "Location", "redirect url")
// @Header 200 {string} Location "redirect url"

Router

형식:

@Router("/path", "method")

변환:

// @Router /path [method]

예시:

@Router("/classrooms", "post")
// @Router /classrooms [post]

어노테이션 파싱 규칙

  • @Tag(...) 또는 #Tag(...) 모두 지원합니다.
  • 문자열은 큰따옴표로 감싸는 것을 권장합니다.
  • 콤마로 인자를 구분합니다.
  • true/false, 숫자, 문자열이 혼합되어도 처리합니다.

진단(Diagnostics)

  • package.Type 또는 package.Function 형태를 기본 정규식으로 검사합니다.
  • 형식이 맞지 않으면 해당 위치에 경고가 표시됩니다.
  • 실제 Go 코드에 해당 타입이 존재하는지는 검사하지 않습니다.

스니펫

  • swagpost: POST용 가상 어노테이션 블록
  • swagget: GET용 가상 어노테이션 블록

개발

  1. 의존성 설치: npm install
  2. 빌드: npm run compile
  3. 실행: VS Code에서 F5로 Extension Development Host 실행

비고

  • 현재는 입력 즉시 변환됩니다.
  • 필요 시 태그별 포맷 규칙을 추가로 확장할 수 있습니다.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft