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:
ehyche 2018-01-25 08:33:11 -05:00 committed by William Cheng
parent 2b84118c9f
commit a3d0f1d4bd
180 changed files with 1436 additions and 4066 deletions

View File

@ -710,8 +710,38 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) { public Map<String, Object> postProcessModels(Map<String, Object> objs) {
// process enum in models Map<String, Object> postProcessedModelsEnum = postProcessModelsEnum(objs);
return 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 @Override

View File

@ -1,12 +1,12 @@
open class {{classname}}: {{#parent}}{{{parent}}}{{/parent}}{{^parent}}Codable{{/parent}} { public struct {{classname}}: Codable {
{{#vars}} {{#allVars}}
{{#isEnum}} {{#isEnum}}
{{> modelInlineEnumDeclaration}} {{> modelInlineEnumDeclaration}}
{{/isEnum}} {{/isEnum}}
{{/vars}} {{/allVars}}
{{#vars}} {{#allVars}}
{{#isEnum}} {{#isEnum}}
{{#description}}/** {{description}} */ {{#description}}/** {{description}} */
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} {{/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}} }{{/vendorExtensions.x-swift-optional-scalar}}{{/objcCompatible}}
{{/isEnum}} {{/isEnum}}
{{/vars}} {{/allVars}}
{{#additionalPropertiesType}} {{#additionalPropertiesType}}
public var additionalProperties: [String:{{{additionalPropertiesType}}}] = [:] public var additionalProperties: [String:{{{additionalPropertiesType}}}] = [:]
@ -37,47 +37,39 @@ open class {{classname}}: {{#parent}}{{{parent}}}{{/parent}}{{^parent}}Codable{{
additionalProperties[key] = newValue 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 // 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) var container = encoder.container(keyedBy: String.self)
{{#vars}} {{#allVars}}
try container.encode{{^required}}IfPresent{{/required}}({{{name}}}, forKey: "{{{baseName}}}") try container.encode{{^required}}IfPresent{{/required}}({{{name}}}, forKey: "{{{baseName}}}")
{{/vars}} {{/allVars}}
{{#additionalPropertiesType}}
try container.encodeMap(additionalProperties) try container.encodeMap(additionalProperties)
{{/additionalPropertiesType}}
} }
// Decodable protocol methods // Decodable protocol methods
public required init(from decoder: Decoder) throws { public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: String.self) let container = try decoder.container(keyedBy: String.self)
{{#vars}} {{#allVars}}
{{name}} = try container.decode{{^required}}IfPresent{{/required}}({{{datatypeWithEnum}}}.self, forKey: "{{{baseName}}}") {{name}} = try container.decode{{^required}}IfPresent{{/required}}({{{datatypeWithEnum}}}.self, forKey: "{{{baseName}}}")
{{/vars}} {{/allVars}}
{{#additionalPropertiesType}}
var nonAdditionalPropertyKeys = Set<String>() var nonAdditionalPropertyKeys = Set<String>()
{{#vars}} {{#allVars}}
nonAdditionalPropertyKeys.insert("{{{baseName}}}") nonAdditionalPropertyKeys.insert("{{{baseName}}}")
{{/vars}} {{/allVars}}
additionalProperties = try container.decodeMap({{{additionalPropertiesType}}}.self, excludedKeys: nonAdditionalPropertyKeys) 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}}
} }

View File

@ -284,6 +284,10 @@
"for": { "for": {
"description": "This property name is a reserved word in most languages, including Swift 4.", "description": "This property name is a reserved word in most languages, including Swift 4.",
"type": "string" "type": "string"
},
"normalName": {
"description": "This model object property name should be unchanged from the JSON property name.",
"type": "string"
} }
} }
}, },
@ -370,6 +374,93 @@
"additionalProperties": { "additionalProperties": {
"type": "string" "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"
}
}
}
]
} }
} }
} }

View File

@ -1 +1 @@
2.3.0-SNAPSHOT 2.4.0-SNAPSHOT

View File

@ -1,5 +1,5 @@
// //
// AnotherfakeAPI.swift // AnotherFakeAPI.swift
// //
// Generated by swagger-codegen // Generated by swagger-codegen
// https://github.com/swagger-api/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 To test special tags

View File

@ -9,36 +9,17 @@ import Foundation
open class AdditionalPropertiesClass: Codable { public struct AdditionalPropertiesClass: Codable {
public var mapProperty: [String:String]? public var mapProperty: [String:String]?
public var mapOfMapProperty: [String:[String:String]]? public var mapOfMapProperty: [String:[String:String]]?
public enum CodingKeys: String, CodingKey {
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) { case mapProperty = "map_property"
self.mapProperty = mapProperty case mapOfMapProperty = "map_of_map_property"
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")
} }
// 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class Animal: Codable { public struct Animal: Codable {
public var className: String public var className: String
public var color: 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")
}
} }

View File

@ -9,40 +9,13 @@ import Foundation
open class ApiResponse: Codable { public struct ApiResponse: Codable {
public var code: Int? public var code: Int?
public var type: String? public var type: String?
public var message: 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class ArrayOfArrayOfNumberOnly: Codable { public struct ArrayOfArrayOfNumberOnly: Codable {
public var arrayArrayNumber: [[Double]]? public var arrayArrayNumber: [[Double]]?
public enum CodingKeys: String, CodingKey {
public init(arrayArrayNumber: [[Double]]?) { case arrayArrayNumber = "ArrayArrayNumber"
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")
} }
// 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class ArrayOfNumberOnly: Codable { public struct ArrayOfNumberOnly: Codable {
public var arrayNumber: [Double]? public var arrayNumber: [Double]?
public enum CodingKeys: String, CodingKey {
public init(arrayNumber: [Double]?) { case arrayNumber = "ArrayNumber"
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")
} }
// 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")
}
} }

View File

@ -9,40 +9,19 @@ import Foundation
open class ArrayTest: Codable { public struct ArrayTest: Codable {
public var arrayOfString: [String]? public var arrayOfString: [String]?
public var arrayArrayOfInteger: [[Int64]]? public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]? public var arrayArrayOfModel: [[ReadOnlyFirst]]?
public enum CodingKeys: String, CodingKey {
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) { case arrayOfString = "array_of_string"
self.arrayOfString = arrayOfString case arrayArrayOfInteger = "array_array_of_integer"
self.arrayArrayOfInteger = arrayArrayOfInteger case arrayArrayOfModel = "array_array_of_model"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class Capitalization: Codable { public struct Capitalization: Codable {
public var smallCamel: String? public var smallCamel: String?
public var capitalCamel: String? public var capitalCamel: String?
@ -20,42 +20,15 @@ open class Capitalization: Codable {
public var ATT_NAME: String? public var ATT_NAME: String?
public enum CodingKeys: String, CodingKey {
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) { case smallCamel
self.smallCamel = smallCamel case capitalCamel = "CapitalCamel"
self.capitalCamel = capitalCamel case smallSnake = "small_Snake"
self.smallSnake = smallSnake case capitalSnake = "Capital_Snake"
self.capitalSnake = capitalSnake case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
self.sCAETHFlowPoints = sCAETHFlowPoints case ATT_NAME
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")
} }
// 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")
}
} }

View File

@ -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? 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)
}
} }

View File

@ -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 var name: String?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, name: String?) { case _id = "id"
self.id = id case name
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")
} }
// 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")
}
} }

