-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(specs): built-in ops accept also int (generated)
algolia/api-clients-automation#3450 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Kai Welke <kai.welke@algolia.com> Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
- Loading branch information
1 parent
438e077
commit 2156ac0
Showing
2 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on | ||
// https://github.com/algolia/api-clients-automation. DO NOT EDIT. | ||
|
||
import Foundation | ||
#if canImport(Core) | ||
import Core | ||
#endif | ||
|
||
public enum BuiltInOperationValue: Codable, JSONEncodable, AbstractEncodable { | ||
case string(String) | ||
case int(Int) | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.singleValueContainer() | ||
switch self { | ||
case let .string(value): | ||
try container.encode(value) | ||
case let .int(value): | ||
try container.encode(value) | ||
} | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
if let value = try? container.decode(String.self) { | ||
self = .string(value) | ||
} else if let value = try? container.decode(Int.self) { | ||
self = .int(value) | ||
} else { | ||
throw DecodingError.typeMismatch( | ||
Self.Type.self, | ||
.init( | ||
codingPath: decoder.codingPath, | ||
debugDescription: "Unable to decode instance of BuiltInOperationValue" | ||
) | ||
) | ||
} | ||
} | ||
|
||
public func GetActualInstance() -> Encodable { | ||
switch self { | ||
case let .string(value): | ||
value as String | ||
case let .int(value): | ||
value as Int | ||
} | ||
} | ||
} | ||
|
||
extension BuiltInOperationValue: Equatable {} | ||
extension BuiltInOperationValue: Hashable {} |