OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dart-dio] Cannot convert Date type using json_serializer
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart and the Date mapping in DartDioClientCodegen.java at lines 298-304. Compare the json_serializable and built_value generation paths for date fields. Done means a date schema generates the correct Dart type and serialization behavior in the json_serializable client.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100