forked from loafle/openapi-generator-original
Swift4: make generated models structs instead of classes (#7345)
* Split up model template into partials * Change models from class to struct. This fixes issue https://github.com/swagger-api/swagger-codegen/issues/6941. In this change, we make our Swift4 generated model objects struct instead of class. However, in order to do this, we needed to handle the following edge cases: * Inheritance and polymorphism (allOf) * With classes, we use inheritance. So therefore, the parent properties are ONLY on the parent generated class, and the model object which derives from the parent class picks up those properties through inheritance. * However, structs do not support inheritance. So we simply duplicate the parent allOf properties in the child struct. * We have to handle the case where the property name on the struct may be different than the property name in the JSON. By default, the Codable protocol assumes that the JSON property name is the same as the struct property name. If they need to be different, then we generate a CodingKeys string enum, which contains the mapping between struct property name and JSON property name. * additionalProperties. We cannot use the default Codable implementation for the additionalProperties, since it will look for an actual dictionary called "additionalProperties" in the JSON. Therefore, for model objects which have additionalProperties, we must generate our own implementation for the Decodable and Encodable protocols. I have run ./bin/swift4-all.sh and ./bin/swift4-test.sh to re-generate all of the sources, and I have verified that the generated code in samples/clients/test/swift4/default builds and the unit tests pass. * Update VERSION in .swagger-codegen * Update generated code for swift4-test schema
This commit is contained in:
parent
2b84118c9f
commit
a3d0f1d4bd
@ -710,8 +710,38 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
// process enum in models
|
||||
return postProcessModelsEnum(objs);
|
||||
Map<String, Object> postProcessedModelsEnum = postProcessModelsEnum(objs);
|
||||
|
||||
// We iterate through the list of models, and also iterate through each of the
|
||||
// properties for each model. For each property, if:
|
||||
//
|
||||
// CodegenProperty.name != CodegenProperty.baseName
|
||||
//
|
||||
// then we set
|
||||
//
|
||||
// CodegenProperty.vendorExtensions["x-codegen-escaped-property-name"] = true
|
||||
//
|
||||
// Also, if any property in the model has x-codegen-escaped-property-name=true, then we mark:
|
||||
//
|
||||
// CodegenModel.vendorExtensions["x-codegen-has-escaped-property-names"] = true
|
||||
//
|
||||
List<Object> models = (List<Object>) postProcessedModelsEnum.get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
boolean modelHasPropertyWithEscapedName = false;
|
||||
for (CodegenProperty prop : cm.allVars) {
|
||||
if (!prop.name.equals(prop.baseName)) {
|
||||
prop.vendorExtensions.put("x-codegen-escaped-property-name", true);
|
||||
modelHasPropertyWithEscapedName = true;
|
||||
}
|
||||
}
|
||||
if (modelHasPropertyWithEscapedName) {
|
||||
cm.vendorExtensions.put("x-codegen-has-escaped-property-names", true);
|
||||
}
|
||||
}
|
||||
|
||||
return postProcessedModelsEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
open class {{classname}}: {{#parent}}{{{parent}}}{{/parent}}{{^parent}}Codable{{/parent}} {
|
||||
public struct {{classname}}: Codable {
|
||||
|
||||
{{#vars}}
|
||||
{{#allVars}}
|
||||
{{#isEnum}}
|
||||
{{> modelInlineEnumDeclaration}}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
{{/allVars}}
|
||||
{{#allVars}}
|
||||
{{#isEnum}}
|
||||
{{#description}}/** {{description}} */
|
||||
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
||||
@ -20,7 +20,7 @@ open class {{classname}}: {{#parent}}{{{parent}}}{{/parent}}{{^parent}}Codable{{
|
||||
}
|
||||
}{{/vendorExtensions.x-swift-optional-scalar}}{{/objcCompatible}}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/allVars}}
|
||||
|
||||
{{#additionalPropertiesType}}
|
||||
public var additionalProperties: [String:{{{additionalPropertiesType}}}] = [:]
|
||||
@ -37,47 +37,39 @@ open class {{classname}}: {{#parent}}{{{parent}}}{{/parent}}{{^parent}}Codable{{
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
{{/additionalPropertiesType}}
|
||||
|
||||
{{^parent}}{{#hasVars}}
|
||||
public init({{#vars}}{{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/vars}}) {
|
||||
{{#vars}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/vars}}
|
||||
}
|
||||
{{/hasVars}}{{/parent}}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public {{#parent}}override {{/parent}}func encode(to encoder: Encoder) throws {
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
{{#vars}}
|
||||
{{#allVars}}
|
||||
try container.encode{{^required}}IfPresent{{/required}}({{{name}}}, forKey: "{{{baseName}}}")
|
||||
{{/vars}}
|
||||
{{#additionalPropertiesType}}
|
||||
{{/allVars}}
|
||||
try container.encodeMap(additionalProperties)
|
||||
{{/additionalPropertiesType}}
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
{{#vars}}
|
||||
{{#allVars}}
|
||||
{{name}} = try container.decode{{^required}}IfPresent{{/required}}({{{datatypeWithEnum}}}.self, forKey: "{{{baseName}}}")
|
||||
{{/vars}}
|
||||
{{#additionalPropertiesType}}
|
||||
{{/allVars}}
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
{{#vars}}
|
||||
{{#allVars}}
|
||||
nonAdditionalPropertyKeys.insert("{{{baseName}}}")
|
||||
{{/vars}}
|
||||
{{/allVars}}
|
||||
additionalProperties = try container.decodeMap({{{additionalPropertiesType}}}.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
{{/additionalPropertiesType}}
|
||||
{{#parent}}
|
||||
try super.init(from: decoder)
|
||||
{{/parent}}
|
||||
}
|
||||
|
||||
{{/additionalPropertiesType}}
|
||||
{{^additionalPropertiesType}}{{#vendorExtensions.x-codegen-has-escaped-property-names}}
|
||||
public enum CodingKeys: String, CodingKey { {{#allVars}}
|
||||
case {{name}}{{#vendorExtensions.x-codegen-escaped-property-name}} = "{{{baseName}}}"{{/vendorExtensions.x-codegen-escaped-property-name}}{{/allVars}}
|
||||
}
|
||||
{{/vendorExtensions.x-codegen-has-escaped-property-names}}{{/additionalPropertiesType}}
|
||||
|
||||
}
|
||||
|
@ -284,6 +284,10 @@
|
||||
"for": {
|
||||
"description": "This property name is a reserved word in most languages, including Swift 4.",
|
||||
"type": "string"
|
||||
},
|
||||
"normalName": {
|
||||
"description": "This model object property name should be unchanged from the JSON property name.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -370,6 +374,93 @@
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"SampleBase": {
|
||||
"type": "object",
|
||||
"description": "This is an base class object from which other classes will derive.",
|
||||
"properties": {
|
||||
"baseClassStringProp": {
|
||||
"type": "string"
|
||||
},
|
||||
"baseClassIntegerProp": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"SampleSubClass": {
|
||||
"description": "This is an subclass defived from the SampleBase class.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/SampleBase"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"subClassStringProp": {
|
||||
"type": "string"
|
||||
},
|
||||
"subClassIntegerProp": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"BaseCard": {
|
||||
"type": "object",
|
||||
"description": "This is a base card object which uses a 'cardType' discriminator.",
|
||||
"x-unit-tests": ["B45"],
|
||||
"discriminator": "cardType",
|
||||
"required": [
|
||||
"cardType"
|
||||
],
|
||||
"properties": {
|
||||
"cardType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"PersonCard": {
|
||||
"description": "This is an card object for a Person derived from BaseCard.",
|
||||
"x-unit-tests": ["B45"],
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/BaseCard"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"PlaceCard": {
|
||||
"description": "This is an card object for a Person derived from BaseCard.",
|
||||
"x-unit-tests": ["B45"],
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/BaseCard"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"placeName": {
|
||||
"type": "string"
|
||||
},
|
||||
"placeAddress": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.4.0-SNAPSHOT
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// AnotherfakeAPI.swift
|
||||
// AnotherFakeAPI.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
@ -10,7 +10,7 @@ import Alamofire
|
||||
|
||||
|
||||
|
||||
open class AnotherfakeAPI {
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
|
||||
|
@ -9,36 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class AdditionalPropertiesClass: Codable {
|
||||
public struct AdditionalPropertiesClass: Codable {
|
||||
|
||||
public var mapProperty: [String:String]?
|
||||
public var mapOfMapProperty: [String:[String:String]]?
|
||||
|
||||
|
||||
|
||||
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) {
|
||||
self.mapProperty = mapProperty
|
||||
self.mapOfMapProperty = mapOfMapProperty
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(mapProperty, forKey: "map_property")
|
||||
try container.encodeIfPresent(mapOfMapProperty, forKey: "map_of_map_property")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapProperty = "map_property"
|
||||
case mapOfMapProperty = "map_of_map_property"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
mapProperty = try container.decodeIfPresent([String:String].self, forKey: "map_property")
|
||||
mapOfMapProperty = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_of_map_property")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Animal: Codable {
|
||||
public struct Animal: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
|
||||
|
||||
|
||||
public init(className: String, color: String?) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encode(className, forKey: "className")
|
||||
try container.encodeIfPresent(color, forKey: "color")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
className = try container.decode(String.self, forKey: "className")
|
||||
color = try container.decodeIfPresent(String.self, forKey: "color")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ApiResponse: Codable {
|
||||
public struct ApiResponse: Codable {
|
||||
|
||||
public var code: Int?
|
||||
public var type: String?
|
||||
public var message: String?
|
||||
|
||||
|
||||
|
||||
public init(code: Int?, type: String?, message: String?) {
|
||||
self.code = code
|
||||
self.type = type
|
||||
self.message = message
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(code, forKey: "code")
|
||||
try container.encodeIfPresent(type, forKey: "type")
|
||||
try container.encodeIfPresent(message, forKey: "message")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
code = try container.decodeIfPresent(Int.self, forKey: "code")
|
||||
type = try container.decodeIfPresent(String.self, forKey: "type")
|
||||
message = try container.decodeIfPresent(String.self, forKey: "message")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayOfArrayOfNumberOnly: Codable {
|
||||
public struct ArrayOfArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayArrayNumber: [[Double]]?
|
||||
|
||||
|
||||
|
||||
public init(arrayArrayNumber: [[Double]]?) {
|
||||
self.arrayArrayNumber = arrayArrayNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayArrayNumber, forKey: "ArrayArrayNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayArrayNumber = "ArrayArrayNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayArrayNumber = try container.decodeIfPresent([[Double]].self, forKey: "ArrayArrayNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayOfNumberOnly: Codable {
|
||||
public struct ArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayNumber: [Double]?
|
||||
|
||||
|
||||
|
||||
public init(arrayNumber: [Double]?) {
|
||||
self.arrayNumber = arrayNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayNumber, forKey: "ArrayNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayNumber = "ArrayNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayNumber = try container.decodeIfPresent([Double].self, forKey: "ArrayNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,19 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayTest: Codable {
|
||||
public struct ArrayTest: Codable {
|
||||
|
||||
public var arrayOfString: [String]?
|
||||
public var arrayArrayOfInteger: [[Int64]]?
|
||||
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
|
||||
|
||||
|
||||
|
||||
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
|
||||
self.arrayOfString = arrayOfString
|
||||
self.arrayArrayOfInteger = arrayArrayOfInteger
|
||||
self.arrayArrayOfModel = arrayArrayOfModel
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayOfString, forKey: "array_of_string")
|
||||
try container.encodeIfPresent(arrayArrayOfInteger, forKey: "array_array_of_integer")
|
||||
try container.encodeIfPresent(arrayArrayOfModel, forKey: "array_array_of_model")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayOfString = "array_of_string"
|
||||
case arrayArrayOfInteger = "array_array_of_integer"
|
||||
case arrayArrayOfModel = "array_array_of_model"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayOfString = try container.decodeIfPresent([String].self, forKey: "array_of_string")
|
||||
arrayArrayOfInteger = try container.decodeIfPresent([[Int64]].self, forKey: "array_array_of_integer")
|
||||
arrayArrayOfModel = try container.decodeIfPresent([[ReadOnlyFirst]].self, forKey: "array_array_of_model")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Capitalization: Codable {
|
||||
public struct Capitalization: Codable {
|
||||
|
||||
public var smallCamel: String?
|
||||
public var capitalCamel: String?
|
||||
@ -20,42 +20,15 @@ open class Capitalization: Codable {
|
||||
public var ATT_NAME: String?
|
||||
|
||||
|
||||
|
||||
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
|
||||
self.smallCamel = smallCamel
|
||||
self.capitalCamel = capitalCamel
|
||||
self.smallSnake = smallSnake
|
||||
self.capitalSnake = capitalSnake
|
||||
self.sCAETHFlowPoints = sCAETHFlowPoints
|
||||
self.ATT_NAME = ATT_NAME
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(smallCamel, forKey: "smallCamel")
|
||||
try container.encodeIfPresent(capitalCamel, forKey: "CapitalCamel")
|
||||
try container.encodeIfPresent(smallSnake, forKey: "small_Snake")
|
||||
try container.encodeIfPresent(capitalSnake, forKey: "Capital_Snake")
|
||||
try container.encodeIfPresent(sCAETHFlowPoints, forKey: "SCA_ETH_Flow_Points")
|
||||
try container.encodeIfPresent(ATT_NAME, forKey: "ATT_NAME")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case smallCamel
|
||||
case capitalCamel = "CapitalCamel"
|
||||
case smallSnake = "small_Snake"
|
||||
case capitalSnake = "Capital_Snake"
|
||||
case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
|
||||
case ATT_NAME
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
smallCamel = try container.decodeIfPresent(String.self, forKey: "smallCamel")
|
||||
capitalCamel = try container.decodeIfPresent(String.self, forKey: "CapitalCamel")
|
||||
smallSnake = try container.decodeIfPresent(String.self, forKey: "small_Snake")
|
||||
capitalSnake = try container.decodeIfPresent(String.self, forKey: "Capital_Snake")
|
||||
sCAETHFlowPoints = try container.decodeIfPresent(String.self, forKey: "SCA_ETH_Flow_Points")
|
||||
ATT_NAME = try container.decodeIfPresent(String.self, forKey: "ATT_NAME")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,29 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Cat: Animal {
|
||||
public struct Cat: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
public var declawed: Bool?
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(declawed, forKey: "declawed")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
declawed = try container.decodeIfPresent(Bool.self, forKey: "declawed")
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Category: Codable {
|
||||
public struct Category: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
public var _id: Int64?
|
||||
public var name: String?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, name: String?) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case name
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,32 +10,11 @@ import Foundation
|
||||
|
||||
/** Model for testing model with \"_class\" property */
|
||||
|
||||
open class ClassModel: Codable {
|
||||
public struct ClassModel: Codable {
|
||||
|
||||
public var _class: String?
|
||||
|
||||
|
||||
|
||||
public init(_class: String?) {
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_class, forKey: "_class")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_class = try container.decodeIfPresent(String.self, forKey: "_class")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,11 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Client: Codable {
|
||||
public struct Client: Codable {
|
||||
|
||||
public var client: String?
|
||||
|
||||
|
||||
|
||||
public init(client: String?) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(client, forKey: "client")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
client = try container.decodeIfPresent(String.self, forKey: "client")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,29 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Dog: Animal {
|
||||
public struct Dog: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
public var breed: String?
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(breed, forKey: "breed")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
breed = try container.decodeIfPresent(String.self, forKey: "breed")
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class EnumArrays: Codable {
|
||||
public struct EnumArrays: Codable {
|
||||
|
||||
public enum JustSymbol: String, Codable {
|
||||
case greaterThanOrEqualTo = ">="
|
||||
@ -23,30 +23,11 @@ open class EnumArrays: Codable {
|
||||
public var arrayEnum: [ArrayEnum]?
|
||||
|
||||
|
||||
|
||||
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
|
||||
self.justSymbol = justSymbol
|
||||
self.arrayEnum = arrayEnum
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(justSymbol, forKey: "just_symbol")
|
||||
try container.encodeIfPresent(arrayEnum, forKey: "array_enum")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justSymbol = "just_symbol"
|
||||
case arrayEnum = "array_enum"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
justSymbol = try container.decodeIfPresent(JustSymbol.self, forKey: "just_symbol")
|
||||
arrayEnum = try container.decodeIfPresent([ArrayEnum].self, forKey: "array_enum")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class EnumTest: Codable {
|
||||
public struct EnumTest: Codable {
|
||||
|
||||
public enum EnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
@ -30,36 +30,13 @@ open class EnumTest: Codable {
|
||||
public var outerEnum: OuterEnum?
|
||||
|
||||
|
||||
|
||||
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
|
||||
self.enumString = enumString
|
||||
self.enumInteger = enumInteger
|
||||
self.enumNumber = enumNumber
|
||||
self.outerEnum = outerEnum
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(enumString, forKey: "enum_string")
|
||||
try container.encodeIfPresent(enumInteger, forKey: "enum_integer")
|
||||
try container.encodeIfPresent(enumNumber, forKey: "enum_number")
|
||||
try container.encodeIfPresent(outerEnum, forKey: "outerEnum")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case enumString = "enum_string"
|
||||
case enumInteger = "enum_integer"
|
||||
case enumNumber = "enum_number"
|
||||
case outerEnum
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
enumString = try container.decodeIfPresent(EnumString.self, forKey: "enum_string")
|
||||
enumInteger = try container.decodeIfPresent(EnumInteger.self, forKey: "enum_integer")
|
||||
enumNumber = try container.decodeIfPresent(EnumNumber.self, forKey: "enum_number")
|
||||
outerEnum = try container.decodeIfPresent(OuterEnum.self, forKey: "outerEnum")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class FormatTest: Codable {
|
||||
public struct FormatTest: Codable {
|
||||
|
||||
public var integer: Int?
|
||||
public var int32: Int?
|
||||
@ -26,63 +26,6 @@ open class FormatTest: Codable {
|
||||
public var password: String
|
||||
|
||||
|
||||
|
||||
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: Data?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
|
||||
self.integer = integer
|
||||
self.int32 = int32
|
||||
self.int64 = int64
|
||||
self.number = number
|
||||
self.float = float
|
||||
self.double = double
|
||||
self.string = string
|
||||
self.byte = byte
|
||||
self.binary = binary
|
||||
self.date = date
|
||||
self.dateTime = dateTime
|
||||
self.uuid = uuid
|
||||
self.password = password
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(integer, forKey: "integer")
|
||||
try container.encodeIfPresent(int32, forKey: "int32")
|
||||
try container.encodeIfPresent(int64, forKey: "int64")
|
||||
try container.encode(number, forKey: "number")
|
||||
try container.encodeIfPresent(float, forKey: "float")
|
||||
try container.encodeIfPresent(double, forKey: "double")
|
||||
try container.encodeIfPresent(string, forKey: "string")
|
||||
try container.encode(byte, forKey: "byte")
|
||||
try container.encodeIfPresent(binary, forKey: "binary")
|
||||
try container.encode(date, forKey: "date")
|
||||
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||
try container.encode(password, forKey: "password")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
integer = try container.decodeIfPresent(Int.self, forKey: "integer")
|
||||
int32 = try container.decodeIfPresent(Int.self, forKey: "int32")
|
||||
int64 = try container.decodeIfPresent(Int64.self, forKey: "int64")
|
||||
number = try container.decode(Double.self, forKey: "number")
|
||||
float = try container.decodeIfPresent(Float.self, forKey: "float")
|
||||
double = try container.decodeIfPresent(Double.self, forKey: "double")
|
||||
string = try container.decodeIfPresent(String.self, forKey: "string")
|
||||
byte = try container.decode(Data.self, forKey: "byte")
|
||||
binary = try container.decodeIfPresent(Data.self, forKey: "binary")
|
||||
date = try container.decode(Date.self, forKey: "date")
|
||||
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||
password = try container.decode(String.self, forKey: "password")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class HasOnlyReadOnly: Codable {
|
||||
public struct HasOnlyReadOnly: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var foo: String?
|
||||
|
||||
|
||||
|
||||
public init(bar: String?, foo: String?) {
|
||||
self.bar = bar
|
||||
self.foo = foo
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(bar, forKey: "bar")
|
||||
try container.encodeIfPresent(foo, forKey: "foo")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
bar = try container.decodeIfPresent(String.self, forKey: "bar")
|
||||
foo = try container.decodeIfPresent(String.self, forKey: "foo")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class List: Codable {
|
||||
public struct List: Codable {
|
||||
|
||||
public var _123List: String?
|
||||
|
||||
|
||||
|
||||
public init(_123List: String?) {
|
||||
self._123List = _123List
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_123List, forKey: "123-list")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _123List = "123-list"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_123List = try container.decodeIfPresent(String.self, forKey: "123-list")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class MapTest: Codable {
|
||||
public struct MapTest: Codable {
|
||||
|
||||
public enum MapOfEnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
@ -19,30 +19,11 @@ open class MapTest: Codable {
|
||||
public var mapOfEnumString: [String:String]?
|
||||
|
||||
|
||||
|
||||
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
|
||||
self.mapMapOfString = mapMapOfString
|
||||
self.mapOfEnumString = mapOfEnumString
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(mapMapOfString, forKey: "map_map_of_string")
|
||||
try container.encodeIfPresent(mapOfEnumString, forKey: "map_of_enum_string")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapMapOfString = "map_map_of_string"
|
||||
case mapOfEnumString = "map_of_enum_string"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
mapMapOfString = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_map_of_string")
|
||||
mapOfEnumString = try container.decodeIfPresent([String:String].self, forKey: "map_of_enum_string")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
|
||||
public var uuid: UUID?
|
||||
public var dateTime: Date?
|
||||
public var map: [String:Animal]?
|
||||
|
||||
|
||||
|
||||
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
|
||||
self.uuid = uuid
|
||||
self.dateTime = dateTime
|
||||
self.map = map
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||
try container.encodeIfPresent(map, forKey: "map")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||
map = try container.decodeIfPresent([String:Animal].self, forKey: "map")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,36 +10,17 @@ import Foundation
|
||||
|
||||
/** Model for testing model name starting with number */
|
||||
|
||||
open class Model200Response: Codable {
|
||||
public struct Model200Response: Codable {
|
||||
|
||||
public var name: Int?
|
||||
public var _class: String?
|
||||
|
||||
|
||||
|
||||
public init(name: Int?, _class: String?) {
|
||||
self.name = name
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
try container.encodeIfPresent(_class, forKey: "class")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case _class = "class"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(Int.self, forKey: "name")
|
||||
_class = try container.decodeIfPresent(String.self, forKey: "class")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
/** Model for testing model name same as property name */
|
||||
|
||||
open class Name: Codable {
|
||||
public struct Name: Codable {
|
||||
|
||||
public var name: Int
|
||||
public var snakeCase: Int?
|
||||
@ -18,36 +18,13 @@ open class Name: Codable {
|
||||
public var _123Number: Int?
|
||||
|
||||
|
||||
|
||||
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) {
|
||||
self.name = name
|
||||
self.snakeCase = snakeCase
|
||||
self.property = property
|
||||
self._123Number = _123Number
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encode(name, forKey: "name")
|
||||
try container.encodeIfPresent(snakeCase, forKey: "snake_case")
|
||||
try container.encodeIfPresent(property, forKey: "property")
|
||||
try container.encodeIfPresent(_123Number, forKey: "123Number")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case snakeCase = "snake_case"
|
||||
case property
|
||||
case _123Number = "123Number"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decode(Int.self, forKey: "name")
|
||||
snakeCase = try container.decodeIfPresent(Int.self, forKey: "snake_case")
|
||||
property = try container.decodeIfPresent(String.self, forKey: "property")
|
||||
_123Number = try container.decodeIfPresent(Int.self, forKey: "123Number")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class NumberOnly: Codable {
|
||||
public struct NumberOnly: Codable {
|
||||
|
||||
public var justNumber: Double?
|
||||
|
||||
|
||||
|
||||
public init(justNumber: Double?) {
|
||||
self.justNumber = justNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(justNumber, forKey: "JustNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justNumber = "JustNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
justNumber = try container.decodeIfPresent(Double.self, forKey: "JustNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,14 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Order: Codable {
|
||||
public struct Order: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var _id: Int64?
|
||||
public var petId: Int64?
|
||||
public var quantity: Int?
|
||||
public var shipDate: Date?
|
||||
@ -25,42 +25,15 @@ open class Order: Codable {
|
||||
public var complete: Bool?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
|
||||
self.id = id
|
||||
self.petId = petId
|
||||
self.quantity = quantity
|
||||
self.shipDate = shipDate
|
||||
self.status = status
|
||||
self.complete = complete
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(petId, forKey: "petId")
|
||||
try container.encodeIfPresent(quantity, forKey: "quantity")
|
||||
try container.encodeIfPresent(shipDate, forKey: "shipDate")
|
||||
try container.encodeIfPresent(status, forKey: "status")
|
||||
try container.encodeIfPresent(complete, forKey: "complete")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case petId
|
||||
case quantity
|
||||
case shipDate
|
||||
case status
|
||||
case complete
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
petId = try container.decodeIfPresent(Int64.self, forKey: "petId")
|
||||
quantity = try container.decodeIfPresent(Int.self, forKey: "quantity")
|
||||
shipDate = try container.decodeIfPresent(Date.self, forKey: "shipDate")
|
||||
status = try container.decodeIfPresent(Status.self, forKey: "status")
|
||||
complete = try container.decodeIfPresent(Bool.self, forKey: "complete")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterBoolean: Codable {
|
||||
public struct OuterBoolean: Codable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,19 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterComposite: Codable {
|
||||
public struct OuterComposite: Codable {
|
||||
|
||||
public var myNumber: OuterNumber?
|
||||
public var myString: OuterString?
|
||||
public var myBoolean: OuterBoolean?
|
||||
|
||||
|
||||
|
||||
public init(myNumber: OuterNumber?, myString: OuterString?, myBoolean: OuterBoolean?) {
|
||||
self.myNumber = myNumber
|
||||
self.myString = myString
|
||||
self.myBoolean = myBoolean
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(myNumber, forKey: "my_number")
|
||||
try container.encodeIfPresent(myString, forKey: "my_string")
|
||||
try container.encodeIfPresent(myBoolean, forKey: "my_boolean")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case myNumber = "my_number"
|
||||
case myString = "my_string"
|
||||
case myBoolean = "my_boolean"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
myNumber = try container.decodeIfPresent(OuterNumber.self, forKey: "my_number")
|
||||
myString = try container.decodeIfPresent(OuterString.self, forKey: "my_string")
|
||||
myBoolean = try container.decodeIfPresent(OuterBoolean.self, forKey: "my_boolean")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterNumber: Codable {
|
||||
public struct OuterNumber: Codable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterString: Codable {
|
||||
public struct OuterString: Codable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,14 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Pet: Codable {
|
||||
public struct Pet: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
case available = "available"
|
||||
case pending = "pending"
|
||||
case sold = "sold"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var _id: Int64?
|
||||
public var category: Category?
|
||||
public var name: String
|
||||
public var photoUrls: [String]
|
||||
@ -25,42 +25,15 @@ open class Pet: Codable {
|
||||
public var status: Status?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) {
|
||||
self.id = id
|
||||
self.category = category
|
||||
self.name = name
|
||||
self.photoUrls = photoUrls
|
||||
self.tags = tags
|
||||
self.status = status
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(category, forKey: "category")
|
||||
try container.encode(name, forKey: "name")
|
||||
try container.encode(photoUrls, forKey: "photoUrls")
|
||||
try container.encodeIfPresent(tags, forKey: "tags")
|
||||
try container.encodeIfPresent(status, forKey: "status")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case category
|
||||
case name
|
||||
case photoUrls
|
||||
case tags
|
||||
case status
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
category = try container.decodeIfPresent(Category.self, forKey: "category")
|
||||
name = try container.decode(String.self, forKey: "name")
|
||||
photoUrls = try container.decode([String].self, forKey: "photoUrls")
|
||||
tags = try container.decodeIfPresent([Tag].self, forKey: "tags")
|
||||
status = try container.decodeIfPresent(Status.self, forKey: "status")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ReadOnlyFirst: Codable {
|
||||
public struct ReadOnlyFirst: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var baz: String?
|
||||
|
||||
|
||||
|
||||
public init(bar: String?, baz: String?) {
|
||||
self.bar = bar
|
||||
self.baz = baz
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(bar, forKey: "bar")
|
||||
try container.encodeIfPresent(baz, forKey: "baz")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
bar = try container.decodeIfPresent(String.self, forKey: "bar")
|
||||
baz = try container.decodeIfPresent(String.self, forKey: "baz")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,32 +10,15 @@ import Foundation
|
||||
|
||||
/** Model for testing reserved words */
|
||||
|
||||
open class Return: Codable {
|
||||
public struct Return: Codable {
|
||||
|
||||
public var _return: Int?
|
||||
|
||||
|
||||
|
||||
public init(_return: Int?) {
|
||||
self._return = _return
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_return, forKey: "return")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _return = "return"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_return = try container.decodeIfPresent(Int.self, forKey: "return")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class SpecialModelName: Codable {
|
||||
public struct SpecialModelName: Codable {
|
||||
|
||||
public var specialPropertyName: Int64?
|
||||
|
||||
|
||||
|
||||
public init(specialPropertyName: Int64?) {
|
||||
self.specialPropertyName = specialPropertyName
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(specialPropertyName, forKey: "$special[property.name]")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case specialPropertyName = "$special[property.name]"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
specialPropertyName = try container.decodeIfPresent(Int64.self, forKey: "$special[property.name]")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Tag: Codable {
|
||||
public struct Tag: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
public var _id: Int64?
|
||||
public var name: String?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, name: String?) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case name
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class User: Codable {
|
||||
public struct User: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
public var _id: Int64?
|
||||
public var username: String?
|
||||
public var firstName: String?
|
||||
public var lastName: String?
|
||||
@ -22,48 +22,17 @@ open class User: Codable {
|
||||
public var userStatus: Int?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) {
|
||||
self.id = id
|
||||
self.username = username
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.email = email
|
||||
self.password = password
|
||||
self.phone = phone
|
||||
self.userStatus = userStatus
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(username, forKey: "username")
|
||||
try container.encodeIfPresent(firstName, forKey: "firstName")
|
||||
try container.encodeIfPresent(lastName, forKey: "lastName")
|
||||
try container.encodeIfPresent(email, forKey: "email")
|
||||
try container.encodeIfPresent(password, forKey: "password")
|
||||
try container.encodeIfPresent(phone, forKey: "phone")
|
||||
try container.encodeIfPresent(userStatus, forKey: "userStatus")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case username
|
||||
case firstName
|
||||
case lastName
|
||||
case email
|
||||
case password
|
||||
case phone
|
||||
case userStatus
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
username = try container.decodeIfPresent(String.self, forKey: "username")
|
||||
firstName = try container.decodeIfPresent(String.self, forKey: "firstName")
|
||||
lastName = try container.decodeIfPresent(String.self, forKey: "lastName")
|
||||
email = try container.decodeIfPresent(String.self, forKey: "email")
|
||||
password = try container.decodeIfPresent(String.self, forKey: "password")
|
||||
phone = try container.decodeIfPresent(String.self, forKey: "phone")
|
||||
userStatus = try container.decodeIfPresent(Int.self, forKey: "userStatus")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.4.0-SNAPSHOT
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// AnotherfakeAPI.swift
|
||||
// AnotherFakeAPI.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
@ -10,7 +10,7 @@ import Alamofire
|
||||
|
||||
|
||||
|
||||
open class AnotherfakeAPI {
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
//
|
||||
// FakeClassnameTags123API.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class FakeClassnameTags123API {
|
||||
/**
|
||||
To test class name in snake case
|
||||
|
||||
- parameter body: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
To test class name in snake case
|
||||
- PATCH /fake_classname_test
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
|
||||
- parameter body: (body) client model
|
||||
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||
let path = "/fake_classname_test"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let url = NSURLComponents(string: URLString)
|
||||
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -9,36 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class AdditionalPropertiesClass: Codable {
|
||||
public struct AdditionalPropertiesClass: Codable {
|
||||
|
||||
public var mapProperty: [String:String]?
|
||||
public var mapOfMapProperty: [String:[String:String]]?
|
||||
|
||||
|
||||
|
||||
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) {
|
||||
self.mapProperty = mapProperty
|
||||
self.mapOfMapProperty = mapOfMapProperty
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(mapProperty, forKey: "map_property")
|
||||
try container.encodeIfPresent(mapOfMapProperty, forKey: "map_of_map_property")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapProperty = "map_property"
|
||||
case mapOfMapProperty = "map_of_map_property"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
mapProperty = try container.decodeIfPresent([String:String].self, forKey: "map_property")
|
||||
mapOfMapProperty = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_of_map_property")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Animal: Codable {
|
||||
public struct Animal: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
|
||||
|
||||
|
||||
public init(className: String, color: String?) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encode(className, forKey: "className")
|
||||
try container.encodeIfPresent(color, forKey: "color")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
className = try container.decode(String.self, forKey: "className")
|
||||
color = try container.decodeIfPresent(String.self, forKey: "color")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ApiResponse: Codable {
|
||||
public struct ApiResponse: Codable {
|
||||
|
||||
public var code: Int?
|
||||
public var codeNum: NSNumber? {
|
||||
@ -21,33 +21,6 @@ open class ApiResponse: Codable {
|
||||
public var message: String?
|
||||
|
||||
|
||||
|
||||
public init(code: Int?, type: String?, message: String?) {
|
||||
self.code = code
|
||||
self.type = type
|
||||
self.message = message
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(code, forKey: "code")
|
||||
try container.encodeIfPresent(type, forKey: "type")
|
||||
try container.encodeIfPresent(message, forKey: "message")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
code = try container.decodeIfPresent(Int.self, forKey: "code")
|
||||
type = try container.decodeIfPresent(String.self, forKey: "type")
|
||||
message = try container.decodeIfPresent(String.self, forKey: "message")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayOfArrayOfNumberOnly: Codable {
|
||||
public struct ArrayOfArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayArrayNumber: [[Double]]?
|
||||
|
||||
|
||||
|
||||
public init(arrayArrayNumber: [[Double]]?) {
|
||||
self.arrayArrayNumber = arrayArrayNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayArrayNumber, forKey: "ArrayArrayNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayArrayNumber = "ArrayArrayNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayArrayNumber = try container.decodeIfPresent([[Double]].self, forKey: "ArrayArrayNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayOfNumberOnly: Codable {
|
||||
public struct ArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayNumber: [Double]?
|
||||
|
||||
|
||||
|
||||
public init(arrayNumber: [Double]?) {
|
||||
self.arrayNumber = arrayNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayNumber, forKey: "ArrayNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayNumber = "ArrayNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayNumber = try container.decodeIfPresent([Double].self, forKey: "ArrayNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,19 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayTest: Codable {
|
||||
public struct ArrayTest: Codable {
|
||||
|
||||
public var arrayOfString: [String]?
|
||||
public var arrayArrayOfInteger: [[Int64]]?
|
||||
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
|
||||
|
||||
|
||||
|
||||
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
|
||||
self.arrayOfString = arrayOfString
|
||||
self.arrayArrayOfInteger = arrayArrayOfInteger
|
||||
self.arrayArrayOfModel = arrayArrayOfModel
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayOfString, forKey: "array_of_string")
|
||||
try container.encodeIfPresent(arrayArrayOfInteger, forKey: "array_array_of_integer")
|
||||
try container.encodeIfPresent(arrayArrayOfModel, forKey: "array_array_of_model")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayOfString = "array_of_string"
|
||||
case arrayArrayOfInteger = "array_array_of_integer"
|
||||
case arrayArrayOfModel = "array_array_of_model"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayOfString = try container.decodeIfPresent([String].self, forKey: "array_of_string")
|
||||
arrayArrayOfInteger = try container.decodeIfPresent([[Int64]].self, forKey: "array_array_of_integer")
|
||||
arrayArrayOfModel = try container.decodeIfPresent([[ReadOnlyFirst]].self, forKey: "array_array_of_model")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Capitalization: Codable {
|
||||
public struct Capitalization: Codable {
|
||||
|
||||
public var smallCamel: String?
|
||||
public var capitalCamel: String?
|
||||
@ -20,42 +20,15 @@ open class Capitalization: Codable {
|
||||
public var ATT_NAME: String?
|
||||
|
||||
|
||||
|
||||
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
|
||||
self.smallCamel = smallCamel
|
||||
self.capitalCamel = capitalCamel
|
||||
self.smallSnake = smallSnake
|
||||
self.capitalSnake = capitalSnake
|
||||
self.sCAETHFlowPoints = sCAETHFlowPoints
|
||||
self.ATT_NAME = ATT_NAME
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(smallCamel, forKey: "smallCamel")
|
||||
try container.encodeIfPresent(capitalCamel, forKey: "CapitalCamel")
|
||||
try container.encodeIfPresent(smallSnake, forKey: "small_Snake")
|
||||
try container.encodeIfPresent(capitalSnake, forKey: "Capital_Snake")
|
||||
try container.encodeIfPresent(sCAETHFlowPoints, forKey: "SCA_ETH_Flow_Points")
|
||||
try container.encodeIfPresent(ATT_NAME, forKey: "ATT_NAME")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case smallCamel
|
||||
case capitalCamel = "CapitalCamel"
|
||||
case smallSnake = "small_Snake"
|
||||
case capitalSnake = "Capital_Snake"
|
||||
case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
|
||||
case ATT_NAME
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
smallCamel = try container.decodeIfPresent(String.self, forKey: "smallCamel")
|
||||
capitalCamel = try container.decodeIfPresent(String.self, forKey: "CapitalCamel")
|
||||
smallSnake = try container.decodeIfPresent(String.self, forKey: "small_Snake")
|
||||
capitalSnake = try container.decodeIfPresent(String.self, forKey: "Capital_Snake")
|
||||
sCAETHFlowPoints = try container.decodeIfPresent(String.self, forKey: "SCA_ETH_Flow_Points")
|
||||
ATT_NAME = try container.decodeIfPresent(String.self, forKey: "ATT_NAME")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Cat: Animal {
|
||||
public struct Cat: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
public var declawed: Bool?
|
||||
public var declawedNum: NSNumber? {
|
||||
get {
|
||||
@ -19,24 +21,6 @@ open class Cat: Animal {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(declawed, forKey: "declawed")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
declawed = try container.decodeIfPresent(Bool.self, forKey: "declawed")
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,41 +9,22 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Category: Codable {
|
||||
public struct Category: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
public var idNum: NSNumber? {
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return id.map({ return NSNumber(value: $0) })
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var name: String?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, name: String?) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case name
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,32 +10,11 @@ import Foundation
|
||||
|
||||
/** Model for testing model with \"_class\" property */
|
||||
|
||||
open class ClassModel: Codable {
|
||||
public struct ClassModel: Codable {
|
||||
|
||||
public var _class: String?
|
||||
|
||||
|
||||
|
||||
public init(_class: String?) {
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_class, forKey: "_class")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_class = try container.decodeIfPresent(String.self, forKey: "_class")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,11 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Client: Codable {
|
||||
public struct Client: Codable {
|
||||
|
||||
public var client: String?
|
||||
|
||||
|
||||
|
||||
public init(client: String?) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(client, forKey: "client")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
client = try container.decodeIfPresent(String.self, forKey: "client")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,29 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Dog: Animal {
|
||||
public struct Dog: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
public var breed: String?
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(breed, forKey: "breed")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
breed = try container.decodeIfPresent(String.self, forKey: "breed")
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class EnumArrays: Codable {
|
||||
public struct EnumArrays: Codable {
|
||||
|
||||
public enum JustSymbol: String, Codable {
|
||||
case greaterThanOrEqualTo = ">="
|
||||
@ -23,30 +23,11 @@ open class EnumArrays: Codable {
|
||||
public var arrayEnum: [ArrayEnum]?
|
||||
|
||||
|
||||
|
||||
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
|
||||
self.justSymbol = justSymbol
|
||||
self.arrayEnum = arrayEnum
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(justSymbol, forKey: "just_symbol")
|
||||
try container.encodeIfPresent(arrayEnum, forKey: "array_enum")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justSymbol = "just_symbol"
|
||||
case arrayEnum = "array_enum"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
justSymbol = try container.decodeIfPresent(JustSymbol.self, forKey: "just_symbol")
|
||||
arrayEnum = try container.decodeIfPresent([ArrayEnum].self, forKey: "array_enum")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class EnumTest: Codable {
|
||||
public struct EnumTest: Codable {
|
||||
|
||||
public enum EnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
@ -30,36 +30,13 @@ open class EnumTest: Codable {
|
||||
public var outerEnum: OuterEnum?
|
||||
|
||||
|
||||
|
||||
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
|
||||
self.enumString = enumString
|
||||
self.enumInteger = enumInteger
|
||||
self.enumNumber = enumNumber
|
||||
self.outerEnum = outerEnum
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(enumString, forKey: "enum_string")
|
||||
try container.encodeIfPresent(enumInteger, forKey: "enum_integer")
|
||||
try container.encodeIfPresent(enumNumber, forKey: "enum_number")
|
||||
try container.encodeIfPresent(outerEnum, forKey: "outerEnum")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case enumString = "enum_string"
|
||||
case enumInteger = "enum_integer"
|
||||
case enumNumber = "enum_number"
|
||||
case outerEnum
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
enumString = try container.decodeIfPresent(EnumString.self, forKey: "enum_string")
|
||||
enumInteger = try container.decodeIfPresent(EnumInteger.self, forKey: "enum_integer")
|
||||
enumNumber = try container.decodeIfPresent(EnumNumber.self, forKey: "enum_number")
|
||||
outerEnum = try container.decodeIfPresent(OuterEnum.self, forKey: "outerEnum")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class FormatTest: Codable {
|
||||
public struct FormatTest: Codable {
|
||||
|
||||
public var integer: Int?
|
||||
public var integerNum: NSNumber? {
|
||||
@ -30,11 +30,6 @@ open class FormatTest: Codable {
|
||||
}
|
||||
}
|
||||
public var number: Double
|
||||
public var numberNum: NSNumber? {
|
||||
get {
|
||||
return number.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var float: Float?
|
||||
public var floatNum: NSNumber? {
|
||||
get {
|
||||
@ -56,63 +51,6 @@ open class FormatTest: Codable {
|
||||
public var password: String
|
||||
|
||||
|
||||
|
||||
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: Data?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
|
||||
self.integer = integer
|
||||
self.int32 = int32
|
||||
self.int64 = int64
|
||||
self.number = number
|
||||
self.float = float
|
||||
self.double = double
|
||||
self.string = string
|
||||
self.byte = byte
|
||||
self.binary = binary
|
||||
self.date = date
|
||||
self.dateTime = dateTime
|
||||
self.uuid = uuid
|
||||
self.password = password
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(integer, forKey: "integer")
|
||||
try container.encodeIfPresent(int32, forKey: "int32")
|
||||
try container.encodeIfPresent(int64, forKey: "int64")
|
||||
try container.encode(number, forKey: "number")
|
||||
try container.encodeIfPresent(float, forKey: "float")
|
||||
try container.encodeIfPresent(double, forKey: "double")
|
||||
try container.encodeIfPresent(string, forKey: "string")
|
||||
try container.encode(byte, forKey: "byte")
|
||||
try container.encodeIfPresent(binary, forKey: "binary")
|
||||
try container.encode(date, forKey: "date")
|
||||
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||
try container.encode(password, forKey: "password")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
integer = try container.decodeIfPresent(Int.self, forKey: "integer")
|
||||
int32 = try container.decodeIfPresent(Int.self, forKey: "int32")
|
||||
int64 = try container.decodeIfPresent(Int64.self, forKey: "int64")
|
||||
number = try container.decode(Double.self, forKey: "number")
|
||||
float = try container.decodeIfPresent(Float.self, forKey: "float")
|
||||
double = try container.decodeIfPresent(Double.self, forKey: "double")
|
||||
string = try container.decodeIfPresent(String.self, forKey: "string")
|
||||
byte = try container.decode(Data.self, forKey: "byte")
|
||||
binary = try container.decodeIfPresent(Data.self, forKey: "binary")
|
||||
date = try container.decode(Date.self, forKey: "date")
|
||||
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||
password = try container.decode(String.self, forKey: "password")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class HasOnlyReadOnly: Codable {
|
||||
public struct HasOnlyReadOnly: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var foo: String?
|
||||
|
||||
|
||||
|
||||
public init(bar: String?, foo: String?) {
|
||||
self.bar = bar
|
||||
self.foo = foo
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(bar, forKey: "bar")
|
||||
try container.encodeIfPresent(foo, forKey: "foo")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
bar = try container.decodeIfPresent(String.self, forKey: "bar")
|
||||
foo = try container.decodeIfPresent(String.self, forKey: "foo")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class List: Codable {
|
||||
public struct List: Codable {
|
||||
|
||||
public var _123List: String?
|
||||
|
||||
|
||||
|
||||
public init(_123List: String?) {
|
||||
self._123List = _123List
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_123List, forKey: "123-list")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _123List = "123-list"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_123List = try container.decodeIfPresent(String.self, forKey: "123-list")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class MapTest: Codable {
|
||||
public struct MapTest: Codable {
|
||||
|
||||
public enum MapOfEnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
@ -19,30 +19,11 @@ open class MapTest: Codable {
|
||||
public var mapOfEnumString: [String:String]?
|
||||
|
||||
|
||||
|
||||
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
|
||||
self.mapMapOfString = mapMapOfString
|
||||
self.mapOfEnumString = mapOfEnumString
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(mapMapOfString, forKey: "map_map_of_string")
|
||||
try container.encodeIfPresent(mapOfEnumString, forKey: "map_of_enum_string")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapMapOfString = "map_map_of_string"
|
||||
case mapOfEnumString = "map_of_enum_string"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
mapMapOfString = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_map_of_string")
|
||||
mapOfEnumString = try container.decodeIfPresent([String:String].self, forKey: "map_of_enum_string")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
|
||||
public var uuid: UUID?
|
||||
public var dateTime: Date?
|
||||
public var map: [String:Animal]?
|
||||
|
||||
|
||||
|
||||
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
|
||||
self.uuid = uuid
|
||||
self.dateTime = dateTime
|
||||
self.map = map
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||
try container.encodeIfPresent(map, forKey: "map")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||
map = try container.decodeIfPresent([String:Animal].self, forKey: "map")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
/** Model for testing model name starting with number */
|
||||
|
||||
open class Model200Response: Codable {
|
||||
public struct Model200Response: Codable {
|
||||
|
||||
public var name: Int?
|
||||
public var nameNum: NSNumber? {
|
||||
@ -21,30 +21,11 @@ open class Model200Response: Codable {
|
||||
public var _class: String?
|
||||
|
||||
|
||||
|
||||
public init(name: Int?, _class: String?) {
|
||||
self.name = name
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
try container.encodeIfPresent(_class, forKey: "class")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case _class = "class"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(Int.self, forKey: "name")
|
||||
_class = try container.decodeIfPresent(String.self, forKey: "class")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
/** Model for testing model name same as property name */
|
||||
|
||||
open class Name: Codable {
|
||||
public struct Name: Codable {
|
||||
|
||||
public var name: Int
|
||||
public var nameNum: NSNumber? {
|
||||
@ -33,36 +33,13 @@ open class Name: Codable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) {
|
||||
self.name = name
|
||||
self.snakeCase = snakeCase
|
||||
self.property = property
|
||||
self._123Number = _123Number
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encode(name, forKey: "name")
|
||||
try container.encodeIfPresent(snakeCase, forKey: "snake_case")
|
||||
try container.encodeIfPresent(property, forKey: "property")
|
||||
try container.encodeIfPresent(_123Number, forKey: "123Number")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case snakeCase = "snake_case"
|
||||
case property
|
||||
case _123Number = "123Number"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decode(Int.self, forKey: "name")
|
||||
snakeCase = try container.decodeIfPresent(Int.self, forKey: "snake_case")
|
||||
property = try container.decodeIfPresent(String.self, forKey: "property")
|
||||
_123Number = try container.decodeIfPresent(Int.self, forKey: "123Number")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,37 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class NumberOnly: Codable {
|
||||
public struct NumberOnly: Codable {
|
||||
|
||||
public var justNumber: Double?
|
||||
public var justNumberNum: NSNumber? {
|
||||
get {
|
||||
return justNumber.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justNumber = "JustNumber"
|
||||
}
|
||||
|
||||
|
||||
|
||||
public init(justNumber: Double?) {
|
||||
self.justNumber = justNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(justNumber, forKey: "JustNumber")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
justNumber = try container.decodeIfPresent(Double.self, forKey: "JustNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Order: Codable {
|
||||
public struct Order: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var idNum: NSNumber? {
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return id.map({ return NSNumber(value: $0) })
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var petId: Int64?
|
||||
@ -45,42 +45,15 @@ open class Order: Codable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
|
||||
self.id = id
|
||||
self.petId = petId
|
||||
self.quantity = quantity
|
||||
self.shipDate = shipDate
|
||||
self.status = status
|
||||
self.complete = complete
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(petId, forKey: "petId")
|
||||
try container.encodeIfPresent(quantity, forKey: "quantity")
|
||||
try container.encodeIfPresent(shipDate, forKey: "shipDate")
|
||||
try container.encodeIfPresent(status, forKey: "status")
|
||||
try container.encodeIfPresent(complete, forKey: "complete")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case petId
|
||||
case quantity
|
||||
case shipDate
|
||||
case status
|
||||
case complete
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
petId = try container.decodeIfPresent(Int64.self, forKey: "petId")
|
||||
quantity = try container.decodeIfPresent(Int.self, forKey: "quantity")
|
||||
shipDate = try container.decodeIfPresent(Date.self, forKey: "shipDate")
|
||||
status = try container.decodeIfPresent(Status.self, forKey: "status")
|
||||
complete = try container.decodeIfPresent(Bool.self, forKey: "complete")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterBoolean: Codable {
|
||||
public struct OuterBoolean: Codable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,19 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterComposite: Codable {
|
||||
public struct OuterComposite: Codable {
|
||||
|
||||
public var myNumber: OuterNumber?
|
||||
public var myString: OuterString?
|
||||
public var myBoolean: OuterBoolean?
|
||||
|
||||
|
||||
|
||||
public init(myNumber: OuterNumber?, myString: OuterString?, myBoolean: OuterBoolean?) {
|
||||
self.myNumber = myNumber
|
||||
self.myString = myString
|
||||
self.myBoolean = myBoolean
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(myNumber, forKey: "my_number")
|
||||
try container.encodeIfPresent(myString, forKey: "my_string")
|
||||
try container.encodeIfPresent(myBoolean, forKey: "my_boolean")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case myNumber = "my_number"
|
||||
case myString = "my_string"
|
||||
case myBoolean = "my_boolean"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
myNumber = try container.decodeIfPresent(OuterNumber.self, forKey: "my_number")
|
||||
myString = try container.decodeIfPresent(OuterString.self, forKey: "my_string")
|
||||
myBoolean = try container.decodeIfPresent(OuterBoolean.self, forKey: "my_boolean")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterNumber: Codable {
|
||||
public struct OuterNumber: Codable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterString: Codable {
|
||||
public struct OuterString: Codable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Pet: Codable {
|
||||
public struct Pet: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
case available = "available"
|
||||
case pending = "pending"
|
||||
case sold = "sold"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var idNum: NSNumber? {
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return id.map({ return NSNumber(value: $0) })
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var category: Category?
|
||||
@ -30,42 +30,15 @@ open class Pet: Codable {
|
||||
public var status: Status?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) {
|
||||
self.id = id
|
||||
self.category = category
|
||||
self.name = name
|
||||
self.photoUrls = photoUrls
|
||||
self.tags = tags
|
||||
self.status = status
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(category, forKey: "category")
|
||||
try container.encode(name, forKey: "name")
|
||||
try container.encode(photoUrls, forKey: "photoUrls")
|
||||
try container.encodeIfPresent(tags, forKey: "tags")
|
||||
try container.encodeIfPresent(status, forKey: "status")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case category
|
||||
case name
|
||||
case photoUrls
|
||||
case tags
|
||||
case status
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
category = try container.decodeIfPresent(Category.self, forKey: "category")
|
||||
name = try container.decode(String.self, forKey: "name")
|
||||
photoUrls = try container.decode([String].self, forKey: "photoUrls")
|
||||
tags = try container.decodeIfPresent([Tag].self, forKey: "tags")
|
||||
status = try container.decodeIfPresent(Status.self, forKey: "status")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ReadOnlyFirst: Codable {
|
||||
public struct ReadOnlyFirst: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var baz: String?
|
||||
|
||||
|
||||
|
||||
public init(bar: String?, baz: String?) {
|
||||
self.bar = bar
|
||||
self.baz = baz
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(bar, forKey: "bar")
|
||||
try container.encodeIfPresent(baz, forKey: "baz")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
bar = try container.decodeIfPresent(String.self, forKey: "bar")
|
||||
baz = try container.decodeIfPresent(String.self, forKey: "baz")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
/** Model for testing reserved words */
|
||||
|
||||
open class Return: Codable {
|
||||
public struct Return: Codable {
|
||||
|
||||
public var _return: Int?
|
||||
public var _returnNum: NSNumber? {
|
||||
@ -20,27 +20,10 @@ open class Return: Codable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public init(_return: Int?) {
|
||||
self._return = _return
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_return, forKey: "return")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _return = "return"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_return = try container.decodeIfPresent(Int.self, forKey: "return")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class SpecialModelName: Codable {
|
||||
public struct SpecialModelName: Codable {
|
||||
|
||||
public var specialPropertyName: Int64?
|
||||
public var specialPropertyNameNum: NSNumber? {
|
||||
@ -19,27 +19,10 @@ open class SpecialModelName: Codable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public init(specialPropertyName: Int64?) {
|
||||
self.specialPropertyName = specialPropertyName
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(specialPropertyName, forKey: "$special[property.name]")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case specialPropertyName = "$special[property.name]"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
specialPropertyName = try container.decodeIfPresent(Int64.self, forKey: "$special[property.name]")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,41 +9,22 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Tag: Codable {
|
||||
public struct Tag: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
public var idNum: NSNumber? {
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return id.map({ return NSNumber(value: $0) })
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var name: String?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, name: String?) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case name
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class User: Codable {
|
||||
public struct User: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
public var idNum: NSNumber? {
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return id.map({ return NSNumber(value: $0) })
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var username: String?
|
||||
@ -32,48 +32,17 @@ open class User: Codable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) {
|
||||
self.id = id
|
||||
self.username = username
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.email = email
|
||||
self.password = password
|
||||
self.phone = phone
|
||||
self.userStatus = userStatus
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(username, forKey: "username")
|
||||
try container.encodeIfPresent(firstName, forKey: "firstName")
|
||||
try container.encodeIfPresent(lastName, forKey: "lastName")
|
||||
try container.encodeIfPresent(email, forKey: "email")
|
||||
try container.encodeIfPresent(password, forKey: "password")
|
||||
try container.encodeIfPresent(phone, forKey: "phone")
|
||||
try container.encodeIfPresent(userStatus, forKey: "userStatus")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case username
|
||||
case firstName
|
||||
case lastName
|
||||
case email
|
||||
case password
|
||||
case phone
|
||||
case userStatus
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
username = try container.decodeIfPresent(String.self, forKey: "username")
|
||||
firstName = try container.decodeIfPresent(String.self, forKey: "firstName")
|
||||
lastName = try container.decodeIfPresent(String.self, forKey: "lastName")
|
||||
email = try container.decodeIfPresent(String.self, forKey: "email")
|
||||
password = try container.decodeIfPresent(String.self, forKey: "password")
|
||||
phone = try container.decodeIfPresent(String.self, forKey: "phone")
|
||||
userStatus = try container.decodeIfPresent(Int.self, forKey: "userStatus")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.4.0-SNAPSHOT
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// AnotherfakeAPI.swift
|
||||
// AnotherFakeAPI.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
@ -11,7 +11,7 @@ import PromiseKit
|
||||
|
||||
|
||||
|
||||
open class AnotherfakeAPI {
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
|
||||
|
@ -9,36 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class AdditionalPropertiesClass: Codable {
|
||||
public struct AdditionalPropertiesClass: Codable {
|
||||
|
||||
public var mapProperty: [String:String]?
|
||||
public var mapOfMapProperty: [String:[String:String]]?
|
||||
|
||||
|
||||
|
||||
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) {
|
||||
self.mapProperty = mapProperty
|
||||
self.mapOfMapProperty = mapOfMapProperty
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(mapProperty, forKey: "map_property")
|
||||
try container.encodeIfPresent(mapOfMapProperty, forKey: "map_of_map_property")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapProperty = "map_property"
|
||||
case mapOfMapProperty = "map_of_map_property"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
mapProperty = try container.decodeIfPresent([String:String].self, forKey: "map_property")
|
||||
mapOfMapProperty = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_of_map_property")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Animal: Codable {
|
||||
public struct Animal: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
|
||||
|
||||
|
||||
public init(className: String, color: String?) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encode(className, forKey: "className")
|
||||
try container.encodeIfPresent(color, forKey: "color")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
className = try container.decode(String.self, forKey: "className")
|
||||
color = try container.decodeIfPresent(String.self, forKey: "color")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ApiResponse: Codable {
|
||||
public struct ApiResponse: Codable {
|
||||
|
||||
public var code: Int?
|
||||
public var type: String?
|
||||
public var message: String?
|
||||
|
||||
|
||||
|
||||
public init(code: Int?, type: String?, message: String?) {
|
||||
self.code = code
|
||||
self.type = type
|
||||
self.message = message
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(code, forKey: "code")
|
||||
try container.encodeIfPresent(type, forKey: "type")
|
||||
try container.encodeIfPresent(message, forKey: "message")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
code = try container.decodeIfPresent(Int.self, forKey: "code")
|
||||
type = try container.decodeIfPresent(String.self, forKey: "type")
|
||||
message = try container.decodeIfPresent(String.self, forKey: "message")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayOfArrayOfNumberOnly: Codable {
|
||||
public struct ArrayOfArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayArrayNumber: [[Double]]?
|
||||
|
||||
|
||||
|
||||
public init(arrayArrayNumber: [[Double]]?) {
|
||||
self.arrayArrayNumber = arrayArrayNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayArrayNumber, forKey: "ArrayArrayNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayArrayNumber = "ArrayArrayNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayArrayNumber = try container.decodeIfPresent([[Double]].self, forKey: "ArrayArrayNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayOfNumberOnly: Codable {
|
||||
public struct ArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayNumber: [Double]?
|
||||
|
||||
|
||||
|
||||
public init(arrayNumber: [Double]?) {
|
||||
self.arrayNumber = arrayNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayNumber, forKey: "ArrayNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayNumber = "ArrayNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayNumber = try container.decodeIfPresent([Double].self, forKey: "ArrayNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,19 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class ArrayTest: Codable {
|
||||
public struct ArrayTest: Codable {
|
||||
|
||||
public var arrayOfString: [String]?
|
||||
public var arrayArrayOfInteger: [[Int64]]?
|
||||
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
|
||||
|
||||
|
||||
|
||||
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
|
||||
self.arrayOfString = arrayOfString
|
||||
self.arrayArrayOfInteger = arrayArrayOfInteger
|
||||
self.arrayArrayOfModel = arrayArrayOfModel
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(arrayOfString, forKey: "array_of_string")
|
||||
try container.encodeIfPresent(arrayArrayOfInteger, forKey: "array_array_of_integer")
|
||||
try container.encodeIfPresent(arrayArrayOfModel, forKey: "array_array_of_model")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayOfString = "array_of_string"
|
||||
case arrayArrayOfInteger = "array_array_of_integer"
|
||||
case arrayArrayOfModel = "array_array_of_model"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
arrayOfString = try container.decodeIfPresent([String].self, forKey: "array_of_string")
|
||||
arrayArrayOfInteger = try container.decodeIfPresent([[Int64]].self, forKey: "array_array_of_integer")
|
||||
arrayArrayOfModel = try container.decodeIfPresent([[ReadOnlyFirst]].self, forKey: "array_array_of_model")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Capitalization: Codable {
|
||||
public struct Capitalization: Codable {
|
||||
|
||||
public var smallCamel: String?
|
||||
public var capitalCamel: String?
|
||||
@ -20,42 +20,15 @@ open class Capitalization: Codable {
|
||||
public var ATT_NAME: String?
|
||||
|
||||
|
||||
|
||||
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
|
||||
self.smallCamel = smallCamel
|
||||
self.capitalCamel = capitalCamel
|
||||
self.smallSnake = smallSnake
|
||||
self.capitalSnake = capitalSnake
|
||||
self.sCAETHFlowPoints = sCAETHFlowPoints
|
||||
self.ATT_NAME = ATT_NAME
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(smallCamel, forKey: "smallCamel")
|
||||
try container.encodeIfPresent(capitalCamel, forKey: "CapitalCamel")
|
||||
try container.encodeIfPresent(smallSnake, forKey: "small_Snake")
|
||||
try container.encodeIfPresent(capitalSnake, forKey: "Capital_Snake")
|
||||
try container.encodeIfPresent(sCAETHFlowPoints, forKey: "SCA_ETH_Flow_Points")
|
||||
try container.encodeIfPresent(ATT_NAME, forKey: "ATT_NAME")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case smallCamel
|
||||
case capitalCamel = "CapitalCamel"
|
||||
case smallSnake = "small_Snake"
|
||||
case capitalSnake = "Capital_Snake"
|
||||
case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
|
||||
case ATT_NAME
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
smallCamel = try container.decodeIfPresent(String.self, forKey: "smallCamel")
|
||||
capitalCamel = try container.decodeIfPresent(String.self, forKey: "CapitalCamel")
|
||||
smallSnake = try container.decodeIfPresent(String.self, forKey: "small_Snake")
|
||||
capitalSnake = try container.decodeIfPresent(String.self, forKey: "Capital_Snake")
|
||||
sCAETHFlowPoints = try container.decodeIfPresent(String.self, forKey: "SCA_ETH_Flow_Points")
|
||||
ATT_NAME = try container.decodeIfPresent(String.self, forKey: "ATT_NAME")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,29 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Cat: Animal {
|
||||
public struct Cat: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
public var declawed: Bool?
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(declawed, forKey: "declawed")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
declawed = try container.decodeIfPresent(Bool.self, forKey: "declawed")
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,17 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Category: Codable {
|
||||
public struct Category: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
public var _id: Int64?
|
||||
public var name: String?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, name: String?) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case name
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,32 +10,11 @@ import Foundation
|
||||
|
||||
/** Model for testing model with \"_class\" property */
|
||||
|
||||
open class ClassModel: Codable {
|
||||
public struct ClassModel: Codable {
|
||||
|
||||
public var _class: String?
|
||||
|
||||
|
||||
|
||||
public init(_class: String?) {
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_class, forKey: "_class")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_class = try container.decodeIfPresent(String.self, forKey: "_class")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,11 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Client: Codable {
|
||||
public struct Client: Codable {
|
||||
|
||||
public var client: String?
|
||||
|
||||
|
||||
|
||||
public init(client: String?) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(client, forKey: "client")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
client = try container.decodeIfPresent(String.self, forKey: "client")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,29 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Dog: Animal {
|
||||
public struct Dog: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String?
|
||||
public var breed: String?
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(breed, forKey: "breed")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
breed = try container.decodeIfPresent(String.self, forKey: "breed")
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class EnumArrays: Codable {
|
||||
public struct EnumArrays: Codable {
|
||||
|
||||
public enum JustSymbol: String, Codable {
|
||||
case greaterThanOrEqualTo = ">="
|
||||
@ -23,30 +23,11 @@ open class EnumArrays: Codable {
|
||||
public var arrayEnum: [ArrayEnum]?
|
||||
|
||||
|
||||
|
||||
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
|
||||
self.justSymbol = justSymbol
|
||||
self.arrayEnum = arrayEnum
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(justSymbol, forKey: "just_symbol")
|
||||
try container.encodeIfPresent(arrayEnum, forKey: "array_enum")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justSymbol = "just_symbol"
|
||||
case arrayEnum = "array_enum"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
justSymbol = try container.decodeIfPresent(JustSymbol.self, forKey: "just_symbol")
|
||||
arrayEnum = try container.decodeIfPresent([ArrayEnum].self, forKey: "array_enum")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class EnumTest: Codable {
|
||||
public struct EnumTest: Codable {
|
||||
|
||||
public enum EnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
@ -30,36 +30,13 @@ open class EnumTest: Codable {
|
||||
public var outerEnum: OuterEnum?
|
||||
|
||||
|
||||
|
||||
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
|
||||
self.enumString = enumString
|
||||
self.enumInteger = enumInteger
|
||||
self.enumNumber = enumNumber
|
||||
self.outerEnum = outerEnum
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(enumString, forKey: "enum_string")
|
||||
try container.encodeIfPresent(enumInteger, forKey: "enum_integer")
|
||||
try container.encodeIfPresent(enumNumber, forKey: "enum_number")
|
||||
try container.encodeIfPresent(outerEnum, forKey: "outerEnum")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case enumString = "enum_string"
|
||||
case enumInteger = "enum_integer"
|
||||
case enumNumber = "enum_number"
|
||||
case outerEnum
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
enumString = try container.decodeIfPresent(EnumString.self, forKey: "enum_string")
|
||||
enumInteger = try container.decodeIfPresent(EnumInteger.self, forKey: "enum_integer")
|
||||
enumNumber = try container.decodeIfPresent(EnumNumber.self, forKey: "enum_number")
|
||||
outerEnum = try container.decodeIfPresent(OuterEnum.self, forKey: "outerEnum")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class FormatTest: Codable {
|
||||
public struct FormatTest: Codable {
|
||||
|
||||
public var integer: Int?
|
||||
public var int32: Int?
|
||||
@ -26,63 +26,6 @@ open class FormatTest: Codable {
|
||||
public var password: String
|
||||
|
||||
|
||||
|
||||
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: Data?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
|
||||
self.integer = integer
|
||||
self.int32 = int32
|
||||
self.int64 = int64
|
||||
self.number = number
|
||||
self.float = float
|
||||
self.double = double
|
||||
self.string = string
|
||||
self.byte = byte
|
||||
self.binary = binary
|
||||
self.date = date
|
||||
self.dateTime = dateTime
|
||||
self.uuid = uuid
|
||||
self.password = password
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(integer, forKey: "integer")
|
||||
try container.encodeIfPresent(int32, forKey: "int32")
|
||||
try container.encodeIfPresent(int64, forKey: "int64")
|
||||
try container.encode(number, forKey: "number")
|
||||
try container.encodeIfPresent(float, forKey: "float")
|
||||
try container.encodeIfPresent(double, forKey: "double")
|
||||
try container.encodeIfPresent(string, forKey: "string")
|
||||
try container.encode(byte, forKey: "byte")
|
||||
try container.encodeIfPresent(binary, forKey: "binary")
|
||||
try container.encode(date, forKey: "date")
|
||||
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||
try container.encode(password, forKey: "password")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
integer = try container.decodeIfPresent(Int.self, forKey: "integer")
|
||||
int32 = try container.decodeIfPresent(Int.self, forKey: "int32")
|
||||
int64 = try container.decodeIfPresent(Int64.self, forKey: "int64")
|
||||
number = try container.decode(Double.self, forKey: "number")
|
||||
float = try container.decodeIfPresent(Float.self, forKey: "float")
|
||||
double = try container.decodeIfPresent(Double.self, forKey: "double")
|
||||
string = try container.decodeIfPresent(String.self, forKey: "string")
|
||||
byte = try container.decode(Data.self, forKey: "byte")
|
||||
binary = try container.decodeIfPresent(Data.self, forKey: "binary")
|
||||
date = try container.decode(Date.self, forKey: "date")
|
||||
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||
password = try container.decode(String.self, forKey: "password")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,36 +9,12 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class HasOnlyReadOnly: Codable {
|
||||
public struct HasOnlyReadOnly: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var foo: String?
|
||||
|
||||
|
||||
|
||||
public init(bar: String?, foo: String?) {
|
||||
self.bar = bar
|
||||
self.foo = foo
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(bar, forKey: "bar")
|
||||
try container.encodeIfPresent(foo, forKey: "foo")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
bar = try container.decodeIfPresent(String.self, forKey: "bar")
|
||||
foo = try container.decodeIfPresent(String.self, forKey: "foo")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class List: Codable {
|
||||
public struct List: Codable {
|
||||
|
||||
public var _123List: String?
|
||||
|
||||
|
||||
|
||||
public init(_123List: String?) {
|
||||
self._123List = _123List
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(_123List, forKey: "123-list")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _123List = "123-list"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
_123List = try container.decodeIfPresent(String.self, forKey: "123-list")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class MapTest: Codable {
|
||||
public struct MapTest: Codable {
|
||||
|
||||
public enum MapOfEnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
@ -19,30 +19,11 @@ open class MapTest: Codable {
|
||||
public var mapOfEnumString: [String:String]?
|
||||
|
||||
|
||||
|
||||
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
|
||||
self.mapMapOfString = mapMapOfString
|
||||
self.mapOfEnumString = mapOfEnumString
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(mapMapOfString, forKey: "map_map_of_string")
|
||||
try container.encodeIfPresent(mapOfEnumString, forKey: "map_of_enum_string")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapMapOfString = "map_map_of_string"
|
||||
case mapOfEnumString = "map_of_enum_string"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
mapMapOfString = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_map_of_string")
|
||||
mapOfEnumString = try container.decodeIfPresent([String:String].self, forKey: "map_of_enum_string")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,40 +9,13 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
|
||||
public var uuid: UUID?
|
||||
public var dateTime: Date?
|
||||
public var map: [String:Animal]?
|
||||
|
||||
|
||||
|
||||
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
|
||||
self.uuid = uuid
|
||||
self.dateTime = dateTime
|
||||
self.map = map
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||
try container.encodeIfPresent(map, forKey: "map")
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||
map = try container.decodeIfPresent([String:Animal].self, forKey: "map")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,36 +10,17 @@ import Foundation
|
||||
|
||||
/** Model for testing model name starting with number */
|
||||
|
||||
open class Model200Response: Codable {
|
||||
public struct Model200Response: Codable {
|
||||
|
||||
public var name: Int?
|
||||
public var _class: String?
|
||||
|
||||
|
||||
|
||||
public init(name: Int?, _class: String?) {
|
||||
self.name = name
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(name, forKey: "name")
|
||||
try container.encodeIfPresent(_class, forKey: "class")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case _class = "class"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(Int.self, forKey: "name")
|
||||
_class = try container.decodeIfPresent(String.self, forKey: "class")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
/** Model for testing model name same as property name */
|
||||
|
||||
open class Name: Codable {
|
||||
public struct Name: Codable {
|
||||
|
||||
public var name: Int
|
||||
public var snakeCase: Int?
|
||||
@ -18,36 +18,13 @@ open class Name: Codable {
|
||||
public var _123Number: Int?
|
||||
|
||||
|
||||
|
||||
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) {
|
||||
self.name = name
|
||||
self.snakeCase = snakeCase
|
||||
self.property = property
|
||||
self._123Number = _123Number
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encode(name, forKey: "name")
|
||||
try container.encodeIfPresent(snakeCase, forKey: "snake_case")
|
||||
try container.encodeIfPresent(property, forKey: "property")
|
||||
try container.encodeIfPresent(_123Number, forKey: "123Number")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case snakeCase = "snake_case"
|
||||
case property
|
||||
case _123Number = "123Number"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decode(Int.self, forKey: "name")
|
||||
snakeCase = try container.decodeIfPresent(Int.self, forKey: "snake_case")
|
||||
property = try container.decodeIfPresent(String.self, forKey: "property")
|
||||
_123Number = try container.decodeIfPresent(Int.self, forKey: "123Number")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,32 +9,15 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class NumberOnly: Codable {
|
||||
public struct NumberOnly: Codable {
|
||||
|
||||
public var justNumber: Double?
|
||||
|
||||
|
||||
|
||||
public init(justNumber: Double?) {
|
||||
self.justNumber = justNumber
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(justNumber, forKey: "JustNumber")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justNumber = "JustNumber"
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
justNumber = try container.decodeIfPresent(Double.self, forKey: "JustNumber")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,14 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class Order: Codable {
|
||||
public struct Order: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var _id: Int64?
|
||||
public var petId: Int64?
|
||||
public var quantity: Int?
|
||||
public var shipDate: Date?
|
||||
@ -25,42 +25,15 @@ open class Order: Codable {
|
||||
public var complete: Bool?
|
||||
|
||||
|
||||
|
||||
public init(id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
|
||||
self.id = id
|
||||
self.petId = petId
|
||||
self.quantity = quantity
|
||||
self.shipDate = shipDate
|
||||
self.status = status
|
||||
self.complete = complete
|
||||
}
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
try container.encodeIfPresent(id, forKey: "id")
|
||||
try container.encodeIfPresent(petId, forKey: "petId")
|
||||
try container.encodeIfPresent(quantity, forKey: "quantity")
|
||||
try container.encodeIfPresent(shipDate, forKey: "shipDate")
|
||||
try container.encodeIfPresent(status, forKey: "status")
|
||||
try container.encodeIfPresent(complete, forKey: "complete")
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case petId
|
||||
case quantity
|
||||
case shipDate
|
||||
case status
|
||||
case complete
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||
petId = try container.decodeIfPresent(Int64.self, forKey: "petId")
|
||||
quantity = try container.decodeIfPresent(Int.self, forKey: "quantity")
|
||||
shipDate = try container.decodeIfPresent(Date.self, forKey: "shipDate")
|
||||
status = try container.decodeIfPresent(Status.self, forKey: "status")
|
||||
complete = try container.decodeIfPresent(Bool.self, forKey: "complete")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,25 +9,10 @@ import Foundation
|
||||
|
||||
|
||||
|
||||
open class OuterBoolean: Codable {
|
||||
public struct OuterBoolean: Codable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user