Skip to content

Commit b41a40f

Browse files
committed
rebuilt
1 parent 2f3a241 commit b41a40f

File tree

14 files changed

+266
-201
lines changed

14 files changed

+266
-201
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "Alamofire/Alamofire" >= 1.2
1+
github "Alamofire/Alamofire" >= 2.0.0
22
github "mxcl/PromiseKit" >=1.5.3

samples/client/petstore/swift/PetstoreClient.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Pod::Spec.new do |s|
77
s.license = 'Apache License, Version 2.0'
88
s.source_files = 'PetstoreClient/Classes/Swaggers/**/*.swift'
99
s.dependency 'PromiseKit', '~> 2.1'
10-
s.dependency 'Alamofire', '~> 1.3'
10+
s.dependency 'Alamofire', '~> 2.0.0'
1111
end

samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77
import Foundation
88

9-
class OneteamAPI {
10-
static let basePath = "http://ec2-52-68-31-200.ap-northeast-1.compute.amazonaws.com/"
9+
public class PetstoreClientAPI {
10+
static let basePath = "http://petstore.swagger.io/v2"
1111
static var credential: NSURLCredential?
1212
static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
1313
}
1414

15-
class APIBase {
15+
public class APIBase {
1616
func toParameters(encodable: JSONEncodable?) -> [String: AnyObject]? {
1717
let encoded: AnyObject? = encodable?.encodeToJSON()
1818

1919
if encoded! is [AnyObject] {
2020
var dictionary = [String:AnyObject]()
21-
for (index, item) in enumerate(encoded as! [AnyObject]) {
21+
for (index, item) in (encoded as! [AnyObject]).enumerate() {
2222
dictionary["\(index)"] = item
2323
}
2424
return dictionary
@@ -28,32 +28,32 @@ class APIBase {
2828
}
2929
}
3030

31-
class RequestBuilder<T> {
31+
public class RequestBuilder<T> {
3232
var credential: NSURLCredential?
3333
var headers: [String:String] = [:]
3434
let parameters: [String:AnyObject]?
3535
let isBody: Bool
3636
let method: String
3737
let URLString: String
3838

39-
required init(method: String, URLString: String, parameters: [String:AnyObject]?, isBody: Bool) {
39+
required public init(method: String, URLString: String, parameters: [String:AnyObject]?, isBody: Bool) {
4040
self.method = method
4141
self.URLString = URLString
4242
self.parameters = parameters
4343
self.isBody = isBody
4444
}
4545

46-
func execute(completion: (response: Response<T>?, erorr: NSError?) -> Void) { }
46+
public func execute(completion: (response: Response<T>?, erorr: ErrorType?) -> Void) { }
4747

48-
func addHeader(#name: String, value: String) -> Self {
48+
public func addHeader(name name: String, value: String) -> Self {
4949
if !value.isEmpty {
5050
headers[name] = value
5151
}
5252
return self
5353
}
5454

55-
func addCredential() -> Self {
56-
self.credential = OneteamAPI.credential
55+
public func addCredential() -> Self {
56+
self.credential = PetstoreClientAPI.credential
5757
return self
5858
}
5959
}

samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift

Lines changed: 83 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import PromiseKit
1010

1111
extension PetstoreClientAPI {
1212

13-
class PetAPI: APIBase {
13+
public class PetAPI: APIBase {
1414

1515
/**
1616

@@ -22,19 +22,19 @@ extension PetstoreClientAPI {
2222
- type: oauth2
2323
- name: petstore_auth
2424

25-
:param: body (body) Pet object that needs to be added to the store
25+
- parameter body: (body) Pet object that needs to be added to the store
2626

27-
:returns: Promise<Response<Void>>
27+
- returns: RequestBuilder<Void>
2828
*/
29-
func updatePet(#body: Pet?) -> RequestBuilder<Void> {
29+
public class func updatePet(body body: Pet?) -> RequestBuilder<Void> {
3030
let path = "/pet"
31-
let url = PetstoreClientAPI.basePath + path
31+
let URLString = PetstoreClientAPI.basePath + path
3232

3333
let parameters = body?.encodeToJSON() as? [String:AnyObject]
3434

3535
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
3636

37-
return requestBuilder(method: "PUT", URLString: url, parameters: parameters, isBody: true)
37+
return requestBuilder.init(method: "PUT", URLString: URLString, parameters: parameters, isBody: true)
3838
}
3939

4040
/**
@@ -47,19 +47,19 @@ extension PetstoreClientAPI {
4747
- type: oauth2
4848
- name: petstore_auth
4949

50-
:param: body (body) Pet object that needs to be added to the store
50+
- parameter body: (body) Pet object that needs to be added to the store
5151

52-
:returns: Promise<Response<Void>>
52+
- returns: RequestBuilder<Void>
5353
*/
54-
func addPet(#body: Pet?) -> RequestBuilder<Void> {
54+
public class func addPet(body body: Pet?) -> RequestBuilder<Void> {
5555
let path = "/pet"
56-
let url = PetstoreClientAPI.basePath + path
56+
let URLString = PetstoreClientAPI.basePath + path
5757

5858
let parameters = body?.encodeToJSON() as? [String:AnyObject]
5959

6060
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
6161

62-
return requestBuilder(method: "POST", URLString: url, parameters: parameters, isBody: true)
62+
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true)
6363
}
6464

6565
/**
@@ -87,7 +87,11 @@ extension PetstoreClientAPI {
8787
} ], contentType=application/json}, {example=<Pet>
8888
<id>123456</id>
8989
<name>doggie</name>
90-
<photoUrls>string</photoUrls>
90+
<photoUrls>
91+
<photoUrls>string</photoUrls>
92+
</photoUrls>
93+
<tags>
94+
</tags>
9195
<status>string</status>
9296
</Pet>, contentType=application/xml}]
9397
- examples: [{example=[ {
@@ -106,17 +110,21 @@ extension PetstoreClientAPI {
106110
} ], contentType=application/json}, {example=<Pet>
107111
<id>123456</id>
108112
<name>doggie</name>
109-
<photoUrls>string</photoUrls>
113+
<photoUrls>
114+
<photoUrls>string</photoUrls>
115+
</photoUrls>
116+
<tags>
117+
</tags>
110118
<status>string</status>
111119
</Pet>, contentType=application/xml}]
112120

113-
:param: status (query) Status values that need to be considered for filter
121+
- parameter status: (query) Status values that need to be considered for filter
114122

115-
:returns: Promise<Response<[Pet]>>
123+
- returns: RequestBuilder<[Pet]>
116124
*/
117-
func findPetsByStatus(#status: [String]?) -> RequestBuilder<[Pet]> {
125+
public class func findPetsByStatus(status status: [String]?) -> RequestBuilder<[Pet]> {
118126
let path = "/pet/findByStatus"
119-
let url = PetstoreClientAPI.basePath + path
127+
let URLString = PetstoreClientAPI.basePath + path
120128

121129
let nillableParameters: [String:AnyObject?] = [
122130
"status": status
@@ -125,7 +133,7 @@ extension PetstoreClientAPI {
125133

126134
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
127135

128-
return requestBuilder(method: "GET", URLString: url, parameters: parameters, isBody: false)
136+
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false)
129137
}
130138

131139
/**
@@ -153,7 +161,11 @@ extension PetstoreClientAPI {
153161
} ], contentType=application/json}, {example=<Pet>
154162
<id>123456</id>
155163
<name>doggie</name>
156-
<photoUrls>string</photoUrls>
164+
<photoUrls>
165+
<photoUrls>string</photoUrls>
166+
</photoUrls>
167+
<tags>
168+
</tags>
157169
<status>string</status>
158170
</Pet>, contentType=application/xml}]
159171
- examples: [{example=[ {
@@ -172,17 +184,21 @@ extension PetstoreClientAPI {
172184
} ], contentType=application/json}, {example=<Pet>
173185
<id>123456</id>
174186
<name>doggie</name>
175-
<photoUrls>string</photoUrls>
187+
<photoUrls>
188+
<photoUrls>string</photoUrls>
189+
</photoUrls>
190+
<tags>
191+
</tags>
176192
<status>string</status>
177193
</Pet>, contentType=application/xml}]
178194

179-
:param: tags (query) Tags to filter by
195+
- parameter tags: (query) Tags to filter by
180196

181-
:returns: Promise<Response<[Pet]>>
197+
- returns: RequestBuilder<[Pet]>
182198
*/
183-
func findPetsByTags(#tags: [String]?) -> RequestBuilder<[Pet]> {
199+
public class func findPetsByTags(tags tags: [String]?) -> RequestBuilder<[Pet]> {
184200
let path = "/pet/findByTags"
185-
let url = PetstoreClientAPI.basePath + path
201+
let URLString = PetstoreClientAPI.basePath + path
186202

187203
let nillableParameters: [String:AnyObject?] = [
188204
"tags": tags
@@ -191,7 +207,7 @@ extension PetstoreClientAPI {
191207

192208
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
193209

194-
return requestBuilder(method: "GET", URLString: url, parameters: parameters, isBody: false)
210+
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false)
195211
}
196212

197213
/**
@@ -222,7 +238,11 @@ extension PetstoreClientAPI {
222238
}, contentType=application/json}, {example=<Pet>
223239
<id>123456</id>
224240
<name>doggie</name>
225-
<photoUrls>string</photoUrls>
241+
<photoUrls>
242+
<photoUrls>string</photoUrls>
243+
</photoUrls>
244+
<tags>
245+
</tags>
226246
<status>string</status>
227247
</Pet>, contentType=application/xml}]
228248
- examples: [{example={
@@ -241,25 +261,29 @@ extension PetstoreClientAPI {
241261
}, contentType=application/json}, {example=<Pet>
242262
<id>123456</id>
243263
<name>doggie</name>
244-
<photoUrls>string</photoUrls>
264+
<photoUrls>
265+
<photoUrls>string</photoUrls>
266+
</photoUrls>
267+
<tags>
268+
</tags>
245269
<status>string</status>
246270
</Pet>, contentType=application/xml}]
247271

248-
:param: petId (path) ID of pet that needs to be fetched
272+
- parameter petId: (path) ID of pet that needs to be fetched
249273

250-
:returns: Promise<Response<Pet>>
274+
- returns: RequestBuilder<Pet>
251275
*/
252-
func getPetById(#petId: Int) -> RequestBuilder<Pet> {
276+
public class func getPetById(petId petId: Int) -> RequestBuilder<Pet> {
253277
var path = "/pet/{petId}"
254278
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
255-
let url = PetstoreClientAPI.basePath + path
279+
let URLString = PetstoreClientAPI.basePath + path
256280

257281
let nillableParameters: [String:AnyObject?] = [:]
258282
let parameters = APIHelper.rejectNil(nillableParameters)
259283

260284
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
261285

262-
return requestBuilder(method: "GET", URLString: url, parameters: parameters, isBody: true)
286+
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
263287
}
264288

265289
/**
@@ -272,23 +296,26 @@ extension PetstoreClientAPI {
272296
- type: oauth2
273297
- name: petstore_auth
274298

275-
:param: petId (path) ID of pet that needs to be updated
276-
:param: name (form) Updated name of the pet
277-
:param: status (form) Updated status of the pet
299+
- parameter petId: (path) ID of pet that needs to be updated
300+
- parameter name: (form) Updated name of the pet
301+
- parameter status: (form) Updated status of the pet
278302

279-
:returns: Promise<Response<Void>>
303+
- returns: RequestBuilder<Void>
280304
*/
281-
func updatePetWithForm(#petId: String, name: String?, status: String?) -> RequestBuilder<Void> {
305+
public class func updatePetWithForm(petId petId: String, name: String?, status: String?) -> RequestBuilder<Void> {
282306
var path = "/pet/{petId}"
283307
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
284-
let url = PetstoreClientAPI.basePath + path
308+
let URLString = PetstoreClientAPI.basePath + path
285309

286-
let nillableParameters: [String:AnyObject?] = [:]
310+
let nillableParameters: [String:AnyObject?] = [
311+
"name": name,
312+
"status": status
313+
]
287314
let parameters = APIHelper.rejectNil(nillableParameters)
288315

289316
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
290317

291-
return requestBuilder(method: "POST", URLString: url, parameters: parameters, isBody: true)
318+
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false)
292319
}
293320

294321
/**
@@ -301,21 +328,21 @@ extension PetstoreClientAPI {
301328
- type: oauth2
302329
- name: petstore_auth
303330

304-
:param: petId (path) Pet id to delete
331+
- parameter petId: (path) Pet id to delete
305332

306-
:returns: Promise<Response<Void>>
333+
- returns: RequestBuilder<Void>
307334
*/
308-
func deletePet(#petId: Int) -> RequestBuilder<Void> {
335+
public class func deletePet(petId petId: Int) -> RequestBuilder<Void> {
309336
var path = "/pet/{petId}"
310337
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
311-
let url = PetstoreClientAPI.basePath + path
338+
let URLString = PetstoreClientAPI.basePath + path
312339

313340
let nillableParameters: [String:AnyObject?] = [:]
314341
let parameters = APIHelper.rejectNil(nillableParameters)
315342

316343
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
317344

318-
return requestBuilder(method: "DELETE", URLString: url, parameters: parameters, isBody: true)
345+
return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true)
319346
}
320347

321348
/**
@@ -328,23 +355,26 @@ extension PetstoreClientAPI {
328355
- type: oauth2
329356
- name: petstore_auth
330357

331-
:param: petId (path) ID of pet to update
332-
:param: additionalMetadata (form) Additional data to pass to server
333-
:param: file (form) file to upload
358+
- parameter petId: (path) ID of pet to update
359+
- parameter additionalMetadata: (form) Additional data to pass to server
360+
- parameter file: (form) file to upload
334361

335-
:returns: Promise<Response<Void>>
362+
- returns: RequestBuilder<Void>
336363
*/
337-
func uploadFile(#petId: Int, additionalMetadata: String?, file: NSData?) -> RequestBuilder<Void> {
364+
public class func uploadFile(petId petId: Int, additionalMetadata: String?, file: NSURL?) -> RequestBuilder<Void> {
338365
var path = "/pet/{petId}/uploadImage"
339366
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
340-
let url = PetstoreClientAPI.basePath + path
367+
let URLString = PetstoreClientAPI.basePath + path
341368

342-
let nillableParameters: [String:AnyObject?] = [:]
369+
let nillableParameters: [String:AnyObject?] = [
370+
"additionalMetadata": additionalMetadata,
371+
"file": file
372+
]
343373
let parameters = APIHelper.rejectNil(nillableParameters)
344374

345375
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
346376

347-
return requestBuilder(method: "POST", URLString: url, parameters: parameters, isBody: true)
377+
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false)
348378
}
349379

350380
}

0 commit comments

Comments
 (0)