Skip to content

Commit d8e419c

Browse files
authored
fix: resolve files specified in the rules and decorators parameters relative to the config file (#2259)
1 parent 6ef4216 commit d8e419c

File tree

22 files changed

+152
-33
lines changed

22 files changed

+152
-33
lines changed

.changeset/dull-singers-lick.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@redocly/openapi-core": patch
3+
"@redocly/cli": patch
4+
---
5+
6+
Fixed an issue where files specified in decorators parameters were not always resolved correctly.
7+
The resolution logic now properly locates the specified files relative to the config file for `info-description-override`, `media-type-examples-override`, `operation-description-override`, and `tag-description-override` decorators.

__tests__/bundle/info-description-override-error/redocly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ apis:
44

55
decorators:
66
info-description-override:
7-
filePath: ./test.md
7+
filePath: ./non-existing.md

__tests__/bundle/info-description-override-error/snapshot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[1] main.yaml:8:16 at #/info/description
22

33
Failed to read markdown override file for "info.description".
4-
ENOENT: no such file or directory, open './test.md'
4+
ENOENT: no such file or directory, open './__tests__/bundle/info-description-override-error/non-existing.md'
55

66
6 | title: Example OpenAPI 3 definition.
77
7 | version: 1.0.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: Test
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Foo
2+
- Bar
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
openapi: 3.1.0
2+
info:
3+
version: 1.0.0
4+
title: Test
5+
paths:
6+
/test:
7+
post:
8+
operationId: test
9+
requestBody:
10+
content:
11+
application/json:
12+
schema:
13+
$ref: '#/components/schemas/TestRequest'
14+
responses:
15+
'200':
16+
content:
17+
application/json:
18+
schema:
19+
type: array
20+
items:
21+
type: string
22+
components:
23+
schemas:
24+
TestRequest:
25+
type: object
26+
properties:
27+
name:
28+
type: string
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apis:
2+
main:
3+
root: openapi.yaml
4+
5+
decorators:
6+
media-type-examples-override:
7+
operationIds:
8+
test:
9+
request:
10+
application/json: ./examples/request.yaml
11+
responses:
12+
200:
13+
application/json: ./examples/response.yaml
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
openapi: 3.1.0
2+
info:
3+
version: 1.0.0
4+
title: Test
5+
paths:
6+
/test:
7+
post:
8+
operationId: test
9+
requestBody:
10+
content:
11+
application/json:
12+
schema:
13+
$ref: '#/components/schemas/TestRequest'
14+
examples:
15+
name: Test
16+
responses:
17+
'200':
18+
content:
19+
application/json:
20+
schema:
21+
type: array
22+
items:
23+
type: string
24+
examples:
25+
- Foo
26+
- Bar
27+
components:
28+
schemas:
29+
TestRequest:
30+
type: object
31+
properties:
32+
name:
33+
type: string
34+
35+
bundling openapi.yaml using configuration for api 'main'...
36+
📦 Created a bundle for openapi.yaml at stdout <test>ms.

__tests__/bundle/operation-description-override-error/redocly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ apis:
55
decorators:
66
operation-description-override:
77
operationIds:
8-
updatePet: ./update-pet-operation-description.md
8+
updatePet: ./non-existing.md

__tests__/bundle/operation-description-override-error/snapshot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[1] openapi.yaml:23:7 at #/paths/~1pet/put/operationId
22

33
Failed to read markdown override file for operation "updatePet".
4-
ENOENT: no such file or directory, open './update-pet-operation-description.md'
4+
ENOENT: no such file or directory, open './__tests__/bundle/operation-description-override-error/non-existing.md'
55

66
21 | summary: Update an existing pet
77
22 | description: ''

0 commit comments

Comments
 (0)