File tree 6 files changed +44
-3
lines changed
__tests__/bundle/reference-ending-in-hash
6 files changed +44
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @redocly/openapi-core " : patch
3
+ " @redocly/cli " : patch
4
+ ---
5
+
6
+ Fixed an issue where ` $ref ` s ending in ` # ` (instead of ` #/ ` ) would break the application.
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.3
2
+ paths :
3
+ /pets/{petId} :
4
+ get :
5
+ responses :
6
+ ' 200 ' :
7
+ content :
8
+ application/json :
9
+ schema :
10
+ $ref : ' ./schemas/Pet.json#'
Original file line number Diff line number Diff line change
1
+ apis :
2
+ main :
3
+ root : ./openapi.yaml
Original file line number Diff line number Diff line change
1
+ {}
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [ `E2E bundle reference-ending-in-hash 1` ] = `
4
+ openapi: 3.0.3
5
+ paths:
6
+ /pets/{petId}:
7
+ get:
8
+ responses:
9
+ '200':
10
+ content:
11
+ application/json:
12
+ schema:
13
+ $ref: '#/components/schemas/Pet'
14
+ components:
15
+ schemas:
16
+ Pet: {}
17
+
18
+ bundling ./openapi.yaml...
19
+ 📦 Created a bundle for ./openapi.yaml at stdout <test>ms.
20
+
21
+ ` ;
Original file line number Diff line number Diff line change @@ -43,15 +43,15 @@ export function escapePointer<T extends string | number>(fragment: T): T {
43
43
}
44
44
45
45
export function parseRef ( ref : string ) : { uri : string | null ; pointer : string [ ] } {
46
- const [ uri , pointer ] = ref . split ( '#/ ' ) ;
46
+ const [ uri , pointer = '' ] = ref . split ( '#' ) ;
47
47
return {
48
48
uri : uri || null ,
49
- pointer : pointer ? pointer . split ( '/' ) . map ( unescapePointer ) . filter ( isTruthy ) : [ ] ,
49
+ pointer : parsePointer ( pointer ) ,
50
50
} ;
51
51
}
52
52
53
53
export function parsePointer ( pointer : string ) {
54
- return pointer . substr ( 2 ) . split ( '/' ) . map ( unescapePointer ) ;
54
+ return pointer . split ( '/' ) . map ( unescapePointer ) . filter ( isTruthy ) ;
55
55
}
56
56
57
57
export function pointerBaseName ( pointer : string ) {
You can’t perform that action at this time.
0 commit comments