File tree Expand file tree Collapse file tree 6 files changed +83
-5
lines changed
__tests__/fixtures/oas-references Expand file tree Collapse file tree 6 files changed +83
-5
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @pactflow/openapi-pact-comparator " : minor
3+ ---
4+
5+ Handle URI encoding in OAS references
Original file line number Diff line number Diff line change 99 parameters :
1010 - $ref : " #/components/parameters/Request.Param"
1111 - $ref : " #/components/parameters/nested.param~1with~0tilde"
12+ - $ref : " #/components/parameters/nested.param.with%7Bbrackets%7D"
1213 requestBody :
1314 $ref : " #/components/requestBodies/Request.Body"
1415 responses :
@@ -39,6 +40,12 @@ components:
3940 required : true
4041 schema :
4142 type : string
43+ " nested.param.with{brackets} " :
44+ in : query
45+ name : bracket
46+ required : true
47+ schema :
48+ type : string
4249 requestBodies :
4350 Request.Body :
4451 required : true
Original file line number Diff line number Diff line change 3131 },
3232 "type" : " error"
3333 },
34+ {
35+ "code" : " request.query.incompatible" ,
36+ "message" : " Value is incompatible with the parameter defined in the spec file: must be string" ,
37+ "mockDetails" : {
38+ "interactionDescription" : " should fail with missing parameters" ,
39+ "interactionState" : " [none]" ,
40+ "location" : " [root].interactions[1].request.query.bracket"
41+ },
42+ "specDetails" : {
43+ "location" : " [root].paths./login.post.parameters[2].schema.type" ,
44+ "pathMethod" : " post" ,
45+ "pathName" : " /login" ,
46+ "value" : " string"
47+ },
48+ "type" : " error"
49+ },
3450 {
3551 "code" : " request.body.incompatible" ,
3652 "message" : " Request body is incompatible with the request body schema in the spec file: must have required property 'username'" ,
Original file line number Diff line number Diff line change 77 "request" : {
88 "method" : " POST" ,
99 "path" : " /login" ,
10- "query" : " account=foo&nested=bar" ,
10+ "query" : " account=foo&nested=bar&bracket=baz " ,
1111 "headers" : {
1212 "Content-Type" : " application/json"
1313 },
4949 "request" : {
5050 "method" : " POST" ,
5151 "path" : " /login" ,
52- "query" : " account=foo&nested=bar" ,
52+ "query" : " account=foo&nested=bar&bracket=baz " ,
5353 "headers" : {
5454 "Content-Type" : " application/json"
5555 },
6767 "request" : {
6868 "method" : " POST" ,
6969 "path" : " /login" ,
70- "query" : " account=foo&nested=bar" ,
70+ "query" : " account=foo&nested=bar&bracket=baz " ,
7171 "headers" : {
7272 "Content-Type" : " application/json"
7373 },
9090 "request" : {
9191 "method" : " POST" ,
9292 "path" : " /login" ,
93- "query" : " account=foo&nested=bar" ,
93+ "query" : " account=foo&nested=bar&bracket=baz " ,
9494 "headers" : {
9595 "Content-Type" : " application/json"
9696 },
Original file line number Diff line number Diff line change 8383 },
8484 "type" : " error"
8585 },
86+ {
87+ "code" : " request.query.incompatible" ,
88+ "message" : " Value is incompatible with the parameter defined in the spec file: must have required property 'value'" ,
89+ "mockDetails" : {
90+ "interactionDescription" : " should fail with missing parameters" ,
91+ "interactionState" : " [none]" ,
92+ "location" : " [root].interactions[1]" ,
93+ "value" : {
94+ "description" : " should fail with missing parameters" ,
95+ "request" : {
96+ "method" : " POST" ,
97+ "path" : " /login" ,
98+ "headers" : {
99+ "Content-Type" : " application/json"
100+ },
101+ "body" : {
102+ "username" : " bob"
103+ }
104+ },
105+ "response" : {
106+ "status" : 201 ,
107+ "body" : {
108+ "id" : " 123"
109+ }
110+ }
111+ }
112+ },
113+ "specDetails" : {
114+ "location" : " [root].paths./login.post.parameters[2]" ,
115+ "pathMethod" : " post" ,
116+ "pathName" : " /login" ,
117+ "value" : {
118+ "in" : " query" ,
119+ "name" : " bracket" ,
120+ "required" : true ,
121+ "schema" : {
122+ "type" : " string"
123+ }
124+ }
125+ },
126+ "type" : " error"
127+ },
86128 {
87129 "code" : " request.body.incompatible" ,
88130 "message" : " Request body is incompatible with the request body schema in the spec file: must have required property 'username'" ,
175217 "schema" : {
176218 "type" : " string"
177219 }
220+ },
221+ {
222+ "in" : " query" ,
223+ "name" : " bracket" ,
224+ "required" : true ,
225+ "schema" : {
226+ "type" : " string"
227+ }
178228 }
179229 ],
180230 "requestBody" : {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { SchemaObject } from "ajv";
33import { each , get } from "lodash-es" ;
44
55const unescape = ( subpath : string ) =>
6- subpath . replaceAll ( "~1" , "/" ) . replaceAll ( "~0" , "~" ) ;
6+ decodeURI ( subpath . replaceAll ( "~1" , "/" ) . replaceAll ( "~0" , "~" ) ) ;
77
88export const splitPath = ( path : string ) => {
99 if ( path . startsWith ( "#/" ) ) {
You can’t perform that action at this time.
0 commit comments