View File

@ -10,32 +10,11 @@ import Foundation
/** Model for testing model with \&quot;_class\&quot; property */ /** Model for testing model with \&quot;_class\&quot; property */
open class ClassModel: Codable { public struct ClassModel: Codable {
public var _class: String? 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")
}
} }

View File

@ -9,32 +9,11 @@ import Foundation
open class Client: Codable { public struct Client: Codable {
public var client: String? 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")
}
} }

View File

@ -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? 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)
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class EnumArrays: Codable { public struct EnumArrays: Codable {
public enum JustSymbol: String, Codable { public enum JustSymbol: String, Codable {
case greaterThanOrEqualTo = ">=" case greaterThanOrEqualTo = ">="
@ -23,30 +23,11 @@ open class EnumArrays: Codable {
public var arrayEnum: [ArrayEnum]? public var arrayEnum: [ArrayEnum]?
public enum CodingKeys: String, CodingKey {
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) { case justSymbol = "just_symbol"
self.justSymbol = justSymbol case arrayEnum = "array_enum"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class EnumTest: Codable { public struct EnumTest: Codable {
public enum EnumString: String, Codable { public enum EnumString: String, Codable {
case upper = "UPPER" case upper = "UPPER"
@ -30,36 +30,13 @@ open class EnumTest: Codable {
public var outerEnum: OuterEnum? public var outerEnum: OuterEnum?
public enum CodingKeys: String, CodingKey {
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) { case enumString = "enum_string"
self.enumString = enumString case enumInteger = "enum_integer"
self.enumInteger = enumInteger case enumNumber = "enum_number"
self.enumNumber = enumNumber case outerEnum
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class FormatTest: Codable { public struct FormatTest: Codable {
public var integer: Int? public var integer: Int?
public var int32: Int? public var int32: Int?
@ -26,63 +26,6 @@ open class FormatTest: Codable {
public var password: String 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class HasOnlyReadOnly: Codable { public struct HasOnlyReadOnly: Codable {
public var bar: String? public var bar: String?
public var foo: 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class List: Codable { public struct List: Codable {
public var _123List: String? public var _123List: String?
public enum CodingKeys: String, CodingKey {
public init(_123List: String?) { case _123List = "123-list"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class MapTest: Codable { public struct MapTest: Codable {
public enum MapOfEnumString: String, Codable { public enum MapOfEnumString: String, Codable {
case upper = "UPPER" case upper = "UPPER"
@ -19,30 +19,11 @@ open class MapTest: Codable {
public var mapOfEnumString: [String:String]? public var mapOfEnumString: [String:String]?
public enum CodingKeys: String, CodingKey {
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) { case mapMapOfString = "map_map_of_string"
self.mapMapOfString = mapMapOfString case mapOfEnumString = "map_of_enum_string"
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")
} }
// 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")
}
} }

View File

@ -9,40 +9,13 @@ import Foundation
open class MixedPropertiesAndAdditionalPropertiesClass: Codable { public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
public var uuid: UUID? public var uuid: UUID?
public var dateTime: Date? public var dateTime: Date?
public var map: [String:Animal]? 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")
}
} }

View File

@ -10,36 +10,17 @@ import Foundation
/** Model for testing model name starting with number */ /** Model for testing model name starting with number */
open class Model200Response: Codable { public struct Model200Response: Codable {
public var name: Int? public var name: Int?
public var _class: String? public var _class: String?
public enum CodingKeys: String, CodingKey {
public init(name: Int?, _class: String?) { case name
self.name = name case _class = "class"
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")
} }
// 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")
}
} }

View File

@ -10,7 +10,7 @@ import Foundation
/** Model for testing model name same as property name */ /** Model for testing model name same as property name */
open class Name: Codable { public struct Name: Codable {
public var name: Int public var name: Int
public var snakeCase: Int? public var snakeCase: Int?
@ -18,36 +18,13 @@ open class Name: Codable {
public var _123Number: Int? public var _123Number: Int?
public enum CodingKeys: String, CodingKey {
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) { case name
self.name = name case snakeCase = "snake_case"
self.snakeCase = snakeCase case property
self.property = property case _123Number = "123Number"
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")
} }
// 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class NumberOnly: Codable { public struct NumberOnly: Codable {
public var justNumber: Double? public var justNumber: Double?
public enum CodingKeys: String, CodingKey {
public init(justNumber: Double?) { case justNumber = "JustNumber"
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")
}
} }

View File

@ -9,14 +9,14 @@ import Foundation
open class Order: Codable { public struct Order: Codable {
public enum Status: String, Codable { public enum Status: String, Codable {
case placed = "placed" case placed = "placed"
case approved = "approved" case approved = "approved"
case delivered = "delivered" case delivered = "delivered"
} }
public var id: Int64? public var _id: Int64?
public var petId: Int64? public var petId: Int64?
public var quantity: Int? public var quantity: Int?
public var shipDate: Date? public var shipDate: Date?
@ -25,42 +25,15 @@ open class Order: Codable {
public var complete: Bool? public var complete: Bool?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) { case _id = "id"
self.id = id case petId
self.petId = petId case quantity
self.quantity = quantity case shipDate
self.shipDate = shipDate case status
self.status = status case complete
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")
} }
// 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")
}
} }

View File

@ -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)
}
} }

View File

@ -9,40 +9,19 @@ import Foundation
open class OuterComposite: Codable { public struct OuterComposite: Codable {
public var myNumber: OuterNumber? public var myNumber: OuterNumber?
public var myString: OuterString? public var myString: OuterString?
public var myBoolean: OuterBoolean? public var myBoolean: OuterBoolean?
public enum CodingKeys: String, CodingKey {
public init(myNumber: OuterNumber?, myString: OuterString?, myBoolean: OuterBoolean?) { case myNumber = "my_number"
self.myNumber = myNumber case myString = "my_string"
self.myString = myString case myBoolean = "my_boolean"
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")
} }
// 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")
}
} }

View File

@ -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)
}
} }

View File

@ -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)
}
} }

View File

@ -9,14 +9,14 @@ import Foundation
open class Pet: Codable { public struct Pet: Codable {
public enum Status: String, Codable { public enum Status: String, Codable {
case available = "available" case available = "available"
case pending = "pending" case pending = "pending"
case sold = "sold" case sold = "sold"
} }
public var id: Int64? public var _id: Int64?
public var category: Category? public var category: Category?
public var name: String public var name: String
public var photoUrls: [String] public var photoUrls: [String]
@ -25,42 +25,15 @@ open class Pet: Codable {
public var status: Status? public var status: Status?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) { case _id = "id"
self.id = id case category
self.category = category case name
self.name = name case photoUrls
self.photoUrls = photoUrls case tags
self.tags = tags case status
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")
} }
// 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class ReadOnlyFirst: Codable { public struct ReadOnlyFirst: Codable {
public var bar: String? public var bar: String?
public var baz: 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")
}
} }

View File

@ -10,32 +10,15 @@ import Foundation
/** Model for testing reserved words */ /** Model for testing reserved words */
open class Return: Codable { public struct Return: Codable {
public var _return: Int? public var _return: Int?
public enum CodingKeys: String, CodingKey {
public init(_return: Int?) { case _return = "return"
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")
} }
// 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class SpecialModelName: Codable { public struct SpecialModelName: Codable {
public var specialPropertyName: Int64? public var specialPropertyName: Int64?
public enum CodingKeys: String, CodingKey {
public init(specialPropertyName: Int64?) { case specialPropertyName = "$special[property.name]"
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]")
} }
// 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]")
}
} }

View File

@ -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 var name: String?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, name: String?) { case _id = "id"
self.id = id case name
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")
} }
// 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")
}
} }

