You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Carl-Erik Kopseng <ca...@gmail.com> on 2012/10/08 22:31:57 UTC

JAXRS: @QueryParam("") just showing one of many parameters in WADL. Bug?

I think I might have found some kind of bug related to QueryParam, but
to make sure, I am posting it here first for input.

Using QueryParam("") MyClass myInput is usually a nice shortcut for
generating a WADL where the fields of MyClass are documented with type
and name. This has worked nicely for any classes composed of simple
fields, such as integers, doubles, Strings, etc, and for complex
Collection-ish fields (such as MyFoo[] foos), the type is not shown in
the WADL.

Today I had a class where one field is complex, and not of a array or
collection type, and to my surprise, the fields of this complex field
were shown. That was new to me! Unfortunately, all the other
parameters (fields of the input object) were _not_ shown. If my
description seems a bit unclear, I pasted the code and resulting wadl
snippet at http://pastebin.com/zqPi7Rfd and  below. Is this a bug or a
really weird feature? Using CXF JAX-RS 2.6.2

calculateCurrencyExchange(@QueryParam("") CurrencyExchangeInput input){
     ...
}

class ExchangeableCurrenciesInput {

	private ExchangeType type;
	private boolean showExchangeRates;
	private boolean showMargins;
	private boolean showProxyCurrencies;

        ...
}
class ExchangeType {

	private Long id;
	private String name;
	private String description;
        ...
}

<resource path="/getExchangeableCurrencies">
<method name="GET">
<request>
<param name="type.name" style="query" type="xs:string"/>
<param name="type.id" style="query" type="xs:long"/>
<param name="type.description" style="query" type="xs:string"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>

-- 
Carl-Erik Kopseng

(+47) 40065078
skype: carl.erik.kopseng
blogg: oligofren.wordpress.com
##########################
Ser ikke skogen for bare syntakstrær

Re: JAXRS: @QueryParam("") just showing one of many parameters in WADL. Bug?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Carl-Eric

sorry for a delay; there was a minor issue with boolean getters starting 
from 'is' not recognized, fixed now. As a workaround, try replace 'is' 
with 'get'. To be honest, this all should be done by common beanutils, 
hopefully we can refactor it in time.

Cheers, Sergey

