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

Can't parse valid yaml definition because of apostrophe character #165

Closed ranacseruet closed 8 years ago

ranacseruet commented 8 years ago
#%RAML 0.8

---
  title: "Test"
  version: "v0.1"
  baseUri: "http://mocksvc.mulesoft.com/mocks/a86239e0-d3af-48c6-9fd5-f8edc7c35d69"
  mediaType: "application/json"
  protocols:
    - "HTTP"
    - "HTTPS"
  documentation:
    -
      title: "Test"
      content: ""
  /test:
    displayName: "test"
    description: ""
    get:
      displayName: ""
      description: ""
      headers: {}
      responses:
        200:
          body:
            application/json:
              schema: "{\"type\":\"string\"}"
              example: "\"the devil's place\""
      queryParameters: {}
  schemas: []

Validated with: http://www.yamllint.com/

The problem is with the string "the devil's place". If I replace the apostrophe with single quote, it works just fine.

dmartinezg commented 8 years ago

hi @ranacseruet, I just tested it, and get this output:

{
 "title": "Test",
 "version": "v0.1",
 "baseUri": "http://mocksvc.mulesoft.com/mocks/a86239e0-d3af-48c6-9fd5-f8edc7c35d69",
 "mediaType": "application/json",
 "protocols": [
  "HTTP",
  "HTTPS"
 ],
 "documentation": [
  {
   "title": "Test",
   "content": ""
  }
 ],
 "schemas": [],
 "resources": [
  {
   "displayName": "test",
   "description": "",
   "relativeUri": "/test",
   "methods": [
    {
     "displayName": "",
     "description": "",
     "headers": {},
     "responses": {
      "200": {
       "body": {
        "application/json": {
         "schema": "{\"type\":\"string\"}",
         "example": "\"the devil's place\""
        }
       }
      }
     },
     "queryParameters": {},
     "protocols": [
      "HTTP",
      "HTTPS"
     ],
     "method": "get"
    }
   ],
   "relativeUriPathSegments": [
    "test"
   ]
  }
 ]
}

Are you sure you are including the right RAML source? maybe it is some weird UNICODE?

ranacseruet commented 8 years ago

Ah, seems like github changed the apostrophe character. Please try this file:

https://dl.dropboxusercontent.com/u/16060416/raml.yaml

Yes, the issue is because of the apostrophe character. But as yaml supports that, I believe the parser also should, right?

ranacseruet commented 8 years ago

Ah, seems like the issue wasn't somewhere else in my app. My bad. Closing it.