mirror of
https://github.com/encounter/JSONAPI.git
synced 2026-03-30 11:18:38 -07:00
Add subscript access to Poly types. Add empty test class for Poly type. Remove unneeded Foundation import. Small README change to read more clearly.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# JSONAPI
|
||||
[](http://opensource.org/licenses/MIT) [](https://swift.org) [](https://app.bitrise.io/app/c8295b9589aa401e)
|
||||
|
||||
A Swift package for encoding and decoding to *JSON API* compliant requests and responses.
|
||||
A Swift package for encoding to- and decoding from *JSON API* compliant requests and responses.
|
||||
|
||||
See the JSON API Spec here: https://jsonapi.org/format/
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ public protocol _Poly1: _Poly0 {
|
||||
|
||||
init(_ a: A)
|
||||
}
|
||||
|
||||
public extension _Poly1 {
|
||||
subscript(_ lookup: A.Type) -> A? {
|
||||
return a
|
||||
}
|
||||
}
|
||||
|
||||
public enum Poly1<A: EntityType>: _Poly1 {
|
||||
case a(A)
|
||||
|
||||
@@ -101,6 +108,13 @@ public protocol _Poly2: _Poly1 {
|
||||
|
||||
init(_ b: B)
|
||||
}
|
||||
|
||||
public extension _Poly2 {
|
||||
subscript(_ lookup: B.Type) -> B? {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
public enum Poly2<A: EntityType, B: EntityType>: _Poly2 {
|
||||
case a(A)
|
||||
case b(B)
|
||||
@@ -173,6 +187,13 @@ public protocol _Poly3: _Poly2 {
|
||||
|
||||
init(_ c: C)
|
||||
}
|
||||
|
||||
public extension _Poly3 {
|
||||
subscript(_ lookup: C.Type) -> C? {
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
public enum Poly3<A: EntityType, B: EntityType, C: EntityType>: _Poly3 {
|
||||
case a(A)
|
||||
case b(B)
|
||||
@@ -260,6 +281,13 @@ public protocol _Poly4: _Poly3 {
|
||||
|
||||
init(_ d: D)
|
||||
}
|
||||
|
||||
public extension _Poly4 {
|
||||
subscript(_ lookup: D.Type) -> D? {
|
||||
return d
|
||||
}
|
||||
}
|
||||
|
||||
public enum Poly4<A: EntityType, B: EntityType, C: EntityType, D: EntityType>: _Poly4 {
|
||||
case a(A)
|
||||
case b(B)
|
||||
@@ -362,6 +390,13 @@ public protocol _Poly5: _Poly4 {
|
||||
|
||||
init(_ e: E)
|
||||
}
|
||||
|
||||
public extension _Poly5 {
|
||||
subscript(_ lookup: E.Type) -> E? {
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
public enum Poly5<A: EntityType, B: EntityType, C: EntityType, D: EntityType, E: EntityType>: _Poly5 {
|
||||
case a(A)
|
||||
case b(B)
|
||||
@@ -479,6 +514,13 @@ public protocol _Poly6: _Poly5 {
|
||||
|
||||
init(_ f: F)
|
||||
}
|
||||
|
||||
public extension _Poly6 {
|
||||
subscript(_ lookup: F.Type) -> F? {
|
||||
return f
|
||||
}
|
||||
}
|
||||
|
||||
public enum Poly6<A: EntityType, B: EntityType, C: EntityType, D: EntityType, E: EntityType, F: EntityType>: _Poly6 {
|
||||
case a(A)
|
||||
case b(B)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// PolyTests.swift
|
||||
// JSONAPITests
|
||||
//
|
||||
// Created by Mathew Polzin on 11/23/18.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import JSONAPI
|
||||
|
||||
class PolyTests: XCTestCase {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//
|
||||
// PolyStubs.swift
|
||||
// JSONAPITests
|
||||
//
|
||||
// Created by Mathew Polzin on 11/23/18.
|
||||
//
|
||||
@@ -5,7 +5,6 @@
|
||||
// Created by Mathew Polzin on 11/15/18.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import JSONAPI
|
||||
|
||||
public typealias Entity<Description: JSONAPI.EntityDescription> = JSONAPI.Entity<Description, Id<String, Description>>
|
||||
|
||||
Reference in New Issue
Block a user