Go library for validating OpenAPI v2 (Swagger) specifications and JSON Schema draft 4 data. Part of the go-openapi ecosystem. API is stable; maintenance-only.
| Package | Contents |
|---|---|
validate (root) |
Spec validator, schema validator, type/format/object/slice/string/number validators, result handling, pools |
post |
Post-validation transforms: ApplyDefaults and Prune |
Spec(doc, formats) error— high-level spec validationAgainstSchema(schema, data, formats, ...Option) error— validate data against a JSON schemaNewSchemaValidator(schema, root, path, formats, ...Option) *SchemaValidatorpost.ApplyDefaults(result)/post.Prune(result)
github.com/go-openapi/spec,analysis,loads,errors,strfmt
- 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 ./...with-race. CI runs on{ubuntu, macos, windows} x {stable, oldstable}. - Test framework:
github.com/go-openapi/testify/v2(notstretchr/testify).
See .github/copilot/ (symlinked to .claude/rules/) for detailed rules on Go conventions, linting, testing, and contributions.