forked from loafle/openapi-generator-original
[kotlin][spring-webclient] Add parseDateToQueryString (#16069)
This commit is contained in:
parent
0a6671044f
commit
3325edc5c5
@ -53,3 +53,20 @@ open class ApiClient(protected val client: WebClient) {
|
|||||||
private fun <I : Any> WebClient.RequestBodySpec.body(requestConfig: RequestConfig<I>) =
|
private fun <I : Any> WebClient.RequestBodySpec.body(requestConfig: RequestConfig<I>) =
|
||||||
apply { if (requestConfig.body != null) bodyValue(requestConfig.body) }
|
apply { if (requestConfig.body != null) bodyValue(requestConfig.body) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <reified T: Any> parseDateToQueryString(value : T): String {
|
||||||
|
{{#toJson}}
|
||||||
|
/*
|
||||||
|
.replace("\"", "") converts the json object string to an actual string for the query parameter.
|
||||||
|
The moshi or gson adapter allows a more generic solution instead of trying to use a native
|
||||||
|
formatter. It also easily allows to provide a simple way to define a custom date format pattern
|
||||||
|
inside a gson/moshi adapter.
|
||||||
|
*/
|
||||||
|
{{#jackson}}
|
||||||
|
return Serializer.jacksonObjectMapper.writeValueAsString(value).replace("\"", "")
|
||||||
|
{{/jackson}}
|
||||||
|
{{/toJson}}
|
||||||
|
{{^toJson}}
|
||||||
|
return value.toString()
|
||||||
|
{{/toJson}}
|
||||||
|
}
|
||||||
|
@ -53,3 +53,13 @@ open class ApiClient(protected val client: WebClient) {
|
|||||||
private fun <I : Any> WebClient.RequestBodySpec.body(requestConfig: RequestConfig<I>) =
|
private fun <I : Any> WebClient.RequestBodySpec.body(requestConfig: RequestConfig<I>) =
|
||||||
apply { if (requestConfig.body != null) bodyValue(requestConfig.body) }
|
apply { if (requestConfig.body != null) bodyValue(requestConfig.body) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <reified T: Any> parseDateToQueryString(value : T): String {
|
||||||
|
/*
|
||||||
|
.replace("\"", "") converts the json object string to an actual string for the query parameter.
|
||||||
|
The moshi or gson adapter allows a more generic solution instead of trying to use a native
|
||||||
|
formatter. It also easily allows to provide a simple way to define a custom date format pattern
|
||||||
|
inside a gson/moshi adapter.
|
||||||
|
*/
|
||||||
|
return Serializer.jacksonObjectMapper.writeValueAsString(value).replace("\"", "")
|
||||||
|
}
|
||||||
|
@ -53,3 +53,13 @@ open class ApiClient(protected val client: WebClient) {
|
|||||||
private fun <I : Any> WebClient.RequestBodySpec.body(requestConfig: RequestConfig<I>) =
|
private fun <I : Any> WebClient.RequestBodySpec.body(requestConfig: RequestConfig<I>) =
|
||||||
apply { if (requestConfig.body != null) bodyValue(requestConfig.body) }
|
apply { if (requestConfig.body != null) bodyValue(requestConfig.body) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <reified T: Any> parseDateToQueryString(value : T): String {
|
||||||
|
/*
|
||||||
|
.replace("\"", "") converts the json object string to an actual string for the query parameter.
|
||||||
|
The moshi or gson adapter allows a more generic solution instead of trying to use a native
|
||||||
|
formatter. It also easily allows to provide a simple way to define a custom date format pattern
|
||||||
|
inside a gson/moshi adapter.
|
||||||
|
*/
|
||||||
|
return Serializer.jacksonObjectMapper.writeValueAsString(value).replace("\"", "")
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user