mulesoft / api-designer

A web editor for creating and sharing RAML API specifications
Other
1.07k stars 269 forks source link

API Designer: Quote at beginning of queryParameter Description causes error. #230

Closed scordatura closed 9 years ago

scordatura commented 9 years ago

This queryParameter Description works:

        happy:
          description: Quotes within a description, 'like this', display correctly. However, if you go into the RAML and uncomment the _next_ queryParameter, whose description begins with a quote, API Designer throws the error **expected block end but found scalar**.
          example: 1
          required: false
          type: integer

This one causes the error expected block end but found scalar. It has a phrase enclosed in quotes; in fact, the second quote can be removed and you still get the error.

       not-so-happy:
          description: 'This throws an error' but it should not.
          example: 99
          required: false
          type: integer

Here's a screenshot and RAML and sample.

quotes-at-start-cause-error

foo.raml

#%RAML 0.8
baseUri: https://foo.example.com
title: Foo API
version: 0.2

resourceTypes:
  - collection:
      description: | 
        Collection of available <<resourcePathName>>. <br /> <br /> POST creates an <<resourcePathName|!singularize>>. GET shows an index. 
      get:
        description: Get a list of <<resourcePathName>>.
        headers: &commonHeaders
          funky-thang:
            displayName: Its-Your-Thing
            description: Do what you want to do. 
            example: "xyz987654"
          accept: 
            displayName: Accept
            description: MIME types that client is willing to accept.
            example: "*/*"
          content-type: 
            displayName: Content Type
            description: MIME type of document being served.
            example: "application/x-www-form-urlencoded,application/json"
        responses: &commonResponses
          200:
            body:
              application/json:
                example: |
                  <<exampleCollection>>
          404:
            body:
              application/json:
                example: |
                  {"message": "<<resourcePathName|!singularize>> not found" }
          422:
            body:
              application/json:
                example: |
                  {"message": "<<resourcePathName|!singularize>> cannot be processed because it has failed validation" }
          500:
            body:
              application/json:
                example: |
                  {"message": "internal server error" }
        is: [
          pageable
        ]
traits:
  - pageable:
      queryParameters:       
        happy:
          description: Quotes within a description, 'like this', display correctly. However, if you go into the RAML and uncomment the _next_ queryParameter, whose description begins with a quote, API Designer throws the error **expected block end but found scalar**.
          example: 1
          required: false
          type: integer
#        not-so-happy:
#          description: 'This throws an error' but it should not.
#          example: 99
#          required: false
#          type: integer
/things:
  description: |
    Many things, cabbages and kings.
  type:
    collection:
      exampleCollection: !include things.sample

things.sample

[{
  "artistId": "110e8300-e32b-41d4-a716-664400445500",
  "artistName": "Daft Punk",
  "description": "French electronic music duo consisting of musicians Guy-Manuel de Homem-Christo and Thomas Bangalter",
  "imageURL": "http://travelhymns.com/wp-content/uploads/2013/06/random-access-memories1.jpg"
  "nationality": {
    "countryCode": "FRA",
    "countryName": "France"
  }
},
{
  "artistId": "110e8300-e32b-41d4-a716-229932554400",
  "artistName": "Pink Floyd",
  "description": "English rock band that achieved international acclaim with their progressive and psychedelic music.",
  "imageURL": "http://www.billboard.com/files/styles/promo_650/public/stylus/1251869-pink-floyd-reunions-617-409.jpg",
  "nationality": {
    "countryCode": "ENG",
    "countryName": "England"
  }
},
{
  "artistId": "11032be3-41d4-4455-a716-664400a71600",
  "artistName": "Radiohead",
  "description": " English rock band from Abingdon, Oxfordshire, formed in 1985",
  "imageURL": "http://www.wired.com/images_blogs/photos/uncategorized/2007/10/01/radiohead.jpg",
  "nationality": {
    "countryCode": "ENG",
    "countryName": "England"
  }
},
]
dmartinezg commented 9 years ago

@scordatura your RAML is invalid YAML, putting a quote at the beginning of the value kicks in the flow scalar mode: you can check "7.3.2. Single-Quoted Style" of the YAML spec: http://yaml.org/spec/1.2/spec.html#id2788097

scordatura commented 9 years ago

Great to know! Thanks!