mirror of
https://github.com/encounter/JSONAPI.git
synced 2026-03-30 11:18:38 -07:00
Not crazy about how I got there, but now it is relatively easy to print arbitrary enum's allCases as the list of possible values in the format specced out by OpenAPI.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
// Created by Mathew Polzin on 01/13/19.
|
||||
//
|
||||
|
||||
import AnyCodable
|
||||
|
||||
/**
|
||||
|
||||
Notable omissions in this library's default offerings:
|
||||
@@ -41,9 +43,9 @@ extension Optional: RawOpenAPINodeType where Wrapped: RawRepresentable, Wrapped.
|
||||
}
|
||||
}
|
||||
|
||||
extension Optional: AnyJSONCaseIterable where Wrapped: CaseIterable {
|
||||
public static var allCases: [Any] {
|
||||
return Array(Wrapped.allCases)
|
||||
extension Optional: AnyJSONCaseIterable where Wrapped: CaseIterable, Wrapped: Codable {
|
||||
public static var allCases: [AnyCodable] {
|
||||
return (try? allCases(from: Array(Wrapped.allCases))) ?? []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user