Closed leflamm closed 7 years ago
I maybe misunderstanding your request, but the raml spec doesn't square very well with jaxrs here:
public @interface QueryParam
Binds the value(s) of a HTTP query parameter to a resource method parameter, resource class field, or resource class bean property. Values are URL decoded unless this is disabled using the Encoded annotation. A default value can be specified using the DefaultValue annotation. The type T of the annotated parameter, field or property must either:
Be a primitive type
Have a constructor that accepts a single String argument
Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String))
Have a registered implementation of ParamConverterProvider JAX-RS extension SPI that returns a ParamConverter instance capable of a "from string" conversion for the type.
Be List
We could generate the object, but the user would have to provide a plugin to generate one of either static methods, or implement an interface.
Stuff like this If a query parameter declaration specifies a non-array type for the value of the query parameter, or doesn't specify a type (equivalent to specifying a string type), processors MUST disallow multiple instances of that query parameter in the request.
is against the jaxrs spec.
I have seen at least two different ways of implementing objects in query parameters.
1) using JSON, e.g. /foo?param={'object':'json'}
2) using dot-notation, e.g. /foo?param.object=json
I personally prefer option 2) but I don't have strong arguments against option 1) plus I think one should have the ability to implement it the way one wants. That being said, @leflamm: would you be ok with what @jpbelang suggested?
We could generate the object, but the user would have to provide a plugin to generate one of either static methods, or implement an interface.
Yes, I currently fail to see another option.
Iv'e fixed this, but it currently requires the user to register a ParameterConverterProvider in jaxrs, as types are currently interfaces right now (so we can't add a static method to it.
Being on commit 4d6de5d (HEAD -> release/2.0.0, origin/release/2.0.0)
raml-to-jaxrs-cli
will fail if query parameters are defined as object type.https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#query-parameters-in-a-query-string