Unknown escape sequence when trying to validate yaml file in a directory path
See original GitHub issueI used create-openapi-repo to create a brand new repo. Then I ran $ npm start
This tries to validate the openapi/openapi.yaml file and the openapi-cli validate failed to resolve the escape character of the path separator. Is this a Windows issue? How do I solve this?
Thanks!
Env: On Windows using Git Bash
$ node -v
v12.16.1
$ npm -v
6.14.3
$ openapi validate openapi/openapi.yaml
C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:173
throw generateError(state, message);
^
YAMLException: unknown escape sequence at line 3, column 18:
main: "openapi\openapi.yaml"
^
at generateError (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:167:10)
at throwError (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:173:9)
at readDoubleQuotedScalar (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:646:9)
at composeNode (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1365:13)
at readBlockMapping (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1089:11)
at composeNode (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1359:12)
at readBlockMapping (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1089:11)
at composeNode (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1359:12)
at readDocument (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1519:3)
at loadDocuments (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1575:5) {
name: 'YAMLException',
reason: 'unknown escape sequence',
mark: Mark {
name: null,
buffer: '# See https://docs.redoc.ly/cli/configuration/ for more information.\r\n' +
'apiDefinitions:\r\n' +
' main: "openapi\\openapi.yaml"\r\n' +
'lint:\r\n' +
' rules:\r\n' +
' no-unused-schemas: warning\r\n' +
'referenceDocs:\r\n' +
' htmlTemplate: ./docs/index.html\r\n' +
' theme:\r\n' +
' colors:\r\n' +
' primary:\r\n' +
' main: "#32329f"\n' +
'\u0000',
position: 104,
line: 2,
column: 17
},
message: 'unknown escape sequence at line 3, column 18:\n' +
' main: "openapi\\openapi.yaml"\n' +
' ^'
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Unknown escape sequence when trying to validate yaml file in ...
This tries to validate the openapi/openapi.yaml file and the openapi-cli validate failed to resolve the escape character of the path separator.
Read more >YAML, linting - syntax error - unknown escape character
This is not a linter error, this is a parser error. Your input is invalid YAML because an escape sequence \' is not...
Read more >Found unexpected or unknown characters - Elastic
If the YAML file contains paths with spaces or unusual characters, wrap the paths in single quotation marks (see Wrap paths in single...
Read more >Error parsing YAML config file: yaml-cpp - DBA Stack Exchange
YAML interprets backslashes inside quoted strings as introducing an escape character, so reports: "error at line 3, column 16: unknown ...
Read more >regex in yaml file - Google Groups
I am attempting to use regex in a yaml automation file for docker to exclude a path. When attempting with these options: excludePaths:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We should fix the generator code to not produce a file path with
\
in the first placeI opened the issue in Redocly/create-openapi-repo, and I’m going to close this issue.