OpenAPITools / OpenAPITools/openapi-generator

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

Open
#13,729 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Spring generator case using the supplied OpenAPI YAML and Gradle configuration, focusing on the generated API parameter handling. Compare the generated signature for house_nr with the specification; done means the generated API accepts the snake_case parameter without requiring houseNr, with a regression test added if the generator's test structure is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.