Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

JS-YAML: missed comma between flow collection entries #9

Open
joaocarreiras opened this issue Feb 21, 2017 · 4 comments
Open

JS-YAML: missed comma between flow collection entries #9

joaocarreiras opened this issue Feb 21, 2017 · 4 comments

Comments

@joaocarreiras
Copy link

Hi,

Following the tutorial in http://apiworkbench.com/docs/ for Api-workbench, section "Extracting the Library". I'm getting the following error "JS-YAML: missed comma between flow collection entries at line" in several lines (which I've put in bold)
My RAML files are
#%RAML 1.0
title: Pet Shop
version: v1
baseUri: /petshop
mediaType:

  • application/json
    description: API example designed with API Workbench

uses:
NewLibrary: NewLibrary.raml
types:
Mammal:
type: NewLibrary.Pet
Bird:
type: NewLibrary.Pet
properties:
wingLength: number

/pets:
type: { NewLibrary.Collection: {item : NewLibrary.Pet }
get:
queryParameters:
petKind:
enum: [bird, mammal]
is: [NewLibrary.FilterableByPrice]
/{id}:
type: { NewLibrary.Member: {item : NewLibrary.Pet} }

/birds:
type: { NewLibrary.Collection: {item: Bird} }
get:
is: NewLibrary.FilterableByPrice
/{id}:
type: { NewLibrary.Member: {item : Bird} }

/mammals:
type: { NewLibrary.Collection: {item: Mammal} }
get:
is: NewLibrary.FilterableByPrice
/{id}:
type: { NewLibrary.Member: {item : Mammal} }

The "NewLibrary.raml" is below
#%RAML 1.0 Library
types:
Pet:
#discriminator: kind
properties:
name: string
kind: string
price: number
color:
enum:
- White
- Black
- Colored
example:
name: Snoopy
kind: Mammal
price: 100
color: Black
resourceTypes:
Collection:
post:
body:
application/json:
type: <>
get:
responses:
200:
body:
application/json:
type: <>[]
Member:
delete:
responses:
204:
put:
body:
application/json:
type: <>
traits:
FilterableByPrice:
queryParameters:
priceLessThan?:
type: number
priceMoreThan?:
type: number

I've no idea why this error appears. I've compared it with the tutorial and can't find the difference

@joaocarreiras
Copy link
Author

I forgot to mention my machine is running Windows 10

@adamvoss
Copy link
Contributor

@joaocarreiras YAML is a whitespace sensitive language, and as you made your post there is no indentation (which I am guessing is not correct) and we cannot tell what your input is. Could edit and correct your post? You will probably want to use fenced code blocks.

@jrop
Copy link

jrop commented May 23, 2018

I can confirm I get the error on this use-case:

const s = `key: [ Some text here
and another line here ]`
safeLoad(s)
// throws YAMLException: missed comma between flow collection entries at line 2, column 1

Although the online YAML parser parses this as:

{
  "key": [
    "Some text here and another line here"
  ]
}

@adamvoss
Copy link
Contributor

adamvoss commented Jul 5, 2018

Showing success against a reference implementation: http://yaml-online-parser.appspot.com/?yaml=key%3A+%5B+Some+text+here%0Aand+another+line+here+%5D&type=json

Showing failure against js-yaml: http://nodeca.github.io/js-yaml/#yaml=a2V5OiBbIFNvbWUgdGV4dCBoZXJlCmFuZCBhbm90aGVyIGxpbmUgaGVyZSBd

Since the issue still exists in js-yaml, you might wish to report the issue there. Once it is fixed here, the fix could be ported to this library.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants