OpenAPITools / OpenAPITools/openapi-generator

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

Aperta
#8,167 3 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Issue: Bug
Lingua principale
Java
Stelle
26.8k
Fork
7.7k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal punto di ingresso del generatore Spring utilizzato dal plugin Maven e segui il modo in cui l’opzione implicitHeaders converte il nome dell’header OpenAPI X-Whatever-Code. Riproduci il problema con la specifica OpenAPI 3.0.2 e la configurazione Spring fornite, quindi verifica che i metadati @ApiImplicitParam generati conservino il nome dell’header previsto e aggiungi o aggiorna il test del generatore pertinente, se ne viene trovato uno.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java, spring
Ambito
api, backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.