View File

@ -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 username: String?
public var firstName: String? public var firstName: String?
public var lastName: String? public var lastName: String?
@ -22,48 +22,17 @@ open class User: Codable {
public var userStatus: Int? public var userStatus: Int?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) { case _id = "id"
self.id = id case username
self.username = username case firstName
self.firstName = firstName case lastName
self.lastName = lastName case email
self.email = email case password
self.password = password case phone
self.phone = phone case userStatus
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")
} }
// 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")
}
} }

View File

@ -1 +1 @@
2.3.0-SNAPSHOT 2.4.0-SNAPSHOT

View File

@ -1,5 +1,5 @@
// //
// AnotherfakeAPI.swift // AnotherFakeAPI.swift
// //
// Generated by swagger-codegen // Generated by swagger-codegen
// https://github.com/swagger-api/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 To test special tags

View File

@ -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)
}
}

View File

@ -9,36 +9,17 @@ import Foundation
open class AdditionalPropertiesClass: Codable { public struct AdditionalPropertiesClass: Codable {
public var mapProperty: [String:String]? public var mapProperty: [String:String]?
public var mapOfMapProperty: [String:[String:String]]? public var mapOfMapProperty: [String:[String:String]]?
public enum CodingKeys: String, CodingKey {
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) { case mapProperty = "map_property"
self.mapProperty = mapProperty case mapOfMapProperty = "map_of_map_property"
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")
} }
// 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class Animal: Codable { public struct Animal: Codable {
public var className: String public var className: String
public var color: 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class ApiResponse: Codable { public struct ApiResponse: Codable {
public var code: Int? public var code: Int?
public var codeNum: NSNumber? { public var codeNum: NSNumber? {
@ -21,33 +21,6 @@ open class ApiResponse: Codable {
public var message: 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class ArrayOfArrayOfNumberOnly: Codable { public struct ArrayOfArrayOfNumberOnly: Codable {
public var arrayArrayNumber: [[Double]]? public var arrayArrayNumber: [[Double]]?
public enum CodingKeys: String, CodingKey {
public init(arrayArrayNumber: [[Double]]?) { case arrayArrayNumber = "ArrayArrayNumber"
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")
} }
// 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class ArrayOfNumberOnly: Codable { public struct ArrayOfNumberOnly: Codable {
public var arrayNumber: [Double]? public var arrayNumber: [Double]?
public enum CodingKeys: String, CodingKey {
public init(arrayNumber: [Double]?) { case arrayNumber = "ArrayNumber"
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")
} }
// 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")
}
} }

View File

@ -9,40 +9,19 @@ import Foundation
open class ArrayTest: Codable { public struct ArrayTest: Codable {
public var arrayOfString: [String]? public var arrayOfString: [String]?
public var arrayArrayOfInteger: [[Int64]]? public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]? public var arrayArrayOfModel: [[ReadOnlyFirst]]?
public enum CodingKeys: String, CodingKey {
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) { case arrayOfString = "array_of_string"
self.arrayOfString = arrayOfString case arrayArrayOfInteger = "array_array_of_integer"
self.arrayArrayOfInteger = arrayArrayOfInteger case arrayArrayOfModel = "array_array_of_model"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class Capitalization: Codable { public struct Capitalization: Codable {
public var smallCamel: String? public var smallCamel: String?
public var capitalCamel: String? public var capitalCamel: String?
@ -20,42 +20,15 @@ open class Capitalization: Codable {
public var ATT_NAME: String? public var ATT_NAME: String?
public enum CodingKeys: String, CodingKey {
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) { case smallCamel
self.smallCamel = smallCamel case capitalCamel = "CapitalCamel"
self.capitalCamel = capitalCamel case smallSnake = "small_Snake"
self.smallSnake = smallSnake case capitalSnake = "Capital_Snake"
self.capitalSnake = capitalSnake case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
self.sCAETHFlowPoints = sCAETHFlowPoints case ATT_NAME
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")
} }
// 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")
}
} }

View File

@ -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 declawed: Bool?
public var declawedNum: NSNumber? { public var declawedNum: NSNumber? {
get { 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)
}
} }

View File

@ -9,41 +9,22 @@ import Foundation
open class Category: Codable { public struct Category: Codable {
public var id: Int64? public var _id: Int64?
public var idNum: NSNumber? { public var _idNum: NSNumber? {
get { get {
return id.map({ return NSNumber(value: $0) }) return _id.map({ return NSNumber(value: $0) })
} }
} }
public var name: String? public var name: String?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, name: String?) { case _id = "id"
self.id = id case name
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")
} }
// 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")
}
} }

View File

@ -10,32 +10,11 @@ import Foundation
/** Model for testing model with \&quot;_class\&quot; property */ /** Model for testing model with \&quot;_class\&quot; property */
open class ClassModel: Codable { public struct ClassModel: Codable {
public var _class: String? 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")
}
} }

View File

@ -9,32 +9,11 @@ import Foundation
open class Client: Codable { public struct Client: Codable {
public var client: String? 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")
}
} }

