Go types modeling the Swagger 2.0 / OpenAPI 2.0 specification. This package is the
foundational data model for the go-swagger ecosystem — every specification object
(Swagger, Schema, Operation, Parameter, etc.) is a Go struct with JSON
round-trip serialization. It also includes a $ref expansion engine for resolving
JSON References across local and remote documents.
Single module: github.com/go-openapi/spec.
| File | Contents |
|---|---|
swagger.go |
Root Swagger type (top-level spec object) |
schema.go |
Schema (JSON Schema subset used by Swagger) |
operation.go |
Operation (single API operation) |
parameter.go |
Parameter (query, header, path, body, formData) |
response.go, responses.go |
Response, Responses |
ref.go |
Ref type, JSON Reference ($ref) handling |
expander.go |
$ref expansion / resolution engine |
normalizer.go |
URL/path normalization (platform-specific variants) |
Swagger— root specification object; deserialize withjson.UnmarshalSchema— JSON Schema with Swagger extensions; supportsallOf,$ref, validationsRef/MustCreateRef(uri)— JSON Reference wrapperExpandSpec(spec, opts)— resolve all$refnodes in a specificationExpandSchema(schema, root, cache)— resolve$refnodes in a single schemaResolveRef(root, ref)/ResolveParameter/ResolveResponse— targeted resolution
github.com/go-openapi/jsonpointer— JSON Pointer (RFC 6901) navigationgithub.com/go-openapi/jsonreference— JSON Reference parsinggithub.com/go-openapi/swag— JSON/YAML utilities, name manglinggithub.com/go-openapi/testify/v2— test-only assertions (zero-dep testify fork)
go test ./...Coding conventions are found beneath .github/copilot
- All
.gofiles must have SPDX license headers (Apache-2.0). - Commits require DCO sign-off (
git commit -s). - Linting:
golangci-lint run— config in.golangci.yml(posture:default: allwith explicit disables). - Every
//nolintdirective must have an inline comment explaining why. - Tests:
go test ./.... CI runs on{ubuntu, macos, windows} x {stable, oldstable}with-race. - Test framework:
github.com/go-openapi/testify/v2(notstretchr/testify;testifylintdoes not work).
See .github/copilot/ (symlinked to .claude/rules/) for detailed rules on Go conventions, linting, testing, and contributions.