Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Response Class
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ron R  
View profile   Translate to Translated (View Original)
 More options Jul 3 2012, 4:29 pm
From: Ron R <web...@gmail.com>
Date: Tue, 3 Jul 2012 13:29:58 -0700 (PDT)
Local: Tues, Jul 3 2012 4:29 pm
Subject: Response Class

Regarding the responseClass parameter of @ApiOperation, is there a reason
why the parameter is the fully qualified name of the class rather than
Class<T>?
Using the fully qualified name is a bit dangerous as it can fail on code
refactoring and obviously is more error prone when it comes to typing (and
it's a runtime error).

On another note, according to Tony, in order to set the return type to a
List<Foo>, the responseClass parameter should be "List[com.bar.Foo]".
When I've tried that, I didn't get any model information for the API
listing (using com.bar.Foo worked fine). Any suggestions as to why?

I imagine the second question might be the answer to the first. However,
using some reflection magic, I'm fairly certain it can still be resolved by
using a class rather than a string.

Also, I'd expect the @GET operations to use the return type of the method
by default. If developers want to override it with the responseClass
parameter, all the better, but since Response is not always used, the
forced usage of the responseClass parameter can be somewhat redundant (a
bit like having to say which HTTP method is used for the API call).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tony tam  
View profile  
 More options Jul 4 2012, 5:16 pm
From: tony tam <feh...@gmail.com>
Date: Wed, 4 Jul 2012 14:16:20 -0700 (PDT)
Local: Wed, Jul 4 2012 5:16 pm
Subject: Re: Response Class

Returning the class would probably be better for the responseClass, good
point.  I'll see if that can be supported.

If you're not getting models for List[com.bar.Foo] you probably found a
defect.  I'll take a look at this.

I think that picking the return type out of the method is pretty tricky and
that's why we made it explicit.

Tony


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ron R  
View profile  
 More options Jul 5 2012, 12:49 am
From: Ron R <web...@gmail.com>
Date: Wed, 4 Jul 2012 21:49:25 -0700 (PDT)
Local: Thurs, Jul 5 2012 12:49 am
Subject: Re: Response Class

Why do you say that picking the return type out of the method can be
tricky? Perhaps I can suggest a solution.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tony tam  
View profile  
 More options Jul 5 2012, 12:48 pm
From: tony tam <feh...@gmail.com>
Date: Thu, 5 Jul 2012 09:48:15 -0700 (PDT)
Local: Thurs, Jul 5 2012 12:48 pm
Subject: Re: Response Class

My understanding of it is that in the resources, people (including
ourselves) will use the Response builder with JAX-RS, not just the return
value--this lets you better control the response handling.

So if we look at the method signature and see that it returns
java.ws.rs.core.Response, we will not get the entity type being marshalled
in the response.

Tony


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ayush Gupta  
View profile  
 More options Jul 5 2012, 1:00 pm
From: Ayush Gupta <ay...@glugbot.com>
Date: Thu, 5 Jul 2012 10:00:12 -0700
Local: Thurs, Jul 5 2012 1:00 pm
Subject: Re: Response Class

This is true of play framework
too<https://github.com/wordnik/swagger-core/blob/master/samples/scala-pla...>,
where controller methods are expected to return an
Action<http://www.playframework.org/documentation/2.0/ScalaActions>
.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ron R  
View profile   Translate to Translated (View Original)
 More options Jul 6 2012, 3:49 am
From: Ron R <web...@gmail.com>
Date: Fri, 6 Jul 2012 00:49:50 -0700 (PDT)
Local: Fri, Jul 6 2012 3:49 am
Subject: Re: Response Class

Fair enough. Since the Response isn't typed, there's no viable way of
finding that out.
I'm not familiar that much with Play, but I imagine it's similar.

Just one of the limitations of JAX-RS.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Dekmetzian  
View profile  
 More options Jan 2, 5:14 pm
From: Michael Dekmetzian <michael.dekmetz...@gmail.com>
Date: Wed, 2 Jan 2013 14:14:28 -0800 (PST)
Local: Wed, Jan 2 2013 5:14 pm
Subject: Re: Response Class

Just for the sake of anyone reading this today, List[com.bar.Foo] is indeed
not correct.

You should use:

@ApiOperation( value="xxx" notes="yyy" responseClass="com.bar.Foo",
multiValueResponse=true)

Internally the representation will be wrapped as List[Foo] after the fact
but based on my reading you cannot declare it as such.

Writing the code to allow for responseClass="List[com.bar.Foo]" isn't super
complex, two methods as per this pastebin would do it:

http://pastebin.com/wY1zjwys

I'm not sure of the best way to write unit tests for swagger though, if
there's interest in having this in the main version then happy to write
same if some guidance can be given. Seems as if the only code that tests
this is in the swagger-jaxrs module, though perhaps some should be in
swagger-core given that that's where the trait resides?

Cheers

-Mike


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tony tam  
View profile  
 More options Jan 9, 5:10 pm
From: tony tam <feh...@gmail.com>
Date: Wed, 9 Jan 2013 14:10:34 -0800 (PST)
Local: Wed, Jan 9 2013 5:10 pm
Subject: Re: Response Class

Hi Michael, I believe you wrote the fix to this :) but the current snapshot
of swagger-core supports the responseClass="List[com.bar.Foo]", and is
available in sonatype snapshots as 1.2.1-SNAPSHOT.

Tony


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eyal Allweil  
View profile  
 More options Feb 7, 4:06 am
From: Eyal Allweil <eyal.allw...@gmail.com>
Date: Thu, 7 Feb 2013 01:06:52 -0800 (PST)
Local: Thurs, Feb 7 2013 4:06 am
Subject: Re: Response Class

Has their been any improvements where this is concerned? Is using the short
class name going to be supported in a future version of Swagger?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tony tam  
View profile  
 More options Feb 7, 9:51 am
From: tony tam <feh...@gmail.com>
Date: Thu, 7 Feb 2013 06:51:38 -0800 (PST)
Local: Thurs, Feb 7 2013 9:51 am
Subject: Re: Response Class

Yes and no--the syntax is much better now, you can use this syntax:

responseClass="List[Customer]"

But it's still a string value, and brittle when refactoring.  This is
something that is very hard to get around in Java, period.  Now if you
venture past Java to scala, you'll see something with much better
integration:

https://github.com/wordnik/swagger-core/blob/master/samples/scala-sca...

Or copied from there:

  get("/:petId", operation(
    apiOperation[Pet]
      ("getPetById")
      .summary("Find pet by ID")
      .notes("Returns a pet based on ID")

Note the response class of [Pet] is typed in the api.  This is an advantage
of the reflection in scala 2.10, which I'll remind folks is compatible with
java at the bytecode level.

Tony


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »