Skip to content

Commit 1e14888

Browse files
author
Anthony Oliveri
committed
feat(AssistantV1): Add additionalProperties property to InputData
1 parent 4a6b615 commit 1e14888

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Source/AssistantV1/Models/InputData.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
**/
1616

1717
import Foundation
18+
import RestKit
1819

1920
/**
2021
An input object that includes the input text.
@@ -27,9 +28,13 @@ public struct InputData: Codable, Equatable {
2728
*/
2829
public var text: String
2930

31+
/// Additional properties associated with this model.
32+
public var additionalProperties: [String: JSON]
33+
3034
// Map each property name to the key that shall be used for encoding/decoding.
3135
private enum CodingKeys: String, CodingKey {
3236
case text = "text"
37+
static let allValues = [text]
3338
}
3439

3540
/**
@@ -41,10 +46,26 @@ public struct InputData: Codable, Equatable {
4146
- returns: An initialized `InputData`.
4247
*/
4348
public init(
44-
text: String
49+
text: String,
50+
additionalProperties: [String: JSON] = [:]
4551
)
4652
{
4753
self.text = text
54+
self.additionalProperties = additionalProperties
55+
}
56+
57+
public init(from decoder: Decoder) throws {
58+
let container = try decoder.container(keyedBy: CodingKeys.self)
59+
text = try container.decode(String.self, forKey: .text)
60+
let dynamicContainer = try decoder.container(keyedBy: DynamicKeys.self)
61+
additionalProperties = try dynamicContainer.decode([String: JSON].self, excluding: CodingKeys.allValues)
62+
}
63+
64+
public func encode(to encoder: Encoder) throws {
65+
var container = encoder.container(keyedBy: CodingKeys.self)
66+
try container.encode(text, forKey: .text)
67+
var dynamicContainer = encoder.container(keyedBy: DynamicKeys.self)
68+
try dynamicContainer.encodeIfPresent(additionalProperties)
4869
}
4970

5071
}

0 commit comments

Comments
 (0)