swagger-api / swagger-api/swagger-codegen

[JAVA] Generated method parameters inverse order

Open
#11,877 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Generated method has parameters in inverse order relative to specification file.
When using delegate pattern, if the order is not respected, can cause issues with reversed parameter values, leading to invalid behavior.

Swagger-codegen version

https://editor.swagger.io/ or
Maven plugin:

<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.34</version>
Swagger declaration file content or url
swagger: '2.0'
info:
  title: ' '
  version: '1.0'
host: test.com
basePath: /v0
x-appVersion: v0
schemes:
  - https
paths:
  /main:
    get:
      produces:
        - application/json
      operationId: op1
      summary: " "
      parameters:
        - in: query
          name: qparm1
          type: string
          required: false
        - in: query
          name: qparm2
          type: string
          required: true
      responses:
        200:
          description: ' return'
          schema:
            type: string
Command line used for generation

Online https://editor.swagger.io/
generate server -> spring

Steps to reproduce

Use https://editor.swagger.io/ to generate spring server.

ResponseEntity<String> op1(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "qparm2", required = true) String qparm2,@ApiParam(value = "") @Valid @RequestParam(value = "qparm1", required = false) String qparm1);

Related issues/PRs
Suggest a fix/enhancement

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in editor.swagger.io using the supplied Swagger 2.0 YAML and the generate server → spring entry point; the Maven plugin version is also provided. Compare the generated op1 signature with the specification's qparm1, qparm2 order, and consider the generator path responsible for that output. Done means the generated Java method preserves the declaration order.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.