OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.58k stars 6.52k forks source link

[BUG][SPRING] Snake_case parameter gets converted to camelCase in api #13729

Open JDalboth opened 1 year ago

JDalboth commented 1 year ago

Bug Report Checklist

Description

When generating an open api spec with a request parameter in snake_case form e.g. house_nr we have found the functionality of the api generated requires the parameter to be of the form houseNr. This is causing issues for us since 1. the spec is inconsistent with functionality, 2. Due to preexisting constraints we require the form to be house_nr.

openapi-generator version

6.1.0

OpenAPI declaration file content or url

If you post the code inline, please wrap it with

in: query
name: address
description: xyz
required: true
style: form
schema:
  type: object
  properties:
    house_nr:
      description: The house number of the location.
      type: string
      example: 200
Generation Details
openApiGenerate {
    generatorName = "spring"
    inputSpec = "src/docs/openapi/openapi_bundled.yaml".toString()
    templateDir = "${project.projectDir}/src/main/resources/openapi/templates"
    outputDir = "$buildDir/generated/raw/openapi".toString()
    apiPackage = "com.{}.generated.api"
    invokerPackage = "com.{}.generated"
    modelPackage = "com.{}.generated.api.model"
    configOptions = [
            interfaceOnly       : "true",
            skipDefaultInterface: "true",
            useTags             : "true",
            dateLibrary         : "java8"
    ]
}
Related issues/PRs
Suggest a fix
Mintas commented 1 year ago

@JDalboth can You please provide more details on problem? As pojo.mustache states, yes, parameter names would be camelized, but they will be prepended with JsonProperty containing baseName (without any changes, as declared in spec)