@@ -3,70 +3,68 @@ import JSONAPI
33import JSONAPITesting // for the convenience of literal initialization
44import JSONAPIOpenAPI
55import SwiftCheck
6- import JSONAPIArbitrary
76import Sampleable
87
9- extension PersonDescription . Attributes : Arbitrary , Sampleable {
10- public static var arbitrary : Gen < PersonDescription . Attributes > {
11- return Gen . compose { c in
12- return PersonDescription . Attributes ( name: c. generate ( ) ,
13- favoriteColor: c. generate ( ) )
14- }
15- }
16-
8+ extension PersonDescription . Attributes : Sampleable {
179 public static var sample : PersonDescription . Attributes {
1810 return . init( name: [ " Abbie " , " Eibba " ] , favoriteColor: " Blue " )
1911 }
2012}
2113
22- extension PersonDescription . Relationships : Arbitrary , Sampleable {
23- public static var arbitrary : Gen < PersonDescription . Relationships > {
24- return Gen . compose { c in
25- return PersonDescription . Relationships ( friends: c. generate ( ) ,
26- dogs: c. generate ( ) ,
27- home: c. generate ( ) )
28- }
29- }
30-
14+ extension PersonDescription . Relationships : Sampleable {
3115 public static var sample : PersonDescription . Relationships {
3216 return . init( friends: [ " 1 " , " 2 " ] , dogs: [ " 2 " ] , home: " 1 " )
3317 }
3418}
3519
36- extension DogDescription . Attributes : Arbitrary , Sampleable {
37- public static var arbitrary : Gen < DogDescription . Attributes > {
38- return Gen . compose { c in
39- return DogDescription . Attributes ( name: c. generate ( ) )
40- }
41- }
42-
20+ extension DogDescription . Attributes : Sampleable {
4321 public static var sample : DogDescription . Attributes {
4422 return DogDescription . Attributes ( name: " Sparky " )
4523 }
4624}
4725
48- extension DogDescription . Relationships : Arbitrary , Sampleable {
49- public static var arbitrary : Gen < DogDescription . Relationships > {
50- return Gen . compose { c in
51- return DogDescription . Relationships ( owner: c. generate ( ) )
52- }
53- }
54-
26+ extension DogDescription . Relationships : Sampleable {
5527 public static var sample : DogDescription . Relationships {
5628 return DogDescription . Relationships ( owner: " 1 " )
5729 }
5830}
5931
60- extension Document : Sampleable where PrimaryResourceBody: Arbitrary , IncludeType: Arbitrary , MetaType: Arbitrary , LinksType: Arbitrary , Error: Arbitrary , APIDescription: Arbitrary {
32+ private var counter = 1
33+ extension Id : Sampleable where RawType == String {
34+ public static var sample : Id < RawType , IdentifiableType > {
35+ let id = " \( counter) "
36+ counter = counter + 1
37+ return . init( rawValue: id)
38+ }
39+ }
40+
41+ extension JSONAPI . ResourceObject : Sampleable where Description. Attributes: Sampleable , Description. Relationships: Sampleable , MetaType: Sampleable , LinksType: Sampleable , EntityRawIdType == String {
42+ public static var sample : JSONAPI . ResourceObject < Description , MetaType , LinksType , EntityRawIdType > {
43+ return JSONAPI . ResourceObject ( id: . sample,
44+ attributes: . sample,
45+ relationships: . sample,
46+ meta: . sample,
47+ links: . sample)
48+ }
49+ }
50+
51+ extension Document : Sampleable where PrimaryResourceBody: Sampleable , IncludeType: Sampleable , MetaType: Sampleable , LinksType: Sampleable , Error: Sampleable , APIDescription: Sampleable {
6152 public static var sample : Document {
62- return Document . arbitrary . generate
53+ return successSample!
6354 }
6455
6556 public static var successSample : Document ? {
66- return Document . arbitraryData. generate
57+ return Document ( apiDescription: APIDescription . sample,
58+ body: PrimaryResourceBody . sample,
59+ includes: . init( values: IncludeType . samples) ,
60+ meta: MetaType . sample,
61+ links: LinksType . sample)
6762 }
6863
6964 public static var failureSample : Document ? {
70- return Document . arbitraryErrors. generate
65+ return Document ( apiDescription: APIDescription . sample,
66+ errors: Error . samples,
67+ meta: MetaType . sample,
68+ links: LinksType . sample)
7169 }
7270}
0 commit comments