Open florianbesserprjphxcom opened 3 years ago
I have the same problem and created a minimal example to reproduce the issue:
openapi: 3.0.3
info:
title: "Example API"
version: "1.0.0"
paths:
/test:
get:
operationId: "test"
tags: [ "First", "Second" ]
responses:
"200":
description: "Success"
I have used the validator to confirm that the spec is valid. I also confirmed that the issue still persists. Sadly, I could not build from source, but I used the following jar to reproduce the problem as described here: https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.0.0-SNAPSHOT/openapi-generator-cli-6.0.0-20210712.095051-16.jar
Steps to reproduce:
api.yaml
and put it in the same directory as the jarjava -jar openapi-generator-cli-6.0.0-20210712.095051-16.jar generate -g kotlin-spring -i api.yaml
src/main/kotlin/org/openapitools/api/TestApi.kt
and you will see the following:package org.openapitools.api
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import javax.validation.Valid
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import kotlin.collections.List
import kotlin.collections.Map
@RestController
@Validated
@RequestMapping("\${api.base-path:}")
class TestApiController() {
@GetMapping(
value = ["/test"]
)
fun test(): ResponseEntity<Unit> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
@GetMapping(
value = ["/test"]
)
fun test(): ResponseEntity<Unit> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
}
This is of course not valid Kotlin code, as the function for the GET /test
is generated twice
Thanks @c-classen , I've updated the original post.
Still happening as of v5.3.1
Bug Report Checklist
Description
Duplicate Kotlin code is generated, which then fails to compile.
openapi-generator version
We use
org.openapitools:openapi-generator-gradle-plugin:5.2.0
OpenAPI declaration file content or url
Excerpt from input file:
as well as
Generation Details
The following code is produced
Steps to reproduce
Due to privacy constraints we can't paste more code here. However once we remove one of the two tags from the input, e.g.:
then the generated Kotlin code does not contain a duplicate method
createCustomer
anymore.Related issues/PRs
None
Suggest a fix
Do not generate a duplicate method even if multiple tags are provided for a given input.