raml-org / raml-js-parser

(deprecated) A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
195 stars 53 forks source link

Misleading error message when the raml file does not exist #153

Closed mik01aj closed 9 years ago

mik01aj commented 9 years ago

Here's my RAML file:

#%RAML 0.8
title: Topics
version: v0.1

I try to create documentation out of it using raml2html@2.0.2 (that uses raml-parser@0.8.11):

raml2html api/discussion/spec.raml -o spec.html

And this is the output I get:

Error parsing: version validation
The first line must be: '#%RAML 0.8'
  in "undefined", line 1, column 1
mik01aj commented 9 years ago

Hmm, possibly it's a bug in raml2obj or raml2html... Parsing the text directly works fine.

> var raml = require('raml2html/node_modules/raml2obj/node_modules/raml-parser/')
undefined
> raml.load('#%RAML 0.8\ntitle: Topics\nversion: v0.1\n').then(function(data) { console.log(data); })
{ state: 'pending' }
> { title: 'Topics', version: 'v0.1' }
mik01aj commented 9 years ago

Yes, it is a bug in raml2html. I gave a wrong path to the file and it produced such a misleading error message.

mik01aj commented 9 years ago

Bouncing back from https://github.com/kevinrenskers/raml2html/issues/144. The error message is produced by raml-js-parser.

blakeembrey commented 9 years ago

@mik01aj I'm taking a look. When the file doesn't exist for me I get:

while reading /Users/blakeembrey/Projects/blakeembrey/raml-js-parser/foo.raml
cannot read /Users/blakeembrey/Projects/blakeembrey/raml-js-parser/foo.raml (Error: ENOENT: no such file or directory, open '/Users/blakeembrey/Projects/blakeembrey/raml-js-parser/foo.raml')

Do you have more information to replicate?

blakeembrey commented 9 years ago

@mik01aj Sorry, I just saw it is the same issue when using raml2html. It actually looks like an issue in raml2html, but I'll investigate it.

blakeembrey commented 9 years ago

@mik01aj Sorry to bounce you around issues, I can create the next one for you. It's caused by https://github.com/kevinrenskers/raml2obj/blob/master/index.js#L85-L91 which assumes if the file doesn't exist it's trying to parse a RAML file directly. Hence, undefined source since the second argument to load is the filename to resolve subsequent includes. I'm going to close this but I'll open an issue against raml2obj for you. It's kind of awkward behaviour to make assumptions on sources like this.

sram54 commented 8 years ago

Is there any workaround to progress with getting the documentation.

sram54 commented 8 years ago

error message: Error parsing: version validation The first line must be: '#%RAML 0.8' in "undefined", line 1, column 1

mik01aj commented 8 years ago

This means that you give raml2html the wrong file path. The problem is that the message you got is misleading, and this ticket is exactly about this.

sram54 commented 8 years ago

The path is correct. order.raml is in this path: C:\Users\sram\Google Drive\Object Edge\Innovation Labs\OeComs\OEOMS API\RAML2HTML. I changed the directory to this path and then ran raml2html order.raml->order.html. I get the same error

sram54 commented 8 years ago

Hi Can you provide some resolution. Is there some way, I can still get the documentation

blakeembrey commented 8 years ago

@sram54 If you're getting that error message, it's coming from raml2html and it's because the path is wrong. Is the path correct? What's the command you're running? This is really an issue for raml2html by the sounds of it.

sram54 commented 8 years ago

Thanks Blake. It seems to be raml2html. Any suggestions on how I can get someone to look at it?

Sincerely,

Ram Subramanian Office: 925 331 8120 Cell: 925 389 2759

On Tue, Oct 6, 2015 at 5:27 PM, Blake Embrey notifications@github.com wrote:

@sram54 https://github.com/sram54 If you're getting that error message, it's coming from raml2html and it's because the path is wrong. Is the path correct? What's the command you're running? This is really an issue for raml2html by the sounds of it.

— Reply to this email directly or view it on GitHub https://github.com/raml-org/raml-js-parser/issues/153#issuecomment-146043285 .

This email message (including any attachments) is for the sole use of the intended recipient and may contain confidential and privileged information. Any unauthorized review; use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Thank you.

blakeembrey commented 8 years ago

@sram54 Can you provide the command you're trying to run or something to replicate the issue?

nisPande17 commented 7 years ago

I am trying to write RAML in Anypoint API Manager and got below error: "Promise is undefined" at the very first line :
1.#%RAML 0.8

This I was getting while using IE and after switching to chrome, don't see any such error.