@@ -16,25 +16,20 @@ describe("bundle", () => {
16
16
const refParser = new $RefParser ( ) ;
17
17
const pathOrUrlOrSchema = path . resolve ( "lib" , "__tests__" , "spec" , "multiple-refs.json" ) ;
18
18
const schema = ( await refParser . bundle ( { pathOrUrlOrSchema } ) ) as any ;
19
+ // console.log(JSON.stringify(schema, null, 2));
19
20
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
32
22
const firstParam = schema . paths [ "/test1/{pathId}" ] . get . parameters [ 0 ] ;
33
23
const secondParam = schema . paths [ "/test2/{pathId}" ] . get . parameters [ 0 ] ;
34
24
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 ( {
38
33
name : "pathId" ,
39
34
in : "path" ,
40
35
required : true ,
0 commit comments