bignerdranch / Freddy

A reusable framework for parsing JSON in Swift.
MIT License
1.09k stars 120 forks source link

Update documentation #240

Closed mdmathias closed 6 years ago

mdmathias commented 7 years ago

The documentation needs to be updated. For example, there are references to errors that have been renamed.

    /// Retrieves an `Int` from a path into JSON or a fallback if not found.
    /// - parameter path: 0 or more `String` or `Int` that subscript the `JSON`
    /// - parameter fallback: `Int` to use when one is missing at the subscript.
    /// - returns: A numeric `Int`
    /// - throws: One of the following errors contained in `JSON.Error`:
    ///   * `KeyNotFound`: A key `path` does not exist inside a descendant
    ///     `JSON` dictionary.
    ///   * `IndexOutOfBounds`: An index `path` is outside the bounds of a
    ///     descendant `JSON` array.
    ///   * `UnexpectedSubscript`: A `path` item cannot be used with the
    ///     corresponding `JSON` value.
    ///   * `TypeNotConvertible`: The target value's type inside of the `JSON`
    ///     instance does not match the decoded value.
    public func getInt(at path: JSONPathType..., or fallback: @autoclosure() -> Int) throws -> Int {
        return try mapOptional(at: path, fallback: fallback, transform: Int.init)
    }

The errors need to be lowercased, and .TypeNotConvertible is now .valueNotConvertible.