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] Data class must have at least one primary constructor parameter #14710

Closed
1 of 6 tasks
alex-hedley opened this issue Feb 15, 2023 · 2 comments · Fixed by #19526
Closed
1 of 6 tasks

[BUG] [Kotlin] Data class must have at least one primary constructor parameter #14710

alex-hedley opened this issue Feb 15, 2023 · 2 comments · Fixed by #19526

Comments

@alex-hedley
Copy link

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

I'm trying to generate a Kotlin class from a Swagger Spec.

Actual Kotlin Class
class FooList : MutableList<Foo> by ArrayList()

OpenAPI Generator output
data class FooList () : kotlin.collections.ArrayList<Foo>()

Build Error:

Data class must have at least one primary constructor parameter

openapi-generator version

6.3.0

Generation Details
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

plugins {
  id("org.openapi.generator") version "6.3.0"
}

tasks.register<GenerateTask>() { ... }
Steps to reproduce

...

Suggest a fix

Tried adding No-arg compiler plugin but it would prob need to be ran at a certain time in the build?

plugins {
// id("org.jetbrains.kotlin.plugin.noarg") version "1.8.10"
  kotlin("plugin.noarg") version "1.7.21"
}

noArg {
  annotation("com.example.FooList")
}
@sumowrestler
Copy link

Also seeing this in my case there is no annotation to target in the noarg plugin.

@Perondas
Copy link

Perondas commented Mar 9, 2024

I am having the same issue trying to generate a client for this spec.
The data classes: End, EndDate, Start, StartDate and LocationInner are all missing a constructor.

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

Successfully merging a pull request may close this issue.

3 participants