You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
This is arguably a feature request, however it can be considered a bug as well as the optional and optional named parameters are accepted.
To Reproduce
Implement something like:
import 'package:dio/dio.dart';
import 'package:retrofit/http.dart';
import 'package:meta/meta.dart';
part 'my_client.g.dart';
@RestApi()
abstract class MyClient {
factory MyClient(Dio dio) = _MyClient;
@GET("content/api")
Future<Result> namedExample(@Query("apikey") String apiKey,
@Query("scope") String scope,
@Query("type") String type, {
@required @Query("from") int from
});
@GET("content/api")
Future<Result> optionalNamedExample(@Query("apikey") String apiKey,
@Query("scope") String scope,
@Query("type") String type, {
@Query("from") int from
});
@GET("content/api")
Future<Result> optionalExample(@Query("apikey") String apiKey,
@Query("scope") String scope,
@Query("type") String type, [
@Query("from") int from
]);
}
Expected behavior
In the case of namedExample, I would expect a null assertion to occur for the from parameter as of the existence of the @required annotation, however this is not the case.
In the case of optionalNamedExample, I would expect no null assertion for the from parameter as @required is not present. This is correct, however I would expect it to only be added to the queryParameters if from is not null (I think Square's Retrofit handles this). This could be done simply with Dart 2.3's control flow collections by doing:
final queryParameters = <String, dynamic>{
'apikey': apiKey,
'scope': scope,
'type': type,
if(from != null) 'from': from
};
In the case of optionalExample, I would expect the same sort of behaviour as above.
The text was updated successfully, but these errors were encountered:
Description
This is arguably a feature request, however it can be considered a bug as well as the optional and optional named parameters are accepted.
To Reproduce
Implement something like:
Expected behavior
In the case of
namedExample
, I would expect a null assertion to occur for thefrom
parameter as of the existence of the@required
annotation, however this is not the case.In the case of
optionalNamedExample
, I would expect no null assertion for thefrom
parameter as@required
is not present. This is correct, however I would expect it to only be added to thequeryParameters
iffrom
is not null (I think Square's Retrofit handles this). This could be done simply with Dart 2.3's control flow collections by doing:In the case of
optionalExample
, I would expect the same sort of behaviour as above.The text was updated successfully, but these errors were encountered: