Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown escape sequence when trying to validate yaml file in a directory path #110

Closed
qhvuEprod opened this issue Mar 26, 2020 · 5 comments
Labels
good first issue Good for newcomers

Comments

@qhvuEprod
Copy link

qhvuEprod commented Mar 26, 2020

I 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' +
    '                     ^'
}
@RomanHotsiy
Copy link
Member

Could you try editing .redocly.yaml file and replace \ with /?
Let us know if it worked

@qhvuEprod
Copy link
Author

Cool, that worked! Thanks!

@adamaltman
Copy link
Member

It seems this will help navigate the error in a nicer way: #114

However, I don't know if it will help a Windows user know how to actually correct the error.

It would be interesting to see if others hit this same issue, and if so, maybe we can detect it and present a specific correction when the file is not found and there is \ in the file location.

@RomanHotsiy
Copy link
Member

We should fix the generator code to not produce a file path with \ in the first place

@adamaltman
Copy link
Member

I opened the issue in Redocly/create-openapi-repo, and I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants