Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aereal/go-openapi3-validation-middleware
net/http middleware to validate HTTP requests/responses against OpenAPI 3 schema using kin-openapi.
https://github.com/aereal/go-openapi3-validation-middleware
go golang openapi3
Last synced: 3 months ago
JSON representation
net/http middleware to validate HTTP requests/responses against OpenAPI 3 schema using kin-openapi.
- Host: GitHub
- URL: https://github.com/aereal/go-openapi3-validation-middleware
- Owner: aereal
- License: mit
- Created: 2021-06-10T07:13:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-11T18:32:29.000Z (4 months ago)
- Last Synced: 2024-10-15T15:44:23.431Z (4 months ago)
- Topics: go, golang, openapi3
- Language: Go
- Homepage:
- Size: 48.8 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![CI][ci-status]
[![PkgGoDev][pkg-go-dev-badge]][pkg-go-dev]# go-openapi3-validation-middleware
net/http middleware to validate HTTP requests/responses against OpenAPI 3 schema using [kin-openapi][].
## Installation
```sh
go get github.com/aereal/go-openapi3-validation-middleware
```## Synopsis
```go
import (
"net/http""github.com/aereal/go-openapi3-validation-middleware"
"github.com/getkin/kin-openapi/routers"
)func main() {
var router routers.Router // must be built with certain way
mw := openapi3middleware.WithValidation(openapi3middleware.MiddlewareOptions{Router: router})
http.Handle("/", mw(http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
// this handler is called if validation succeeds
})))
}
```## License
See LICENSE file.
[pkg-go-dev]: https://pkg.go.dev/github.com/aereal/go-openapi3-validation-middleware
[pkg-go-dev-badge]: https://pkg.go.dev/badge/aereal/go-openapi3-validation-middleware
[ci-status]: https://github.com/aereal/go-openapi3-validation-middleware/workflows/CI/badge.svg?branch=main
[kin-openapi]: https://github.com/getkin/kin-openapi