@@ -16,25 +16,20 @@ describe("bundle", () => {
1616 const refParser = new $RefParser ( ) ;
1717 const pathOrUrlOrSchema = path . resolve ( "lib" , "__tests__" , "spec" , "multiple-refs.json" ) ;
1818 const schema = ( await refParser . bundle ( { pathOrUrlOrSchema } ) ) as any ;
19+ // console.log(JSON.stringify(schema, null, 2));
1920
20- // First reference should be fully resolved (no $ref)
21- expect ( schema . paths [ "/test1/{pathId}" ] . get . parameters [ 0 ] . name ) . toBe ( "pathId" ) ;
22- expect ( schema . paths [ "/test1/{pathId}" ] . get . parameters [ 0 ] . schema . type ) . toBe ( "string" ) ;
23- expect ( schema . paths [ "/test1/{pathId}" ] . get . parameters [ 0 ] . schema . format ) . toBe ( "uuid" ) ;
24- expect ( schema . paths [ "/test1/{pathId}" ] . get . parameters [ 0 ] . $ref ) . toBeUndefined ( ) ;
25-
26- // Second reference should be remapped to point to the first reference
27- expect ( schema . paths [ "/test2/{pathId}" ] . get . parameters [ 0 ] . $ref ) . toBe (
28- "#/paths/~1test1~1%7BpathId%7D/get/parameters/0" ,
29- ) ;
30-
31- // Both should effectively resolve to the same data
21+ // Both parameters should now be $ref to the same internal definition
3222 const firstParam = schema . paths [ "/test1/{pathId}" ] . get . parameters [ 0 ] ;
3323 const secondParam = schema . paths [ "/test2/{pathId}" ] . get . parameters [ 0 ] ;
3424
35- // The second parameter should resolve to the same data as the first
36- expect ( secondParam . $ref ) . toBeDefined ( ) ;
37- expect ( firstParam ) . toEqual ( {
25+ // The $ref should match the output structure in file_context_0
26+ expect ( firstParam . $ref ) . toBe ( "#/components/parameters/path-parameter_pathId" ) ;
27+ expect ( secondParam . $ref ) . toBe ( "#/components/parameters/path-parameter_pathId" ) ;
28+
29+ // The referenced parameter should exist and match the expected structure
30+ expect ( schema . components ) . toBeDefined ( ) ;
31+ expect ( schema . components . parameters ) . toBeDefined ( ) ;
32+ expect ( schema . components . parameters [ "path-parameter_pathId" ] ) . toEqual ( {
3833 name : "pathId" ,
3934 in : "path" ,
4035 required : true ,
0 commit comments