OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Kotlin] Multiple interface composition is not implemented
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 a type implements multiple supertypes (aka the perfect case for interfaces), the generator does not extend those interfaces properly, even though it is actually importing both
openapi-generator version
7.12.0
OpenAPI declaration file content or url
components:
schemas:
searchInput:
type: object
discriminator:
propertyName: type
mapping:
DOG: '#/components/schemas/dogSearchInput'
properties:
query:
type: string
required:
- query
animalSearchInput:
type: object
discriminator:
propertyName: type
mapping:
DOG: '#/components/schemas/dogSearchInput'
properties:
id:
type: string
required:
- id
dogSearchInput:
allOf:
- $ref: '#/components/schemas/animalSearchInput'
- $ref: '#/components/schemas/searchInput'
properties:
name:
type: string
This is the output of the DogSearchInput class:
package no.example
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import no.example.AnimalSearchInput
import no.example.SearchInput
/**
*
* @param query
* @param name
*/
data class DogSearchInput(
@get:JsonProperty("query", required = true) val query: kotlin.String,
@get:JsonProperty("id", required = true) override val id: kotlin.String,
@get:JsonProperty("name") val name: kotlin.String? = null
) : AnimalSearchInput{
}
Generation Details
Generate the code using the cli and choose kotlin-spring as the generator
Steps to reproduce
Related issues/PRs
Suggest a fix
The fix here is to just extend both interfaces. The generator is already there in terms of importing the correct interface.
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 supplied OpenAPI YAML and the CLI entry point for the kotlin-spring generator, then inspect the generated DogSearchInput class. Compare its declared supertypes with the imported AnimalSearchInput and SearchInput; done means the generated Kotlin class extends both interfaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100