raml-org / raml-js-parser-2

(deprecated)
Other
138 stars 53 forks source link

When property is named 'value' the parser throws an error #131

Closed Narkhip closed 8 years ago

Narkhip commented 8 years ago

In the following example the parser throws a problem in line 29. If the value property is renamed to something differently it works.

#%RAML 1.0
title: API with Examples
types:
  User:
    type: object
    properties:
      name: string
      lastname: string
    example:
      name: Bob
      lastname: Marley
  Org:
    type: object
    properties:
      name: string
      address?: string
      value? : string
/organisation:
  post:
    headers:
      UserID:
        description: the identifier for the user that posts a new organisation
        type: string
        example: SWED-123 # single scalar example
    body:
      application/json:
        type: Org
        example: # single request body example
          name: Doe Enterprise
          value: Silver
  get:
    description: Returns an organisation entity.
    responses:
      201:
        body:
          application/json:
            type: Org
            examples:
              acme:
                name: Acme
              softwareCorp:
                value: # validate against the available facets for the map value of an example
                  name: Software Corp
                  address: 35 Central Street
                  value: Gold # validate against instance of the `value` property
sichvoge commented 8 years ago

What version of the parser do you use?

Narkhip commented 8 years ago

v0.2.5-rc2, using it from the API Designer

petrochenko-pavel-a commented 8 years ago

According to what I see from your sample it seems that parser behaves pretty correctly.

As you may see from:

https://github.com/raml-org/raml-spec/blob/raml-10-rc2/versions/raml-10/raml-10.md#single-example and from https://github.com/raml-org/raml-spec/issues/239

using value: as the top level element of examples serves as a sign that actual example content is located inside, so it validates string "Silver" against Org and correctly complains that value of example should be an object.

P.S. Please let me know if you see any other kind of problems with it.

Regards, Pavel