Skip to content

Commit

Permalink
[swift5] Update samples and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Apr 22, 2021
1 parent 7ea2c87 commit 86a6047
Show file tree
Hide file tree
Showing 411 changed files with 6,655 additions and 332 deletions.
2 changes: 1 addition & 1 deletion docs/generators/swift5.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|lenientTypeCast|Accept and cast values for simple types (string-&gt;bool, string-&gt;int, int-&gt;string)| |false|
|library|Library template (sub-template) to use|<dl><dt>**urlsession**</dt><dd>[DEFAULT] HTTP client: URLSession</dd><dt>**alamofire**</dt><dd>HTTP client: Alamofire</dd><dt>**vapor**</dt><dd>HTTP client: Vapor</dd></dl>|urlsession|
|library|Library template (sub-template) to use|<dl><dt>**urlsession**</dt><dd>[DEFAULT] HTTP client: URLSession</dd><dt>**alamofire**</dt><dd>HTTP client: Alamofire</dd></dl>|urlsession|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null|
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
|podAuthors|Authors used for Podspec| |null|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ public struct AdditionalPropertiesClass: Codable, Hashable {
self.mapString = mapString
self.mapMapString = mapMapString
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case mapString = "map_string"
case mapMapString = "map_map_string"
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(mapString, forKey: .mapString)
try container.encodeIfPresent(mapMapString, forKey: .mapMapString)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,19 @@ public struct Animal: Codable, Hashable {
self.className = className
self.color = color
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case className
case color
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(className, forKey: .className)
try container.encodeIfPresent(color, forKey: .color)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,21 @@ public struct ApiResponse: Codable, Hashable {
self.type = type
self.message = message
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case code
case type
case message
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(code, forKey: .code)
try container.encodeIfPresent(type, forKey: .type)
try container.encodeIfPresent(message, forKey: .message)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ public struct ArrayOfArrayOfNumberOnly: Codable, Hashable {
public init(arrayArrayNumber: [[Double]]? = nil) {
self.arrayArrayNumber = arrayArrayNumber
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case arrayArrayNumber = "ArrayArrayNumber"
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(arrayArrayNumber, forKey: .arrayArrayNumber)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ public struct ArrayOfNumberOnly: Codable, Hashable {
public init(arrayNumber: [Double]? = nil) {
self.arrayNumber = arrayNumber
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case arrayNumber = "ArrayNumber"
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(arrayNumber, forKey: .arrayNumber)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@ public struct ArrayTest: Codable, Hashable {
self.arrayArrayOfInteger = arrayArrayOfInteger
self.arrayArrayOfModel = arrayArrayOfModel
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case arrayOfString = "array_of_string"
case arrayArrayOfInteger = "array_array_of_integer"
case arrayArrayOfModel = "array_array_of_model"
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(arrayOfString, forKey: .arrayOfString)
try container.encodeIfPresent(arrayArrayOfInteger, forKey: .arrayArrayOfInteger)
try container.encodeIfPresent(arrayArrayOfModel, forKey: .arrayArrayOfModel)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct Capitalization: Codable, Hashable {
self.sCAETHFlowPoints = sCAETHFlowPoints
self.ATT_NAME = ATT_NAME
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case smallCamel
case capitalCamel = "CapitalCamel"
Expand All @@ -35,4 +34,18 @@ public struct Capitalization: Codable, Hashable {
case ATT_NAME
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(smallCamel, forKey: .smallCamel)
try container.encodeIfPresent(capitalCamel, forKey: .capitalCamel)
try container.encodeIfPresent(smallSnake, forKey: .smallSnake)
try container.encodeIfPresent(capitalSnake, forKey: .capitalSnake)
try container.encodeIfPresent(sCAETHFlowPoints, forKey: .sCAETHFlowPoints)
try container.encodeIfPresent(ATT_NAME, forKey: .ATT_NAME)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,21 @@ public struct Cat: Codable, Hashable {
self.color = color
self.declawed = declawed
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case className
case color
case declawed
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(className, forKey: .className)
try container.encodeIfPresent(color, forKey: .color)
try container.encodeIfPresent(declawed, forKey: .declawed)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ public struct CatAllOf: Codable, Hashable {
public init(declawed: Bool? = nil) {
self.declawed = declawed
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case declawed
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(declawed, forKey: .declawed)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ import Foundation
public struct Category: Codable, Hashable {

public var id: Int64?
public var name: String = "default-name"
public var name: String? = "default-name"

public init(id: Int64? = nil, name: String = "default-name") {
public init(id: Int64? = nil, name: String? = "default-name") {
self.id = id
self.name = name
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case id
case name
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(id, forKey: .id)
try container.encode(name, forKey: .name)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,17 @@ public struct ClassModel: Codable, Hashable {
public init(_class: String? = nil) {
self._class = _class
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case _class
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(_class, forKey: ._class)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ public struct Client: Codable, Hashable {
public init(client: String? = nil) {
self.client = client
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case client
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(client, forKey: .client)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,21 @@ public struct Dog: Codable, Hashable {
self.color = color
self.breed = breed
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case className
case color
case breed
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(className, forKey: .className)
try container.encodeIfPresent(color, forKey: .color)
try container.encodeIfPresent(breed, forKey: .breed)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ public struct DogAllOf: Codable, Hashable {
public init(breed: String? = nil) {
self.breed = breed
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case breed
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(breed, forKey: .breed)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ public struct EnumArrays: Codable, Hashable {
self.justSymbol = justSymbol
self.arrayEnum = arrayEnum
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case justSymbol = "just_symbol"
case arrayEnum = "array_enum"
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(justSymbol, forKey: .justSymbol)
try container.encodeIfPresent(arrayEnum, forKey: .arrayEnum)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public struct EnumTest: Codable, Hashable {
self.enumNumber = enumNumber
self.outerEnum = outerEnum
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case enumString = "enum_string"
case enumStringRequired = "enum_string_required"
Expand All @@ -49,4 +48,17 @@ public struct EnumTest: Codable, Hashable {
case outerEnum
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(enumString, forKey: .enumString)
try container.encode(enumStringRequired, forKey: .enumStringRequired)
try container.encodeIfPresent(enumInteger, forKey: .enumInteger)
try container.encodeIfPresent(enumNumber, forKey: .enumNumber)
try container.encodeIfPresent(outerEnum, forKey: .outerEnum)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@ public struct File: Codable, Hashable {
public init(sourceURI: String? = nil) {
self.sourceURI = sourceURI
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case sourceURI
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(sourceURI, forKey: .sourceURI)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,19 @@ public struct FileSchemaTestClass: Codable, Hashable {
self.file = file
self.files = files
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case file
case files
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(file, forKey: .file)
try container.encodeIfPresent(files, forKey: .files)
}



}
Loading

0 comments on commit 86a6047

Please sign in to comment.