Documentation ¶
Index ¶
- type DataResolver
- func (resolver *DataResolver) CollectHeaders(specResp *openapi3.Response) ([]ResolverExpectedHeader, error)
- func (resolver *DataResolver) Content(mt *openapi3.MediaType, CT string, v contract.Validator) error
- func (resolver *DataResolver) Headers(specResp *openapi3.Response, v contract.Validator) error
- func (resolver *DataResolver) Host(hostHint string) contract.ParameterSource
- func (resolver *DataResolver) MakeSchema(oasSchemaName string, oasSchema *openapi3.Schema) (*api.Schema, error)
- func (resolver *DataResolver) MetaData(status int64, CT string) (int, string, *openapi3.MediaType, *openapi3.Response, error)
- func (resolver *DataResolver) Response(status int64, CT string) contract.Validator
- func (resolver *DataResolver) Security(name string) contract.Security
- func (resolver *DataResolver) SecurityCredentials(scheme *openapi3.SecurityScheme) (string, string, string, error)
- func (resolver *DataResolver) SecurityName(name string) string
- type Operation
- type ResolverExpectedHeader
- type Spec
- func (spec *Spec) Description() string
- func (spec *Spec) GetOperation(name string) contract.Operation
- func (spec *Spec) IterateOverRequiredParameters(params *openapi3.Parameters, handler func(*openapi3.Parameter))
- func (spec *Spec) MakeOperation(method string, oasOp *openapi3.Operation, oasPath string, ...) contract.Operation
- func (spec *Spec) Operations() contract.OperationIterator
- func (spec *Spec) Title() string
- func (spec *Spec) Version() string
- type SpecParameterSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataResolver ¶
type DataResolver struct { contract.EntityTrait Spec *openapi3.Swagger Op *Operation SpecResponses *openapi3.Responses }
DataResolver provides spec data based on user input. OAS spec file may contain multiple definitions for everything, so this resolver helps to choose the right one among htem based on hints.
func NewDataResolver ¶
func NewDataResolver(log contract.Logger, spec *openapi3.Swagger, op *Operation, resps *openapi3.Responses) *DataResolver
NewDataResolver creates a new DataResolver instance.
func (*DataResolver) CollectHeaders ¶
func (resolver *DataResolver) CollectHeaders(specResp *openapi3.Response) ( []ResolverExpectedHeader, error, )
CollectHeaders collects the headers to expect in response.
func (*DataResolver) Content ¶
func (resolver *DataResolver) Content(mt *openapi3.MediaType, CT string, v contract.Validator) error
Content populates the provided validator with expectations for HTTP response body structure.
func (*DataResolver) Headers ¶
Headers populates the provided validator with expectations for HTTP headers.
func (*DataResolver) Host ¶
func (resolver *DataResolver) Host(hostHint string) contract.ParameterSource
Host returns a ParameterSource which contains a host name under the params.KeyHost key to be used in the URL parameter set.
func (*DataResolver) MakeSchema ¶
func (resolver *DataResolver) MakeSchema( oasSchemaName string, oasSchema *openapi3.Schema, ) (*api.Schema, error)
MakeSchema creates an api.Schema instance from available operation spec data. The schema is later used to test response contents (headers & bodies) against it.
func (*DataResolver) MetaData ¶
func (resolver *DataResolver) MetaData(status int64, CT string) ( int, string, *openapi3.MediaType, *openapi3.Response, error, )
MetaData populates the provided validator with expectations for HTTP status & content type.
func (*DataResolver) Response ¶
func (resolver *DataResolver) Response(status int64, CT string) contract.Validator
Response returns a Validator instance to test response correctness. Since there may be multiple responses in a OAS spec file, it selects on of them based on the arguments. If no status is supplied then 200 is used by default. If no CT is supplied then "application/json" is used by default.
func (*DataResolver) Security ¶
func (resolver *DataResolver) Security(name string) contract.Security
Security returns a security object to use in request.
func (*DataResolver) SecurityCredentials ¶
func (resolver *DataResolver) SecurityCredentials(scheme *openapi3.SecurityScheme) (string, string, string, error)
SecurityCredentials returns a username, password and token when available.
func (*DataResolver) SecurityName ¶
func (resolver *DataResolver) SecurityName(name string) string
SecurityName figures security scheme name from the operation.
type Operation ¶
type Operation struct { *api.OperationPrototype RequestMethod string RequestPath string SpecPath *openapi3.PathItem SpecOp *openapi3.Operation Resolver *DataResolver }
Operation provides access to OAS3-specific API data.
func (*Operation) Description ¶
Description returns an operation description.
func (*Operation) Resolve ¶
func (op *Operation) Resolve() contract.DataResolver
Resolve returns a DataResolver instance which is used to resolve data based on user input.
type ResolverExpectedHeader ¶
ResolverExpectedHeader is header to expect.
type Spec ¶
Spec is an OAS3-backed API test spec.
func (*Spec) Description ¶
Description return project description.
func (*Spec) GetOperation ¶
GetOperation returns a list of all available test operations from the spec.
func (*Spec) IterateOverRequiredParameters ¶
func (spec *Spec) IterateOverRequiredParameters(params *openapi3.Parameters, handler func(*openapi3.Parameter))
IterateOverRequiredParameters iterates over items in the provided parameter list and invokes the handler function for every required one.
func (*Spec) MakeOperation ¶
func (spec *Spec) MakeOperation( method string, oasOp *openapi3.Operation, oasPath string, oasPathItem *openapi3.PathItem, ) contract.Operation
MakeOperation creates an Operation instance from available spec data.
func (*Spec) Operations ¶
func (spec *Spec) Operations() contract.OperationIterator
Operations returns an iterable channel with operations.
type SpecParameterSource ¶
type SpecParameterSource struct { Params *openapi3.Parameters In string Name string }
SpecParameterSource provides access to spec data.
func HeadersParameterSource ¶
func HeadersParameterSource(p *openapi3.Parameters, name string) *SpecParameterSource
HeadersParameterSource creates a parameter source concerned with extracting the "header" parameters from a spec.
func PathParameterSource ¶
func PathParameterSource(p *openapi3.Parameters, name string) *SpecParameterSource
PathParameterSource creates a parameter source concerned with extracting the "path" parameters from a spec.
func QueryParameterSource ¶
func QueryParameterSource(p *openapi3.Parameters, name string) *SpecParameterSource
QueryParameterSource creates a parameter source concerned with extracting the "query" parameters from a spec.
func (*SpecParameterSource) Get ¶
func (ds *SpecParameterSource) Get(n string) string
Get retrieves the requested parameters from the spec parameter list.
func (*SpecParameterSource) Iterate ¶
func (ds *SpecParameterSource) Iterate() contract.ParameterIterator
Iterate returns an iterable channel to read parameter values.