@@ -33,14 +33,11 @@ interface TestFixture {
3333 }
3434 request : {
3535 method ?: string
36- path ?: string
36+ route ?: string
3737 body ?: unknown
3838 params ?: {
3939 [ key : string ] : string
4040 }
41- headers ?: {
42- [ key : string ] : string
43- }
4441 query ?: {
4542 [ key : string ] : string
4643 }
@@ -77,7 +74,7 @@ describe('The api validator', () => {
7774 } else {
7875 if ( fixture . validateArgs . requestBody || fixture . validateArgs . parameters ) {
7976 const operations : { [ method in OpenAPIV3 . HttpMethods ] ?: OpenAPIV3 . OperationObject < any > } = { }
80- spec . paths [ fixture . request . path ?? '/test' ] = operations
77+ spec . paths [ `/ ${ fixture . request . route } ` ?? '/test' ] = operations
8178 operations [ ( fixture . request . method as OpenAPIV3 . HttpMethods ) ?? 'post' ] = {
8279 requestBody : fixture . validateArgs . requestBody ,
8380 responses : { } ,
@@ -88,7 +85,11 @@ describe('The api validator', () => {
8885 const validator = new AjvOpenApiValidator ( spec )
8986
9087 if ( fixture . validateArgs . requestBody && fixture . request . body ) {
91- const result = validator . validateRequestBody ( fixture . request . path ?? '/test' , fixture . request . method ?? 'post' , fixture . request . body )
88+ const result = validator . validateRequestBody (
89+ `/${ fixture . request . route } ` ?? '/test' ,
90+ fixture . request . method ?? 'post' ,
91+ fixture . request . body
92+ )
9293 if ( fixture . expectedErrors ) {
9394 expect ( result ) . toEqual ( fixture . expectedErrors )
9495 } else {
@@ -117,11 +118,7 @@ describe('The api validator', () => {
117118 }
118119 }
119120 if ( operation . requestBody && fixture . request . body ) {
120- const result = validator . validateRequestBody (
121- fixture . request . path ?? '/test' ,
122- fixture . request . method ?? 'post' ,
123- fixture . request . body
124- )
121+ const result = validator . validateRequestBody ( path , methodName , fixture . request . body )
125122 if ( fixture . expectedErrors ) {
126123 expect ( result ) . toEqual ( fixture . expectedErrors )
127124 } else {
0 commit comments