Skip to content

[BUG] Incorrect java files generated with x-spring-paginated and explicit size and page parameters in 7.13.0 #21172

@alien11689

Description

@alien11689

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

New version of open api generator 7.13.0 generates incorrect java file when x-spring-paginated is set to true and explicit page and size parameters are provided.

Version 7.12.0 generetes:

@Operation(
        operationId = "getTasks",
        summary = "Returns a list of tasks.",
        tags = { "tasks" },
        responses = {
            @ApiResponse(responseCode = "200", description = "Successful response", content = {
                @Content(mediaType = "application/json", schema = @Schema(implementation = GetTasksResponseDTO.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.GET,
        value = "/tasks",
        produces = { "application/json" }
    )
    
    ResponseEntity<GetTasksResponseDTO> getTasks(
        @Min(0) @Parameter(name = "page", description = "", in = ParameterIn.QUERY) @Valid @RequestParam(value = "page", required = false) Integer page,
        @Min(10) @Max(100) @Parameter(name = "size", description = "", in = ParameterIn.QUERY) @Valid @RequestParam(value = "size", required = false) Integer size,
        @ParameterObject final Pageable pageable
    );

Version 7.13.0 generetes:

@Operation(
        operationId = "getTasks",
        summary = "Returns a list of tasks.",
        tags = { "tasks" },
        responses = {
            @ApiResponse(responseCode = "200", description = "Successful response", content = {
                @Content(mediaType = "application/json", schema = @Schema(implementation = GetTasksResponseDTO.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.GET,
        value = "/tasks",
        produces = { "application/json" }
    )
    
    ResponseEntity<GetTasksResponseDTO> getTasks(
        ,
        @ParameterObject final Pageable pageable
    );

In version 7.13.0 there is an additional coma and parameters documentation in annotation are missing

openapi-generator version

7.13.0

OpenAPI declaration file content or url
openapi: 3.1.1
info:
  title: Tasks API
  description: Tasks sample API
  version: 0.0.1

paths:
  /tasks:
    get:
      summary: Returns a list of tasks.
      operationId: GetTasks
      tags:
        - tasks
      x-spring-paginated: true
      parameters:
        - $ref: "#/components/parameters/pageablePage"
        - $ref: "#/components/parameters/pageableSize"
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetTasksResponse"

components:
  schemas:
    GetTasksResponse:
      type: object
      properties:
        tasks:
          type: array
          items:
            $ref: "#/components/schemas/Task"
      required:
        - tasks

    Task:
      type: object
      properties:
        id:
          type: string
          readOnly: true
        summary:
          type: string
      required:
        - id
        - summary

  parameters:
    pageablePage:
      in: query
      name: page
      schema:
        type: integer
        format: int32
        minimum: 0
      required: false
    pageableSize:
      in: query
      name: size
      schema:
        type: integer
        format: int32
        minimum: 10
        maximum: 100
      required: false
Generation Details

I have configured maven plugin:

            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>${openapi-generator-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>process-resources</phase>
                        <configuration>
                            <inputSpec>${project.basedir}/tasks-openapi.yaml</inputSpec>
                            <generatorName>spring</generatorName>
                            <modelPackage>alien11689.playground.taskprovider.tasks.model</modelPackage>
                            <apiPackage>alien11689.playground.taskprovider.tasks.api</apiPackage>
                            <invokerPackage>alien11689.playground.taskprovider.tasks.invoker</invokerPackage>
                            <modelNameSuffix>DTO</modelNameSuffix>
                            <configOptions>
                                <interfaceOnly>true</interfaceOnly>
                                <skipDefaultInterface>true</skipDefaultInterface>
                                <useSpringBoot3>true</useSpringBoot3>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Steps to reproduce

Generate java+spring project with provided above plugin and open api file

Related issues/PRs

#21016 seems to be the cause

Suggest a fix

N/A

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