BodyFormat

public struct BodyFormat : Equatable

A set of values representing the format of a response body.

This struct is intended to be “enum-like” and values should be accessed via the public static stored properties.

Note

An enum was not used here because currently enums are always exhaustive. This means adding a case to an enum is a breaking change. In order to keep such additions non-breaking we have used an “enum-like” struct instead. This means code using BodyFormat should always handle unrecognised BodyFormat values (eg in a default case of a switch). UnsupportedBodyFormatError may be used in this situation.

Usage Example:

let format = BodyFormat.json
  • A String value of the type that the body format will be represented in, which is used to ensure that both the left-hand side and the right-hand side are of the same type in the response body.

    Declaration

    Swift

    public let type: String
  • This function checks that both the left-hand side and the right-hand side of the response body are of the same type.

    Declaration

    Swift

    public static func == (lhs: BodyFormat, rhs: BodyFormat) -> Bool
  • The JSON representation of the response body.

    Declaration

    Swift

    public static let json: BodyFormat