Skip to content

JSONSchema_ObjectContext

mattpolzin edited this page Jun 11, 2021 · 5 revisions

JSONSchema.ObjectContext

The context that only applies to .object schemas.

public struct ObjectContext: Equatable 

Inheritance

Decodable, Encodable, Equatable

Initializers

init(properties:additionalProperties:maxProperties:minProperties:)

public init(
            properties: [String: JSONSchema],
            additionalProperties: Either<Bool, JSONSchema>? = nil,
            maxProperties: Int? = nil,
            minProperties: Int? = nil
        ) 

init(from:)

public init(from decoder: Decoder) throws 

Properties

maxProperties

The maximum number of properties the object is allowed to have.

public let maxProperties: Int?

properties

public let properties: [String: JSONSchema]

additionalProperties

Either a boolean or a schema defining or allowing additional properties on this object.

public let additionalProperties: Either<Bool, JSONSchema>?

A value of false means that only properties listed in the properties dictionary may be defined on this object.

A value of true means that properties not named in the properties dictionary are allowed.

A JSONSchema value means that additional properties not listed in the properties dictionary are allowed but must match the given schema.

A nil value is treated like a true value but allows you to omit the property from encoding.

requiredProperties

The properties of this object that are required.

public var requiredProperties: [String] 

optionalProperties

The properties of this object that are optional.

public var optionalProperties: [String] 

minProperties

The minimum number of properties allowed.

public var minProperties: Int 

This might constradict a value explicitly specified on initialization or when decoding if the number of required properties is greater than the explicitly set minimum.

Methods

encode(to:)

public func encode(to encoder: Encoder) throws 
Types
Protocols
Global Functions
Extensions
Clone this wiki locally