File tree Expand file tree Collapse file tree 5 files changed +81
-1
lines changed
Expand file tree Collapse file tree 5 files changed +81
-1
lines changed Original file line number Diff line number Diff line change 210210 }
211211 },
212212 "type" : " warning"
213+ },
214+ {
215+ "code" : " request.content-type.incompatible" ,
216+ "message" : " Request Content-Type header is incompatible with the mime-types the spec accepts to consume" ,
217+ "mockDetails" : {
218+ "interactionDescription" : " should error about incorrect request content type" ,
219+ "interactionState" : " [none]" ,
220+ "location" : " [root].interactions[9].request.headers.content-type" ,
221+ "value" : " unknown"
222+ },
223+ "specDetails" : {
224+ "location" : " [root].paths./submit.post.requestBody.content" ,
225+ "pathMethod" : " post" ,
226+ "pathName" : " /submit" ,
227+ "value" : [
228+ " application/json"
229+ ]
230+ },
231+ "type" : " error"
213232 }
214233]
Original file line number Diff line number Diff line change @@ -43,6 +43,19 @@ paths:
4343 description : Bad request
4444 content :
4545 application/json : {}
46+ /submit :
47+ post :
48+ requestBody :
49+ required : true
50+ content :
51+ application/json :
52+ schema : {}
53+ responses :
54+ " 400 " :
55+ description : Bad request
56+ content :
57+ " application/json " :
58+ schema : {}
4659 /no-response :
4760 get :
4861 responses :
Original file line number Diff line number Diff line change 190190 "Content-Type" : " application/json"
191191 }
192192 }
193+ },
194+ {
195+ "description" : " should error about incorrect request content type" ,
196+ "providerState" : " " ,
197+ "request" : {
198+ "method" : " POST" ,
199+ "path" : " /submit" ,
200+ "headers" : {
201+ "content-type" : " unknown"
202+ },
203+ "body" : " unknown"
204+ },
205+ "response" : {
206+ "status" : 400 ,
207+ "headers" : {
208+ "Content-Type" : " application/json"
209+ }
210+ }
193211 }
194212 ]
195213}
Original file line number Diff line number Diff line change 199199 }
200200 },
201201 "type" : " warning"
202+ },
203+ {
204+ "code" : " request.content-type.incompatible" ,
205+ "message" : " Request Content-Type header is incompatible with the mime-types the spec accepts to consume" ,
206+ "mockDetails" : {
207+ "interactionDescription" : " should error about incorrect request content type" ,
208+ "interactionState" : " [none]" ,
209+ "location" : " [root].interactions[9].request.headers.content-type" ,
210+ "value" : " unknown"
211+ },
212+ "specDetails" : {
213+ "location" : " [root].paths./submit.post.requestBody.content" ,
214+ "pathMethod" : " post" ,
215+ "pathName" : " /submit" ,
216+ "value" : [
217+ " application/json"
218+ ]
219+ },
220+ "type" : " error"
202221 }
203222]
Original file line number Diff line number Diff line change @@ -24,6 +24,17 @@ export function* compareResHeader(
2424) : Iterable < Result > {
2525 const { method, oas, operation, path } = route . store ;
2626
27+ const allAvailableResponseContentTypes =
28+ operation . produces ||
29+ Object . entries ( operation . responses ) . reduce (
30+ ( acc : string [ ] , [ _status , response ] ) => {
31+ return [
32+ ...acc ,
33+ ...Object . keys ( dereferenceOas ( response || { } , oas ) ?. content || { } ) ,
34+ ] ;
35+ } ,
36+ [ ] ,
37+ ) ;
2738 const availableResponseContentType =
2839 operation . produces ||
2940 Object . keys (
@@ -41,7 +52,7 @@ export function* compareResHeader(
4152 const responseContentType =
4253 responseHeaders . get ( "content-type" ) ?. split ( ";" ) [ 0 ] || "" ;
4354
44- if ( responseContentType && ! availableResponseContentType . length ) {
55+ if ( responseContentType && ! allAvailableResponseContentTypes . length ) {
4556 yield {
4657 code : "response.content-type.unknown" ,
4758 message :
You can’t perform that action at this time.
0 commit comments