lib

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDocumentFromFile

func NewDocumentFromFile(filePath string) (openapi.Document, error)

NewDocumentFromFile creates a new Document from a file path. It uses libopenapi to parse the file and then builds a model. Circular references are handled by logging the error and returning Document without errors.

func NewSchema

func NewSchema(schema *base.Schema, parseConfig *config.ParseConfig) *openapi.Schema

NewSchema creates a new Schema from a libopenapi Schema.

func NewValidator

func NewValidator(doc openapi.Document) openapi.Validator

NewValidator creates a new Validator using the libopenapi-validator library

Types

type V2Document

type V2Document struct {
	*libopenapi.DocumentModel[v2high.Swagger]
	ParseConfig *config.ParseConfig
}

V2Document is a wrapper around libopenapi.DocumentModel Implements Document interface

func (*V2Document) FindOperation

func (d *V2Document) FindOperation(options *openapi.OperationDescription) openapi.Operation

FindOperation finds an operation by resource and method.

func (*V2Document) GetResources

func (d *V2Document) GetResources() map[string][]string

GetResources returns a map of resource names and their methods.

func (*V2Document) GetVersion

func (d *V2Document) GetVersion() string

GetVersion returns the version of the document

func (*V2Document) Provider

func (d *V2Document) Provider() config.SchemaProvider

Provider returns the SchemaProvider for this document

type V2Operation

type V2Operation struct {
	*v2high.Operation
	ParseConfig *config.ParseConfig
	// contains filtered or unexported fields
}

V2Operation is a wrapper around libopenapi.Operation

func (*V2Operation) GetParameters

func (op *V2Operation) GetParameters() openapi.Parameters

GetParameters returns a list of parameters for this operation

func (*V2Operation) GetRequestBody

func (op *V2Operation) GetRequestBody() (*openapi.Schema, string)

GetRequestBody returns the request body for this operation

func (*V2Operation) GetResponse

func (op *V2Operation) GetResponse() *openapi.Response

GetResponse returns the response for this operation

func (*V2Operation) ID

func (op *V2Operation) ID() string

ID returns the operation ID

func (*V2Operation) WithParseConfig

func (op *V2Operation) WithParseConfig(parseConfig *config.ParseConfig) openapi.Operation

WithParseConfig sets the ParseConfig for the operation

type V3Document

type V3Document struct {
	*libopenapi.DocumentModel[v3high.Document]
}

V3Document is a wrapper around libopenapi.DocumentModel Implements Document interface

func (*V3Document) FindOperation

func (d *V3Document) FindOperation(options *openapi.OperationDescription) openapi.Operation

FindOperation finds an operation by resource and method.

func (*V3Document) GetResources

func (d *V3Document) GetResources() map[string][]string

GetResources returns a map of resource names and their methods.

func (*V3Document) GetVersion

func (d *V3Document) GetVersion() string

GetVersion returns the version of the document

func (*V3Document) Provider

func (d *V3Document) Provider() config.SchemaProvider

Provider returns the SchemaProvider for this document

type V3Operation

type V3Operation struct {
	*v3high.Operation
	// contains filtered or unexported fields
}

V3Operation is a wrapper around libopenapi.Operation

func (*V3Operation) GetParameters

func (op *V3Operation) GetParameters() openapi.Parameters

GetParameters returns a list of parameters for the operation

func (*V3Operation) GetRequestBody

func (op *V3Operation) GetRequestBody() (*openapi.Schema, string)

GetRequestBody returns the request body for the operation.

func (*V3Operation) GetResponse

func (op *V3Operation) GetResponse() *openapi.Response

GetResponse returns the response for the operation. If no response is defined, a default response is returned. Responses are prioritized by status code, with 200 being the highest priority.

func (*V3Operation) ID

func (op *V3Operation) ID() string

ID returns the operation ID

func (*V3Operation) WithParseConfig

func (op *V3Operation) WithParseConfig(parseConfig *config.ParseConfig) openapi.Operation

WithParseConfig sets the ParseConfig for the operation.

type Validator

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

func (*Validator) ValidateRequest

func (v *Validator) ValidateRequest(req *openapi.GeneratedRequest) []error

ValidateRequest validates a GeneratedRequest against the OpenAPI document. Implements Validator interface.

func (*Validator) ValidateResponse

func (v *Validator) ValidateResponse(res *openapi.GeneratedResponse) []error

ValidateResponse validates a response against the OpenAPI document. Implements Validator interface.

Jump to

Keyboard shortcuts

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