OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dart] date-time data type: Nullable value generates uncompilable code
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Inside the attached openapi.yaml you'll find an 'Instant' type defined as:
Instant:
format: date-time
type: string
example: 2022-03-10T16:15:50Z
This data type is used for nullable and not nullable properties (e.g. GraphTouchResponse nullable, GraphTransactionResponse not nullable). Generating Dart code (openapi-generator generate ... -g dart) generates:
return GraphTransactionResponse(
uuid: mapValueOfType<String>(json, r'uuid')!,
expires: mapDateTime(json, r'expires', '')!,
);
and
return GraphTouchResponse(
uuid: mapValueOfType<String>(json, r'uuid'),
internalId: mapValueOfType<String>(json, r'internalId'),
expires: DateTime.fromJson(json[r'expires']),
touched: mapValueOfType<bool>(json, r'touched'),
);
In the latter case expires: mapDateTime(json, r'expires', ''), would be expected as it is the case with the (String) type uuid.
Version
D:\source\rinkon\clientdart>openapi-generator.bat version
0
6.0.0
OpenAPI declaration file content or url
yaml file attached inside the zip
Generation Details
D:\source\rinkon\clientdart>openapi-generator.bat generate -i {path/to/openapi.yaml} -g dart --additional-properties=pubName=client_dart,pubLibrary=client_dart.api --minimal-update
Steps to reproduce
Output of CLI command above
Related issues/PRs
Unknown
Suggest a fix
So far I do not see any particular details in DartClientCodegen.java and AbstractDartCodegen.java
openapi.zip
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 the attached openapi.yaml and reproduce the issue using the documented openapi-generator generate command with the dart generator. Read DartClientCodegen.java and AbstractDartCodegen.java to trace nullable date-time property handling. Done means nullable date-time fields generate the same nullable mapDateTime form as the expected expires output and the generated Dart code compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100