openapi

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(authorizer *Authorizer, openapi *Schema) func(http.Handler) http.Handler

Middleware returns a function that generates per-request middleware functions.

Types

type Authorizer

type Authorizer struct {
	// contains filtered or unexported fields
}

Authorizer provides OpenAPI based authorization middleware.

func NewAuthorizer

func NewAuthorizer(issuer *jose.JWTIssuer) *Authorizer

NewAuthorizer returns a new authorizer with required parameters.

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema abstracts schema access and validation.

func NewSchema

func NewSchema() (*Schema, error)

NewOpenRpi extracts the swagger document. NOTE: this is surprisingly slow, make sure you cache it and reuse it.

func (*Schema) FindRoute

func (s *Schema) FindRoute(r *http.Request) (*routers.Route, map[string]string, error)

FindRoute looks up the route from the specification.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator provides Schema validation of request and response codes, media, and schema validation of payloads to ensure we are meeting the specification.

func NewValidator

func NewValidator(authorizer *Authorizer, next http.Handler, openapi *Schema) *Validator

NewValidator returns an initialized validator middleware.

func (*Validator) ServeHTTP

func (v *Validator) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL