mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
54 lines
1.9 KiB
Swift
54 lines
1.9 KiB
Swift
//
|
|
// Content.swift
|
|
//
|
|
// Generated by openapi-generator
|
|
// https://openapi-generator.tech
|
|
//
|
|
|
|
import Foundation
|
|
#if canImport(AnyCodable)
|
|
import AnyCodable
|
|
#endif
|
|
|
|
public enum Content: Codable, JSONEncodable, Hashable {
|
|
case typeRawAudioContent(RawAudioContent)
|
|
case typeRawEmbeddedResource(RawEmbeddedResource)
|
|
case typeRawImageContent(RawImageContent)
|
|
case typeRawResource(RawResource)
|
|
case typeRawTextContent(RawTextContent)
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.singleValueContainer()
|
|
switch self {
|
|
case .typeRawAudioContent(let value):
|
|
try container.encode(value)
|
|
case .typeRawEmbeddedResource(let value):
|
|
try container.encode(value)
|
|
case .typeRawImageContent(let value):
|
|
try container.encode(value)
|
|
case .typeRawResource(let value):
|
|
try container.encode(value)
|
|
case .typeRawTextContent(let value):
|
|
try container.encode(value)
|
|
}
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.singleValueContainer()
|
|
if let value = try? container.decode(RawAudioContent.self) {
|
|
self = .typeRawAudioContent(value)
|
|
} else if let value = try? container.decode(RawEmbeddedResource.self) {
|
|
self = .typeRawEmbeddedResource(value)
|
|
} else if let value = try? container.decode(RawImageContent.self) {
|
|
self = .typeRawImageContent(value)
|
|
} else if let value = try? container.decode(RawResource.self) {
|
|
self = .typeRawResource(value)
|
|
} else if let value = try? container.decode(RawTextContent.self) {
|
|
self = .typeRawTextContent(value)
|
|
} else {
|
|
throw DecodingError.typeMismatch(Self.Type.self, .init(codingPath: decoder.codingPath, debugDescription: "Unable to decode instance of Content"))
|
|
}
|
|
}
|
|
}
|
|
|