-
Notifications
You must be signed in to change notification settings - Fork 123
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
[chopper_built_value] @Query does not use serializers to serialize query params #332
Comments
This comment was marked as spam.
This comment was marked as spam.
Sorry, just dropped out of life a bit. Will have a look later. |
@danielgomezrico is this still an issue? |
@techouse yeah |
@danielgomezrico Getting to the bottom of this slowly. From some initial tests I've written, the support for these /// An interface for implementing request and response converters.
///
/// [Converter]s convert objects to and from their representation in HTTP.
///
/// [convertRequest] is called before [RequestInterceptor]s
/// and [convertResponse] is called just after the HTTP response,
/// before [ResponseInterceptor]s.
///
/// See [JsonConverter] and [FormUrlEncodedConverter] for example implementations.
@immutable
abstract class Converter {
/// Converts the received [Request] to a [Request] which has a body with the
/// HTTP representation of the original body.
FutureOr<Request> convertRequest(Request request);
/// Converts the received [Response] to a [Response] which has a body of the
/// type [BodyType].
///
/// `BodyType` is the expected type of the resulting `Response`'s body
/// \(e.g., `String` or `CustomObject)`.
///
/// If `BodyType` is a `List` or a `BuiltList`, `InnerType` is the type of the
/// generic parameter (e.g., `convertResponse<List<CustomObject>, CustomObject>(response)` ).
FutureOr<Response<BodyType>> convertResponse<BodyType, InnerType>(
Response response,
);
} To encode this in the Query will require quite some work. |
I am missing this too. What is even worse is that I can not write my own converter to handle query params as I need. Request converter will be only applied when body is not empty. |
@radzish you can always submit a PR 🤗 |
Ran into this problem with regular enums. One way to work around this is to write custom toString() method: @override
String toString() {
return this.name;
} |
@dustin-graham yep, that's how I always work with it. I'll take another look at this over the Xmas holidays unless someone beats me to it 🤞 |
Not sure if this resolves this particular custom serialization issue, but last week I replaced the old query serialization with my own port of qs in #592. |
Current
I use BuiltValue with EnumClass to have nice enums, but Im trying to use an enum as a
@Query
param and it uses thetoString
value in the request instead of using the serializer value.I have an Enum that is declared like:
The generated serializer:
And my service like this:
But when I see how the request is done, it sends
faceToFace
(visitType.toString()
value) instead of the serializerTurnVisitType.serializer
and thewiredValue
and sendface_to_face
.Some places on chopper
It does use
toString
on every query param, and it does not try to use the serializes.Here:
chopper/chopper/lib/src/request.dart
Line 126 in f558bc7
Here:
chopper/chopper/lib/src/utils.dart
Lines 76 to 82 in 82b951f
Expected
The url is built using the serializer if the type have it declared, and
The text was updated successfully, but these errors were encountered: