Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Kotlin] Schema with object named Timestamp does not compile #21044

Open
5 of 6 tasks
ross-paypay opened this issue Apr 6, 2025 · 0 comments
Open
5 of 6 tasks

[BUG][Kotlin] Schema with object named Timestamp does not compile #21044

ross-paypay opened this issue Apr 6, 2025 · 0 comments

Comments

@ross-paypay
Copy link

ross-paypay commented Apr 6, 2025

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

When generator a client from a schema with a schema object named Timestamp invalid Kotlin code is generated.

data class java.sql.Timestamp (

    /* Milliseconds since the Unix epoch */
    @get:JsonProperty("epochMillis")
    val epochMillis: kotlin.String

)

The generator seems to be blindly using java.sql.Timestamp as the {{classname}} in template rendering even though it is defined as a custom schema.

openapi-generator version

7.12

OpenAPI declaration file content or url
info:
  title: OpenAPI definition
  version: v0
paths: {}
openapi: 3.0.1
servers:
  - url: http://localhost:8080
    description: Generated server url
components:
  schemas:
    Timestamp:
      type: object
      required:
        - epochMillis
      properties:
        epochMillis:
          type: string
          example: '1481899949606'
          description: Milliseconds since the Unix epoch
      description: A timestamp object representing a point on the ISO timeline in milliseconds since the Unix epoch.
Generation Details
generatorName: kotlin
library: jvm-okhttp4
additionalProperties:
  groupId: jp.ne.paypay
  useSpringBoot3: true
  serializationLibrary: jackson
  idea: true
Steps to reproduce
  1. Generate the schema above using the openapi-generator config above
  2. chmod +x gradlew
  3. ./gradlew compileKotlin
Related issues/PRs
Suggest a fix

The issue appears to be that the CodegenModel's classname is being set to java.sql.Timestamp even though it should not.
I believe the fix should probably prevent that implicate behavior if the model is defined in the components.schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant