OpenAPITools / OpenAPITools/openapi-generator

[BUG][KOTLIN] Invalid project structure when using @Parcelize

Open
#4,669 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

When I use gradle plugin to generate kotlin client with additional parameters for generating parcelable model, I get project with missing dependencies:

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

When I looked through mustache templates, I realised that there is no any android dependencies, but project needs them to use @Parcelize annotation.

openapi-generator version - 4.2.2
Command line used for generation
task buildClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
    generatorName = "kotlin"
    inputSpec = "$buildDir/generated/specs/spec.yml".toString()
    outputDir = generatedProjectDir.toString()
    apiPackage = "com.serhii"
    library = "jvm-okhttp4"
    configOptions = [
            artifactId          : "someId",
            dateLibrary         : "threetenbp",
            serializationLibrary: "gson",
            parcelizeModels     : "true",
            artifactVersion     : "1.0",
            collectionType      : "list",
            enumPropertyNaming  : "UPPERCASE"
    ]
}

Steps to reproduce

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the Kotlin generator's mustache templates and the generated Gradle project when parcelizeModels is enabled. Compare the generated project with the Android imports shown in the report. Done means the generated project declares the dependencies required by @Parcelize and has valid project structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
build-system, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.