func (v OpenAPI3Validator) Validate(r HTTPResponse) ([]Failure, error) {
	failures := []Failure{}

	serverPath := v.doc.Servers[0].URL
	var path string
	serverIndex := strings.Index(r.Path, serverPath)
	if serverIndex != -1 {
		path = r.Path[serverIndex:]
	} else {
		path = serverPath + r.Path
	}

	httpReq, err := createHTTPReq(r.Method, path)
	if err != nil {
		return nil, err
	}

	route, pathParams, err := v.router.FindRoute(httpReq)
	if err != nil {
		return nil, err
	}

	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return nil, fmt.Errorf("OpenApi3Validator: error converting body %s", err)
	}

	// check body
	params := validateParams{
		httpReq:    httpReq,
		route:      route,
		pathParams: pathParams,
		statusCode: r.StatusCode,
		header:     r.Header,
		body:       body,
	}

	// accumulate failures
	err = v.validateResponse(params)
	if err != nil {
		return nil, fmt.Errorf("Validate error response:  %s", err.Error())
	}

	return failures, nil
}
// Validate - validates the response
validates the response
// Validate - validates the response
func (v OpenAPI3Validator) Validate(r HTTPResponse) ([]Failure, error) {
	failures := []Failure{}
	serverPath := v.doc.Servers[0].URL
	var path string
	serverIndex := strings.Index(r.Path, serverPath)
	if serverIndex != -1 {
		path = r.Path[serverIndex:]
	} else {
		path = serverPath + r.Path
	}
	httpReq, err := createHTTPReq(r.Method, path)
	if err != nil {
		return nil, err
	}
	route, pathParams, err := v.router.FindRoute(httpReq)
	if err != nil {
		return nil, err
	}
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return nil, fmt.Errorf("OpenApi3Validator: error converting body %s", err)
	}
	params := validateParams{
		httpReq:    httpReq,
		route:      route,
		pathParams: pathParams,
		statusCode: r.StatusCode,
		header:     r.Header,
		body:       body,
	}
	err = v.validateResponse(params)
	if err != nil {
		return nil, fmt.Errorf("Validate error response:  %s", err.Error())
	}
	return failures, nil
}
func ( v OpenAPI3Validator ) Validate ( r HTTPResponse ) ( [ ] Failure , error ) { failures := [ ] Failure { } serverPath := v . doc . Servers [ 0 ] . URL var path string serverIndex := strings . Index ( r . Path , serverPath ) if serverIndex != - 1 { path = r . Path [ serverIndex : ] } else { path = serverPath + r . Path } httpReq , err := createHTTPReq ( r . Method , path ) if err != nil { return nil , err } route , pathParams , err := v . router . FindRoute ( httpReq ) if err != nil { return nil , err } body , err := ioutil . ReadAll ( r . Body ) if err != nil { return nil , fmt . Errorf ( " " , err ) } params := validateParams { httpReq : httpReq , route : route , pathParams : pathParams , statusCode : r . StatusCode , header : r . Header , body : body , } err = v . validateResponse ( params ) if err != nil { return nil , fmt . Errorf ( " " , err . Error ( ) ) } return failures , nil }
validates the response
validates the response
// check body // accumulate failures