OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Kotlin][kotlin-spring] Multi-level interface inheritance doesn't work
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 (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 using multi-level inheritance, the kotlin-spring generator produces non-compiling code.
Geometry.kt:32:13 'type' hides member of supertype 'GeoJsonObject' and needs 'override' modifier
GeometryElement.kt:31:13 'type' hides member of supertype 'Geometry' and needs 'override' modifier
MultiPoint.kt:25:86 Unresolved reference: Type -> must be GeometryElement.Type instead of MultiPoint.Type
openapi-generator version
$ openapi-generator-cli version
7.7.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
paths:
/points:
get:
summary: Returns all points.
description: Optional extended description in Markdown.
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PageOfPoints'
components:
schemas:
PageOfPoints:
required:
- content
allOf:
- $ref: "#/components/schemas/Page"
- properties:
content:
type: array
default: []
items:
$ref: "#/components/schemas/Points"
Points:
type: object
required:
- points
properties:
points:
$ref: "./common/GeoJson.yaml#/components/schemas/MultiPoint"
Page:
type: object
required:
- number
- size
- totalPages
- totalElements
properties:
number:
type: integer
format: int32
default: 0
description: Current page number
size:
type: integer
format: int32
default: 0
description: Number of elements per page
totalPages:
type: integer
format: int32
default: 0
description: Number of total pages
totalElements:
type: integer
format: int64
default: 0
description: Total number of elements
https://app.swaggerhub.com/apis/OlivierMartineau/GeoJSON/1.0.1
Generation Details
openapi-generator-cli generate -g kotlin-spring -i openapi.yaml --additional-properties documentationProvider=none --additional-properties interfaceOnly=true
Steps to reproduce
- run generation command above
- run gradle build
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/16946
https://github.com/OpenAPITools/openapi-generator/issues/18206
Suggest a fix
As a temporary workaround, it might be possible to bypass the issue using custom mustache templates, but I'm not familiar with them.
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
Run the listed openapi-generator-cli command with the supplied OpenAPI declaration, then inspect the generated Geometry.kt, GeometryElement.kt, and MultiPoint.kt files. Trace the kotlin-spring generator path that produces these declarations. Done means the generated project builds with Gradle without the reported override and unresolved Type errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100