Add todos for Entity Id and type. Add example usage of OpenAPI entity schema support in Playground

This commit is contained in:
Mathew Polzin
2019-01-20 16:10:31 -08:00
parent 531a7f35bd
commit 1ed34b00dc
5 changed files with 34 additions and 26 deletions
@@ -104,6 +104,7 @@ extension ToManyRelationship: OpenAPINodeType {
extension Entity: OpenAPINodeType where Description.Attributes: Sampleable, Description.Relationships: Sampleable {
public static func openAPINode() throws -> JSONNode {
// TODO: Id, type, metadata, links
let attributesNode: JSONNode? = Description.Attributes.self == NoAttributes.self
? nil
: try Description.Attributes.genericObjectOpenAPINode()
+1 -26
View File
@@ -49,32 +49,7 @@ extension Sampleable {
let newNode: JSONNode?
if let allCases = maybeAllCases,
let openAPINode = maybeOpenAPINode {
newNode = try openAPINode.with(allowedValues: allCases) // try {
// if let cases = allCases as? [JSONTypeFormat.BooleanFormat.SwiftType] {
// return try openAPINode.with(allowedValues: cases)
//
// } else if let cases = allCases as? [JSONTypeFormat.ArrayFormat.SwiftType] {
// return try openAPINode.with(allowedValues: cases)
//
// } else if let cases = allCases as? [JSONTypeFormat.ObjectFormat.SwiftType] {
// return try openAPINode.with(allowedValues: cases)
//
// } else if let cases = allCases as? [JSONTypeFormat.NumberFormat.SwiftType] {
// return try openAPINode.with(allowedValues: cases)
//
// } else if let cases = allCases as? [JSONTypeFormat.IntegerFormat.SwiftType] {
// return try openAPINode.with(allowedValues: cases)
//
// } else if let cases = allCases as? [JSONTypeFormat.StringFormat.SwiftType] {
// return try openAPINode.with(allowedValues: cases)
//
// } else if allCases.compactMap({ $0 as? RawStringRepresentable }).count == allCases.count {
// return try openAPINode.with(allowedValues: allCases.compactMap { ($0 as? RawStringRepresentable)?.rawValue })
//
// } else {
// throw SampleableError.allowedValuesNotOfExpectedType(forNode: openAPINode, allowedValues: allCases)
// }
// }()
newNode = try openAPINode.with(allowedValues: allCases)
} else {
newNode = maybeOpenAPINode
}