[BUG][Kotlin][Multiplatform] Support for date format is missing for kotlinx-datetime library
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
For the input data in Schema:
shipDate:
type: string
format: date-time
generator produces
@SerialName(value = "shipDate") val shipDate: java.time.LocalDate? = null
Which is incorrect for multiplatform, and breaks the build
openapi-generator version
7.2.0
OpenAPI declaration file content or url
Just edit the original petstore.yaml and change shipDate to date:
Order:
title: Pet Order
description: An order for a pets from the pet store
type: object
properties:
id:
type: integer
format: int64
petId:
type: integer
format: int64
quantity:
type: integer
format: int32
shipDate:
type: string
format: date
status:
type: string
description: Order Status
enum:
- placed
- approved
- delivered
complete:
type: boolean
default: false
xml:
name: Order
Generation Details
Just run sample generator
Steps to reproduce
Generate kotlin-multiplatform-kotlinx-datetime sample
Related issues/PRs
none
Suggest a fix
Probably registering a date type in KotlinClientCodegen.java should be enough
private void processKotlinxDate() {
additionalProperties.put(DateLibrary.KOTLINX_DATETIME.value, true);
typeMapping.put("date", "kotlinx.datetime.LocalDate");
typeMapping.put("date-time", "kotlinx.datetime.Instant");
typeMapping.put("DateTime", "Instant");
importMapping.put("Instant", "kotlinx.datetime.Instant");
}
Just adding my two cents. Ran into the same issue using 7.3.0 and 7.2.0. Version 7.1.0 doesn't have the same problem.
We can confirm - we have the problem using 7.3.0 ❌ - version 7.1.0 works without issues ✅ .
It looks like the kotlinx-multiplatform serialization part of the openapi generator is not covered by unit tests.