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

Error parsing: while scanning for the next token found character that cannot start any token in "Todo.raml", line 7, column 1 #149

Closed jbrauchler closed 9 years ago

jbrauchler commented 9 years ago

I am getting this error when trying to parse my raml file. Error parsing: while scanning for the next token found character that cannot start any token in "Todo.raml", line 7, column 1 I don't know what I am doing wrong. Any guidance would be great. This is my raml file:

#%RAML 0.8
title: Todo API
version: v1
baseUri: http://localhost:3000
protocols: [HTTP, HTTPS]
mediaType: application/json
    /tasks:
        get:
            description: Get a list of all Tasks.
            responses:
                200:
                    body:
                        application/json:
                            example: |
                                {
                                    "tasks": [
                                        {
                                            "_id": "556f927e265f627993000012",
                                            "description": "Make dinner",
                                            "name": "task1",
                                            "date_created": "2015-06-03T23:49:18.059Z"
                                         },
                                        {
                                            "_id": "55705da20f014efb93000009",
                                            "description": "Watch your sister",
                                            "name": "task2",
                                            "date_created": "2015-06-04T14:16:02.087Z"
                                        },
                                        {
                                            "_id": "557069295ec4d36d94000006",
                                            "description": "Meeting at 9:30",
                                            "name": "task3",
                                            "date_created": "2015-06-04T15:05:13.612Z"
                                        },
                                        {
                                            "_id": "557088e7c08d7e6495000001",
                                            "description": "Go home",
                                            "name": "task4",
                                            "date_created": "2015-06-04T17:20:39.330Z"
                                        }
                                        {
                                            "_id": "55708ee2efba7e9d95000009",
                                            "description": "Go to bed",
                                            "name": "task5",                                                                                           "date_created": "2015-06-04T17:46:10.530Z"
                                        },
                                        {
                                            "_id": "55807c154790bb000000003a",
                                            "description": "Eat Dinner",
                                            "name": "task 6",
                                            "date_created": "2015-06-16T19:42:13.798Z"
                                        }
                                     ]
                                }
        post:
            description: |
                Add a new task.
            queryParameters:
                task_name:
                    description: "Unique Task name"
                    example: task1
                    required: true
                    type: string
                task_description:
                    description: "Description of the task"
                    example: Mow the lawn.
                    required: true
                    type: string
            body:
                application/json:
                    schema: task
            responses:
                200:
                    body:
                        application/json:
                            example: |
                                {
                                    "message": "Task added with name: task1"
                                }

        put:
            description: |
                Update a task.
            queryParameters:
                task_name:
                    description: "Unique Task name"
                    example: task1
                    required: true
                    type: string
                task_description:
                    description: "Description of the task"
                    example: Mow the lawn.
                    required: true
                    type: string
                task_id:
                    description: "Unique Task id"
                    example: 56f927e265f627993000012
                    required: true
                    type: number

            body:
                application/json:
                    schema: task
            responses:
                200:
                    body:
                        application/json:
                            example: |
                                {
                                    "message": "Task updated"
                                }
        delete:
            description: |
                Remove a task.
            queryParameters:
                task_id:
                    description: "Unique Task id"
                    example: 56f927e265f627993000012
                    required: true
                    type: number

            body:
                application/json:
                    schema: task
            responses:
                200:
                    body:
                        application/json:
                            example: |
                                {
                                    "message": "Task removed"
                                }

    /tasks/{task_id}:
        get:
            description: Get a list of a specific task by id.
            queryParameters:
                task_id:
                    description: "Unique Task id"
                    example: 56f927e265f627993000012
                    required: true
                    type: number
            responses:
                200:
                    body:
                        application/json:
                            example: |
                                {
                                    "_id": "556f927e265f627993000012",
                                    "description": "Make dinner",
                                    "name": "task1",
                                    "date_created": "2015-06-03T23:49:18.059Z"
                                }
blakeembrey commented 9 years ago

@jabr9983 Could you try fixing up the snippet to have the proper whitespace? I can't see anything wrong around the error you're indicating.

blakeembrey commented 9 years ago

Actually, looking at the error message I think you have a non-printable character on line 7. The error message actually tells you what the character is, but since you can't read it it just says "... character that ...".

dmartinezg commented 9 years ago

Hi @jabr9983 you cannot use tabs to indent YAML, and hence RAML.

Check answer 2 in the faq: http://www.yaml.org/faq.html

jbrauchler commented 9 years ago

I still can't get this functioning even with just using spaces rather than tabs, I am still getting the same error though. I have ran the project through a yaml checker and it says it is formatted correctly.

dmartinezg commented 9 years ago

Can you re-share the RAML without tabs? (make sure to put it in ``` so that it is easier to see)

jbrauchler commented 9 years ago

Yes I have a meeting to attend here but as soon as I return I will get that posted thanks, for your help.

jbrauchler commented 9 years ago

Here is part of my RAML:

'"#%RAML 0.8 title: Todo API version: v1 baseUri: http://localhost:3000 protocols: [HTTP, HTTPS] mediaType: application/json /tasks: get: description: Get a list of all Tasks. responses: 200: body: application/json: example: | { "tasks": [ { "_id": "556f927e265f627993000012", "description": "Make dinner", "name": "task1", "date_created": "2015-06-03T23:49:18.059Z" }, { "_id": "55705da20f014efb93000009", "description": "Watch your sister", "name": "task2", "date_created": "2015-06-04T14:16:02.087Z" }, { "_id": "557069295ec4d36d94000006", "description": "Meeting at 9:30", "name": "task3", "date_created": "2015-06-04T15:05:13.612Z" }, { "_id": "557088e7c08d7e6495000001", "description": "Go home", "name": "task4", "date_created": "2015-06-04T17:20:39.330Z" } { "_id": "55708ee2efba7e9d95000009", "description": "Go to bed", "name": "task5",
"date_created": "2015-06-16T1904T17:46:10.530Z"
}, { "_id": "55807c154790bb000000003a", "description": "Eat Dinner", "name": "task 6", "date_created": "2015-06-16T19:42:13.798Z" } ] }'"

dmartinezg commented 9 years ago

There are still tabs all over the place:

image

jbrauchler commented 9 years ago

Okay I guess I'm confused are you not supposed to space at all I didn't tab I just did 2 spaced between each.

On Thu, Jun 18, 2015 at 10:24 AM, Damian Martinez Gelabert < notifications@github.com> wrote:

There are still tabs all over the place:

[image: image] https://cloud.githubusercontent.com/assets/1099335/8236220/4c52cff0-15bd-11e5-94a9-4d8f86959c0a.png

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

jbrauchler commented 9 years ago

Even like this it doesn't work.

'"#%RAML 0.8 title: Todo API version: v1 baseUri: http://localhost:3000 protocols: [HTTP, HTTPS] mediaType: application/json /tasks: get: description: Get a list of all Tasks. responses: 200: body: application/json: example: | { "tasks": [ { "_id": "556f927e265f627993000012", "description": "Make dinner", "name": "task1", "date_created": "2015-06-03T23:49:18.059Z" }, { "_id": "55705da20f014efb93000009", "description": "Watch your sister", "name": "task2", "date_created": "2015-06-04T14:16:02.087Z" }, { "_id": "557069295ec4d36d94000006", "description": "Meeting at 9:30", "name": "task3", "date_created": "2015-06-04T15:05:13.612Z" }, { "_id": "557088e7c08d7e6495000001", "description": "Go home", "name": "task4", "date_created": "2015-06-04T17:20:39.330Z" } { "_id": "55708ee2efba7e9d95000009", "description": "Go to bed", "name": "task5",
"date_created": "2015-06-04T17:46:10.530Z"
}, { "_id": "55807c154790bb000000003a", "description": "Eat Dinner", "name": "task 6", "date_created": "2015-06-16T19:42:13.798Z" } ] }'"

dmartinezg commented 9 years ago

You need to indent, you had the right idea at first, but indentation must be with spaces:

#%RAML 0.8
title: Todo API
version: v1
baseUri: http://localhost:3000
protocols: [HTTP, HTTPS]
mediaType: application/json
  /tasks:
    get:
      description: Get a list of all Tasks.
      responses:
        200:
        body:
          application/json:
            example: |
              {
                "tasks": [
                  {
                    "_id": "556f927e265f627993000012",
                    "description": "Make dinner",
                    "name": "task1",
                    "date_created": "2015-06-03T23:49:18.059Z"
                  },
                  {
                    "_id": "55705da20f014efb93000009",
                    "description": "Watch your sister",
                    "name": "task2",
                    "date_created": "2015-06-04T14:16:02.087Z"
                  },
                  {
                    "_id": "557069295ec4d36d94000006",
                    "description": "Meeting at 9:30",
                    "name": "task3",
                    "date_created": "2015-06-04T15:05:13.612Z"
                  },
                  {
                    "_id": "557088e7c08d7e6495000001",
                    "description": "Go home",
                    "name": "task4",
                    "date_created": "2015-06-04T17:20:39.330Z"
                  }
                  {
                    "_id": "55708ee2efba7e9d95000009",
                    "description": "Go to bed",
                    "name": "task5",
                    "date_created": "2015-06-16T1904T17:46:10.530Z"
                  },
                  {
                    "_id": "55807c154790bb000000003a",
                    "description": "Eat Dinner",
                    "name": "task 6",
                    "date_created": "2015-06-16T19:42:13.798Z"
                  }
                ]
              }

this works BTW ^^^ (use backticks, not singlequotes for code fences

jbrauchler commented 9 years ago

Okay thanks