mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-10 04:21:20 +00:00
fix: hash ending path resolution fails (#1408)
This commit is contained in:
6
.changeset/soft-planets-watch.md
Normal file
6
.changeset/soft-planets-watch.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@redocly/openapi-core": patch
|
||||||
|
"@redocly/cli": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed an issue where `$ref`s ending in `#` (instead of `#/`) would break the application.
|
||||||
10
__tests__/bundle/reference-ending-in-hash/openapi.yaml
Normal file
10
__tests__/bundle/reference-ending-in-hash/openapi.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
openapi: 3.0.3
|
||||||
|
paths:
|
||||||
|
/pets/{petId}:
|
||||||
|
get:
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: './schemas/Pet.json#'
|
||||||
3
__tests__/bundle/reference-ending-in-hash/redocly.yaml
Normal file
3
__tests__/bundle/reference-ending-in-hash/redocly.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
apis:
|
||||||
|
main:
|
||||||
|
root: ./openapi.yaml
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
21
__tests__/bundle/reference-ending-in-hash/snapshot.js
Normal file
21
__tests__/bundle/reference-ending-in-hash/snapshot.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`E2E bundle reference-ending-in-hash 1`] = `
|
||||||
|
openapi: 3.0.3
|
||||||
|
paths:
|
||||||
|
/pets/{petId}:
|
||||||
|
get:
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Pet: {}
|
||||||
|
|
||||||
|
bundling ./openapi.yaml...
|
||||||
|
📦 Created a bundle for ./openapi.yaml at stdout <test>ms.
|
||||||
|
|
||||||
|
`;
|
||||||
@@ -43,15 +43,15 @@ export function escapePointer<T extends string | number>(fragment: T): T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function parseRef(ref: string): { uri: string | null; pointer: string[] } {
|
export function parseRef(ref: string): { uri: string | null; pointer: string[] } {
|
||||||
const [uri, pointer] = ref.split('#/');
|
const [uri, pointer = ''] = ref.split('#');
|
||||||
return {
|
return {
|
||||||
uri: uri || null,
|
uri: uri || null,
|
||||||
pointer: pointer ? pointer.split('/').map(unescapePointer).filter(isTruthy) : [],
|
pointer: parsePointer(pointer),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parsePointer(pointer: string) {
|
export function parsePointer(pointer: string) {
|
||||||
return pointer.substr(2).split('/').map(unescapePointer);
|
return pointer.split('/').map(unescapePointer).filter(isTruthy);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pointerBaseName(pointer: string) {
|
export function pointerBaseName(pointer: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user