Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ayadavkrt opened this issue Dec 12, 2018 · 0 comments

Comments

@ayadavkrt
Copy link

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 !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant