rpc
rpc copied to clipboard
Post method throws when setting a num value with no precision on a property of type double.
Hello, i have the following api.
import 'package:rpc/rpc.dart';
@ApiClass(name: "test", version: "v1")
class TestApi {
@ApiMethod(path: 'fail/post', method: 'POST')
TestResponse testPost(TestRequest request) {
return new TestResponse()..message = "all ok";
}
}
class TestRequest {
double value;
}
class TestResponse {
String message;
}
When i post with body {"value": 1.0 }
, everything works fine but when i post with body {"value": 1 }
the reponse is of status 400 with the following body.
{
"error": {
"code": 400,
"message": "Failed to decode request with internal error: type 'int' is not a subtype of type 'double' of 'value' where\n int is from dart:core\n double is from dart:core\n"
}
}
I am not sure if this is a bug or not. Nevertheless i cannot find a workaround when calling the post method from an angular typescript SPA.