forked from loafle/openapi-generator-original
Merge branch 'enum' of https://github.com/cjolif/swagger-codegen into cjolif-enum
This commit is contained in:
commit
e0ce491b44
@ -355,8 +355,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (value.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
|
if (value.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
char[] separators = {'-', '_', ' '};
|
char[] separators = {'-', '_', ' ', ':'};
|
||||||
return WordUtils.capitalizeFully(StringUtils.lowerCase(value), separators).replaceAll("[-_ ]", "");
|
return WordUtils.capitalizeFully(StringUtils.lowerCase(value), separators).replaceAll("[-_ :]", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -502,6 +502,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumVarName(String name, String datatype) {
|
public String toEnumVarName(String name, String datatype) {
|
||||||
|
// TODO: this code is probably useless, because the var name is computed from the value in map.put("enum", toSwiftyEnumName(value));
|
||||||
// number
|
// number
|
||||||
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
||||||
String varName = new String(name);
|
String varName = new String(name);
|
||||||
@ -525,8 +526,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumName(CodegenProperty property) {
|
public String toEnumName(CodegenProperty property) {
|
||||||
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
String enumName = toModelName(property.name);
|
||||||
|
|
||||||
|
// TODO: toModelName already does something for names starting with number, so this code is probably never called
|
||||||
if (enumName.matches("\\d.*")) { // starts with number
|
if (enumName.matches("\\d.*")) { // starts with number
|
||||||
return "_" + enumName;
|
return "_" + enumName;
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,13 +155,13 @@ public class PetAPI: APIBase {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, 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: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], 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>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], 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>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- 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
|
||||||
- API Key:
|
|
||||||
- type: apiKey api_key
|
|
||||||
- name: api_key
|
|
||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- API Key:
|
||||||
"tags" : [ {
|
- type: apiKey api_key
|
||||||
"id" : 123456789,
|
- name: api_key
|
||||||
"name" : "aeiou"
|
- examples: [{contentType=application/json, example={
|
||||||
} ],
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, 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>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, 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>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- parameter petId: (path) ID of pet that needs to be fetched
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
@ -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: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"key" : 123
|
||||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"key" : 123
|
||||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||||
|
|
||||||
- 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: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, 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>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, 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>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- 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: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, 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>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, 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>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- parameter body: (body) order placed for purchasing the pet (optional)
|
- parameter body: (body) order placed for purchasing the pet (optional)
|
||||||
|
|
||||||
|
@ -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: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, 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>, contentType=application/xml}]
|
</User>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, 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>, contentType=application/xml}]
|
</User>}]
|
||||||
|
|
||||||
- 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: [{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}]
|
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||||
|
|
||||||
- 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)
|
||||||
|
@ -156,7 +156,7 @@ class Decoders {
|
|||||||
instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"])
|
instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"])
|
||||||
instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"])
|
instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"])
|
||||||
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
|
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
|
||||||
instance.status = Order.ST(rawValue: (sourceDictionary["status"] as? String) ?? "")
|
instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
|
||||||
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
|
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ class Decoders {
|
|||||||
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
|
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
|
||||||
instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"])
|
instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"])
|
||||||
instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"])
|
instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"])
|
||||||
instance.status = Pet.ST(rawValue: (sourceDictionary["status"] as? String) ?? "")
|
instance.status = Pet.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import Foundation
|
|||||||
|
|
||||||
|
|
||||||
public class Order: JSONEncodable {
|
public class Order: JSONEncodable {
|
||||||
public enum ST: String {
|
public enum Status: String {
|
||||||
case Placed = "placed"
|
case Placed = "placed"
|
||||||
case Approved = "approved"
|
case Approved = "approved"
|
||||||
case Delivered = "delivered"
|
case Delivered = "delivered"
|
||||||
@ -19,7 +19,7 @@ public class Order: JSONEncodable {
|
|||||||
public var quantity: Int32?
|
public var quantity: Int32?
|
||||||
public var shipDate: NSDate?
|
public var shipDate: NSDate?
|
||||||
/** Order Status */
|
/** Order Status */
|
||||||
public var status: ST?
|
public var status: Status?
|
||||||
public var complete: Bool?
|
public var complete: Bool?
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
|
@ -9,7 +9,7 @@ import Foundation
|
|||||||
|
|
||||||
|
|
||||||
public class Pet: JSONEncodable {
|
public class Pet: JSONEncodable {
|
||||||
public enum ST: String {
|
public enum Status: String {
|
||||||
case Available = "available"
|
case Available = "available"
|
||||||
case Pending = "pending"
|
case Pending = "pending"
|
||||||
case Sold = "sold"
|
case Sold = "sold"
|
||||||
@ -20,7 +20,7 @@ public class Pet: JSONEncodable {
|
|||||||
public var photoUrls: [String]?
|
public var photoUrls: [String]?
|
||||||
public var tags: [Tag]?
|
public var tags: [Tag]?
|
||||||
/** pet status in the store */
|
/** pet status in the store */
|
||||||
public var status: ST?
|
public var status: Status?
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ class StoreAPITests: XCTestCase {
|
|||||||
order.complete = false
|
order.complete = false
|
||||||
order.quantity = 10
|
order.quantity = 10
|
||||||
order.shipDate = NSDate()
|
order.shipDate = NSDate()
|
||||||
order.status = .Placed
|
// use explicit naming to reference the enum so that we test we don't regress on enum naming
|
||||||
|
order.status = Order.Status.Placed
|
||||||
let expectation = self.expectationWithDescription("testPlaceOrder")
|
let expectation = self.expectationWithDescription("testPlaceOrder")
|
||||||
StoreAPI.placeOrder(body: order).then { order -> Void in
|
StoreAPI.placeOrder(body: order).then { order -> Void in
|
||||||
XCTAssert(order.id == 1000, "invalid id")
|
XCTAssert(order.id == 1000, "invalid id")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user