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] Duplicate @serializable annotation for generated data class (kotlinx-serialization) #20501

Open
3 of 6 tasks
anwarpro opened this issue Jan 19, 2025 · 0 comments

Comments

@anwarpro
Copy link

anwarpro commented Jan 19, 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

Duplicate @serializable annotation for generated data class. which lead to error This annotation is not repeatable.

openapi-generator version

openapi-generator-gradle-plugin 7.10.0

OpenAPI declaration file content or url
  schemas:
    AuthCallbackResponse:
      type: object
      description: The authentication's details.
      x-schemaName: AuthCallbackResponse
      required:
        - location
      properties:
        location:
          type: string
          title: location
          description: The location to redirect the user to for further authentication with the third-party provider.
    AuthResponse:
      type: object
      description: The authentication's details.
      x-schemaName: AuthResponse
      required:
        - token
      properties:
        token:
          type: string
          title: token
          description: The JWT token used for registration or authentication.

paths:
  /auth/customer/{auth_provider}:
    post:
      operationId: PostActor_typeAuth_provider
      summary: Authenticate Customer
      description: |
        Authenticate a customer and receive the JWT token to be used in the header of subsequent requests.

        When used with a third-party provider, such as Google, the request returns a `location` property. You redirect to the specified URL in your storefront to continue authentication with the third-party service.
      externalDocs:
        url: https://docs.medusajs.com/v2/storefront-development/customers/login#1-using-a-jwt-token
        description: 'Storefront development: How to login as a customer'
      x-authenticated: false
      parameters:
        - name: auth_provider
          in: path
          description: The provider used for authentication.
          required: true
          schema:
            type: string
            example: emailpass
      requestBody:
        content:
          application/json:
            schema:
              type: object
              description: The input data necessary for authentication. For example, for email-pass authentication, pass `email` and `password` properties.
              properties:
                email:
                  type: string
                password:
                  type: string
      tags:
        - Auth
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/AuthResponse'
                  - $ref: '#/components/schemas/AuthCallbackResponse'
                x-kotlin-discriminator:
                  token: AuthResponse
                  location: AuthCallbackResponse
Generation Details

gradle configration

val generatedSourcesPath = "$buildDir/generated"
val apiDescriptionFile = "${projectDir}/src/medusaOpenApiOnlyStore.yaml"
val apiRootName = "com.medusa"

openApiGenerate {
    generatorName.set("kotlin")
    inputSpec.set(apiDescriptionFile)
    outputDir.set("${rootDir.absolutePath}/kotlin-client")
    apiPackage.set("$apiRootName.api")
    invokerPackage.set("$apiRootName.invoker")
    modelPackage.set("$apiRootName.model")
    additionalProperties.set(
        mapOf(
            "library" to "multiplatform",
            "dateLibrary" to "kotlinx-datetime",
            "serializationLibrary" to "kotlinx_serialization"
        )
    )
}

generated code

/**
 * The authenticated customer's details.
 *
 * @param user 
 */
@Serializable@Serializable

data class AuthStoreSessionResponse (

    @SerialName(value = "user") @Required val user: StoreCustomer

) {


}

Here need only on @serializable annotation

Steps to reproduce
Related issues/PRs
Suggest a fix
@anwarpro anwarpro changed the title [BUG] Description [BUG] Duplicate @serializable annotation for generated data class (kotlinx-serialization) Jan 19, 2025
@anwarpro anwarpro changed the title [BUG] Duplicate @serializable annotation for generated data class (kotlinx-serialization) [BUG][kotlin] Duplicate @serializable annotation for generated data class (kotlinx-serialization) Jan 19, 2025
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