This repository was archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
SyntaxError: Unexpected token < in JSON at position 0 #182
Copy link
Copy link
Open
Description
Looks like dereferenceSchemas
is attempting to JSON.parse a raml file.
Below is a redacted version of my raml file.
#%RAML 0.8
---
title: Example API
baseUri: /{version}
version: v1
mediaType: application/json
schemas:
- cart: !include schemas/cart/cart.json
resourceTypes:
- collection: !include resourceTypes/collection.yaml
/carts: !include types/carts.yaml
I changed line 302 of dereferenceSchemas
to:
try {
schema = JSON.parse(schemaNode.value);
} catch (err) {
console.log(schemaNode.value);
console.log(schemaNode.start_mark.name);
throw err;
}
Output:
<<resourcePathName>>
src/resourceTypes/collection.yaml
SyntaxError: Unexpected token < in JSON at position 0
at Object.parse (native)
at /Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/lib/raml.js:303:27
at Array.map (native)
at RamlParser.__dirname.RamlParser.RamlParser.dereferenceSchemas (/Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/lib/raml.js:295:36)
at RamlParser.dereferenceSchemas (/Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/lib/raml.js:5:61)
at /Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/lib/raml.js:233:24
at _fulfilled (/Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/node_modules/q/q.js:760:13)
at /Users/patrickhousley/Documents/projects/proj/digital-apis/node_modules/raml-parser/node_modules/q/q.js:574:44
This leads me to believe it is attempting to parse src/resourceTypes/collection.yaml
as JSON. Below is the contents of that file:
get:
description: Get a collection of <<resourcePathName>>.
responses:
200:
body:
schema: <<resourcePathName>>
example: <<get-example>>
post:
description: Creates a <<resourcePathName | !singularize>>.
body:
schema: <<resourcePathName | !singularize>>
example: <<post-example>>
responses:
201:
description: Successfully created the resource.
headers:
Location:
description: The location of the created resource.
type: string
Rotzbua
Metadata
Metadata
Assignees
Labels
No labels