1

I have an issue similar to what is described here.

I have a JSON that looks like this:

{
  "photos": [
    {
      "key": "y37dmj10jkwof/moOIUB8912JKVgh",
      "caption": "A world of gamers.",
      "tags": [
        "game",
        "japan"
      ],
      "attributes": {
        "copyright": true,
        "use": [
          "public",
          "private"
        ]
      }
    }
  ]
}

and I am trying to describe the attributes using MSON, to render the blueprint. However, I am not successful at it. Here is my attempt:

+ Attributes (required, object)
    + photos (required, array)
        + (object)
            + key (required, string) - Photo key
            + caption (required, string) - Photo caption
            + tags (required, array)
                + game (string)
                + japan (string)
            + attributes (required, object)
                + (object)
                    + copyright: true (required, boolean)
                    + uses (required, array)
                        + public (string)
                        + private (string)

Ideas anyone? Any input would be highly appreciated.

Stefan
  • 1,214
  • 1
  • 9
  • 17

1 Answers1

1

Here's an example that I think does what you want:

+ Attributes
    + photos (required, array)
        + (object)
            + key: y37dmj10jkwof/moOIUB8912JKVgh (required) - Photo key
            + caption: A world of gamers (required) - Photo caption
            + tags: game, japan (required, array)
            + attributes (required)
                + copyright: true (required, boolean)
                + use: public, private (required, array)

Note that you can put the sample values for the arrays as a comma separated list, and there's usually no need to explicitly state when the type is a string or object (unless it has no name). As for the attributes object, you can put the keys on it directly, no need to make another level with + (object)

Hope this helps!

Daniel
  • 8,212
  • 2
  • 43
  • 36
  • 1
    Hey Daniel, thank you for that. I am using aglio to render this. Your example is one I have already used in the past and still not what I am expecting. Aglio only renders the photos array in the schema. See here: https://gist.github.com/aichholzer/612f0c359309f455fe69#file-rendered-schema – Stefan Aug 03 '15 at 17:01
  • 1
    Perhaps an issue with aglio? – Stefan Aug 03 '15 at 17:03
  • @Aichholzer this is currently handled behind the scenes by a library called [boutique.js](https://github.com/apiaryio/boutique.js) (through the aglio dependency drafter.js). It's possible it isn't working properly. The plan is to replace it soon by the C++ implementation of [Drafter](https://github.com/apiaryio/drafter) which has (or will have) similar (faster, better) functionality. – Daniel Aug 03 '15 at 18:25