Skip to content

[BUG] [dart-dio] Cannot convert Date type using json_serializer #15182

@AAkira

Description

@AAkira

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The dart-dio doesn't convert the Date type using json_serializer but the dart-dio can convert the Date type using built_value.

openapi-generator version

v6.5.0

OpenAPI declaration file content or URL
  • openapi.yaml
...
        binary:
          description: None
          format: binary
          type: string
        date:
          description: None
          format: date
          type: string
        dateTime:
          description: None
          format: date-time
          type: string
...
Generation Details
  • samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart
...

 Future<Response<void>> testEndpointParameters({ 
    required num number,
    required double double_,
    required String patternWithoutDelimiter,
    required String byte,
    int? integer,
    int? int32,
    int? int64,
    double? float,
    String? string,
    MultipartFile? binary,
    DateTime? date,                     // <= Scheme type is Date but here is DateTime.
    DateTime? dateTime,
    String? password,
    String? callback,
    CancelToken? cancelToken,
    Map<String, dynamic>? headers,
    Map<String, dynamic>? extra,
    ValidateStatus? validateStatus,
    ProgressCallback? onSendProgress,
    ProgressCallback? onReceiveProgress,
  }) async {
    final _path = r'/fake';

...
Suggest a fix

Conversion of the Date type is only with bulit_value.

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java#L298-L304

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions