[bug][Kotlin] Default typeMapping for 'date' should be LocalDate
Created by: legzo
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output?
Description
When a spec specifies a property as :
"type": "string",
"format": "date",
the Kotlin generator generates the corresponding field as a LocalDateTime
and later, the parsing fails when Jackson is used (Gson too) saying it cannot find a converter for this type.
As I understand the spec, "format":"date"
should result in a LocalDate
and "format":"date-time"
in a LocalDateTime
openapi-generator version
I tried version 3.3.4, but I read the code of master and the problem is still present.
Steps to reproduce
Use as an input any spec that has a property configured as :
"type": "string",
"format": "date",
Suggest a fix/enhancement
I think there is only one line to change at https://github.com/OpenAPITools/openapi-generator/blob/0b66fa5c8214e2907a326fa8684cb2adcfa438a6/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java#L175
it should be
typeMapping.put("Date", "java.time.LocalDate");
I can provide a PR if you think it is really a bug.
Cheers.