mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-21 06:37:10 +00:00
* #1023 - [Scala] Use status family during response processing * #1023 - [Scala] Use status family during response processing - adding REDIRECTION & INFORMATIONAL support
This commit is contained in:
committed by
William Cheng
parent
822234dd76
commit
c81c09b941
@@ -13,12 +13,13 @@ import com.sun.jersey.multipart.file.FileDataBodyPart
|
||||
import com.wordnik.swagger.client._
|
||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||
import javax.ws.rs.core.Response.Status.Family
|
||||
|
||||
import java.net.URI
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.TimeZone
|
||||
import javax.ws.rs.core.MediaType
|
||||
import javax.ws.rs.core.{MediaType, Response}
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent._
|
||||
@@ -144,7 +145,11 @@ class {{classname}}AsyncHelper(client: TransportClient, config: SwaggerConfig) e
|
||||
|
||||
val resFuture = client.submit("{{httpMethod}}", path, queryParams.toMap, headerParams.toMap, {{#bodyParam}}writer.write({{paramName}}){{/bodyParam}}{{^bodyParam}}"{{emptyBodyParam}}"{{/bodyParam}})
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||
status.getFamily match {
|
||||
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user