forked from loafle/openapi-generator-original
scala-sttp4: fix for issue 15785 api returns unit. (#18536)
This commit is contained in:
parent
2a1b4f90df
commit
5e40fe7f8f
@ -19,7 +19,7 @@ class {{classname}}(baseUrl: String) {
|
|||||||
{{#javadocRenderer}}
|
{{#javadocRenderer}}
|
||||||
{{>javadoc}}
|
{{>javadoc}}
|
||||||
{{/javadocRenderer}}
|
{{/javadocRenderer}}
|
||||||
def {{operationId}}({{>methodParameters}}): Request[{{#defaultReturnType}}Either[Either[String, String], Unit]{{/defaultReturnType}}{{^defaultReturnType}}{{#separateErrorChannel}}Either[ResponseException[String, Exception], {{>operationReturnType}}]{{/separateErrorChannel}}{{^separateErrorChannel}}{{>operationReturnType}}{{/separateErrorChannel}}{{/defaultReturnType}}] =
|
def {{operationId}}({{>methodParameters}}): Request[{{#separateErrorChannel}}Either[ResponseException[String, Exception], {{>operationReturnType}}]{{/separateErrorChannel}}{{^separateErrorChannel}}{{>operationReturnType}}{{/separateErrorChannel}}] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{#queryParams}}{{baseName}}=${ {{{paramName}}} }{{^-last}}&{{/-last}}{{/queryParams}}{{/queryParams.0}}{{#isApiKey}}{{#isKeyInQuery}}{{^queryParams.0}}?{{/queryParams.0}}{{#queryParams.0}}&{{/queryParams.0}}{{keyParamName}}=${apiKey.value}&{{/isKeyInQuery}}{{/isApiKey}}")
|
.method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{#queryParams}}{{baseName}}=${ {{{paramName}}} }{{^-last}}&{{/-last}}{{/queryParams}}{{/queryParams.0}}{{#isApiKey}}{{#isKeyInQuery}}{{^queryParams.0}}?{{/queryParams.0}}{{#queryParams.0}}&{{/queryParams.0}}{{keyParamName}}=${apiKey.value}&{{/isKeyInQuery}}{{/isApiKey}}")
|
||||||
.contentType({{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}){{#headerParams}}
|
.contentType({{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}){{#headerParams}}
|
||||||
@ -35,7 +35,7 @@ class {{classname}}(baseUrl: String) {
|
|||||||
{{>paramMultipartCreation}}{{^-last}}, {{/-last}}{{/formParams}}
|
{{>paramMultipartCreation}}{{^-last}}, {{/-last}}{{/formParams}}
|
||||||
).flatten){{/isMultipart}}{{/formParams.0}}{{#bodyParam}}
|
).flatten){{/isMultipart}}{{/formParams.0}}{{#bodyParam}}
|
||||||
.body({{paramName}}){{/bodyParam}}
|
.body({{paramName}}){{/bodyParam}}
|
||||||
.response({{#defaultReturnType}}asEither(asString, ignore){{/defaultReturnType}}{{^defaultReturnType}}{{#separateErrorChannel}}asJson{{/separateErrorChannel}}{{^separateErrorChannel}}asJsonAlwaysUnsafe{{/separateErrorChannel}}[{{>operationReturnType}}]{{/defaultReturnType}})
|
.response({{#separateErrorChannel}}{{^returnType}}asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))){{/returnType}}{{#returnType}}asJson[{{>operationReturnType}}]{{/returnType}}{{/separateErrorChannel}}{{^separateErrorChannel}}{{^returnType}}asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))).getRight{{/returnType}}{{#returnType}}asJson[{{>operationReturnType}}].getRight{{/returnType}}{{/separateErrorChannel}})
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class PetApi(baseUrl: String) {
|
|||||||
.method(Method.DELETE, uri"$baseUrl/pet/${petId}")
|
.method(Method.DELETE, uri"$baseUrl/pet/${petId}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey.toString)
|
.header("api_key", apiKey.toString)
|
||||||
.response(asJson[Unit])
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple status values can be provided with comma separated strings
|
* Multiple status values can be provided with comma separated strings
|
||||||
@ -142,7 +142,7 @@ class PetApi(baseUrl: String) {
|
|||||||
"name" -> name,
|
"name" -> name,
|
||||||
"status" -> status
|
"status" -> status
|
||||||
))
|
))
|
||||||
.response(asJson[Unit])
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -35,7 +35,7 @@ class StoreApi(baseUrl: String) {
|
|||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.DELETE, uri"$baseUrl/store/order/${orderId}")
|
.method(Method.DELETE, uri"$baseUrl/store/order/${orderId}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.response(asJson[Unit])
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of status codes to quantities
|
* Returns a map of status codes to quantities
|
||||||
|
@ -34,13 +34,13 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
def createUser(apiKey: String)(user: User): Request[Either[Either[String, String], Unit]] =
|
def createUser(apiKey: String)(user: User): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user")
|
.method(Method.POST, uri"$baseUrl/user")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKey)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asEither(asString, ignore))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -53,13 +53,13 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(apiKey: String)(user: Seq[User]): Request[Either[Either[String, String], Unit]] =
|
def createUsersWithArrayInput(apiKey: String)(user: Seq[User]): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKey)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asEither(asString, ignore))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -72,13 +72,13 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(apiKey: String)(user: Seq[User]): Request[Either[Either[String, String], Unit]] =
|
def createUsersWithListInput(apiKey: String)(user: Seq[User]): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKey)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asEither(asString, ignore))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
@ -97,7 +97,7 @@ class UserApi(baseUrl: String) {
|
|||||||
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKey)
|
||||||
.response(asJson[Unit])
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -144,12 +144,12 @@ class UserApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def logoutUser(apiKey: String)(): Request[Either[Either[String, String], Unit]] =
|
def logoutUser(apiKey: String)(): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/user/logout")
|
.method(Method.GET, uri"$baseUrl/user/logout")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKey)
|
||||||
.response(asEither(asString, ignore))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
@ -170,6 +170,6 @@ class UserApi(baseUrl: String) {
|
|||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKey)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asJson[Unit])
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user