OpenAPITools / OpenAPITools/openapi-generator
[BUG][kotlin-server] Kotlin Server Generator Does Not Support UUID
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?
- 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
When having next spec:
definitions:
UuidTest:
type: object
required:
- uuidReq
properties:
uuidReq:
type: string
format: uuid
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
uuidNoReq:
type: string
format: uuid
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
the generator generates next code:
@Serializable
data class UuidTest(
val uuidReq: UUID,
var uuidNoReq: UUID,
)
which causes next compilation error after running gradle assemble:
Details: kotlinx.serialization compiler plugin internal error: unable to transform declaration, see cause
...
Caused by: java.lang.IllegalStateException: Serializer for element of type java.util.UUID? has not been found
at org.jetbrains.kotlinx.serialization.compiler.backend.ir.SerializerSearchUtilKt.findTypeSerializerOrContext(SerializerSearchUtil.kt:84)
To solve this issue is it should generate next kotlin code with the annotation @Contextual from kotlinx.serialization package:
@Serializable
data class UuidTest(
@Contextual
val uuidReq: UUID,
@Contextual
var uuidNoReq: UUID,
)
openapi-generator version
7.4.0
Generation Details
openapi-generator generate -i uuid-test.yaml -g kotlin-server
Suggest a fix
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 kotlin-server generator entry point and reproduce the issue using the shown openapi-generator command and uuid-test.yaml specification. Inspect how UUID properties are rendered in the generated Kotlin data class, then run gradle assemble and verify both required and optional UUID fields compile with the expected contextual serialization handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100