Document metadata
A single swagger:meta block on a package doc comment carries the document’s
top-level metadata: its info (title, description, version, license, contact),
the host and basePath, the default schemes, and consumes/produces. The
pane pairs the annotated package with the document it produces, from the
test-covered docs/examples/concepts/meta
package.
swagger:meta
The block lives in the package doc comment. The title comes from the first
line with the Package <name> prefix stripped; the following paragraph becomes
the description. The indented Key: value lines and list blocks populate the
rest — License: and Contact: parse into structured objects.
// Package meta Pet Store.
//
// A small API that demonstrates the document-level swagger:meta block: the
// package doc comment carries the spec's top-level metadata.
//
// Schemes: https
// Host: api.example.com
// BasePath: /v1
// Version: 1.2.0
// License: Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0.html
// Contact: API Team <api@example.com> https://example.com/support
//
// Consumes:
// - application/json
//
// Produces:
// - application/json
//
// swagger:meta
package metaFull source: docs/examples/concepts/meta/doc.go
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0",
"info": {
"description": "A small API that demonstrates the document-level swagger:meta block: the\npackage doc comment carries the spec's top-level metadata.",
"title": "Pet Store.",
"contact": {
"name": "API Team",
"url": "https://example.com/support",
"email": "api@example.com"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.2.0"
},
"host": "api.example.com",
"basePath": "/v1",
"paths": {}
}
Full source: docs/examples/concepts/meta/testdata/meta.json
For the full meta keyword surface (security definitions, external docs,
extensions, terms of service), see the
swagger:meta reference
and the meta keywords.
What’s next
- Routes & operations — add the paths this document describes.
- Putting it together — a complete scan from meta to definitions.