Add Arbitrary conformance for UnknownJSONAPIError. Fix weird encoding exception that I cannot quite figure out or explain at the moment.

This commit is contained in:
Mathew Polzin
2019-01-21 21:56:33 -08:00
parent d6911f170c
commit 95f9d8084d
7 changed files with 68 additions and 10 deletions
+7 -1
View File
@@ -267,7 +267,11 @@ public enum JSONNode: Equatable {
/// into an allowed value.
public let allowedValues: [AnyCodable]?
public let example: AnyCodable?
// I wanted example to be AnyCodable, but alas that causes
// runtime problems when encoding in a very strange way.
// For now, a String (which is OK by the OpenAPI spec) will
// have to do.
public let example: String?
public init(format: Format,
required: Bool,
@@ -279,6 +283,8 @@ public enum JSONNode: Equatable {
self.nullable = nullable
self.allowedValues = allowedValues
self.example = example
.flatMap { try? JSONEncoder().encode($0)}
.flatMap { String(data: $0, encoding: .utf8) }
}
/// Return the optional version of this Context