Skip to content

[BUG][Kotlin] The character '-' in request headers replaced with 'Minus' #7322

@ahreed304

Description

@ahreed304
Description

Header names defined in the api spec that contain dashes are generated incorrectly. 'x-application-name' generates as 'xMinusApplicationMinusName. This only happens when generating Kotin. If the same spec is used to generate Java code, it will appear correctly as 'xApplicationName'.

openapi-generator version

Using version 4.3.1. Also tried 5.0.0-beta with same results

OpenAPI declaration file content or url

The following excerpt of my .yml spec:

paths:
  /reload:
    parameters:
      - in: header
        name: x-application-name
        required: true
        description: "foo"
        example: "bar"
        schema:
          type: string
    post:
      tags:
        - Reload
      summary: "foo bar"
      operationId: "reload"
      # etc.

Produces the following Kotlin code:

@Validated
@RequestMapping("\${api.base-path:/v1}")
interface ReloadApi {


    @RequestMapping(
            value = ["/reload"],
            produces = ["application/json"], 
            consumes = ["application/json"],
            method = [RequestMethod.POST])
    fun reload( @RequestHeader(value="x-application-name", required=true) xMinusApplicationMinusName: kotlin.String
, @Valid @RequestBody reloadRequest: ReloadRequest
): ResponseEntity<ReloadResponse> {
        return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
    }
}
Generation Details

Language: Kotlin
Build tool: Maven
GeneratorName: kotlin-spring
library: spring-boot

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions