Skip to content

Commit

Permalink
bump short circuit code into better positioning.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed Apr 6, 2020
1 parent 6c7cf1e commit 952af87
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/OpenAPIReflection/Sampleable+OpenAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import OpenAPIKit

extension Sampleable where Self: Encodable {
public static func genericOpenAPISchemaGuess(using encoder: JSONEncoder) throws -> JSONSchema {
// short circuit for dates
if let dateType = self as? Date.Type,
let node = try dateType.dateOpenAPISchemaGuess(using: encoder) ?? reencodedSchemaGuess(for: Self.sample, using: encoder) {
return node
}

return try OpenAPIReflection.genericOpenAPISchemaGuess(for: Self.sample, using: encoder)
}
}

public func genericOpenAPISchemaGuess<T>(for value: T, using encoder: JSONEncoder) throws -> JSONSchema {
// short circuit for dates
if let date = value as? Date,
let node = try type(of: date).dateOpenAPISchemaGuess(using: encoder) ?? reencodedSchemaGuess(for: date, using: encoder) {
return node
}

let mirror = Mirror(reflecting: value)
let properties: [(String, JSONSchema)] = try mirror.children.compactMap { child in

Expand Down

0 comments on commit 952af87

Please sign in to comment.