Skip to content

Commit 445d0f7

Browse files
committed
rebuilt
1 parent 637ee77 commit 445d0f7

File tree

10 files changed

+422
-382
lines changed

10 files changed

+422
-382
lines changed

samples/client/petstore/async-scala/build.sbt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ organization := ""
33
name := "-client"
44

55
libraryDependencies ++= Seq(
6-
"com.wordnik.swagger" %% "swagger-async-httpclient" % "0.3.5",
7-
"joda-time" % "joda-time" % "2.3",
8-
"org.joda" % "joda-convert" % "1.3.1",
9-
"ch.qos.logback" % "logback-classic" % "1.0.13" % "provided",
10-
"org.scalatest" %% "scalatest" % "2.2.1" % "test",
11-
"junit" % "junit" % "4.11" % "test"
6+
"com.wordnik" %% "swagger-async-httpclient" % "0.3.5",
7+
"joda-time" % "joda-time" % "2.3",
8+
"org.joda" % "joda-convert" % "1.3.1",
9+
"ch.qos.logback" % "logback-classic" % "1.0.13" % "provided",
10+
"org.scalatest" %% "scalatest" % "2.2.1" % "test",
11+
"junit" % "junit" % "4.11" % "test"
1212
)
Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
package io.swagger.client
22

3+
import io.swagger.client.api._
4+
5+
import io.swagger.client._
6+
37
import java.io.Closeable
48

59
class SwaggerClient(config: SwaggerConfig) extends Closeable {
6-
val locator = config.locator
7-
val name = config.name
8-
val user = new UserApi(client, config)
9-
val pet = new PetApi(client, config)
10-
val store = new StoreApi(client, config)
11-
private[this] val client = transportClient
12-
13-
def close() {
14-
client.close()
15-
}
16-
17-
protected def transportClient: TransportClient = new RestClient(config)
10+
val locator = config.locator
11+
val name = config.name
12+
13+
private[this] val client = transportClient
14+
15+
protected def transportClient: TransportClient = new RestClient(config)
16+
17+
val user = new UserApi(client, config)
18+
19+
val pet = new PetApi(client, config)
20+
21+
val store = new StoreApi(client, config)
22+
23+
24+
def close() {
25+
client.close()
26+
}
1827
}

samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala

Lines changed: 138 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,190 +1,193 @@
11
package io.swagger.client.api
22

3+
import io.swagger.client.model.Pet
34
import java.io.File
5+
import io.swagger.client._
6+
import scala.concurrent.{ Future, Await }
7+
import scala.concurrent.duration._
8+
import collection.mutable
49

5-
import scala.collection.mutable
6-
import scala.concurrent.Future
10+
class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
711

8-
class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
12+
13+
def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
14+
// create path and map variables
15+
val path = (addFmt("/pet"))
916

17+
// query params
18+
val queryParams = new mutable.HashMap[String, String]
19+
val headerParams = new mutable.HashMap[String, String]
1020

11-
def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
12-
// create path and map variables
13-
val path = (addFmt("/pet"))
21+
1422

15-
// query params
16-
val queryParams = new mutable.HashMap[String, String]
17-
val headerParams = new mutable.HashMap[String, String]
23+
1824

25+
1926

27+
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
28+
resFuture flatMap { resp =>
29+
process(reader.read(resp))
30+
}
31+
}
2032

33+
34+
def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
35+
// create path and map variables
36+
val path = (addFmt("/pet"))
2137

38+
// query params
39+
val queryParams = new mutable.HashMap[String, String]
40+
val headerParams = new mutable.HashMap[String, String]
2241

42+
2343

44+
2445

25-
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
26-
resFuture flatMap { resp =>
27-
process(reader.read(resp))
28-
}
29-
}
30-
31-
32-
def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
33-
// create path and map variables
34-
val path = (addFmt("/pet"))
35-
36-
// query params
37-
val queryParams = new mutable.HashMap[String, String]
38-
val headerParams = new mutable.HashMap[String, String]
39-
40-
41-
42-
43-
44-
45-
46-
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
47-
resFuture flatMap { resp =>
48-
process(reader.read(resp))
49-
}
50-
}
46+
5147

48+
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
49+
resFuture flatMap { resp =>
50+
process(reader.read(resp))
51+
}
52+
}
5253

53-
def findPetsByStatus(status: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
54-
// create path and map variables
55-
val path = (addFmt("/pet/findByStatus"))
54+
55+
def findPetsByStatus(status: List[String] = available)(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
56+
// create path and map variables
57+
val path = (addFmt("/pet/findByStatus"))
5658

57-
// query params
58-
val queryParams = new mutable.HashMap[String, String]
59-
val headerParams = new mutable.HashMap[String, String]
59+
// query params
60+
val queryParams = new mutable.HashMap[String, String]
61+
val headerParams = new mutable.HashMap[String, String]
6062

63+
6164

65+
66+
if(status != null) queryParams += "status" -> status.toString
6267

68+
6369

64-
if (status != null) queryParams += "status" -> status.toString
70+
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
71+
resFuture flatMap { resp =>
72+
process(reader.read(resp))
73+
}
74+
}
6575

76+
77+
def findPetsByTags(tags: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
78+
// create path and map variables
79+
val path = (addFmt("/pet/findByTags"))
6680

81+
// query params
82+
val queryParams = new mutable.HashMap[String, String]
83+
val headerParams = new mutable.HashMap[String, String]
6784

68-
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
69-
resFuture flatMap { resp =>
70-
process(reader.read(resp))
71-
}
72-
}
85+
7386

87+
88+
if(tags != null) queryParams += "tags" -> tags.toString
7489

75-
def findPetsByTags(tags: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
76-
// create path and map variables
77-
val path = (addFmt("/pet/findByTags"))
90+
7891

79-
// query params
80-
val queryParams = new mutable.HashMap[String, String]
81-
val headerParams = new mutable.HashMap[String, String]
92+
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
93+
resFuture flatMap { resp =>
94+
process(reader.read(resp))
95+
}
96+
}
8297

98+
99+
def getPetById(petId: Long)(implicit reader: ClientResponseReader[Pet]): Future[Pet] = {
100+
// create path and map variables
101+
val path = (addFmt("/pet/{petId}")
102+
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
83103

104+
// query params
105+
val queryParams = new mutable.HashMap[String, String]
106+
val headerParams = new mutable.HashMap[String, String]
84107

108+
85109

86-
if (tags != null) queryParams += "tags" -> tags.toString
110+
87111

112+
88113

114+
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
115+
resFuture flatMap { resp =>
116+
process(reader.read(resp))
117+
}
118+
}
89119

90-
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
91-
resFuture flatMap { resp =>
92-
process(reader.read(resp))
93-
}
94-
}
95-
120+
121+
def updatePetWithForm(petId: String,
122+
name: String,
123+
status: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
124+
// create path and map variables
125+
val path = (addFmt("/pet/{petId}")
126+
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
96127

97-
def getPetById(petId: Long)(implicit reader: ClientResponseReader[Pet]): Future[Pet] = {
98-
// create path and map variables
99-
val path = (addFmt("/pet/{petId}")
100-
replaceAll("\\{" + "petId" + "\\}", petId.toString))
128+
// query params
129+
val queryParams = new mutable.HashMap[String, String]
130+
val headerParams = new mutable.HashMap[String, String]
101131

102-
// query params
103-
val queryParams = new mutable.HashMap[String, String]
104-
val headerParams = new mutable.HashMap[String, String]
132+
105133

134+
106135

136+
107137

138+
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
139+
resFuture flatMap { resp =>
140+
process(reader.read(resp))
141+
}
142+
}
108143

144+
145+
def deletePet(apiKey: String,
146+
petId: Long)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
147+
// create path and map variables
148+
val path = (addFmt("/pet/{petId}")
149+
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
109150

151+
// query params
152+
val queryParams = new mutable.HashMap[String, String]
153+
val headerParams = new mutable.HashMap[String, String]
110154

155+
111156

112-
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
113-
resFuture flatMap { resp =>
114-
process(reader.read(resp))
115-
}
116-
}
157+
117158

159+
headerParams += "api_key" -> apiKey.toString
118160

119-
def updatePetWithForm(petId: String,
120-
name: String,
121-
status: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
122-
// create path and map variables
123-
val path = (addFmt("/pet/{petId}")
124-
replaceAll("\\{" + "petId" + "\\}", petId.toString))
161+
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
162+
resFuture flatMap { resp =>
163+
process(reader.read(resp))
164+
}
165+
}
125166

126-
// query params
127-
val queryParams = new mutable.HashMap[String, String]
128-
val headerParams = new mutable.HashMap[String, String]
167+
168+
def uploadFile(petId: Long,
169+
additionalMetadata: String,
170+
file: File)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
171+
// create path and map variables
172+
val path = (addFmt("/pet/{petId}/uploadImage")
173+
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
129174

175+
// query params
176+
val queryParams = new mutable.HashMap[String, String]
177+
val headerParams = new mutable.HashMap[String, String]
130178

179+
131180

181+
132182

183+
133184

185+
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
186+
resFuture flatMap { resp =>
187+
process(reader.read(resp))
188+
}
189+
}
134190

191+
135192

136-
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
137-
resFuture flatMap { resp =>
138-
process(reader.read(resp))
139193
}
140-
}
141-
142-
143-
def deletePet(api_key: String,
144-
petId: Long)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
145-
// create path and map variables
146-
val path = (addFmt("/pet/{petId}")
147-
replaceAll("\\{" + "petId" + "\\}", petId.toString))
148-
149-
// query params
150-
val queryParams = new mutable.HashMap[String, String]
151-
val headerParams = new mutable.HashMap[String, String]
152-
153-
154-
155-
156-
157-
headerParams += "api_key" -> api_key.toString
158-
159-
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
160-
resFuture flatMap { resp =>
161-
process(reader.read(resp))
162-
}
163-
}
164-
165-
166-
def uploadFile(petId: Long,
167-
additionalMetadata: String,
168-
file: File)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
169-
// create path and map variables
170-
val path = (addFmt("/pet/{petId}/uploadImage")
171-
replaceAll("\\{" + "petId" + "\\}", petId.toString))
172-
173-
// query params
174-
val queryParams = new mutable.HashMap[String, String]
175-
val headerParams = new mutable.HashMap[String, String]
176-
177-
178-
179-
180-
181-
182-
183-
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
184-
resFuture flatMap { resp =>
185-
process(reader.read(resp))
186-
}
187-
}
188-
189-
190-
}

0 commit comments

Comments
 (0)