View File

@ -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? 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)
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class EnumArrays: Codable { public struct EnumArrays: Codable {
public enum JustSymbol: String, Codable { public enum JustSymbol: String, Codable {
case greaterThanOrEqualTo = ">=" case greaterThanOrEqualTo = ">="
@ -23,30 +23,11 @@ open class EnumArrays: Codable {
public var arrayEnum: [ArrayEnum]? public var arrayEnum: [ArrayEnum]?
public enum CodingKeys: String, CodingKey {
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) { case justSymbol = "just_symbol"
self.justSymbol = justSymbol case arrayEnum = "array_enum"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class EnumTest: Codable { public struct EnumTest: Codable {
public enum EnumString: String, Codable { public enum EnumString: String, Codable {
case upper = "UPPER" case upper = "UPPER"
@ -30,36 +30,13 @@ open class EnumTest: Codable {
public var outerEnum: OuterEnum? public var outerEnum: OuterEnum?
public enum CodingKeys: String, CodingKey {
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) { case enumString = "enum_string"
self.enumString = enumString case enumInteger = "enum_integer"
self.enumInteger = enumInteger case enumNumber = "enum_number"
self.enumNumber = enumNumber case outerEnum
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class FormatTest: Codable { public struct FormatTest: Codable {
public var integer: Int? public var integer: Int?
public var integerNum: NSNumber? { public var integerNum: NSNumber? {
@ -30,11 +30,6 @@ open class FormatTest: Codable {
} }
} }
public var number: Double public var number: Double
public var numberNum: NSNumber? {
get {
return number.map({ return NSNumber(value: $0) })
}
}
public var float: Float? public var float: Float?
public var floatNum: NSNumber? { public var floatNum: NSNumber? {
get { get {
@ -56,63 +51,6 @@ open class FormatTest: Codable {
public var password: String 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class HasOnlyReadOnly: Codable { public struct HasOnlyReadOnly: Codable {
public var bar: String? public var bar: String?
public var foo: 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class List: Codable { public struct List: Codable {
public var _123List: String? public var _123List: String?
public enum CodingKeys: String, CodingKey {
public init(_123List: String?) { case _123List = "123-list"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class MapTest: Codable { public struct MapTest: Codable {
public enum MapOfEnumString: String, Codable { public enum MapOfEnumString: String, Codable {
case upper = "UPPER" case upper = "UPPER"
@ -19,30 +19,11 @@ open class MapTest: Codable {
public var mapOfEnumString: [String:String]? public var mapOfEnumString: [String:String]?
public enum CodingKeys: String, CodingKey {
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) { case mapMapOfString = "map_map_of_string"
self.mapMapOfString = mapMapOfString case mapOfEnumString = "map_of_enum_string"
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")
} }
// 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")
}
} }

View File

@ -9,40 +9,13 @@ import Foundation
open class MixedPropertiesAndAdditionalPropertiesClass: Codable { public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
public var uuid: UUID? public var uuid: UUID?
public var dateTime: Date? public var dateTime: Date?
public var map: [String:Animal]? 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")
}
} }

View File

@ -10,7 +10,7 @@ import Foundation
/** Model for testing model name starting with number */ /** Model for testing model name starting with number */
open class Model200Response: Codable { public struct Model200Response: Codable {
public var name: Int? public var name: Int?
public var nameNum: NSNumber? { public var nameNum: NSNumber? {
@ -21,30 +21,11 @@ open class Model200Response: Codable {
public var _class: String? public var _class: String?
public enum CodingKeys: String, CodingKey {
public init(name: Int?, _class: String?) { case name
self.name = name case _class = "class"
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")
} }
// 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")
}
} }

View File

@ -10,7 +10,7 @@ import Foundation
/** Model for testing model name same as property name */ /** Model for testing model name same as property name */
open class Name: Codable { public struct Name: Codable {
public var name: Int public var name: Int
public var nameNum: NSNumber? { public var nameNum: NSNumber? {
@ -33,36 +33,13 @@ open class Name: Codable {
} }
public enum CodingKeys: String, CodingKey {
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) { case name
self.name = name case snakeCase = "snake_case"
self.snakeCase = snakeCase case property
self.property = property case _123Number = "123Number"
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")
} }
// 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")
}
} }

View File

@ -9,37 +9,15 @@ import Foundation
open class NumberOnly: Codable { public struct NumberOnly: Codable {
public var justNumber: Double? 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")
}
} }

View File

@ -9,17 +9,17 @@ import Foundation
open class Order: Codable { public struct Order: Codable {
public enum Status: String, Codable { public enum Status: String, Codable {
case placed = "placed" case placed = "placed"
case approved = "approved" case approved = "approved"
case delivered = "delivered" case delivered = "delivered"
} }
public var id: Int64? public var _id: Int64?
public var idNum: NSNumber? { public var _idNum: NSNumber? {
get { get {
return id.map({ return NSNumber(value: $0) }) return _id.map({ return NSNumber(value: $0) })
} }
} }
public var petId: Int64? public var petId: Int64?
@ -45,42 +45,15 @@ open class Order: Codable {
} }
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) { case _id = "id"
self.id = id case petId
self.petId = petId case quantity
self.quantity = quantity case shipDate
self.shipDate = shipDate case status
self.status = status case complete
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")
} }
// 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")
}
} }

View File

@ -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)
}
} }

View File

@ -9,40 +9,19 @@ import Foundation
open class OuterComposite: Codable { public struct OuterComposite: Codable {
public var myNumber: OuterNumber? public var myNumber: OuterNumber?
public var myString: OuterString? public var myString: OuterString?
public var myBoolean: OuterBoolean? public var myBoolean: OuterBoolean?
public enum CodingKeys: String, CodingKey {
public init(myNumber: OuterNumber?, myString: OuterString?, myBoolean: OuterBoolean?) { case myNumber = "my_number"
self.myNumber = myNumber case myString = "my_string"
self.myString = myString case myBoolean = "my_boolean"
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")
} }
// 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")
}
} }

View File

@ -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)
}
} }

View File

@ -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)
}
} }

View File

@ -9,17 +9,17 @@ import Foundation
open class Pet: Codable { public struct Pet: Codable {
public enum Status: String, Codable { public enum Status: String, Codable {
case available = "available" case available = "available"
case pending = "pending" case pending = "pending"
case sold = "sold" case sold = "sold"
} }
public var id: Int64? public var _id: Int64?
public var idNum: NSNumber? { public var _idNum: NSNumber? {
get { get {
return id.map({ return NSNumber(value: $0) }) return _id.map({ return NSNumber(value: $0) })
} }
} }
public var category: Category? public var category: Category?
@ -30,42 +30,15 @@ open class Pet: Codable {
public var status: Status? public var status: Status?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) { case _id = "id"
self.id = id case category
self.category = category case name
self.name = name case photoUrls
self.photoUrls = photoUrls case tags
self.tags = tags case status
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")
} }
// 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class ReadOnlyFirst: Codable { public struct ReadOnlyFirst: Codable {
public var bar: String? public var bar: String?
public var baz: 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")
}
} }

View File

@ -10,7 +10,7 @@ import Foundation
/** Model for testing reserved words */ /** Model for testing reserved words */
open class Return: Codable { public struct Return: Codable {
public var _return: Int? public var _return: Int?
public var _returnNum: NSNumber? { public var _returnNum: NSNumber? {
@ -20,27 +20,10 @@ open class Return: Codable {
} }
public enum CodingKeys: String, CodingKey {
public init(_return: Int?) { case _return = "return"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class SpecialModelName: Codable { public struct SpecialModelName: Codable {
public var specialPropertyName: Int64? public var specialPropertyName: Int64?
public var specialPropertyNameNum: NSNumber? { public var specialPropertyNameNum: NSNumber? {
@ -19,27 +19,10 @@ open class SpecialModelName: Codable {
} }
public enum CodingKeys: String, CodingKey {
public init(specialPropertyName: Int64?) { case specialPropertyName = "$special[property.name]"
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]")
} }
// 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]")
}
} }

View File

@ -9,41 +9,22 @@ import Foundation
open class Tag: Codable { public struct Tag: Codable {
public var id: Int64? public var _id: Int64?
public var idNum: NSNumber? { public var _idNum: NSNumber? {
get { get {
return id.map({ return NSNumber(value: $0) }) return _id.map({ return NSNumber(value: $0) })
} }
} }
public var name: String? public var name: String?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, name: String?) { case _id = "id"
self.id = id case name
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")
} }
// 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")
}
} }

View File

@ -9,12 +9,12 @@ import Foundation
open class User: Codable { public struct User: Codable {
public var id: Int64? public var _id: Int64?
public var idNum: NSNumber? { public var _idNum: NSNumber? {
get { get {
return id.map({ return NSNumber(value: $0) }) return _id.map({ return NSNumber(value: $0) })
} }
} }
public var username: String? public var username: String?
@ -32,48 +32,17 @@ open class User: Codable {
} }
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) { case _id = "id"
self.id = id case username
self.username = username case firstName
self.firstName = firstName case lastName
self.lastName = lastName case email
self.email = email case password
self.password = password case phone
self.phone = phone case userStatus
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")
} }
// 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")
}
} }

View File

@ -1 +1 @@
2.3.0-SNAPSHOT 2.4.0-SNAPSHOT

View File

@ -1,5 +1,5 @@
// //
// AnotherfakeAPI.swift // AnotherFakeAPI.swift
// //
// Generated by swagger-codegen // Generated by swagger-codegen
// https://github.com/swagger-api/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 To test special tags

View File

@ -9,36 +9,17 @@ import Foundation
open class AdditionalPropertiesClass: Codable { public struct AdditionalPropertiesClass: Codable {
public var mapProperty: [String:String]? public var mapProperty: [String:String]?
public var mapOfMapProperty: [String:[String:String]]? public var mapOfMapProperty: [String:[String:String]]?
public enum CodingKeys: String, CodingKey {
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) { case mapProperty = "map_property"
self.mapProperty = mapProperty case mapOfMapProperty = "map_of_map_property"
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")
} }
// 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class Animal: Codable { public struct Animal: Codable {
public var className: String public var className: String
public var color: 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")
}
} }

