Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #9317
Closed
Open
Issue created Apr 22, 2021 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][Kotlin][retrofit2] @Path must be before @Query

Created by: shanselm-ergon

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

See: https://github.com/eManPrague/swagger-codegen/issues/11, this is the same issue I face in the newest OpenApi generator.

    java.lang.IllegalArgumentException: A @Path parameter must not come after a @Query. (parameter #2)
        for method MapItemApi.getMapItemMa
        at retrofit2.Utils.methodError(Utils.java:52)
        at retrofit2.Utils.methodError(Utils.java:42)
        at retrofit2.Utils.parameterError(Utils.java:61)
        at retrofit2.RequestFactory$Builder.parseParameterAnnotation(RequestFactory.java:376)
        at retrofit2.RequestFactory$Builder.parseParameter(RequestFactory.java:306)
        at retrofit2.RequestFactory$Builder.build(RequestFactory.java:193)
        at retrofit2.RequestFactory.parseAnnotations(RequestFactory.java:67)
        at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:26)
        at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
        at retrofit2.Retrofit$1.invoke(Retrofit.java:149)
        at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
        at $Proxy15.getMapItemMa(Unknown Source)

Experienced:

@GET("do/something")
fun doSomething(@Query("queryParam") queryParam: kotlin.Int? = null, @Path("pathParam") pathParam: kotlin.String): Single<SomethingDTO>

Expected:

@GET("do/something")
fun doSomething(@Path("pathParam") pathParam: kotlin.String, @Query("queryParam") queryParam: kotlin.Int? = null): Single<SomethingDTO>
openapi-generator version

5.1.0

OpenAPI declaration file content or url
"/do/something": {
  "get": {
    "tags": [
      "something"
    ],
    "operationId": "doSomething",
    "produces": [
      "application/json"
    ],
    "parameters": [
      {
        "name": "queryParam",
        "in": "query",
        "required": false,
        "type": "integer",
        "default": 0,
        "minimum": 0,
        "format": "int32"
      },
      {
        "name": "pathParam",
        "in": "path",
        "required": true,
        "type": "string"
      }
    ],
    "responses": {
      "200": {
        "description": "successful operation",
        "schema": {
          "$ref": "#/definitions/SomethingDTO"
        }
      }
    }
  }
}
Related issues/PRs

https://github.com/eManPrague/swagger-codegen/issues/11

Suggest a fix

In Java it is done by sorting params here

Assignee
Assign to
Time tracking