OpenAPITools / OpenAPITools/openapi-generator

[BUG][Java][Spring] implicitHeaders replace the - in header name by a camelCased name

オープン
#8,167 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Issue: Bug
主要言語
Java
スター
26.8k
フォーク
7.7k
PR マージ指標
PR 指標を取得中

説明

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

Using the maven plugin configuration with implicitHeaders and with this API specification :

openapi: 3.0.2
info:
  title: Whatever
  version: 1.0.0
paths:
  /Whatever:
    summary: Get Whatever
    parameters:
      - name: 'X-Whatever-Code'
        in: header
        required: true
        description: Whatever
        allowEmptyValue: false
        schema:
          type: string
    get:
      responses:
        '200':
          description: Whatever
          content:
            application/json:
              schema:
                type: string

The name of the implicit param is defined to xWhateverCode instead of X-Whatever-Code

  @ApiImplicitParams({
    @ApiImplicitParam(name = "xWhateverCode", value = "Whatever", required=true, dataType = "String", paramType = "header"),
    })
openapi-generator version

4.3.1

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: Whatever
  version: 1.0.0
paths:
  /Whatever:
    summary: Get Whatever
    parameters:
      - name: 'X-Whatever-Code'
        in: header
        required: true
        description: Whatever
        allowEmptyValue: false
        schema:
          type: string
    get:
      responses:
        '200':
          description: Whatever
          content:
            application/json:
              schema:
                type: string
Generation Details
<plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>4.3.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <output>${openapi.generation.directory}</output>
                            <inputSpec>src/main/resources/openapi.yaml</inputSpec>
                            <generatorName>spring</generatorName>
                            <apiPackage>com.whatever.api.controller</apiPackage>
                            <modelPackage>com.whatever.api.model</modelPackage>
                            <generateSupportingFiles>false</generateSupportingFiles>
                            <configOptions>
                                <sourceFolder>.</sourceFolder>
                                <groupId>whatever</groupId>
                                <invokerPackage>com.whatever.api</invokerPackage>
                                <dateLibrary>java8</dateLibrary>
                                <artifactId>whatever-api</artifactId>
                                <artifactVersion>1.0.0</artifactVersion>
                                <configPackage>com.whatever.configuration</configPackage>
                                <basePackage>com.whatever</basePackage>
                                <reactive>true</reactive>
                                <interfaceOnly>true</interfaceOnly>
                                <skipDefaultInterface>true</skipDefaultInterface>
                                <implicitHeaders>true</implicitHeaders>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Steps to reproduce

Simply generate the source code with the configurations above

Related issues/PRs

Seems to be a similar problem with Kotlin generation : https://github.com/OpenAPITools/openapi-generator/issues/7322

Suggest a fix

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Maven plugin が使用する Spring generator のエントリーポイントから始め、implicitHeaders オプションが OpenAPI のヘッダー名 X-Whatever-Code をどのように変換するかを追跡します。提供された OpenAPI 3.0.2 仕様と Spring 設定で問題を再現し、生成された @ApiImplicitParam メタデータで期待されるヘッダー名が保持されることを確認して、該当する generator test が見つかった場合は追加または更新します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, spring
領域
api, backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。