View File

@ -9,40 +9,13 @@ import Foundation
open class ApiResponse: Codable { public struct ApiResponse: Codable {
public var code: Int? public var code: Int?
public var type: String? public var type: String?
public var message: 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class ArrayOfArrayOfNumberOnly: Codable { public struct ArrayOfArrayOfNumberOnly: Codable {
public var arrayArrayNumber: [[Double]]? public var arrayArrayNumber: [[Double]]?
public enum CodingKeys: String, CodingKey {
public init(arrayArrayNumber: [[Double]]?) { case arrayArrayNumber = "ArrayArrayNumber"
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")
} }
// 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class ArrayOfNumberOnly: Codable { public struct ArrayOfNumberOnly: Codable {
public var arrayNumber: [Double]? public var arrayNumber: [Double]?
public enum CodingKeys: String, CodingKey {
public init(arrayNumber: [Double]?) { case arrayNumber = "ArrayNumber"
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")
} }
// 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")
}
} }

View File

@ -9,40 +9,19 @@ import Foundation
open class ArrayTest: Codable { public struct ArrayTest: Codable {
public var arrayOfString: [String]? public var arrayOfString: [String]?
public var arrayArrayOfInteger: [[Int64]]? public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]? public var arrayArrayOfModel: [[ReadOnlyFirst]]?
public enum CodingKeys: String, CodingKey {
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) { case arrayOfString = "array_of_string"
self.arrayOfString = arrayOfString case arrayArrayOfInteger = "array_array_of_integer"
self.arrayArrayOfInteger = arrayArrayOfInteger case arrayArrayOfModel = "array_array_of_model"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class Capitalization: Codable { public struct Capitalization: Codable {
public var smallCamel: String? public var smallCamel: String?
public var capitalCamel: String? public var capitalCamel: String?
@ -20,42 +20,15 @@ open class Capitalization: Codable {
public var ATT_NAME: String? public var ATT_NAME: String?
public enum CodingKeys: String, CodingKey {
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) { case smallCamel
self.smallCamel = smallCamel case capitalCamel = "CapitalCamel"
self.capitalCamel = capitalCamel case smallSnake = "small_Snake"
self.smallSnake = smallSnake case capitalSnake = "Capital_Snake"
self.capitalSnake = capitalSnake case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
self.sCAETHFlowPoints = sCAETHFlowPoints case ATT_NAME
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")
} }
// 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")
}
} }

View File

@ -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? 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)
}
} }

