diff --git a/JSONAPI.playground/Pages/OpenAPI Documentation.xcplaygroundpage/Contents.swift b/JSONAPI.playground/Pages/OpenAPI Documentation.xcplaygroundpage/Contents.swift deleted file mode 100644 index 597375b..0000000 --- a/JSONAPI.playground/Pages/OpenAPI Documentation.xcplaygroundpage/Contents.swift +++ /dev/null @@ -1,46 +0,0 @@ -//: [Previous](@previous) - -import Foundation -import JSONAPI -import JSONAPIOpenAPI -import Poly - -// print Entity Schema -let encoder = JSONEncoder() -encoder.outputFormatting = .prettyPrinted - -let personSchemaData = try? encoder.encode(Person.openAPINode(using: encoder)) - -print("Person Schema") -print("====") -print(personSchemaData.map { String(data: $0, encoding: .utf8)! } ?? "Schema Construction Failed") -print("====") - -let dogDocumentSchemaData = try? encoder.encode(SingleDogDocument.openAPINodeWithExample(using: encoder)) - -print("Dog Document Schema") -print("====") -print(dogDocumentSchemaData.map { String(data: $0, encoding: .utf8)! } ?? "Schema Construction Failed") -print("====") - -let batchPersonSchemaData = try? encoder.encode(BatchPeopleDocument.openAPINodeWithExample(using: encoder)) - -print("Batch Person Document Schema") -print("====") -print(batchPersonSchemaData.map { String(data: $0, encoding: .utf8)! } ?? "Schema Construction Failed") -print("====") - -let tmp: [String: JSONNode] = [ - "BatchPerson": try! BatchPeopleDocument.openAPINodeWithExample(using: encoder) -] - -let components = OpenAPIComponents(schemas: tmp, parameters: [:]) - -let batchPeopleRef = JSONReference.node(.init(type: \OpenAPIComponents.schemas, selector: "BatchPerson")) - -let tmp2 = JSONNode.reference(batchPeopleRef) - -print("====") -print("====") -//print(String(data: try! encoder.encode(components), encoding: .utf8)!) -print(String(data: try! encoder.encode(tmp2), encoding: .utf8)!) diff --git a/JSONAPI.playground/Sources/OpenAPISupport.swift b/JSONAPI.playground/Sources/OpenAPISupport.swift deleted file mode 100644 index ff2471a..0000000 --- a/JSONAPI.playground/Sources/OpenAPISupport.swift +++ /dev/null @@ -1,71 +0,0 @@ -import Foundation -import JSONAPI -import JSONAPITesting // for the convenience of literal initialization -import JSONAPIOpenAPI -import SwiftCheck -import JSONAPIArbitrary - -extension PersonDescription.Attributes: Arbitrary, Sampleable { - public static var arbitrary: Gen { - return Gen.compose { c in - return PersonDescription.Attributes(name: c.generate(), - favoriteColor: c.generate()) - } - } - - public static var sample: PersonDescription.Attributes { - return .init(name: ["Abbie", "Eibba"], favoriteColor: "Blue") - } -} - -extension PersonDescription.Relationships: Arbitrary, Sampleable { - public static var arbitrary: Gen { - return Gen.compose { c in - return PersonDescription.Relationships(friends: c.generate(), - dogs: c.generate(), - home: c.generate()) - } - } - - public static var sample: PersonDescription.Relationships { - return .init(friends: ["1", "2"], dogs: ["2"], home: "1") - } -} - -extension DogDescription.Attributes: Arbitrary, Sampleable { - public static var arbitrary: Gen { - return Gen.compose { c in - return DogDescription.Attributes(name: c.generate()) - } - } - - public static var sample: DogDescription.Attributes { - return DogDescription.Attributes.arbitrary.generate - } -} - -extension DogDescription.Relationships: Arbitrary, Sampleable { - public static var arbitrary: Gen { - return Gen.compose { c in - return DogDescription.Relationships(owner: c.generate()) - } - } - - public static var sample: DogDescription.Relationships { - return DogDescription.Relationships.arbitrary.generate - } -} - -extension Document: Sampleable where PrimaryResourceBody: Arbitrary, IncludeType: Arbitrary, MetaType: Arbitrary, LinksType: Arbitrary, Error: Arbitrary, APIDescription: Arbitrary { - public static var sample: Document { - return Document.arbitrary.generate - } - - public static var successSample: Document? { - return Document.arbitraryData.generate - } - - public static var failureSample: Document? { - return Document.arbitraryErrors.generate - } -}