redocly-cli
redocly-cli copied to clipboard
Issue with path resolving in the configuration file
Describe the bug
If using the --config
option to specify the path to a configuration file, an issue occurs when the specified config file is located at a different directory level compared to the command execution directory. In such cases, path resolution works incorrectly
To Reproduce
- File Tree structure:
├── folder1
│ ├── subfolder
│ │ └── redocly.yaml
├── folder2
│ ├── openapi.yaml
-
redocly.yaml
file
apis:
main:
root: ../../folder2/openapi.yaml
extends:
- recommended
- Run command:
redocly lint main --config folder1/subfolder/redocly.yaml
-
See error
../../folder2/openapi.yaml does not exist or is invalid.
Expected behavior
Should correctly resolve paths
Logs
Redocly Version(s)
1.5.0
Node.js
Version(s)
20.4.0
Additional context
Paths from the config file are resolved relative to the location where the command is run, but should be relative to the location of the config file
isn't path always resolving in the context of where the command is executed? I use this quite a bit and always use a relative path to the pwd
This behaviour also caught me by surprise.
With contracts/v1.yaml
and contracts/v2.yaml
, and the config contracts/redocly.yaml
:
apis:
my-api@v1:
root: ./v1.yaml
my-api@v2:
root: ./v2.yaml
I can bundle successfully with these commands:
cd contracts
redocly lint
I then also expected this to work, and resolve the ./v1.yaml
and ./v2.yaml
files reltive to the config file:
cd ..
redocly lint --config contracts/redocly.yaml
Instead I get these errors:
v1.yaml does not exist or is invalid.
v2.yaml does not exist or is invalid.
Please provide a valid path.