forked from loafle/openapi-generator-original
[Kotlin][#9317] Add parameter sorting to Kotlin client generator (as used in the Java generator). (#9318)
This commit is contained in:
committed by
GitHub
parent
946d145d30
commit
05f329959c
@@ -17,6 +17,8 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import static java.util.Collections.sort;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@@ -656,6 +658,20 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
operation.path = operation.path.substring(1);
|
||||
}
|
||||
|
||||
// sorting operation parameters to make sure path params are parsed before query params
|
||||
if (operation.allParams != null) {
|
||||
sort(operation.allParams, (one, another) -> {
|
||||
if (one.isPathParam && another.isQueryParam) {
|
||||
return -1;
|
||||
}
|
||||
if (one.isQueryParam && another.isPathParam){
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
// modify the data type of binary form parameters to a more friendly type for multiplatform builds
|
||||
if (MULTIPLATFORM.equals(getLibrary()) && operation.allParams != null) {
|
||||
for (CodegenParameter param : operation.allParams) {
|
||||
|
||||
Reference in New Issue
Block a user