trevorwang / retrofit.dart

retrofit.dart is an dio client generator using source_gen and inspired by Chopper and Retrofit.
https://mings.in/retrofit.dart/
MIT License
1.07k stars 246 forks source link

Query(bool encoded) is not used anywhere #458

Open xeinebiu opened 2 years ago

xeinebiu commented 2 years ago

Describe the bug While delcaring an API, for a QueryParameter there is the flag called encoded. After some inspection, I do not see it being used anywhere.

Encoded = true

  @GET("/users/{userId}/notes")
  Future<Response> getUsers(
    @Path() String userId,
    @Query("book_id", encoded: true) String bookId,
  );

  @override
  Future<Response> getUsers(userId, bookId) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{r'book_id': bookId};
    final _headers = <String, dynamic>{};
    final _data = <String, dynamic>{};
    final _result = await _dio.fetch<Map<String, dynamic>>(
        _setStreamType<Response>(
            Options(method: 'GET', headers: _headers, extra: _extra)
                .compose(_dio.options, '/users/${userId}/notes',
                    queryParameters: queryParameters, data: _data)
                .copyWith(baseUrl: baseUrl ?? _dio.options.baseUrl)));
    final value = Response.fromJson(_result.data!);
    return value;
  }

Encoded = false

  @GET("/users/{userId}/notes")
  Future<Response> getUsers(
    @Path() String userId,
    @Query("book_id", encoded: false) String bookId,
  );

  @override
  Future<Response> getUsers(userId, bookId) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{r'book_id': bookId};
    final _headers = <String, dynamic>{};
    final _data = <String, dynamic>{};
    final _result = await _dio.fetch<Map<String, dynamic>>(
        _setStreamType<Response>(
            Options(method: 'GET', headers: _headers, extra: _extra)
                .compose(_dio.options, '/users/${userId}/notes',
                    queryParameters: queryParameters, data: _data)
                .copyWith(baseUrl: baseUrl ?? _dio.options.baseUrl)));
    final value = Response.fromJson(_result.data!);
    return value;
  }
dependencies:
  http: ^0.13.4
  json_annotation: ^4.4.0
  retrofit: ^3.0.1
  dio: ^4.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^1.0.0
  build_runner: ^2.1.7
  json_serializable: ^6.1.3
  retrofit_generator: '>=3.0.0 <4.0.0'
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

xeinebiu commented 2 years ago

Any update on the current issue?

TatyanaRTB commented 2 years ago

Hope it will be fixed. Indeed encoded parameter is not used after code generation and not affecting query in tests.