@@ -13,7 +13,7 @@ import (
1313 "github.com/pb33f/libopenapi/orderedmap"
1414)
1515
16- func RequestContentTypeNotFound (op * v3.Operation , request * http.Request ) * ValidationError {
16+ func RequestContentTypeNotFound (op * v3.Operation , request * http.Request , specPath string ) * ValidationError {
1717 ct := request .Header .Get (helpers .ContentTypeHeader )
1818 var ctypes []string
1919 for pair := orderedmap .First (op .RequestBody .Content ); pair != nil ; pair = pair .Next () {
@@ -26,23 +26,29 @@ func RequestContentTypeNotFound(op *v3.Operation, request *http.Request) *Valida
2626 request .Method , ct ),
2727 Reason : fmt .Sprintf ("The content type '%s' of the %s request submitted has not " +
2828 "been defined, it's an unknown type" , ct , request .Method ),
29- SpecLine : op .RequestBody .GoLow ().Content .KeyNode .Line ,
30- SpecCol : op .RequestBody .GoLow ().Content .KeyNode .Column ,
31- Context : op ,
32- HowToFix : fmt .Sprintf (HowToFixInvalidContentType , orderedmap .Len (op .RequestBody .Content ), strings .Join (ctypes , ", " )),
29+ SpecLine : op .RequestBody .GoLow ().Content .KeyNode .Line ,
30+ SpecCol : op .RequestBody .GoLow ().Content .KeyNode .Column ,
31+ Context : op ,
32+ HowToFix : fmt .Sprintf (HowToFixInvalidContentType , orderedmap .Len (op .RequestBody .Content ), strings .Join (ctypes , ", " )),
33+ RequestPath : request .URL .Path ,
34+ RequestMethod : request .Method ,
35+ SpecPath : specPath ,
3336 }
3437}
3538
36- func OperationNotFound (pathItem * v3.PathItem , request * http.Request , method string ) * ValidationError {
39+ func OperationNotFound (pathItem * v3.PathItem , request * http.Request , method string , specPath string ) * ValidationError {
3740 return & ValidationError {
3841 ValidationType : helpers .RequestValidation ,
3942 ValidationSubType : helpers .RequestMissingOperation ,
4043 Message : fmt .Sprintf ("%s operation request content type '%s' does not exist" ,
4144 request .Method , method ),
42- Reason : fmt .Sprintf ("The path was found, but there was no '%s' method found in the spec" , request .Method ),
43- SpecLine : pathItem .GoLow ().KeyNode .Line ,
44- SpecCol : pathItem .GoLow ().KeyNode .Column ,
45- Context : pathItem ,
46- HowToFix : HowToFixPathMethod ,
45+ Reason : fmt .Sprintf ("The path was found, but there was no '%s' method found in the spec" , request .Method ),
46+ SpecLine : pathItem .GoLow ().KeyNode .Line ,
47+ SpecCol : pathItem .GoLow ().KeyNode .Column ,
48+ Context : pathItem ,
49+ HowToFix : HowToFixPathMethod ,
50+ RequestPath : request .URL .Path ,
51+ RequestMethod : request .Method ,
52+ SpecPath : specPath ,
4753 }
4854}
0 commit comments