Skip to content

[BUG] [JAVA | JAXRS-Spec] Cookie in parameter is not correctly generated #2908

@grantsunny

Description

@grantsunny
Description

When trying to do code generation with cookie in parameter yaml file, uncompilable code are being generated and generator does not report error.

openapi-generator version

openapi-generator-maven-plugin 4.0.0

OpenAPI declaration file content or url
  /products:
    get:
      tags: 
        - products
      summary: List all products
      operationId: listProducts
      parameters:
        - in: cookie
          name: debug
          schema:
            type: string
            default: ""
        - in: query
          name: page
          description: Specify which page shall be returned. Default value is 0.
          required: false
          schema:
            type: integer
            format: int32
            default: 0
Command line used for generation
			<plugin>
				<groupId>org.openapitools</groupId>
				<artifactId>openapi-generator-maven-plugin</artifactId>
				<version>4.0.0</version>
				<executions>
					<execution>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<inputSpec>${project.basedir}/src/main/resources/email-api.yaml</inputSpec>
							<generatorName>jaxrs-spec</generatorName>
							<configOptions>
								<java8>true</java8>
								<dateLibrary>java8</dateLibrary>
								<interfaceOnly>true</interfaceOnly>
								<useSwaggerAnnotations>false</useSwaggerAnnotations>
								<generatPom>false</generatPom>
							</configOptions>
							<output>${project.basedir}</output>
							<apiPackage>...</apiPackage>
							<modelPackage>...</modelPackage>
						</configuration>
					</execution>
				</executions>
			</plugin>
Steps to reproduce

Using maven to trigger the generation. While I believe this is something to do with generator itself instead of the maven plug-in.

Related issues/PRs

#2689
I believe this is related but not same generator.

Suggest a fix

So far the generated code is like this

    @GET
    @Produces({ "application/json" })
    List<Product> listProducts(, @QueryParam("page")  @DefaultValue("0")   Integer page);

And it shall be like tihs

    @GET
    @Produces({ "application/json" })
    List<Product> listProducts(@CookieParam("debug") String debug, @QueryParam("page")  @DefaultValue("0")   Integer page);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions