bukalapak/snowboard

Description is not displayed in the JSON schema defition

zshamrock opened this issue · 0 comments

I have the following API Blueprint (just a snippet):

...
### Initiate sign-up [POST /v1/users/signup]

+ Attributes (object)
    + state_id (number)
    + count_id (number)
    + elements (array[Element], fixed-type)

+ Request (application/json)

        {
            "state_id": 27,
            "count_id": 10,
            "elements": [
                {
                    "id": 1,
                    "status": true,
                    "facts": [
                        "fact1",
                        "fact2",
                        "etc"
                    ]
                }
            ]
        }
...
# Data Structures

## Element (object)

+ id: 1 (number) - Element id
+ status: true (boolean) - Whether the particular element is present or not
+ facts: [""] (array[string]) - Supporting facts for the elements with the "status: true"

Initially elements in the JSON schema has not been expanded at all, and has been rendered as "elements": "array", unless I added the fixed-type as mentioned at #40.

Now JSON schema includes the Element type definition, although description is missing, i.e. this how Snowboard renders it:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "state_id": {
      "type": "number"
    },
    "count_id": {
      "type": "number"
    },
    "elements": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "number"
              },
              "status": {
                "type": "boolean"
              },
              "facts": {
                "type": "array"
              }
            }
          }
        ]
      }
    }
  }
}

And this how Apiary renders it:

image

See the description I highlighted. In various examples, on the internet, I see that JSON Schema supports this extra description field in the output, but Snowboard doesn't display it.

I expect as you already parsed the Data Structures block (as Element type has been processed), it should be not difficult to access the description of the field and put it into the JSON schema definition.