apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.64k stars 2.14k forks source link

Adding a boolean to attributes removes the name of the boolean on nested objects. #352

Closed ghost closed 7 years ago

ghost commented 7 years ago
+ Attributes
        + anObject (object) - Some Text
            + anArray (array) - Some Text
                + aString: someTextInAString  - Some Text
                + aBoolean:  false (boolean) - Some Text

booleansdonotworkright

I would expect booleans to show the name and value just like strings arrays and objects and booleans at higher levels.

kylef commented 7 years ago

Hi @gsigler2,

What you have described is equivalent to the following in JSON:

[
  "aString: someTextInAString",
  false
]

The value of your boolean is set to aBoolean: false which translates to false because it is not true.

You cannot have key/value pairs directly inside an array. I expect you meant to instead wrap them in a object. Which you can do with the following syntax:

+ Attributes
    + anObject (object) - Some Text
        + anArray (array) - Some Text
             + (object)
                 + aString: someTextInAString  - Some Text
                 + aBoolean: false (boolean) - Some Text

Which results in the following JSON:

[
  {
    "aString": "someTextInAString",
    "aBoolean": false
  }
]
ghost commented 7 years ago

Ahh duh. makes sense.