[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