summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-openapi/runtime/middleware/validation.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-openapi/runtime/middleware/validation.go')
-rw-r--r--vendor/github.com/go-openapi/runtime/middleware/validation.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/vendor/github.com/go-openapi/runtime/middleware/validation.go b/vendor/github.com/go-openapi/runtime/middleware/validation.go
index bb8df3cb3d..1f0135b578 100644
--- a/vendor/github.com/go-openapi/runtime/middleware/validation.go
+++ b/vendor/github.com/go-openapi/runtime/middleware/validation.go
@@ -20,8 +20,9 @@ import (
"strings"
"github.com/go-openapi/errors"
- "github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
+
+ "github.com/go-openapi/runtime"
)
type validation struct {
@@ -115,7 +116,10 @@ func (v *validation) contentType() {
}
func (v *validation) responseFormat() {
- if str, rCtx := v.context.ResponseFormat(v.request, v.route.Produces); str == "" && runtime.HasBody(v.request) {
+ // if the route provides values for Produces and no format could be identify then return an error.
+ // if the route does not specify values for Produces then treat request as valid since the API designer
+ // choose not to specify the format for responses.
+ if str, rCtx := v.context.ResponseFormat(v.request, v.route.Produces); str == "" && len(v.route.Produces) > 0 {
v.request = rCtx
v.result = append(v.result, errors.InvalidResponseFormat(v.request.Header.Get(runtime.HeaderAccept), v.route.Produces))
}