OpenAPITools / OpenAPITools/openapi-generator

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

Abierto
#8,167 3 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Issue: Bug
Lenguaje dominante
Java
Estrellas
26.8k
Forks
7.7k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el punto de entrada del generador de Spring utilizado por el plugin de Maven y sigue cómo la opción implicitHeaders convierte el nombre del encabezado de OpenAPI X-Whatever-Code. Reproduce el problema con la especificación OpenAPI 3.0.2 y la configuración de Spring proporcionadas; después, verifica que los metadatos @ApiImplicitParam generados conserven el nombre de encabezado esperado y añade o actualiza la prueba correspondiente del generador si se encuentra una.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java, spring
Área
api, backend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.