swagger-blocks icon indicating copy to clipboard operation
swagger-blocks copied to clipboard

Unable to define array of objects for response parameters, allOff doesn't work here

Open ayadavkrt opened this issue 7 years ago • 0 comments

I'm using swagger-blocks for quite a bit now, we have started documenting our code using it, in one place there's an API response which returns multiple objects in the included block.

Example:

{
    "data": {
        "id": "1",
        "type": "schoolPositions",
        "attributes": {
            "description": "teases the students",
            "mustHaves": "principle"
        },
        "relationships": {
            "schoolLocation": {
                "data": {
                    "id": "72",
                    "type": "schoolLocations"
                }
            },
            "schoolCompensation": {
                "data": {
                    "id": "75",
                    "type": "schoolCompensations"
                }
            },
            "jobSpecs": {
                "data": [
                    {
                        "id": "82",
                        "type": "schoolAttachments"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "id": "72",
            "type": "schoolLocations",
            "attributes": {
                "city": "Berhampore",
                "state": "West Bengal",
                "postalCode": "742101",
                "country": "India",
                "globalRegionId": 30,
                "regionId": 683
            }
        },
        {
            "id": "75",
            "type": "schoolCompensations",
            "attributes": {
                "salary": "",
                "bonus": "",
                "equity": "",
                "currencyId": null,
                "equityType": "percent",
                "salaryDescription": null
            }
        },
        {
            "id": "82",
            "type": "schoolAttachments",
            "attributes": {
                "attachmentType": "JobSpecificationAttachmentType",
                "fileFileName": "vs.jpg",
                "fileContentType": "image/jpeg",
                "fileFileSize": 2410039,
                "fileUpdatedAt": "2018-12-12T07:06:38Z",
                "downloadUrl": "001-vs.jpg?1544598398",
                "klass": "SchoolAttachments"
            }
        }
    ]

I have wasted entire day trying to document the included part

      response 200 do
        key :description, 'School Data'
        schema do
          property :data do
            key :type, :array
            items do
              key :'$ref', :School
            end
          end

          property :included do
            key :type, :array
            items do
              key :'$ref', :SchoolLocations
              key :'$ref', :SchoolCompensations
              key :'$ref', :SchoolAttachments
            end
          end
        end
      end

This shows only the SchoolAttachments in the included part.

This has become a real pain for me now, please help !!!

ayadavkrt avatar Dec 12 '18 13:12 ayadavkrt