Skip to content

net/http middleware to validate HTTP requests/responses against OpenAPI 3 schema using kin-openapi.

License

Notifications You must be signed in to change notification settings

aereal/go-openapi3-validation-middleware

Repository files navigation

CI PkgGoDev

go-openapi3-validation-middleware

net/http middleware to validate HTTP requests/responses against OpenAPI 3 schema using kin-openapi.

Installation

go get github.com/aereal/go-openapi3-validation-middleware

Synopsis

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.

About

net/http middleware to validate HTTP requests/responses against OpenAPI 3 schema using kin-openapi.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages