update swift sample

This commit is contained in:
wing328 2016-05-13 16:40:01 +08:00
parent e0ce491b44
commit 610af20712
4 changed files with 107 additions and 107 deletions

View File

@ -155,13 +155,13 @@ public class PetAPI: APIBase {
- OAuth: - OAuth:
- type: oauth2 - type: oauth2
- name: petstore_auth - name: petstore_auth
- examples: [{contentType=application/json, example={ - examples: [{example={
"name" : "Puma", "name" : "Puma",
"type" : "Dog", "type" : "Dog",
"color" : "Black", "color" : "Black",
"gender" : "Female", "gender" : "Female",
"breed" : "Mixed" "breed" : "Mixed"
}}] }, contentType=application/json}]
- parameter status: (query) Status values that need to be considered for filter (optional, default to available) - parameter status: (query) Status values that need to be considered for filter (optional, default to available)
@ -218,20 +218,20 @@ public class PetAPI: APIBase {
- OAuth: - OAuth:
- type: oauth2 - type: oauth2
- name: petstore_auth - name: petstore_auth
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], } ], contentType=application/json}, {example=<Pet>
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -240,21 +240,21 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], } ], contentType=application/json}, {example=<Pet>
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -263,7 +263,7 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- parameter tags: (query) Tags to filter by (optional) - parameter tags: (query) Tags to filter by (optional)
@ -317,26 +317,26 @@ public class PetAPI: APIBase {
Find pet by ID Find pet by ID
- GET /pet/{petId} - GET /pet/{petId}
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- OAuth:
- type: oauth2
- name: petstore_auth
- API Key: - API Key:
- type: apiKey api_key - type: apiKey api_key
- name: api_key - name: api_key
- examples: [{contentType=application/json, example={ - OAuth:
"photoUrls" : [ "aeiou" ], - type: oauth2
"name" : "doggie", - name: petstore_auth
- examples: [{example={
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], }, contentType=application/json}, {example=<Pet>
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -345,21 +345,21 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], }, contentType=application/json}, {example=<Pet>
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -368,7 +368,7 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- parameter petId: (path) ID of pet that needs to be fetched - parameter petId: (path) ID of pet that needs to be fetched

View File

@ -98,12 +98,12 @@ public class StoreAPI: APIBase {
- API Key: - API Key:
- type: apiKey api_key - type: apiKey api_key
- name: api_key - name: api_key
- examples: [{contentType=application/json, example={ - examples: [{example={
"key" : 123 "key" : 123
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] }, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"key" : 123 "key" : 123
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] }, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- returns: RequestBuilder<[String:Int32]> - returns: RequestBuilder<[String:Int32]>
*/ */
@ -153,36 +153,36 @@ public class StoreAPI: APIBase {
Find purchase order by ID Find purchase order by ID
- GET /store/order/{orderId} - GET /store/order/{orderId}
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- examples: [{contentType=application/json, example={ - examples: [{example={
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- parameter orderId: (path) ID of pet that needs to be fetched - parameter orderId: (path) ID of pet that needs to be fetched
@ -235,36 +235,36 @@ public class StoreAPI: APIBase {
Place an order for a pet Place an order for a pet
- POST /store/order - POST /store/order
- -
- examples: [{contentType=application/json, example={ - examples: [{example={
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- parameter body: (body) order placed for purchasing the pet (optional) - parameter body: (body) order placed for purchasing the pet (optional)

View File

@ -244,16 +244,16 @@ public class UserAPI: APIBase {
Get user by user name Get user by user name
- GET /user/{username} - GET /user/{username}
- -
- examples: [{contentType=application/json, example={ - examples: [{example={
"firstName" : "aeiou",
"lastName" : "aeiou",
"password" : "aeiou",
"userStatus" : 123,
"phone" : "aeiou",
"id" : 123456789, "id" : 123456789,
"lastName" : "aeiou",
"phone" : "aeiou",
"username" : "aeiou",
"email" : "aeiou", "email" : "aeiou",
"username" : "aeiou" "userStatus" : 123,
}}, {contentType=application/xml, example=<User> "firstName" : "aeiou",
"password" : "aeiou"
}, contentType=application/json}, {example=<User>
<id>123456</id> <id>123456</id>
<username>string</username> <username>string</username>
<firstName>string</firstName> <firstName>string</firstName>
@ -262,17 +262,17 @@ public class UserAPI: APIBase {
<password>string</password> <password>string</password>
<phone>string</phone> <phone>string</phone>
<userStatus>0</userStatus> <userStatus>0</userStatus>
</User>}] </User>, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"firstName" : "aeiou",
"lastName" : "aeiou",
"password" : "aeiou",
"userStatus" : 123,
"phone" : "aeiou",
"id" : 123456789, "id" : 123456789,
"lastName" : "aeiou",
"phone" : "aeiou",
"username" : "aeiou",
"email" : "aeiou", "email" : "aeiou",
"username" : "aeiou" "userStatus" : 123,
}}, {contentType=application/xml, example=<User> "firstName" : "aeiou",
"password" : "aeiou"
}, contentType=application/json}, {example=<User>
<id>123456</id> <id>123456</id>
<username>string</username> <username>string</username>
<firstName>string</firstName> <firstName>string</firstName>
@ -281,7 +281,7 @@ public class UserAPI: APIBase {
<password>string</password> <password>string</password>
<phone>string</phone> <phone>string</phone>
<userStatus>0</userStatus> <userStatus>0</userStatus>
</User>}] </User>, contentType=application/xml}]
- parameter username: (path) The name that needs to be fetched. Use user1 for testing. - parameter username: (path) The name that needs to be fetched. Use user1 for testing.
@ -336,8 +336,8 @@ public class UserAPI: APIBase {
Logs user into the system Logs user into the system
- GET /user/login - GET /user/login
- -
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
- parameter username: (query) The user name for login (optional) - parameter username: (query) The user name for login (optional)
- parameter password: (query) The password for login in clear text (optional) - parameter password: (query) The password for login in clear text (optional)

View File

@ -46,9 +46,9 @@ class Decoders {
} }
static func decode<T, Key: Hashable>(clazz clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { static func decode<T, Key: Hashable>(clazz clazz: [Key:T].Type, source: AnyObject) -> [Key:T] {
let sourceDictinoary = source as! [Key: AnyObject] let sourceDictionary = source as! [Key: AnyObject]
var dictionary = [Key:T]() var dictionary = [Key:T]()
for (key, value) in sourceDictinoary { for (key, value) in sourceDictionary {
dictionary[key] = Decoders.decode(clazz: T.self, source: value) dictionary[key] = Decoders.decode(clazz: T.self, source: value)
} }
return dictionary return dictionary