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

Collections are not rendered in Swagger responses #139

Closed
moorereason opened this issue Dec 24, 2015 · 2 comments
Closed

Collections are not rendered in Swagger responses #139

moorereason opened this issue Dec 24, 2015 · 2 comments

Comments

@moorereason
Copy link
Contributor

Given the following API snippet:

var _ = Resource("organization", func() {
    Action("list", func() {
        Description("Retrieve list of organizations")
        Routing(GET(""))
        Response(OK, func() {
            Media(CollectionOf(OrganizationMedia, func() {
                View("default")
            }))
        })
    })
})

var OrganizationMedia = MediaType("application/vnd.test.organization+json", func() {
    Description("An organization")
    Attributes(func() {
        Attribute("organization_id", Integer, "Unique organization ID")
        Attribute("name", String, "Organization Name")
    })
    View("default", func() {
        Attribute("organization_id")
        Attribute("name")
    })
})

The generated swagger output only contains the following for the response:

"responses": {
  "200": {
    "description": ""
  }
}

I would expect goa to generate something like this:

"responses": {
  "200": {
    "description": "",
    "schema": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/TestOrganization"
      }
    }
  }
}

It looks like genswagger.responseFromDefinition is where it's falling apart. A collection response has a MediaType like application/vnd.test.organization+json; type=collection instead of application/vnd.test.organization.

@raphael
Copy link
Member

raphael commented Dec 24, 2015

Thank you! this should now be fixed.

@raphael raphael closed this as completed Dec 24, 2015
@moorereason
Copy link
Contributor Author

Confirmed. Thanks!!

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

2 participants