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

Support multiple response class for multiple response content types #308

Closed
jerome-leclercq opened this issue Sep 4, 2013 · 2 comments
Closed

Comments

@jerome-leclercq
Copy link

#77 allows to specify an array of response content types.

But there is no way to specify a specific reponse class for each content type.

The use case is an operation producing both application/json and application/hal+json and not having the same response classes.

Now the only way to achieve that is to create 2 separate operations each having only one response content type :

    {
      "httpMethod" : "GET",
      "nickname" : "getResourceJson", 
      "produces": [ "application/json" ],
      "responseClass" : "RegularJsonResponse",
    }
    {
      "httpMethod" : "GET",
      "nickname" : "getResourceHalJson", 
      "produces": [ "application/hal+json" ],
      "responseClass" : "HalJsonResponse",
    }

but this appears as 2 different operations in the UI.
It would be more useful to have something like :

    {
      "httpMethod" : "GET",
      "nickname" : "getResource", 
      "responses" : [
        {
          "contentTypes": [ "application/json" ],
          "responseClass" : "RegularJsonResponse"
        },
        {
          "contentTypes": [ "application/hal+json" ],
          "responseClass" : "HalJsonResponse"
        },
      ]
    }
@fehguy
Copy link
Contributor

fehguy commented Sep 4, 2013

Hi, I understand the need, but that's outside the goal of swagger. The response model definition cannot vary based on content-type.

You CAN, however, return different models depending on the response code. So a HTTP 299 code, for example (not suggesting that you use that code) can return a completely different model.

@fehguy
Copy link
Contributor

fehguy commented Aug 30, 2014

per design, not supported.

@fehguy fehguy closed this as completed Aug 30, 2014
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