refractproject / minim-api-description

API Description namespace for Minim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dataStructure?.toValue()

tu1ly opened this issue · comments

 return this.content && this.content.toValue();
                                            ^
TypeError: Object [object Object] has no method 'toValue'
    at DataStructure.toValue (/home/towdie/Data/work/horsehead/node_modules/minim-parse-result/node_modules/minim-api-description/lib/elements/data-structure.js:32:45)

@tu1ly would you be able to provide some sample data to create this error? We have tests to cover this function, however, since Minim or this library has no guards against bad values, you don't get any errors until you try to call one of these methods.

@smizell

{
  "content": [
    {
      "content": [
        {
          "content": {
            "key": {
              "content": "data",
              "_storedElement": "string",
              "_attributes": {
                "content": [
                  {
                    "content": {
                      "key": {
                        "content": "sourceMap",
                        "_storedElement": "string"
                      },
                      "value": {
                        "_meta": {
                          "content": [],
                          "_storedElement": "object"
                        },
                        "_attributes": {
                          "content": [],
                          "_storedElement": "object"
                        },
                        "content": [
                          {
                            "content": [
                              [
                                1960,
                                15
                              ]
                            ],
                            "_storedElement": "sourceMap"
                          }
                        ],
                        "_storedElement": "array"
                      }
                    },
                    "_storedElement": "member"
                  }
                ],
                "_storedElement": "object"
              }
            },
            "value": {
              "_storedElement": "Session"
            }
          },
          "_storedElement": "member"
        }
      ],
      "_storedElement": "object"
    }
  ],
  "_storedElement": "dataStructure"
}

mson:

### Create a new Session [POST]

Request a new session ID.

+ Response 201 (application/vnd.api+json)
    + Headers

            Location: /api/v1/sessions/{session_id}

    + Attributes
        - data (Session)

This is a problem in Drafter itself, Drafter is serialising the data structures content inside an array. The content should be an element and not an array. Linking in #25 (comment)