View File

@ -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 var name: String?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, name: String?) { case _id = "id"
self.id = id case name
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")
} }
// 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")
}
} }

View File

@ -10,32 +10,11 @@ import Foundation
/** Model for testing model with \&quot;_class\&quot; property */ /** Model for testing model with \&quot;_class\&quot; property */
open class ClassModel: Codable { public struct ClassModel: Codable {
public var _class: String? 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")
}
} }

View File

@ -9,32 +9,11 @@ import Foundation
open class Client: Codable { public struct Client: Codable {
public var client: String? 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")
}
} }

View File

@ -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? 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)
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class EnumArrays: Codable { public struct EnumArrays: Codable {
public enum JustSymbol: String, Codable { public enum JustSymbol: String, Codable {
case greaterThanOrEqualTo = ">=" case greaterThanOrEqualTo = ">="
@ -23,30 +23,11 @@ open class EnumArrays: Codable {
public var arrayEnum: [ArrayEnum]? public var arrayEnum: [ArrayEnum]?
public enum CodingKeys: String, CodingKey {
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) { case justSymbol = "just_symbol"
self.justSymbol = justSymbol case arrayEnum = "array_enum"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class EnumTest: Codable { public struct EnumTest: Codable {
public enum EnumString: String, Codable { public enum EnumString: String, Codable {
case upper = "UPPER" case upper = "UPPER"
@ -30,36 +30,13 @@ open class EnumTest: Codable {
public var outerEnum: OuterEnum? public var outerEnum: OuterEnum?
public enum CodingKeys: String, CodingKey {
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) { case enumString = "enum_string"
self.enumString = enumString case enumInteger = "enum_integer"
self.enumInteger = enumInteger case enumNumber = "enum_number"
self.enumNumber = enumNumber case outerEnum
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class FormatTest: Codable { public struct FormatTest: Codable {
public var integer: Int? public var integer: Int?
public var int32: Int? public var int32: Int?
@ -26,63 +26,6 @@ open class FormatTest: Codable {
public var password: String 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")
}
} }

View File

@ -9,36 +9,12 @@ import Foundation
open class HasOnlyReadOnly: Codable { public struct HasOnlyReadOnly: Codable {
public var bar: String? public var bar: String?
public var foo: 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class List: Codable { public struct List: Codable {
public var _123List: String? public var _123List: String?
public enum CodingKeys: String, CodingKey {
public init(_123List: String?) { case _123List = "123-list"
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")
} }
// 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")
}
} }

View File

@ -9,7 +9,7 @@ import Foundation
open class MapTest: Codable { public struct MapTest: Codable {
public enum MapOfEnumString: String, Codable { public enum MapOfEnumString: String, Codable {
case upper = "UPPER" case upper = "UPPER"
@ -19,30 +19,11 @@ open class MapTest: Codable {
public var mapOfEnumString: [String:String]? public var mapOfEnumString: [String:String]?
public enum CodingKeys: String, CodingKey {
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) { case mapMapOfString = "map_map_of_string"
self.mapMapOfString = mapMapOfString case mapOfEnumString = "map_of_enum_string"
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")
} }
// 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")
}
} }

View File

@ -9,40 +9,13 @@ import Foundation
open class MixedPropertiesAndAdditionalPropertiesClass: Codable { public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
public var uuid: UUID? public var uuid: UUID?
public var dateTime: Date? public var dateTime: Date?
public var map: [String:Animal]? 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")
}
} }

View File

@ -10,36 +10,17 @@ import Foundation
/** Model for testing model name starting with number */ /** Model for testing model name starting with number */
open class Model200Response: Codable { public struct Model200Response: Codable {
public var name: Int? public var name: Int?
public var _class: String? public var _class: String?
public enum CodingKeys: String, CodingKey {
public init(name: Int?, _class: String?) { case name
self.name = name case _class = "class"
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")
} }
// 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")
}
} }

View File

@ -10,7 +10,7 @@ import Foundation
/** Model for testing model name same as property name */ /** Model for testing model name same as property name */
open class Name: Codable { public struct Name: Codable {
public var name: Int public var name: Int
public var snakeCase: Int? public var snakeCase: Int?
@ -18,36 +18,13 @@ open class Name: Codable {
public var _123Number: Int? public var _123Number: Int?
public enum CodingKeys: String, CodingKey {
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) { case name
self.name = name case snakeCase = "snake_case"
self.snakeCase = snakeCase case property
self.property = property case _123Number = "123Number"
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")
} }
// 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")
}
} }

View File

@ -9,32 +9,15 @@ import Foundation
open class NumberOnly: Codable { public struct NumberOnly: Codable {
public var justNumber: Double? public var justNumber: Double?
public enum CodingKeys: String, CodingKey {
public init(justNumber: Double?) { case justNumber = "JustNumber"
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")
}
} }

View File

@ -9,14 +9,14 @@ import Foundation
open class Order: Codable { public struct Order: Codable {
public enum Status: String, Codable { public enum Status: String, Codable {
case placed = "placed" case placed = "placed"
case approved = "approved" case approved = "approved"
case delivered = "delivered" case delivered = "delivered"
} }
public var id: Int64? public var _id: Int64?
public var petId: Int64? public var petId: Int64?
public var quantity: Int? public var quantity: Int?
public var shipDate: Date? public var shipDate: Date?
@ -25,42 +25,15 @@ open class Order: Codable {
public var complete: Bool? public var complete: Bool?
public enum CodingKeys: String, CodingKey {
public init(id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) { case _id = "id"
self.id = id case petId
self.petId = petId case quantity
self.quantity = quantity case shipDate
self.shipDate = shipDate case status
self.status = status case complete
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")
} }
// 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")
}
} }

View File

@ -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