Add JSON Reference and OpenAPIComponents (initially just with schemas)

This commit is contained in:
Mathew Polzin
2019-01-22 16:08:47 -08:00
parent e3c637a41e
commit 59835fbe11
3 changed files with 113 additions and 7 deletions
@@ -3,6 +3,7 @@
import Foundation
import JSONAPI
import JSONAPIOpenAPI
import Poly
// print Entity Schema
let encoder = JSONEncoder()
@@ -28,3 +29,18 @@ print("Batch Person Document Schema")
print("====")
print(batchPersonSchemaData.map { String(data: $0, encoding: .utf8)! } ?? "Schema Construction Failed")
print("====")
let tmp: [String: OpenAPIComponents.SchemasDict.RefType] = [
"BatchPerson": try! BatchPeopleDocument.openAPINodeWithExample()
]
let components = OpenAPIComponents(schemas: tmp)
let batchPeopleRef = JSONReference(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)!)