forked from loafle/openapi-generator-original
Fix generation of query parameters for optional/nullable function arguments (#3903)
* OpenAPITools/openapi-generator#3880 Fix generation of query parameters for optional/nullable function arguments * OpenAPITools/openapi-generator#3880 Updated generated samples
This commit is contained in:
parent
893f16ad3c
commit
ba04939c7a
@ -29,7 +29,16 @@ import {{packageName}}.infrastructure.toMultiValue
|
||||
@Suppress("UNCHECKED_CAST"){{/returnType}}
|
||||
fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} {
|
||||
val localVariableBody: kotlin.Any? = {{#hasBodyParam}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/hasBodyParam}}{{^hasBodyParam}}{{^hasFormParams}}null{{/hasFormParams}}{{#hasFormParams}}mapOf({{#formParams}}"{{{baseName}}}" to "${{paramName}}"{{#hasMore}}, {{/hasMore}}{{/formParams}}){{/hasFormParams}}{{/hasBodyParam}}
|
||||
val localVariableQuery: MultiValueMap = {{^hasQueryParams}}mapOf(){{/hasQueryParams}}{{#hasQueryParams}}mapOf({{#queryParams}}"{{paramName}}" to {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{paramName}}"){{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/queryParams}}){{/hasQueryParams}}
|
||||
val localVariableQuery: MultiValueMap = {{^hasQueryParams}}mapOf()
|
||||
{{/hasQueryParams}}{{#hasQueryParams}}mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
{{#queryParams}}
|
||||
{{^required}}if ({{paramName}} != null) {
|
||||
put("{{paramName}}", {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{paramName}}.toString()){{/isContainer}})
|
||||
}{{/required}}{{#required}}put("{{paramName}}", {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{paramName}}.toString()){{/isContainer}}){{/required}}
|
||||
{{/queryParams}}
|
||||
}
|
||||
{{/hasQueryParams}}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf({{#hasFormParams}}"Content-Type" to {{^consumes}}"multipart/form-data"{{/consumes}}{{#consumes.0}}"{{MediaType}}"{{/consumes.0}}{{/hasFormParams}}{{^hasHeaderParams}}){{/hasHeaderParams}}{{#hasHeaderParams}}{{#hasFormParams}}, {{/hasFormParams}}{{#headerParams}}"{{baseName}}" to {{#isContainer}}{{paramName}}.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}{{paramName}}.toString(){{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/headerParams}}){{/hasHeaderParams}}
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.{{httpMethod}},
|
||||
|
@ -98,7 +98,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "csv"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("status", toMultiValue(status.toList(), "csv"))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -129,7 +132,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "csv"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("tags", toMultiValue(tags.toList(), "csv"))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
|
@ -188,7 +188,11 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("username" to listOf("$username"), "password" to listOf("$password"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("username", listOf(username.toString()))
|
||||
put("password", listOf(password.toString()))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
|
@ -98,7 +98,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "csv"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("status", toMultiValue(status.toList(), "csv"))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -129,7 +132,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "csv"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("tags", toMultiValue(tags.toList(), "csv"))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
|
@ -188,7 +188,11 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("username" to listOf("$username"), "password" to listOf("$password"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("username", listOf(username.toString()))
|
||||
put("password", listOf(password.toString()))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
|
@ -98,7 +98,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "csv"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("status", toMultiValue(status.toList(), "csv"))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -129,7 +132,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "csv"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("tags", toMultiValue(tags.toList(), "csv"))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
|
@ -188,7 +188,11 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf("username" to listOf("$username"), "password" to listOf("$password"))
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
put("username", listOf(username.toString()))
|
||||
put("password", listOf(password.toString()))
|
||||
}
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
|
Loading…
x
Reference in New Issue
Block a user