forked from loafle/openapi-generator-original
[Swift 3] Use ISOFullDate for date format
This commit is contained in:
parent
43af07a2d4
commit
993f9eec65
@ -116,8 +116,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("array", "Array");
|
typeMapping.put("array", "Array");
|
||||||
typeMapping.put("List", "Array");
|
typeMapping.put("List", "Array");
|
||||||
typeMapping.put("map", "Dictionary");
|
typeMapping.put("map", "Dictionary");
|
||||||
typeMapping.put("date", "Date");
|
typeMapping.put("date", "ISOFullDate");
|
||||||
typeMapping.put("Date", "Date");
|
|
||||||
typeMapping.put("DateTime", "Date");
|
typeMapping.put("DateTime", "Date");
|
||||||
typeMapping.put("boolean", "Bool");
|
typeMapping.put("boolean", "Bool");
|
||||||
typeMapping.put("string", "String");
|
typeMapping.put("string", "String");
|
||||||
|
@ -84,6 +84,106 @@ extension UUID: JSONEncodable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents an ISO-8601 full-date (RFC-3339).
|
||||||
|
/// ex: 12-31-1999
|
||||||
|
/// https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14
|
||||||
|
public final class ISOFullDate: CustomStringConvertible {
|
||||||
|
|
||||||
|
public let year: Int
|
||||||
|
public let month: Int
|
||||||
|
public let day: Int
|
||||||
|
|
||||||
|
public init(year: Int, month: Int, day: Int) {
|
||||||
|
self.year = year
|
||||||
|
self.month = month
|
||||||
|
self.day = day
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a Date to an ISOFullDate. Only interested in the year, month, day components.
|
||||||
|
|
||||||
|
- parameter date: The date to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the year, month, day of the date.
|
||||||
|
*/
|
||||||
|
public static func from(date: Date) -> ISOFullDate? {
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
|
||||||
|
let components = calendar.dateComponents(
|
||||||
|
[
|
||||||
|
.year,
|
||||||
|
.month,
|
||||||
|
.day,
|
||||||
|
],
|
||||||
|
from: date
|
||||||
|
)
|
||||||
|
|
||||||
|
guard
|
||||||
|
let year = components.year,
|
||||||
|
let month = components.month,
|
||||||
|
let day = components.day
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: year,
|
||||||
|
month: month,
|
||||||
|
day: day
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a ISO-8601 full-date string to an ISOFullDate.
|
||||||
|
|
||||||
|
- parameter string: The ISO-8601 full-date format string to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the string.
|
||||||
|
*/
|
||||||
|
public static func from(string: String) -> ISOFullDate? {
|
||||||
|
let components = string
|
||||||
|
.characters
|
||||||
|
.split(separator: "-")
|
||||||
|
.map(String.init)
|
||||||
|
.flatMap { Int($0) }
|
||||||
|
guard components.count == 3 else { return nil }
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: components[0],
|
||||||
|
month: components[1],
|
||||||
|
day: components[2]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts the receiver to a Date, in the default time zone.
|
||||||
|
|
||||||
|
- returns: A Date from the components of the receiver, in the default time zone.
|
||||||
|
*/
|
||||||
|
public func toDate() -> Date? {
|
||||||
|
var components = DateComponents()
|
||||||
|
components.year = year
|
||||||
|
components.month = month
|
||||||
|
components.day = day
|
||||||
|
components.timeZone = TimeZone.ReferenceType.default
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
return calendar.date(from: components)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
|
public var description: String {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ISOFullDate: JSONEncodable {
|
||||||
|
public func encodeToJSON() -> Any {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{{#usePromiseKit}}extension RequestBuilder {
|
{{#usePromiseKit}}extension RequestBuilder {
|
||||||
public func execute() -> Promise<Response<T>> {
|
public func execute() -> Promise<Response<T>> {
|
||||||
let deferred = Promise<Response<T>>.pending()
|
let deferred = Promise<Response<T>>.pending()
|
||||||
|
@ -146,6 +146,15 @@ class Decoders {
|
|||||||
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
||||||
}
|
}
|
||||||
fatalError("formatter failed to parse \(source)")
|
fatalError("formatter failed to parse \(source)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decoder for ISOFullDate
|
||||||
|
Decoders.addDecoder(clazz: ISOFullDate.self) { (source: AnyObject) -> ISOFullDate in
|
||||||
|
if let string = source as? String,
|
||||||
|
let isoDate = ISOFullDate.from(string: string) {
|
||||||
|
return isoDate
|
||||||
|
}
|
||||||
|
fatalError("formatter failed to parse \(source)")
|
||||||
} {{#models}}{{#model}}
|
} {{#models}}{{#model}}
|
||||||
|
|
||||||
// Decoder for [{{{classname}}}]
|
// Decoder for [{{{classname}}}]
|
||||||
|
@ -62,6 +62,18 @@ public class Swift3CodegenTest {
|
|||||||
Assert.assertTrue(op.responses.get(0).isBinary);
|
Assert.assertTrue(op.responses.get(0).isBinary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(description = "returns ISOFullDate when response format is date")
|
||||||
|
public void dateTest() {
|
||||||
|
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/datePropertyTest.json");
|
||||||
|
final DefaultCodegen codegen = new Swift3Codegen();
|
||||||
|
final String path = "/tests/dateResponse";
|
||||||
|
final Operation p = model.getPaths().get(path).getPost();
|
||||||
|
final CodegenOperation op = codegen.fromOperation(path, "post", p, model.getDefinitions());
|
||||||
|
|
||||||
|
Assert.assertEquals(op.returnType, "ISOFullDate");
|
||||||
|
Assert.assertEquals(op.bodyParam.dataType, "ISOFullDate");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultPodAuthors() throws Exception {
|
public void testDefaultPodAuthors() throws Exception {
|
||||||
// Given
|
// Given
|
||||||
@ -88,4 +100,4 @@ public class Swift3CodegenTest {
|
|||||||
Assert.assertEquals(podAuthors, swaggerDevs);
|
Assert.assertEquals(podAuthors, swaggerDevs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class Swift3ModelTest {
|
|||||||
.property("binary", new BinaryProperty())
|
.property("binary", new BinaryProperty())
|
||||||
.property("byte", new ByteArrayProperty())
|
.property("byte", new ByteArrayProperty())
|
||||||
.property("uuid", new UUIDProperty())
|
.property("uuid", new UUIDProperty())
|
||||||
|
.property("dateOfBirth", new DateProperty())
|
||||||
.required("id")
|
.required("id")
|
||||||
.required("name")
|
.required("name")
|
||||||
.discriminator("test");
|
.discriminator("test");
|
||||||
@ -32,7 +33,7 @@ public class Swift3ModelTest {
|
|||||||
Assert.assertEquals(cm.name, "sample");
|
Assert.assertEquals(cm.name, "sample");
|
||||||
Assert.assertEquals(cm.classname, "Sample");
|
Assert.assertEquals(cm.classname, "Sample");
|
||||||
Assert.assertEquals(cm.description, "a sample model");
|
Assert.assertEquals(cm.description, "a sample model");
|
||||||
Assert.assertEquals(cm.vars.size(), 6);
|
Assert.assertEquals(cm.vars.size(), 7);
|
||||||
Assert.assertEquals(cm.discriminator,"test");
|
Assert.assertEquals(cm.discriminator,"test");
|
||||||
|
|
||||||
final CodegenProperty property1 = cm.vars.get(0);
|
final CodegenProperty property1 = cm.vars.get(0);
|
||||||
@ -93,9 +94,19 @@ public class Swift3ModelTest {
|
|||||||
Assert.assertEquals(property6.name, "uuid");
|
Assert.assertEquals(property6.name, "uuid");
|
||||||
Assert.assertNull(property6.defaultValue);
|
Assert.assertNull(property6.defaultValue);
|
||||||
Assert.assertEquals(property6.baseType, "UUID");
|
Assert.assertEquals(property6.baseType, "UUID");
|
||||||
Assert.assertNull(property6.hasMore);
|
Assert.assertTrue(property6.hasMore);
|
||||||
Assert.assertNull(property6.required);
|
Assert.assertNull(property6.required);
|
||||||
Assert.assertTrue(property6.isNotContainer);
|
Assert.assertTrue(property6.isNotContainer);
|
||||||
|
|
||||||
|
final CodegenProperty property7 = cm.vars.get(6);
|
||||||
|
Assert.assertEquals(property7.baseName, "dateOfBirth");
|
||||||
|
Assert.assertEquals(property7.datatype, "ISOFullDate");
|
||||||
|
Assert.assertEquals(property7.name, "dateOfBirth");
|
||||||
|
Assert.assertNull(property7.defaultValue);
|
||||||
|
Assert.assertEquals(property7.baseType, "ISOFullDate");
|
||||||
|
Assert.assertNull(property7.hasMore);
|
||||||
|
Assert.assertNull(property7.required);
|
||||||
|
Assert.assertTrue(property7.isNotContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -108,13 +108,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)
|
||||||
|
|
||||||
@ -157,20 +157,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>
|
||||||
@ -179,21 +179,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>
|
||||||
@ -202,7 +202,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)
|
||||||
|
|
||||||
@ -242,26 +242,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>
|
||||||
@ -270,21 +270,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>
|
||||||
@ -293,7 +293,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
|
||||||
|
|
||||||
|
@ -67,12 +67,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]>
|
||||||
*/
|
*/
|
||||||
@ -108,36 +108,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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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
|
||||||
|
|
||||||
@ -176,36 +176,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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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)
|
||||||
|
|
||||||
|
@ -167,16 +167,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>
|
||||||
@ -185,17 +185,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>
|
||||||
@ -204,7 +204,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.
|
||||||
|
|
||||||
@ -244,8 +244,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)
|
||||||
|
@ -160,13 +160,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)
|
||||||
|
|
||||||
@ -226,20 +226,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>
|
||||||
@ -248,21 +248,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>
|
||||||
@ -271,7 +271,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)
|
||||||
|
|
||||||
@ -328,26 +328,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>
|
||||||
@ -356,21 +356,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>
|
||||||
@ -379,7 +379,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
|
||||||
|
|
||||||
|
@ -101,12 +101,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]>
|
||||||
*/
|
*/
|
||||||
@ -159,36 +159,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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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
|
||||||
|
|
||||||
@ -244,36 +244,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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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)
|
||||||
|
|
||||||
|
@ -253,16 +253,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>
|
||||||
@ -271,17 +271,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>
|
||||||
@ -290,7 +290,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.
|
||||||
|
|
||||||
@ -348,8 +348,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)
|
||||||
|
@ -166,13 +166,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)
|
||||||
|
|
||||||
@ -234,20 +234,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>
|
||||||
@ -256,21 +256,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>
|
||||||
@ -279,7 +279,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)
|
||||||
|
|
||||||
@ -338,26 +338,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>
|
||||||
@ -366,21 +366,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>
|
||||||
@ -389,7 +389,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
|
||||||
|
|
||||||
|
@ -105,12 +105,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]>
|
||||||
*/
|
*/
|
||||||
@ -165,36 +165,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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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
|
||||||
|
|
||||||
@ -252,36 +252,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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"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)
|
||||||
|
|
||||||
|
@ -263,16 +263,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>
|
||||||
@ -281,17 +281,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>
|
||||||
@ -300,7 +300,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.
|
||||||
|
|
||||||
@ -360,8 +360,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)
|
||||||
|
@ -139,7 +139,7 @@ class Decoders {
|
|||||||
return NSDate(timeIntervalSince1970: Double(sourceInt / 1000) )
|
return NSDate(timeIntervalSince1970: Double(sourceInt / 1000) )
|
||||||
}
|
}
|
||||||
fatalError("formatter failed to parse \(source)")
|
fatalError("formatter failed to parse \(source)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder for ISOFullDate
|
// Decoder for ISOFullDate
|
||||||
Decoders.addDecoder(clazz: ISOFullDate.self, decoder: { (source: AnyObject) -> ISOFullDate in
|
Decoders.addDecoder(clazz: ISOFullDate.self, decoder: { (source: AnyObject) -> ISOFullDate in
|
||||||
|
@ -83,4 +83,104 @@ extension UUID: JSONEncodable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents an ISO-8601 full-date (RFC-3339).
|
||||||
|
/// ex: 12-31-1999
|
||||||
|
/// https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14
|
||||||
|
public final class ISOFullDate: CustomStringConvertible {
|
||||||
|
|
||||||
|
public let year: Int
|
||||||
|
public let month: Int
|
||||||
|
public let day: Int
|
||||||
|
|
||||||
|
public init(year: Int, month: Int, day: Int) {
|
||||||
|
self.year = year
|
||||||
|
self.month = month
|
||||||
|
self.day = day
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a Date to an ISOFullDate. Only interested in the year, month, day components.
|
||||||
|
|
||||||
|
- parameter date: The date to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the year, month, day of the date.
|
||||||
|
*/
|
||||||
|
public static func from(date: Date) -> ISOFullDate? {
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
|
||||||
|
let components = calendar.dateComponents(
|
||||||
|
[
|
||||||
|
.year,
|
||||||
|
.month,
|
||||||
|
.day,
|
||||||
|
],
|
||||||
|
from: date
|
||||||
|
)
|
||||||
|
|
||||||
|
guard
|
||||||
|
let year = components.year,
|
||||||
|
let month = components.month,
|
||||||
|
let day = components.day
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: year,
|
||||||
|
month: month,
|
||||||
|
day: day
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a ISO-8601 full-date string to an ISOFullDate.
|
||||||
|
|
||||||
|
- parameter string: The ISO-8601 full-date format string to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the string.
|
||||||
|
*/
|
||||||
|
public static func from(string: String) -> ISOFullDate? {
|
||||||
|
let components = string
|
||||||
|
.characters
|
||||||
|
.split(separator: "-")
|
||||||
|
.map(String.init)
|
||||||
|
.flatMap { Int($0) }
|
||||||
|
guard components.count == 3 else { return nil }
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: components[0],
|
||||||
|
month: components[1],
|
||||||
|
day: components[2]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts the receiver to a Date, in the default time zone.
|
||||||
|
|
||||||
|
- returns: A Date from the components of the receiver, in the default time zone.
|
||||||
|
*/
|
||||||
|
public func toDate() -> Date? {
|
||||||
|
var components = DateComponents()
|
||||||
|
components.year = year
|
||||||
|
components.month = month
|
||||||
|
components.day = day
|
||||||
|
components.timeZone = TimeZone.ReferenceType.default
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
return calendar.date(from: components)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
|
public var description: String {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ISOFullDate: JSONEncodable {
|
||||||
|
public func encodeToJSON() -> Any {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,6 +146,15 @@ class Decoders {
|
|||||||
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
||||||
}
|
}
|
||||||
fatalError("formatter failed to parse \(source)")
|
fatalError("formatter failed to parse \(source)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decoder for ISOFullDate
|
||||||
|
Decoders.addDecoder(clazz: ISOFullDate.self) { (source: AnyObject) -> ISOFullDate in
|
||||||
|
if let string = source as? String,
|
||||||
|
let isoDate = ISOFullDate.from(string: string) {
|
||||||
|
return isoDate
|
||||||
|
}
|
||||||
|
fatalError("formatter failed to parse \(source)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder for [AdditionalPropertiesClass]
|
// Decoder for [AdditionalPropertiesClass]
|
||||||
|
@ -100,7 +100,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
if stringResponse.result.isFailure {
|
if stringResponse.result.isFailure {
|
||||||
completion(
|
completion(
|
||||||
nil,
|
nil,
|
||||||
ErrorResponse.Error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!)
|
ErrorResponse.Error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -161,6 +161,13 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle HTTP 204 No Content
|
||||||
|
// NSNull would crash decoders
|
||||||
|
if response.response?.statusCode == 204 && response.result.value is NSNull{
|
||||||
|
completion(nil, nil)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if () is T {
|
if () is T {
|
||||||
completion(Response(response: response.response!, body: (() as! T)), nil)
|
completion(Response(response: response.response!, body: (() as! T)), nil)
|
||||||
return
|
return
|
||||||
|
@ -84,6 +84,106 @@ extension UUID: JSONEncodable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents an ISO-8601 full-date (RFC-3339).
|
||||||
|
/// ex: 12-31-1999
|
||||||
|
/// https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14
|
||||||
|
public final class ISOFullDate: CustomStringConvertible {
|
||||||
|
|
||||||
|
public let year: Int
|
||||||
|
public let month: Int
|
||||||
|
public let day: Int
|
||||||
|
|
||||||
|
public init(year: Int, month: Int, day: Int) {
|
||||||
|
self.year = year
|
||||||
|
self.month = month
|
||||||
|
self.day = day
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a Date to an ISOFullDate. Only interested in the year, month, day components.
|
||||||
|
|
||||||
|
- parameter date: The date to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the year, month, day of the date.
|
||||||
|
*/
|
||||||
|
public static func from(date: Date) -> ISOFullDate? {
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
|
||||||
|
let components = calendar.dateComponents(
|
||||||
|
[
|
||||||
|
.year,
|
||||||
|
.month,
|
||||||
|
.day,
|
||||||
|
],
|
||||||
|
from: date
|
||||||
|
)
|
||||||
|
|
||||||
|
guard
|
||||||
|
let year = components.year,
|
||||||
|
let month = components.month,
|
||||||
|
let day = components.day
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: year,
|
||||||
|
month: month,
|
||||||
|
day: day
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a ISO-8601 full-date string to an ISOFullDate.
|
||||||
|
|
||||||
|
- parameter string: The ISO-8601 full-date format string to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the string.
|
||||||
|
*/
|
||||||
|
public static func from(string: String) -> ISOFullDate? {
|
||||||
|
let components = string
|
||||||
|
.characters
|
||||||
|
.split(separator: "-")
|
||||||
|
.map(String.init)
|
||||||
|
.flatMap { Int($0) }
|
||||||
|
guard components.count == 3 else { return nil }
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: components[0],
|
||||||
|
month: components[1],
|
||||||
|
day: components[2]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts the receiver to a Date, in the default time zone.
|
||||||
|
|
||||||
|
- returns: A Date from the components of the receiver, in the default time zone.
|
||||||
|
*/
|
||||||
|
public func toDate() -> Date? {
|
||||||
|
var components = DateComponents()
|
||||||
|
components.year = year
|
||||||
|
components.month = month
|
||||||
|
components.day = day
|
||||||
|
components.timeZone = TimeZone.ReferenceType.default
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
return calendar.date(from: components)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
|
public var description: String {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ISOFullDate: JSONEncodable {
|
||||||
|
public func encodeToJSON() -> Any {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension RequestBuilder {
|
extension RequestBuilder {
|
||||||
public func execute() -> Promise<Response<T>> {
|
public func execute() -> Promise<Response<T>> {
|
||||||
let deferred = Promise<Response<T>>.pending()
|
let deferred = Promise<Response<T>>.pending()
|
||||||
|
@ -44,6 +44,15 @@ class Decoders {
|
|||||||
decoders[key] = { decoder($0) as AnyObject }
|
decoders[key] = { decoder($0) as AnyObject }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func decode<T>(clazz: T.Type, discriminator: String, source: AnyObject) -> T {
|
||||||
|
let key = discriminator;
|
||||||
|
if let decoder = decoders[key] {
|
||||||
|
return decoder(source) as! T
|
||||||
|
} else {
|
||||||
|
fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static func decode<T>(clazz: [T].Type, source: AnyObject) -> [T] {
|
static func decode<T>(clazz: [T].Type, source: AnyObject) -> [T] {
|
||||||
let array = source as! [AnyObject]
|
let array = source as! [AnyObject]
|
||||||
return array.map { Decoders.decode(clazz: T.self, source: $0) }
|
return array.map { Decoders.decode(clazz: T.self, source: $0) }
|
||||||
@ -137,6 +146,15 @@ class Decoders {
|
|||||||
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
||||||
}
|
}
|
||||||
fatalError("formatter failed to parse \(source)")
|
fatalError("formatter failed to parse \(source)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decoder for ISOFullDate
|
||||||
|
Decoders.addDecoder(clazz: ISOFullDate.self) { (source: AnyObject) -> ISOFullDate in
|
||||||
|
if let string = source as? String,
|
||||||
|
let isoDate = ISOFullDate.from(string: string) {
|
||||||
|
return isoDate
|
||||||
|
}
|
||||||
|
fatalError("formatter failed to parse \(source)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder for [AdditionalPropertiesClass]
|
// Decoder for [AdditionalPropertiesClass]
|
||||||
@ -146,6 +164,7 @@ class Decoders {
|
|||||||
// Decoder for AdditionalPropertiesClass
|
// Decoder for AdditionalPropertiesClass
|
||||||
Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject) -> AdditionalPropertiesClass in
|
Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject) -> AdditionalPropertiesClass in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = AdditionalPropertiesClass()
|
let instance = AdditionalPropertiesClass()
|
||||||
instance.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?)
|
instance.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?)
|
||||||
instance.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?)
|
instance.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?)
|
||||||
@ -160,6 +179,11 @@ class Decoders {
|
|||||||
// Decoder for Animal
|
// Decoder for Animal
|
||||||
Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in
|
Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
// Check discriminator to support inheritance
|
||||||
|
if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{
|
||||||
|
return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source)
|
||||||
|
}
|
||||||
|
|
||||||
let instance = Animal()
|
let instance = Animal()
|
||||||
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
||||||
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
||||||
@ -185,6 +209,7 @@ class Decoders {
|
|||||||
// Decoder for ApiResponse
|
// Decoder for ApiResponse
|
||||||
Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject) -> ApiResponse in
|
Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject) -> ApiResponse in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ApiResponse()
|
let instance = ApiResponse()
|
||||||
instance.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?)
|
instance.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?)
|
||||||
instance.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?)
|
instance.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?)
|
||||||
@ -200,6 +225,7 @@ class Decoders {
|
|||||||
// Decoder for ArrayOfArrayOfNumberOnly
|
// Decoder for ArrayOfArrayOfNumberOnly
|
||||||
Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfArrayOfNumberOnly in
|
Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfArrayOfNumberOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ArrayOfArrayOfNumberOnly()
|
let instance = ArrayOfArrayOfNumberOnly()
|
||||||
instance.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?)
|
instance.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -213,6 +239,7 @@ class Decoders {
|
|||||||
// Decoder for ArrayOfNumberOnly
|
// Decoder for ArrayOfNumberOnly
|
||||||
Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfNumberOnly in
|
Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfNumberOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ArrayOfNumberOnly()
|
let instance = ArrayOfNumberOnly()
|
||||||
instance.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?)
|
instance.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -226,6 +253,7 @@ class Decoders {
|
|||||||
// Decoder for ArrayTest
|
// Decoder for ArrayTest
|
||||||
Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject) -> ArrayTest in
|
Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject) -> ArrayTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ArrayTest()
|
let instance = ArrayTest()
|
||||||
instance.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?)
|
instance.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?)
|
||||||
instance.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?)
|
instance.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?)
|
||||||
@ -241,6 +269,7 @@ class Decoders {
|
|||||||
// Decoder for Cat
|
// Decoder for Cat
|
||||||
Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in
|
Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Cat()
|
let instance = Cat()
|
||||||
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
||||||
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
||||||
@ -256,6 +285,7 @@ class Decoders {
|
|||||||
// Decoder for Category
|
// Decoder for Category
|
||||||
Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in
|
Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Category()
|
let instance = Category()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
@ -270,6 +300,7 @@ class Decoders {
|
|||||||
// Decoder for Client
|
// Decoder for Client
|
||||||
Decoders.addDecoder(clazz: Client.self) { (source: AnyObject) -> Client in
|
Decoders.addDecoder(clazz: Client.self) { (source: AnyObject) -> Client in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Client()
|
let instance = Client()
|
||||||
instance.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?)
|
instance.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -283,6 +314,7 @@ class Decoders {
|
|||||||
// Decoder for Dog
|
// Decoder for Dog
|
||||||
Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in
|
Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Dog()
|
let instance = Dog()
|
||||||
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
||||||
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
||||||
@ -298,6 +330,7 @@ class Decoders {
|
|||||||
// Decoder for EnumArrays
|
// Decoder for EnumArrays
|
||||||
Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject) -> EnumArrays in
|
Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject) -> EnumArrays in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = EnumArrays()
|
let instance = EnumArrays()
|
||||||
if let justSymbol = sourceDictionary["just_symbol"] as? String {
|
if let justSymbol = sourceDictionary["just_symbol"] as? String {
|
||||||
instance.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol))
|
instance.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol))
|
||||||
@ -333,6 +366,7 @@ class Decoders {
|
|||||||
// Decoder for EnumTest
|
// Decoder for EnumTest
|
||||||
Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject) -> EnumTest in
|
Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject) -> EnumTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = EnumTest()
|
let instance = EnumTest()
|
||||||
if let enumString = sourceDictionary["enum_string"] as? String {
|
if let enumString = sourceDictionary["enum_string"] as? String {
|
||||||
instance.enumString = EnumTest.EnumString(rawValue: (enumString))
|
instance.enumString = EnumTest.EnumString(rawValue: (enumString))
|
||||||
@ -357,6 +391,7 @@ class Decoders {
|
|||||||
// Decoder for FormatTest
|
// Decoder for FormatTest
|
||||||
Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in
|
Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = FormatTest()
|
let instance = FormatTest()
|
||||||
instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?)
|
instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?)
|
||||||
instance.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?)
|
instance.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?)
|
||||||
@ -382,6 +417,7 @@ class Decoders {
|
|||||||
// Decoder for HasOnlyReadOnly
|
// Decoder for HasOnlyReadOnly
|
||||||
Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject) -> HasOnlyReadOnly in
|
Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject) -> HasOnlyReadOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = HasOnlyReadOnly()
|
let instance = HasOnlyReadOnly()
|
||||||
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
||||||
instance.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?)
|
instance.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?)
|
||||||
@ -396,6 +432,7 @@ class Decoders {
|
|||||||
// Decoder for List
|
// Decoder for List
|
||||||
Decoders.addDecoder(clazz: List.self) { (source: AnyObject) -> List in
|
Decoders.addDecoder(clazz: List.self) { (source: AnyObject) -> List in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = List()
|
let instance = List()
|
||||||
instance._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?)
|
instance._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -409,6 +446,7 @@ class Decoders {
|
|||||||
// Decoder for MapTest
|
// Decoder for MapTest
|
||||||
Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject) -> MapTest in
|
Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject) -> MapTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = MapTest()
|
let instance = MapTest()
|
||||||
instance.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?)
|
instance.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?)
|
||||||
if let mapOfEnumString = sourceDictionary["map_of_enum_string"] as? [String:String] { //TODO: handle enum map scenario
|
if let mapOfEnumString = sourceDictionary["map_of_enum_string"] as? [String:String] { //TODO: handle enum map scenario
|
||||||
@ -425,6 +463,7 @@ class Decoders {
|
|||||||
// Decoder for MixedPropertiesAndAdditionalPropertiesClass
|
// Decoder for MixedPropertiesAndAdditionalPropertiesClass
|
||||||
Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject) -> MixedPropertiesAndAdditionalPropertiesClass in
|
Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject) -> MixedPropertiesAndAdditionalPropertiesClass in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = MixedPropertiesAndAdditionalPropertiesClass()
|
let instance = MixedPropertiesAndAdditionalPropertiesClass()
|
||||||
instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?)
|
instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?)
|
||||||
instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?)
|
instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?)
|
||||||
@ -440,6 +479,7 @@ class Decoders {
|
|||||||
// Decoder for Model200Response
|
// Decoder for Model200Response
|
||||||
Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in
|
Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Model200Response()
|
let instance = Model200Response()
|
||||||
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?)
|
instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?)
|
||||||
@ -454,6 +494,7 @@ class Decoders {
|
|||||||
// Decoder for Name
|
// Decoder for Name
|
||||||
Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in
|
Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Name()
|
let instance = Name()
|
||||||
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?)
|
instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?)
|
||||||
@ -470,6 +511,7 @@ class Decoders {
|
|||||||
// Decoder for NumberOnly
|
// Decoder for NumberOnly
|
||||||
Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject) -> NumberOnly in
|
Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject) -> NumberOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = NumberOnly()
|
let instance = NumberOnly()
|
||||||
instance.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?)
|
instance.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -483,6 +525,7 @@ class Decoders {
|
|||||||
// Decoder for Order
|
// Decoder for Order
|
||||||
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
|
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Order()
|
let instance = Order()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?)
|
instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?)
|
||||||
@ -504,6 +547,7 @@ class Decoders {
|
|||||||
// Decoder for Pet
|
// Decoder for Pet
|
||||||
Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in
|
Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Pet()
|
let instance = Pet()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?)
|
instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?)
|
||||||
@ -525,6 +569,7 @@ class Decoders {
|
|||||||
// Decoder for ReadOnlyFirst
|
// Decoder for ReadOnlyFirst
|
||||||
Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject) -> ReadOnlyFirst in
|
Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject) -> ReadOnlyFirst in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ReadOnlyFirst()
|
let instance = ReadOnlyFirst()
|
||||||
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
||||||
instance.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?)
|
instance.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?)
|
||||||
@ -539,6 +584,7 @@ class Decoders {
|
|||||||
// Decoder for Return
|
// Decoder for Return
|
||||||
Decoders.addDecoder(clazz: Return.self) { (source: AnyObject) -> Return in
|
Decoders.addDecoder(clazz: Return.self) { (source: AnyObject) -> Return in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Return()
|
let instance = Return()
|
||||||
instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?)
|
instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -552,6 +598,7 @@ class Decoders {
|
|||||||
// Decoder for SpecialModelName
|
// Decoder for SpecialModelName
|
||||||
Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in
|
Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = SpecialModelName()
|
let instance = SpecialModelName()
|
||||||
instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?)
|
instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -565,6 +612,7 @@ class Decoders {
|
|||||||
// Decoder for Tag
|
// Decoder for Tag
|
||||||
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
|
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Tag()
|
let instance = Tag()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
@ -579,6 +627,7 @@ class Decoders {
|
|||||||
// Decoder for User
|
// Decoder for User
|
||||||
Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in
|
Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = User()
|
let instance = User()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?)
|
instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?)
|
||||||
|
@ -15,7 +15,7 @@ open class AdditionalPropertiesClass: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["map_property"] = self.mapProperty?.encodeToJSON()
|
nillableDictionary["map_property"] = self.mapProperty?.encodeToJSON()
|
||||||
nillableDictionary["map_of_map_property"] = self.mapOfMapProperty?.encodeToJSON()
|
nillableDictionary["map_of_map_property"] = self.mapOfMapProperty?.encodeToJSON()
|
||||||
|
@ -15,7 +15,7 @@ open class Animal: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["className"] = self.className
|
nillableDictionary["className"] = self.className
|
||||||
nillableDictionary["color"] = self.color
|
nillableDictionary["color"] = self.color
|
||||||
|
@ -16,7 +16,7 @@ open class ApiResponse: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["code"] = self.code?.encodeToJSON()
|
nillableDictionary["code"] = self.code?.encodeToJSON()
|
||||||
nillableDictionary["type"] = self.type
|
nillableDictionary["type"] = self.type
|
||||||
|
@ -14,7 +14,7 @@ open class ArrayOfArrayOfNumberOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["ArrayArrayNumber"] = self.arrayArrayNumber?.encodeToJSON()
|
nillableDictionary["ArrayArrayNumber"] = self.arrayArrayNumber?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -14,7 +14,7 @@ open class ArrayOfNumberOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["ArrayNumber"] = self.arrayNumber?.encodeToJSON()
|
nillableDictionary["ArrayNumber"] = self.arrayNumber?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -16,7 +16,7 @@ open class ArrayTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["array_of_string"] = self.arrayOfString?.encodeToJSON()
|
nillableDictionary["array_of_string"] = self.arrayOfString?.encodeToJSON()
|
||||||
nillableDictionary["array_array_of_integer"] = self.arrayArrayOfInteger?.encodeToJSON()
|
nillableDictionary["array_array_of_integer"] = self.arrayArrayOfInteger?.encodeToJSON()
|
||||||
|
@ -8,18 +8,14 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
open class Cat: JSONEncodable {
|
open class Cat: Animal {
|
||||||
public var className: String?
|
|
||||||
public var color: String?
|
|
||||||
public var declawed: Bool?
|
public var declawed: Bool?
|
||||||
|
|
||||||
public init() {}
|
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
override open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]()
|
||||||
nillableDictionary["className"] = self.className
|
|
||||||
nillableDictionary["color"] = self.color
|
|
||||||
nillableDictionary["declawed"] = self.declawed
|
nillableDictionary["declawed"] = self.declawed
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
return dictionary
|
return dictionary
|
||||||
|
@ -15,7 +15,7 @@ open class Category: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["name"] = self.name
|
nillableDictionary["name"] = self.name
|
||||||
|
@ -14,7 +14,7 @@ open class Client: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["client"] = self.client
|
nillableDictionary["client"] = self.client
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -8,18 +8,14 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
open class Dog: JSONEncodable {
|
open class Dog: Animal {
|
||||||
public var className: String?
|
|
||||||
public var color: String?
|
|
||||||
public var breed: String?
|
public var breed: String?
|
||||||
|
|
||||||
public init() {}
|
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
override open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]()
|
||||||
nillableDictionary["className"] = self.className
|
|
||||||
nillableDictionary["color"] = self.color
|
|
||||||
nillableDictionary["breed"] = self.breed
|
nillableDictionary["breed"] = self.breed
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
return dictionary
|
return dictionary
|
||||||
|
@ -23,7 +23,7 @@ open class EnumArrays: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["just_symbol"] = self.justSymbol?.rawValue
|
nillableDictionary["just_symbol"] = self.justSymbol?.rawValue
|
||||||
nillableDictionary["array_enum"] = self.arrayEnum?.map({$0.rawValue}).encodeToJSON()
|
nillableDictionary["array_enum"] = self.arrayEnum?.map({$0.rawValue}).encodeToJSON()
|
||||||
|
@ -28,7 +28,7 @@ open class EnumTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["enum_string"] = self.enumString?.rawValue
|
nillableDictionary["enum_string"] = self.enumString?.rawValue
|
||||||
nillableDictionary["enum_integer"] = self.enumInteger?.rawValue
|
nillableDictionary["enum_integer"] = self.enumInteger?.rawValue
|
||||||
|
@ -26,7 +26,7 @@ open class FormatTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["integer"] = self.integer?.encodeToJSON()
|
nillableDictionary["integer"] = self.integer?.encodeToJSON()
|
||||||
nillableDictionary["int32"] = self.int32?.encodeToJSON()
|
nillableDictionary["int32"] = self.int32?.encodeToJSON()
|
||||||
|
@ -15,7 +15,7 @@ open class HasOnlyReadOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["bar"] = self.bar
|
nillableDictionary["bar"] = self.bar
|
||||||
nillableDictionary["foo"] = self.foo
|
nillableDictionary["foo"] = self.foo
|
||||||
|
@ -14,7 +14,7 @@ open class List: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["123-list"] = self._123List
|
nillableDictionary["123-list"] = self._123List
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -19,7 +19,7 @@ open class MapTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["map_map_of_string"] = self.mapMapOfString?.encodeToJSON()//TODO: handle enum map scenario
|
nillableDictionary["map_map_of_string"] = self.mapMapOfString?.encodeToJSON()//TODO: handle enum map scenario
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -16,7 +16,7 @@ open class MixedPropertiesAndAdditionalPropertiesClass: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["uuid"] = self.uuid?.encodeToJSON()
|
nillableDictionary["uuid"] = self.uuid?.encodeToJSON()
|
||||||
nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON()
|
nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON()
|
||||||
|
@ -16,7 +16,7 @@ open class Model200Response: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["name"] = self.name?.encodeToJSON()
|
nillableDictionary["name"] = self.name?.encodeToJSON()
|
||||||
nillableDictionary["class"] = self._class
|
nillableDictionary["class"] = self._class
|
||||||
|
@ -18,7 +18,7 @@ open class Name: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["name"] = self.name?.encodeToJSON()
|
nillableDictionary["name"] = self.name?.encodeToJSON()
|
||||||
nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON()
|
nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON()
|
||||||
|
@ -14,7 +14,7 @@ open class NumberOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["JustNumber"] = self.justNumber
|
nillableDictionary["JustNumber"] = self.justNumber
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -25,7 +25,7 @@ open class Order: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["petId"] = self.petId?.encodeToJSON()
|
nillableDictionary["petId"] = self.petId?.encodeToJSON()
|
||||||
|
@ -25,7 +25,7 @@ open class Pet: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["category"] = self.category?.encodeToJSON()
|
nillableDictionary["category"] = self.category?.encodeToJSON()
|
||||||
|
@ -15,7 +15,7 @@ open class ReadOnlyFirst: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["bar"] = self.bar
|
nillableDictionary["bar"] = self.bar
|
||||||
nillableDictionary["baz"] = self.baz
|
nillableDictionary["baz"] = self.baz
|
||||||
|
@ -15,7 +15,7 @@ open class Return: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["return"] = self._return?.encodeToJSON()
|
nillableDictionary["return"] = self._return?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -14,7 +14,7 @@ open class SpecialModelName: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON()
|
nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -15,7 +15,7 @@ open class Tag: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["name"] = self.name
|
nillableDictionary["name"] = self.name
|
||||||
|
@ -22,7 +22,7 @@ open class User: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["username"] = self.username
|
nillableDictionary["username"] = self.username
|
||||||
|
@ -100,7 +100,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
if stringResponse.result.isFailure {
|
if stringResponse.result.isFailure {
|
||||||
completion(
|
completion(
|
||||||
nil,
|
nil,
|
||||||
ErrorResponse.Error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!)
|
ErrorResponse.Error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -161,6 +161,13 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle HTTP 204 No Content
|
||||||
|
// NSNull would crash decoders
|
||||||
|
if response.response?.statusCode == 204 && response.result.value is NSNull{
|
||||||
|
completion(nil, nil)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if () is T {
|
if () is T {
|
||||||
completion(Response(response: response.response!, body: (() as! T)), nil)
|
completion(Response(response: response.response!, body: (() as! T)), nil)
|
||||||
return
|
return
|
||||||
|
@ -83,4 +83,104 @@ extension UUID: JSONEncodable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents an ISO-8601 full-date (RFC-3339).
|
||||||
|
/// ex: 12-31-1999
|
||||||
|
/// https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14
|
||||||
|
public final class ISOFullDate: CustomStringConvertible {
|
||||||
|
|
||||||
|
public let year: Int
|
||||||
|
public let month: Int
|
||||||
|
public let day: Int
|
||||||
|
|
||||||
|
public init(year: Int, month: Int, day: Int) {
|
||||||
|
self.year = year
|
||||||
|
self.month = month
|
||||||
|
self.day = day
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a Date to an ISOFullDate. Only interested in the year, month, day components.
|
||||||
|
|
||||||
|
- parameter date: The date to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the year, month, day of the date.
|
||||||
|
*/
|
||||||
|
public static func from(date: Date) -> ISOFullDate? {
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
|
||||||
|
let components = calendar.dateComponents(
|
||||||
|
[
|
||||||
|
.year,
|
||||||
|
.month,
|
||||||
|
.day,
|
||||||
|
],
|
||||||
|
from: date
|
||||||
|
)
|
||||||
|
|
||||||
|
guard
|
||||||
|
let year = components.year,
|
||||||
|
let month = components.month,
|
||||||
|
let day = components.day
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: year,
|
||||||
|
month: month,
|
||||||
|
day: day
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a ISO-8601 full-date string to an ISOFullDate.
|
||||||
|
|
||||||
|
- parameter string: The ISO-8601 full-date format string to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the string.
|
||||||
|
*/
|
||||||
|
public static func from(string: String) -> ISOFullDate? {
|
||||||
|
let components = string
|
||||||
|
.characters
|
||||||
|
.split(separator: "-")
|
||||||
|
.map(String.init)
|
||||||
|
.flatMap { Int($0) }
|
||||||
|
guard components.count == 3 else { return nil }
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: components[0],
|
||||||
|
month: components[1],
|
||||||
|
day: components[2]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts the receiver to a Date, in the default time zone.
|
||||||
|
|
||||||
|
- returns: A Date from the components of the receiver, in the default time zone.
|
||||||
|
*/
|
||||||
|
public func toDate() -> Date? {
|
||||||
|
var components = DateComponents()
|
||||||
|
components.year = year
|
||||||
|
components.month = month
|
||||||
|
components.day = day
|
||||||
|
components.timeZone = TimeZone.ReferenceType.default
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
return calendar.date(from: components)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
|
public var description: String {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ISOFullDate: JSONEncodable {
|
||||||
|
public func encodeToJSON() -> Any {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +44,15 @@ class Decoders {
|
|||||||
decoders[key] = { decoder($0) as AnyObject }
|
decoders[key] = { decoder($0) as AnyObject }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func decode<T>(clazz: T.Type, discriminator: String, source: AnyObject) -> T {
|
||||||
|
let key = discriminator;
|
||||||
|
if let decoder = decoders[key] {
|
||||||
|
return decoder(source) as! T
|
||||||
|
} else {
|
||||||
|
fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static func decode<T>(clazz: [T].Type, source: AnyObject) -> [T] {
|
static func decode<T>(clazz: [T].Type, source: AnyObject) -> [T] {
|
||||||
let array = source as! [AnyObject]
|
let array = source as! [AnyObject]
|
||||||
return array.map { Decoders.decode(clazz: T.self, source: $0) }
|
return array.map { Decoders.decode(clazz: T.self, source: $0) }
|
||||||
@ -137,6 +146,15 @@ class Decoders {
|
|||||||
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
return Date(timeIntervalSince1970: Double(sourceInt / 1000) )
|
||||||
}
|
}
|
||||||
fatalError("formatter failed to parse \(source)")
|
fatalError("formatter failed to parse \(source)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decoder for ISOFullDate
|
||||||
|
Decoders.addDecoder(clazz: ISOFullDate.self) { (source: AnyObject) -> ISOFullDate in
|
||||||
|
if let string = source as? String,
|
||||||
|
let isoDate = ISOFullDate.from(string: string) {
|
||||||
|
return isoDate
|
||||||
|
}
|
||||||
|
fatalError("formatter failed to parse \(source)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder for [AdditionalPropertiesClass]
|
// Decoder for [AdditionalPropertiesClass]
|
||||||
@ -146,6 +164,7 @@ class Decoders {
|
|||||||
// Decoder for AdditionalPropertiesClass
|
// Decoder for AdditionalPropertiesClass
|
||||||
Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject) -> AdditionalPropertiesClass in
|
Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject) -> AdditionalPropertiesClass in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = AdditionalPropertiesClass()
|
let instance = AdditionalPropertiesClass()
|
||||||
instance.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?)
|
instance.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?)
|
||||||
instance.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?)
|
instance.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?)
|
||||||
@ -160,6 +179,11 @@ class Decoders {
|
|||||||
// Decoder for Animal
|
// Decoder for Animal
|
||||||
Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in
|
Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
// Check discriminator to support inheritance
|
||||||
|
if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{
|
||||||
|
return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source)
|
||||||
|
}
|
||||||
|
|
||||||
let instance = Animal()
|
let instance = Animal()
|
||||||
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
||||||
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
||||||
@ -185,6 +209,7 @@ class Decoders {
|
|||||||
// Decoder for ApiResponse
|
// Decoder for ApiResponse
|
||||||
Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject) -> ApiResponse in
|
Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject) -> ApiResponse in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ApiResponse()
|
let instance = ApiResponse()
|
||||||
instance.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?)
|
instance.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?)
|
||||||
instance.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?)
|
instance.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?)
|
||||||
@ -200,6 +225,7 @@ class Decoders {
|
|||||||
// Decoder for ArrayOfArrayOfNumberOnly
|
// Decoder for ArrayOfArrayOfNumberOnly
|
||||||
Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfArrayOfNumberOnly in
|
Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfArrayOfNumberOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ArrayOfArrayOfNumberOnly()
|
let instance = ArrayOfArrayOfNumberOnly()
|
||||||
instance.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?)
|
instance.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -213,6 +239,7 @@ class Decoders {
|
|||||||
// Decoder for ArrayOfNumberOnly
|
// Decoder for ArrayOfNumberOnly
|
||||||
Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfNumberOnly in
|
Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfNumberOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ArrayOfNumberOnly()
|
let instance = ArrayOfNumberOnly()
|
||||||
instance.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?)
|
instance.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -226,6 +253,7 @@ class Decoders {
|
|||||||
// Decoder for ArrayTest
|
// Decoder for ArrayTest
|
||||||
Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject) -> ArrayTest in
|
Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject) -> ArrayTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ArrayTest()
|
let instance = ArrayTest()
|
||||||
instance.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?)
|
instance.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?)
|
||||||
instance.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?)
|
instance.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?)
|
||||||
@ -241,6 +269,7 @@ class Decoders {
|
|||||||
// Decoder for Cat
|
// Decoder for Cat
|
||||||
Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in
|
Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Cat()
|
let instance = Cat()
|
||||||
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
||||||
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
||||||
@ -256,6 +285,7 @@ class Decoders {
|
|||||||
// Decoder for Category
|
// Decoder for Category
|
||||||
Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in
|
Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Category()
|
let instance = Category()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
@ -270,6 +300,7 @@ class Decoders {
|
|||||||
// Decoder for Client
|
// Decoder for Client
|
||||||
Decoders.addDecoder(clazz: Client.self) { (source: AnyObject) -> Client in
|
Decoders.addDecoder(clazz: Client.self) { (source: AnyObject) -> Client in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Client()
|
let instance = Client()
|
||||||
instance.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?)
|
instance.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -283,6 +314,7 @@ class Decoders {
|
|||||||
// Decoder for Dog
|
// Decoder for Dog
|
||||||
Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in
|
Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Dog()
|
let instance = Dog()
|
||||||
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?)
|
||||||
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?)
|
||||||
@ -298,6 +330,7 @@ class Decoders {
|
|||||||
// Decoder for EnumArrays
|
// Decoder for EnumArrays
|
||||||
Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject) -> EnumArrays in
|
Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject) -> EnumArrays in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = EnumArrays()
|
let instance = EnumArrays()
|
||||||
if let justSymbol = sourceDictionary["just_symbol"] as? String {
|
if let justSymbol = sourceDictionary["just_symbol"] as? String {
|
||||||
instance.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol))
|
instance.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol))
|
||||||
@ -333,6 +366,7 @@ class Decoders {
|
|||||||
// Decoder for EnumTest
|
// Decoder for EnumTest
|
||||||
Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject) -> EnumTest in
|
Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject) -> EnumTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = EnumTest()
|
let instance = EnumTest()
|
||||||
if let enumString = sourceDictionary["enum_string"] as? String {
|
if let enumString = sourceDictionary["enum_string"] as? String {
|
||||||
instance.enumString = EnumTest.EnumString(rawValue: (enumString))
|
instance.enumString = EnumTest.EnumString(rawValue: (enumString))
|
||||||
@ -357,6 +391,7 @@ class Decoders {
|
|||||||
// Decoder for FormatTest
|
// Decoder for FormatTest
|
||||||
Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in
|
Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = FormatTest()
|
let instance = FormatTest()
|
||||||
instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?)
|
instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?)
|
||||||
instance.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?)
|
instance.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?)
|
||||||
@ -382,6 +417,7 @@ class Decoders {
|
|||||||
// Decoder for HasOnlyReadOnly
|
// Decoder for HasOnlyReadOnly
|
||||||
Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject) -> HasOnlyReadOnly in
|
Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject) -> HasOnlyReadOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = HasOnlyReadOnly()
|
let instance = HasOnlyReadOnly()
|
||||||
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
||||||
instance.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?)
|
instance.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?)
|
||||||
@ -396,6 +432,7 @@ class Decoders {
|
|||||||
// Decoder for List
|
// Decoder for List
|
||||||
Decoders.addDecoder(clazz: List.self) { (source: AnyObject) -> List in
|
Decoders.addDecoder(clazz: List.self) { (source: AnyObject) -> List in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = List()
|
let instance = List()
|
||||||
instance._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?)
|
instance._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -409,6 +446,7 @@ class Decoders {
|
|||||||
// Decoder for MapTest
|
// Decoder for MapTest
|
||||||
Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject) -> MapTest in
|
Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject) -> MapTest in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = MapTest()
|
let instance = MapTest()
|
||||||
instance.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?)
|
instance.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?)
|
||||||
if let mapOfEnumString = sourceDictionary["map_of_enum_string"] as? [String:String] { //TODO: handle enum map scenario
|
if let mapOfEnumString = sourceDictionary["map_of_enum_string"] as? [String:String] { //TODO: handle enum map scenario
|
||||||
@ -425,6 +463,7 @@ class Decoders {
|
|||||||
// Decoder for MixedPropertiesAndAdditionalPropertiesClass
|
// Decoder for MixedPropertiesAndAdditionalPropertiesClass
|
||||||
Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject) -> MixedPropertiesAndAdditionalPropertiesClass in
|
Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject) -> MixedPropertiesAndAdditionalPropertiesClass in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = MixedPropertiesAndAdditionalPropertiesClass()
|
let instance = MixedPropertiesAndAdditionalPropertiesClass()
|
||||||
instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?)
|
instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?)
|
||||||
instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?)
|
instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?)
|
||||||
@ -440,6 +479,7 @@ class Decoders {
|
|||||||
// Decoder for Model200Response
|
// Decoder for Model200Response
|
||||||
Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in
|
Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Model200Response()
|
let instance = Model200Response()
|
||||||
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?)
|
instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?)
|
||||||
@ -454,6 +494,7 @@ class Decoders {
|
|||||||
// Decoder for Name
|
// Decoder for Name
|
||||||
Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in
|
Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Name()
|
let instance = Name()
|
||||||
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?)
|
instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?)
|
||||||
@ -470,6 +511,7 @@ class Decoders {
|
|||||||
// Decoder for NumberOnly
|
// Decoder for NumberOnly
|
||||||
Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject) -> NumberOnly in
|
Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject) -> NumberOnly in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = NumberOnly()
|
let instance = NumberOnly()
|
||||||
instance.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?)
|
instance.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -483,6 +525,7 @@ class Decoders {
|
|||||||
// Decoder for Order
|
// Decoder for Order
|
||||||
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
|
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Order()
|
let instance = Order()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?)
|
instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?)
|
||||||
@ -504,6 +547,7 @@ class Decoders {
|
|||||||
// Decoder for Pet
|
// Decoder for Pet
|
||||||
Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in
|
Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Pet()
|
let instance = Pet()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?)
|
instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?)
|
||||||
@ -525,6 +569,7 @@ class Decoders {
|
|||||||
// Decoder for ReadOnlyFirst
|
// Decoder for ReadOnlyFirst
|
||||||
Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject) -> ReadOnlyFirst in
|
Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject) -> ReadOnlyFirst in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = ReadOnlyFirst()
|
let instance = ReadOnlyFirst()
|
||||||
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?)
|
||||||
instance.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?)
|
instance.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?)
|
||||||
@ -539,6 +584,7 @@ class Decoders {
|
|||||||
// Decoder for Return
|
// Decoder for Return
|
||||||
Decoders.addDecoder(clazz: Return.self) { (source: AnyObject) -> Return in
|
Decoders.addDecoder(clazz: Return.self) { (source: AnyObject) -> Return in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Return()
|
let instance = Return()
|
||||||
instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?)
|
instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -552,6 +598,7 @@ class Decoders {
|
|||||||
// Decoder for SpecialModelName
|
// Decoder for SpecialModelName
|
||||||
Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in
|
Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = SpecialModelName()
|
let instance = SpecialModelName()
|
||||||
instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?)
|
instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?)
|
||||||
return instance
|
return instance
|
||||||
@ -565,6 +612,7 @@ class Decoders {
|
|||||||
// Decoder for Tag
|
// Decoder for Tag
|
||||||
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
|
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = Tag()
|
let instance = Tag()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?)
|
||||||
@ -579,6 +627,7 @@ class Decoders {
|
|||||||
// Decoder for User
|
// Decoder for User
|
||||||
Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in
|
Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in
|
||||||
let sourceDictionary = source as! [AnyHashable: Any]
|
let sourceDictionary = source as! [AnyHashable: Any]
|
||||||
|
|
||||||
let instance = User()
|
let instance = User()
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?)
|
||||||
instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?)
|
instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?)
|
||||||
|
@ -15,7 +15,7 @@ open class AdditionalPropertiesClass: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["map_property"] = self.mapProperty?.encodeToJSON()
|
nillableDictionary["map_property"] = self.mapProperty?.encodeToJSON()
|
||||||
nillableDictionary["map_of_map_property"] = self.mapOfMapProperty?.encodeToJSON()
|
nillableDictionary["map_of_map_property"] = self.mapOfMapProperty?.encodeToJSON()
|
||||||
|
@ -15,7 +15,7 @@ open class Animal: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["className"] = self.className
|
nillableDictionary["className"] = self.className
|
||||||
nillableDictionary["color"] = self.color
|
nillableDictionary["color"] = self.color
|
||||||
|
@ -16,7 +16,7 @@ open class ApiResponse: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["code"] = self.code?.encodeToJSON()
|
nillableDictionary["code"] = self.code?.encodeToJSON()
|
||||||
nillableDictionary["type"] = self.type
|
nillableDictionary["type"] = self.type
|
||||||
|
@ -14,7 +14,7 @@ open class ArrayOfArrayOfNumberOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["ArrayArrayNumber"] = self.arrayArrayNumber?.encodeToJSON()
|
nillableDictionary["ArrayArrayNumber"] = self.arrayArrayNumber?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -14,7 +14,7 @@ open class ArrayOfNumberOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["ArrayNumber"] = self.arrayNumber?.encodeToJSON()
|
nillableDictionary["ArrayNumber"] = self.arrayNumber?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -16,7 +16,7 @@ open class ArrayTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["array_of_string"] = self.arrayOfString?.encodeToJSON()
|
nillableDictionary["array_of_string"] = self.arrayOfString?.encodeToJSON()
|
||||||
nillableDictionary["array_array_of_integer"] = self.arrayArrayOfInteger?.encodeToJSON()
|
nillableDictionary["array_array_of_integer"] = self.arrayArrayOfInteger?.encodeToJSON()
|
||||||
|
@ -8,18 +8,14 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
open class Cat: JSONEncodable {
|
open class Cat: Animal {
|
||||||
public var className: String?
|
|
||||||
public var color: String?
|
|
||||||
public var declawed: Bool?
|
public var declawed: Bool?
|
||||||
|
|
||||||
public init() {}
|
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
override open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]()
|
||||||
nillableDictionary["className"] = self.className
|
|
||||||
nillableDictionary["color"] = self.color
|
|
||||||
nillableDictionary["declawed"] = self.declawed
|
nillableDictionary["declawed"] = self.declawed
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
return dictionary
|
return dictionary
|
||||||
|
@ -15,7 +15,7 @@ open class Category: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["name"] = self.name
|
nillableDictionary["name"] = self.name
|
||||||
|
@ -14,7 +14,7 @@ open class Client: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["client"] = self.client
|
nillableDictionary["client"] = self.client
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -8,18 +8,14 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
open class Dog: JSONEncodable {
|
open class Dog: Animal {
|
||||||
public var className: String?
|
|
||||||
public var color: String?
|
|
||||||
public var breed: String?
|
public var breed: String?
|
||||||
|
|
||||||
public init() {}
|
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
override open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]()
|
||||||
nillableDictionary["className"] = self.className
|
|
||||||
nillableDictionary["color"] = self.color
|
|
||||||
nillableDictionary["breed"] = self.breed
|
nillableDictionary["breed"] = self.breed
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
return dictionary
|
return dictionary
|
||||||
|
@ -23,7 +23,7 @@ open class EnumArrays: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["just_symbol"] = self.justSymbol?.rawValue
|
nillableDictionary["just_symbol"] = self.justSymbol?.rawValue
|
||||||
nillableDictionary["array_enum"] = self.arrayEnum?.map({$0.rawValue}).encodeToJSON()
|
nillableDictionary["array_enum"] = self.arrayEnum?.map({$0.rawValue}).encodeToJSON()
|
||||||
|
@ -28,7 +28,7 @@ open class EnumTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["enum_string"] = self.enumString?.rawValue
|
nillableDictionary["enum_string"] = self.enumString?.rawValue
|
||||||
nillableDictionary["enum_integer"] = self.enumInteger?.rawValue
|
nillableDictionary["enum_integer"] = self.enumInteger?.rawValue
|
||||||
|
@ -26,7 +26,7 @@ open class FormatTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["integer"] = self.integer?.encodeToJSON()
|
nillableDictionary["integer"] = self.integer?.encodeToJSON()
|
||||||
nillableDictionary["int32"] = self.int32?.encodeToJSON()
|
nillableDictionary["int32"] = self.int32?.encodeToJSON()
|
||||||
|
@ -15,7 +15,7 @@ open class HasOnlyReadOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["bar"] = self.bar
|
nillableDictionary["bar"] = self.bar
|
||||||
nillableDictionary["foo"] = self.foo
|
nillableDictionary["foo"] = self.foo
|
||||||
|
@ -14,7 +14,7 @@ open class List: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["123-list"] = self._123List
|
nillableDictionary["123-list"] = self._123List
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -19,7 +19,7 @@ open class MapTest: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["map_map_of_string"] = self.mapMapOfString?.encodeToJSON()//TODO: handle enum map scenario
|
nillableDictionary["map_map_of_string"] = self.mapMapOfString?.encodeToJSON()//TODO: handle enum map scenario
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -16,7 +16,7 @@ open class MixedPropertiesAndAdditionalPropertiesClass: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["uuid"] = self.uuid?.encodeToJSON()
|
nillableDictionary["uuid"] = self.uuid?.encodeToJSON()
|
||||||
nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON()
|
nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON()
|
||||||
|
@ -16,7 +16,7 @@ open class Model200Response: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["name"] = self.name?.encodeToJSON()
|
nillableDictionary["name"] = self.name?.encodeToJSON()
|
||||||
nillableDictionary["class"] = self._class
|
nillableDictionary["class"] = self._class
|
||||||
|
@ -18,7 +18,7 @@ open class Name: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["name"] = self.name?.encodeToJSON()
|
nillableDictionary["name"] = self.name?.encodeToJSON()
|
||||||
nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON()
|
nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON()
|
||||||
|
@ -14,7 +14,7 @@ open class NumberOnly: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["JustNumber"] = self.justNumber
|
nillableDictionary["JustNumber"] = self.justNumber
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -25,7 +25,7 @@ open class Order: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["petId"] = self.petId?.encodeToJSON()
|
nillableDictionary["petId"] = self.petId?.encodeToJSON()
|
||||||
|
@ -25,7 +25,7 @@ open class Pet: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["category"] = self.category?.encodeToJSON()
|
nillableDictionary["category"] = self.category?.encodeToJSON()
|
||||||
|
@ -15,7 +15,7 @@ open class ReadOnlyFirst: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["bar"] = self.bar
|
nillableDictionary["bar"] = self.bar
|
||||||
nillableDictionary["baz"] = self.baz
|
nillableDictionary["baz"] = self.baz
|
||||||
|
@ -15,7 +15,7 @@ open class Return: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["return"] = self._return?.encodeToJSON()
|
nillableDictionary["return"] = self._return?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -14,7 +14,7 @@ open class SpecialModelName: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON()
|
nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON()
|
||||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
@ -15,7 +15,7 @@ open class Tag: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["name"] = self.name
|
nillableDictionary["name"] = self.name
|
||||||
|
@ -22,7 +22,7 @@ open class User: JSONEncodable {
|
|||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> Any {
|
open func encodeToJSON() -> Any {
|
||||||
var nillableDictionary = [String:Any?]()
|
var nillableDictionary = [String:Any?]()
|
||||||
nillableDictionary["id"] = self.id?.encodeToJSON()
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
nillableDictionary["username"] = self.username
|
nillableDictionary["username"] = self.username
|
||||||
|
Loading…
x
Reference in New Issue
Block a user