Documentation
¶
Index ¶
- Constants
- Variables
- func AddMethod(def *openapi3.T, path, method string) (*openapi3.Operation, string)
- func CallByMethodAndReturnBody(method *openapi3.Operation, nameOfPath, nameOfMethod string, ...) (hasChange bool, body io.ReadCloser, extraInfos *TestResult, ...)
- func EncodingParToString(def *openapi3.Schema, style string, value interface{}) string
- func GetBaseUrlFromServer(serv *openapi3.Server, args map[string]string) string
- func GetMethod(t *openapi3.T, args *CallConfig) (method *openapi3.Operation, nameOfPath string, nameOfMethod string, err error)
- func GetValue(p *ParameterSelection, name string, typ string, ...) (interface{}, error)
- func TestResponse(method *openapi3.Operation, body io.ReadCloser, extraInfos *TestResult, ...) (bool, error)
- func TestSchemaInResponse(typ string, schema *openapi3.Schema, bts []byte, contentTester DefHandler) (hasChange bool, obj interface{}, err error)
- type AscOrderedMap
- type CallConfig
- type CallingArgs
- type CallingPathArgs
- type DataResult
- type DefHandler
- type DescOrderedMap
- type Item
- type Items
- type OperationSelection
- type ParameterSelection
- type ParameterSelectionArray
- type PathSelection
- type RequestBodySelection
- type ResponseSelection
- type SecuritySelection
- type SignedCookieSession
- type TestResult
Constants ¶
View Source
const ( InputType_AsStandard = iota InputType_AsRawMap InputType_AsWholeRaw )
Variables ¶
View Source
var NullValue = errors.New("null value")
Functions ¶
func CallByMethodAndReturnBody ¶
func CallByMethodAndReturnBody(method *openapi3.Operation, nameOfPath, nameOfMethod string, server *openapi3.Server, args *CallConfig, fn DefHandler) (hasChange bool, body io.ReadCloser, extraInfos *TestResult, mSel *OperationSelection, statuscode int, err error)
CallByMethod 根据方法进行调用
func EncodingParToString ¶
将参数按风格转换为可用于参数设置等的字符串,用在query、path、header、cookie等参数的设置
func GetBaseUrlFromServer ¶
func GetMethod ¶
func GetMethod(t *openapi3.T, args *CallConfig) (method *openapi3.Operation, nameOfPath string, nameOfMethod string, err error)
GetMethod 按调用参数从配置中选择合适的method
func GetValue ¶
func GetValue(p *ParameterSelection, name string, typ string, others map[string]map[string]*ParameterSelection, inputs map[string]interface{}, handled map[string]interface{}, schemas openapi3.Schemas, encodings map[string]*openapi3.Encoding, ) (interface{}, error)
GetValue 返回对应的参数的计算值,name 待计算参数的名称,用于比较和过滤 typ 用于标注其他来源的参数 others 传入的其他参数, inputs 用户传入的输入 handled 用于在迭代过程中标注已经处理过的参数 def 传入的整体消息定义(注意:是整体的定义,以便在迭代过程中获取其他参数的定义) 返回: 1、具体处理后的值,使用interface{}以便兼容array、object、number和string等不同类型
func TestResponse ¶
func TestResponse(method *openapi3.Operation, body io.ReadCloser, extraInfos *TestResult, mSel *OperationSelection, statuscode int, fn DefHandler) (bool, error)
func TestSchemaInResponse ¶
func TestSchemaInResponse(typ string, schema *openapi3.Schema, bts []byte, contentTester DefHandler) (hasChange bool, obj interface{}, err error)
对返回结果进行测试
Types ¶
type AscOrderedMap ¶
type AscOrderedMap map[string]interface{}
func (AscOrderedMap) Strings ¶
func (a AscOrderedMap) Strings() []string
type CallConfig ¶
type CallConfig struct {
Def json.RawMessage
Selection CallingArgs
Session *SignedCookieSession
EmulatedUrl string //不经过server选择,直接使用某个baseURL
Input map[string]interface{}
NameOfPath string
NameOfMethod string
DisableSslCheck bool //不验证服务器证书
ShowCertification bool //将证书内容返回
Origin string //请求的原始地址
InputType int //input模式
Header http.Header //用于非标模式下Header数据的存储
Query url.Values //用于非标模式下Query数据的存储
PathVars url.Values //解析url中的变量
RequestBody interface{} //用于非标模式下Body数据的存储
RequestType string //用于非标模式下Body数据的存储
}
type CallingArgs ¶
type CallingPathArgs ¶
type CallingPathArgs interface {
GetByMethod(method string) *OperationSelection
}
type DataResult ¶
用于表示返回结果的内置结构体
func (*DataResult) MarshalJSON ¶
func (s *DataResult) MarshalJSON() ([]byte, error)
func (*DataResult) MarshalXML ¶
func (s *DataResult) MarshalXML(e *xml.Encoder, start xml.StartElement) error
StringMap marshals into XML.
func (*DataResult) UnmarshalJSON ¶
func (s *DataResult) UnmarshalJSON(data []byte) error
func (*DataResult) UnmarshalXML ¶
func (s *DataResult) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type DefHandler ¶
type DescOrderedMap ¶
type DescOrderedMap map[string]interface{}
func (DescOrderedMap) Strings ¶
func (a DescOrderedMap) Strings() []string
type OperationSelection ¶
type OperationSelection struct {
Response *ResponseSelection `goblet:"response" json:"response,omitempty"`
Security *SecuritySelection `goblet:"security" json:"security,omitempty"`
Opened bool `goblet:"opened" json:"opened,omitempty"`
Parameters ParameterSelectionArray `goblet:"parameters" json:"parameters,omitempty"`
RequestBody *RequestBodySelection `goblet:"requestBody" json:"requestBody,omitempty"`
InputMode string `goblet:"input_mode" json:"input_mode"`
}
type ParameterSelection ¶
type ParameterSelectionArray ¶
type ParameterSelectionArray []*ParameterSelection
func (*ParameterSelectionArray) ToMap ¶
func (p *ParameterSelectionArray) ToMap(defs openapi3.Parameters) map[string]*ParameterSelection
type PathSelection ¶
type PathSelection struct {
Connect *OperationSelection `goblet:"connect" json:"connect,omitempty" yaml:"connect,omitempty"`
Delete *OperationSelection `goblet:"delete" json:"delete,omitempty" yaml:"delete,omitempty"`
Get *OperationSelection `goblet:"get" json:"get,omitempty" yaml:"get,omitempty"`
Head *OperationSelection `goblet:"head" json:"head,omitempty" yaml:"head,omitempty"`
Options *OperationSelection `goblet:"options" json:"options,omitempty" yaml:"options,omitempty"`
Patch *OperationSelection `goblet:"patch" json:"patch,omitempty" yaml:"patch,omitempty"`
Post *OperationSelection `goblet:"post" json:"post,omitempty" yaml:"post,omitempty"`
Put *OperationSelection `goblet:"put" json:"put,omitempty" yaml:"put,omitempty"`
Trace *OperationSelection `goblet:"trace" json:"trace,omitempty" yaml:"trace,omitempty"`
}
func (*PathSelection) AddByMethod ¶
func (p *PathSelection) AddByMethod(name string, selection ...*OperationSelection) *OperationSelection
func (*PathSelection) GetByMethod ¶
func (p *PathSelection) GetByMethod(name string) *OperationSelection
type RequestBodySelection ¶
type RequestBodySelection struct {
Default string `goblet:"default" json:"default,omitempty"`
Inputs map[string]*ParameterSelection `goblet:"inputs" json:"inputs,omitempty"`
Order []string `goblet:"order" json:"order,omitempty"` //参数的渲染顺序,可调
}
type ResponseSelection ¶
type ResponseSelection struct {
Default string `goblet:"default" json:"default"`
}
type SecuritySelection ¶
type SignedCookieSession ¶
type TestResult ¶
type TestResult struct {
Raw string `json:"raw"` //原始的返回值
Url string `json:"url"`
Header http.Header `json:"Header"`
Request interface{} `json:"request"`
Response json.RawMessage `json:"response"`
Def string `json:"def"`
Parsed interface{} `json:"parsed"`
X509 *x509.Certificate `json:"x509"`
Type string `json:"type"`
}
Click to show internal directories.
Click to hide internal directories.