This package provides structured error types for the go-openapi/go-swagger ecosystem.
It defines an Error interface (with an HTTP status code and message) and concrete types
for validation failures, parsing errors, authentication errors, and HTTP middleware errors.
| File | Contents |
|---|---|
api.go |
Core Error interface, constructors (New, NotFound, NotImplemented, MethodNotAllowed), ServeError HTTP handler |
schema.go |
Validation struct, CompositeError, ~30 validation constructors, error code constants |
headers.go |
InvalidContentType, InvalidResponseFormat |
parsing.go |
ParseError struct for parameter parsing failures |
auth.go |
Unauthenticated constructor |
middleware.go |
APIVerificationFailed for spec/registration mismatches |
- Error codes >= 600 are domain codes (not HTTP);
ServeErrormaps them to 422. - All error types implement
json.Marshalerfor structured JSON responses. - Zero runtime dependencies outside the Go standard library.
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.