On 09/10/12 14:09, Carl-Erik Kopseng wrote:
>>>> Unfortunately, all the other
>>>> parameters (fields of the input object) were _not_ shown. If my
>>>> description seems a bit unclear, I pasted the code and resulting wadl
>>>> snippet at http://pastebin.com/zqPi7Rfd and  below. Is this a bug or a
>>>> really weird feature? Using CXF JAX-RS 2.6.2
>>>>
>>>> calculateCurrencyExchange(@QueryParam("") CurrencyExchangeInput input){
>>>>        ...
>>>> }
>>>>
>>>> class ExchangeableCurrenciesInput {
>>>>
>>>>          private ExchangeType type;
>>>>          private boolean showExchangeRates;
>>>>          private boolean showMargins;
>>>>          private boolean showProxyCurrencies;
>>>>
>>>>           ...
>>>> }
>>>> class ExchangeType {
>>>>
>>>>          private Long id;
>>>>          private String name;
>>>>          private String description;
>
>>> I have a test with simple and complex fields, but that may be a bit brittle,
>>> the actual code dealing with that, may be even an ordering issue, example,
>>> having 'private ExchangeType type' as the last field may work better, I'll
>>> investigate
>
> A little addendum: it seems that the case is not simply that the
> parameters are not shown - they are effectively not used either. If I
> invoke the function using a query like
> .../getExchangeableCurrencies?type.id=1&showProxyCurrencies=true&showExchangeRate=true&showMargins=true
> both showExchangeRate and showMargins are false when viewing them in
> the debugger.
>
> This is a little worse than simply not being shown in the WADL :-(
>
> Regards
> Carl-Erik


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: JAXRS: @QueryParam("") just showing one of many parameters in WADL. Bug?

Posted by Carl-Erik Kopseng <ca...@gmail.com>.
I tried changing it to be the last field, per your recommendation, but
alas, it did nothing. I both tried changing the order of the
attributes, and putting the accessor methods last (was first).

P.S. This was using Glassfish 2.1.1. I used to be able to deploy and
work in Glassfish 3.1.1, but GF 3 now fails on writing the WADL to the
outputstream with "WebappClassLoader unable to load resource
[java.util.TreeSet], because it has not yet been started, or was
already stopped". Any idea if this bug is of a recent date?


Regards
Carl-Erik

2012/10/8 Sergey Beryozkin <sb...@gmail.com>:
> Hi Carl-Erik
>
> On 08/10/12 21:31, Carl-Erik Kopseng wrote:
>>
>> I think I might have found some kind of bug related to QueryParam, but
>> to make sure, I am posting it here first for input.
>>
>> Using QueryParam("") MyClass myInput is usually a nice shortcut for
>> generating a WADL where the fields of MyClass are documented with type
>> and name. This has worked nicely for any classes composed of simple
>> fields, such as integers, doubles, Strings, etc, and for complex
>> Collection-ish fields (such as MyFoo[] foos), the type is not shown in
>> the WADL.
>>
>> Today I had a class where one field is complex, and not of a array or
>> collection type, and to my surprise, the fields of this complex field
>> were shown. That was new to me! Unfortunately, all the other
>> parameters (fields of the input object) were _not_ shown. If my
>> description seems a bit unclear, I pasted the code and resulting wadl
>> snippet at http://pastebin.com/zqPi7Rfd and  below. Is this a bug or a
>> really weird feature? Using CXF JAX-RS 2.6.2
>>
>> calculateCurrencyExchange(@QueryParam("") CurrencyExchangeInput input){
>>       ...
>> }
>>
>> class ExchangeableCurrenciesInput {
>>
>>         private ExchangeType type;
>>         private boolean showExchangeRates;
>>         private boolean showMargins;
>>         private boolean showProxyCurrencies;
>>
>>          ...
>> }
>> class ExchangeType {
>>
>>         private Long id;
>>         private String name;
>>         private String description;
>>          ...
>> }
>>
>> <resource path="/getExchangeableCurrencies">
>> <method name="GET">
>> <request>
>> <param name="type.name" style="query" type="xs:string"/>
>> <param name="type.id" style="query" type="xs:long"/>
>> <param name="type.description" style="query" type="xs:string"/>
>> </request>
>> <response>
>> <representation mediaType="application/json"/>
>> </response>
>> </method>
>> </resource>
>>
> I have a test with simple and complex fields, but that may be a bit brittle,
> the actual code dealing with that, may be even an ordering issue, example,
> having 'private ExchangeType type' as the last field may work better, I'll
> investigate
>
> Sergey
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com



-- 
Carl-Erik Kopseng

(+47) 40065078
skype: carl.erik.kopseng
blogg: oligofren.wordpress.com
##########################
Ser ikke skogen for bare syntakstrær

Re: JAXRS: @QueryParam("") just showing one of many parameters in WADL. Bug?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Carl-Erik
On 08/10/12 21:31, Carl-Erik Kopseng wrote:
> I think I might have found some kind of bug related to QueryParam, but
> to make sure, I am posting it here first for input.
>
> Using QueryParam("") MyClass myInput is usually a nice shortcut for
> generating a WADL where the fields of MyClass are documented with type
> and name. This has worked nicely for any classes composed of simple
> fields, such as integers, doubles, Strings, etc, and for complex
> Collection-ish fields (such as MyFoo[] foos), the type is not shown in
> the WADL.
>
> Today I had a class where one field is complex, and not of a array or
> collection type, and to my surprise, the fields of this complex field
> were shown. That was new to me! Unfortunately, all the other
> parameters (fields of the input object) were _not_ shown. If my
> description seems a bit unclear, I pasted the code and resulting wadl
> snippet at http://pastebin.com/zqPi7Rfd and  below. Is this a bug or a
> really weird feature? Using CXF JAX-RS 2.6.2
>
> calculateCurrencyExchange(@QueryParam("") CurrencyExchangeInput input){
>       ...
> }
>
> class ExchangeableCurrenciesInput {
>
> 	private ExchangeType type;
> 	private boolean showExchangeRates;
> 	private boolean showMargins;
> 	private boolean showProxyCurrencies;
>
>          ...
> }
> class ExchangeType {
>
> 	private Long id;
> 	private String name;
> 	private String description;
>          ...
> }
>
> <resource path="/getExchangeableCurrencies">
> <method name="GET">
> <request>
> <param name="type.name" style="query" type="xs:string"/>
> <param name="type.id" style="query" type="xs:long"/>
> <param name="type.description" style="query" type="xs:string"/>
> </request>
> <response>
> <representation mediaType="application/json"/>
> </response>
> </method>
> </resource>
>
I have a test with simple and complex fields, but that may be a bit 
brittle, the actual code dealing with that, may be even an ordering 
issue, example, having 'private ExchangeType type' as the last field may 
work better, I'll investigate

Sergey

-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com