danielgtaylor / eidolon

Generate JSON or JSON Schema from Refract & MSON data structures
MIT License
6 stars 1 forks source link

Mark all inherited properties as inherited #3

Closed Baggz closed 8 years ago

Baggz commented 8 years ago

Hello!

As we are proceeding further with the Data Structures section in the Apiary API Documentation and improving rendering of the inherited properties (please se below), I would like to rise a feature request. :-)

screen shot 2016-02-23 at 16 34 49

The source blueprint is at https://gist.github.com/Baggz/3d93a571b1e045d3e96b.

Let's say we would like to render the first data structure (= List of Orders (HAL Resource)) with Attributes Kit, I run it through eidolon.dereference and this is what I get.

{
  "element": "object",
  "meta": {
    "description": "HAL Specification: [Example Document](https://tools.ietf.org/html/draft-kelly-json-hal-07#section-6)\n\n",
    "ref": "HAL Resource",
    "id": "List of Orders"
  },
  "content": [
    {
      "element": "member",
      "content": {
        "key": {
          "element": "string",
          "content": "foo"
        },
        "value": {
          "element": "string",
          "content": "bar"
        }
      }
    },
    {
      "element": "member",
      "content": {
        "key": {
          "element": "string",
          "content": "bar"
        },
        "value": {
          "element": "string",
          "content": "baz"
        }
      }
    }
  ]
}

meta.ref links to the parent data structure (= HAL Resource), but there's no way I can tell which of the properties were inherited from the parent data structure (= foo: bar).

@danielgtaylor, do you think it would be possible to add meta.ref to each property (element) which was inherited? I'm not sure whether meta.ref is the right syntax, looping Mr. @smizell in. :-)

  {
    "element": "object",
    "meta": {
      "description": "HAL Specification: [Example Document](https://tools.ietf.org/html/draft-kelly-json-hal-07#section-6)\n\n",
      "ref": "HAL Resource",
      "id": "List of Orders"
    },
    "content": [
      {
        "element": "member",
+       "meta": {
+         "ref": "HAL Resource",
+       },
        "content": {
          "key": {
            "element": "string",
            "content": "foo"
          },
          "value": {
            "element": "string",
            "content": "bar"
          }
        }
      },
      {
        "element": "member",
        "content": {
          "key": {
            "element": "string",
            "content": "bar"
          },
          "value": {
            "element": "string",
            "content": "baz"
          }
        }
      }
    ]
  }
Baggz commented 8 years ago

Thanks a lot for the fix, @danielgtaylor!