1- import { normalize } from '../../src'
1+ import { normalize , RefErrorType , RefErrorTypes } from '../../src'
22import source31x from '../resources/openapi31x.json'
33import source30x from '../resources/openapi30x.json'
44import { JsonPath } from '@netcracker/qubership-apihub-json-crawl'
@@ -7,7 +7,8 @@ import { ErrorMessage } from '../../src/errors'
77interface Error {
88 readonly message : string ,
99 readonly path : JsonPath ,
10- readonly ref : unknown
10+ readonly ref : unknown ,
11+ readonly errorType : RefErrorType
1112}
1213
1314describe ( 'merge allof in openapi schema' , function ( ) {
@@ -128,7 +129,7 @@ describe('merge allof in openapi schema', function () {
128129 const errors : Error [ ] = [ ]
129130 const result = normalize ( { ...documentFragment , openapi : '3.0.0' } , {
130131 source : documentSource ,
131- onRefResolveError : ( message , path , ref ) => errors . push ( { message, path, ref : ref } ) ,
132+ onRefResolveError : ( message , path , ref , errorType ) => errors . push ( { message, path, ref : ref , errorType } ) ,
132133 } )
133134 const expected = {
134135 openapi : '3.0.0' ,
@@ -170,19 +171,22 @@ describe('merge allof in openapi schema', function () {
170171 expect ( result ) . toEqual ( expected )
171172 expect ( errors ) . toEqual ( [
172173 {
173- message : ErrorMessage . richRefObjectNotAllowed ( ) ,
174+ message : ErrorMessage . richRefObjectNotAllowed ( '#/components/schemas/Human' ) ,
174175 path : [ 'paths' , 'humans' , 'get' , 'responses' , '200' , 'content' , 'application/json' , 'schema' , 'items' ] ,
175176 ref : '#/components/schemas/Human' ,
177+ errorType : RefErrorTypes . RICH_REF_NOT_ALLOWED
176178 } ,
177179 {
178- message : ErrorMessage . richRefObjectNotAllowed ( ) ,
180+ message : ErrorMessage . richRefObjectNotAllowed ( '#/components/schemas/Location' ) ,
179181 path : [ 'paths' , 'humans' , 'get' , 'responses' , '200' , 'content' , 'application/json' , 'schema' , 'items' , 'properties' , 'location' ] ,
180182 ref : '#/components/schemas/Location' ,
183+ errorType : RefErrorTypes . RICH_REF_NOT_ALLOWED
181184 } ,
182185 {
183- message : ErrorMessage . richRefObjectNotAllowed ( ) ,
186+ message : ErrorMessage . richRefObjectNotAllowed ( '#/components/schemas/Human' ) ,
184187 path : [ 'paths' , 'humans' , 'get' , 'responses' , '200' , 'content' , 'application/json' , 'schema' , 'items' , 'properties' , 'location' , 'allOf' , 0 , 'properties' , 'ownedBy' ] ,
185188 ref : '#/components/schemas/Human' ,
189+ errorType : RefErrorTypes . RICH_REF_NOT_ALLOWED
186190 } ,
187191 ] as Error [ ] )
188192 } )
0 commit comments