OSS TanbouSign in with GitHub

generate Swagger and OpenAPI documents from declarative comments in Go source

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
13,040
Primary language
Go
License
MIT
Repository last updated
Sep 30, 2026
On this page

Overview

Swag parses declarative comments in Go source and generates API documentation. It is centered on Swagger 2.0, while the v2 line expands OpenAPI v3 support, and it integrates with common Go web frameworks and Swagger UI workflows.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Generate API operations and schemas from annotations near handlers

General API metadata, routes, parameters, responses, and security can be described in comments, then swag init generates docs.go plus JSON or YAML specifications.

Sources: [2]

Extend Swagger 2.0 workflows with growing OpenAPI v3 support in v2

Version 2.0.0-rc6 includes fixes for duplicate enums, discriminators, and oneOf handling in OpenAPI v3 while retaining established Swagger-oriented workflows.

Sources: [2][4]

Best fit

Fits Go web APIs that want documentation maintained close to handler source

It is useful when teams want annotations beside Gin or other handlers and generated specifications for Swagger UI, clients, or publishing during builds.

Sources: [2]

Before adoption

v2.0.0-rc6 is a release candidate; go.mod declares Go 1.18 while source-build docs say Go 1.19+

The v2.0.0-rc6 go.mod declares Go 1.18, while the README asks for Go 1.19 or newer to build from source. Since v2 remains in RC with active OpenAPI v3 changes, pin the generator and regression-test annotation parsing plus generated-spec diffs.

Sources: [3][2][4]

Official sources

  1. [1]swaggo/swag — GitHub repository(2026-10-06)
  2. [2]Swag v2.0.0-rc6 — README(2026-10-06)
  3. [3]Swag v2.0.0-rc6 — go.mod(2026-10-06)
  4. [4]Swag v2.0.0-rc6 release(2026-10-06)
  5. [5]Swag MIT license(2026-10-06)
Supplemental curator note

Swag generates API documentation from comments near Go handlers and integrates with common web frameworks. Because the v2 line is currently a release candidate, pin the generator version and review generated specification diffs in CI, especially when using OpenAPI v3 features.

Try it in 3 steps

  1. 1

    Get the source

    git clone --depth 1 https://github.com/swaggo/swag.git
  2. 2

    Enter the repository

    cd swag
  3. 3

    Check the official steps

    Continue with the commands in the README Installation, Quick Start, or Getting Started section.

    find . -maxdepth 1 -iname 'README*' -exec sed -n '1,220p' {} \; -quit
Check the official README

Growth

Growth trends · Last 30 days

13,040 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
5
Open PRs
63

Development activity is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • golang
  • swagger
  • swagger2
  • annotations
  • openapi
Stars
13,040
Forks
1,545
Watchers
113
Open issues
409
Contributors
251
Owner type
Organization
Primary language
Go
License
MIT
Repository last updated
Sep 30, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?