@@ -124,9 +124,58 @@ extension SymbolGraph.Symbol {
124
124
public init ( _ value: ValueType ) {
125
125
self . value = value
126
126
}
127
+
128
+ // Need custom init(from:) to special case `null` value.
129
+ public init ( from decoder: Decoder ) throws {
130
+ let container = try decoder. singleValueContainer ( )
131
+ if container. decodeNil ( ) {
132
+ self . init ( . null)
133
+ return
134
+ }
135
+ self . init ( try container. decode ( ValueType . self) )
136
+ }
127
137
}
128
138
129
139
public var defaultValue : SymbolGraph . AnyScalar ? {
130
140
( mixins [ DefaultValue . mixinKey] as? DefaultValue ) ? . value
131
141
}
142
+
143
+ /// A detailed description of the set of types allowed for a parameter or key.
144
+ ///
145
+ /// Weakly-typed data structures, such as JSON, can allow a field to hold a value from a set of types,
146
+ /// rather than being of a singular fixed type.
147
+ /// For example, a time could be specified as an integer number of seconds from an epoch (eg, 1234)
148
+ /// or a time stamp string ("12:34pm"). A client can detect the different types and interpret them accordingly.
149
+ /// Whereas ``DeclarationFragments`` represents the declaration of the whole entity,
150
+ /// each ``TypeDetail`` member provides information, including the declaration, about the individual allowed types.
151
+ public struct TypeDetails : SingleValueMixin {
152
+ public static let mixinKey = " typeDetails "
153
+ public typealias ValueType = [ TypeDetail ]
154
+ public var value : ValueType
155
+ public init ( _ value: ValueType ) {
156
+ self . value = value
157
+ }
158
+ }
159
+
160
+ public var typeDetails : [ TypeDetail ] ? {
161
+ ( mixins [ TypeDetails . mixinKey] as? TypeDetails ) ? . value
162
+ }
163
+
164
+ /// Detailed description of one of the types allowed for a weakly-typed parameter or key.
165
+ public struct TypeDetail : Codable {
166
+ /// The declaration of this individual type.
167
+ public var fragments : [ DeclarationFragments . Fragment ] ?
168
+
169
+ /// The primitive type of this type, such as "string", "integer", or "dictionary".
170
+ public var baseType : String ?
171
+
172
+ /// Whether the value for this type is actually an array of values.
173
+ public var arrayMode : Bool ?
174
+
175
+ public init ( fragments: [ DeclarationFragments . Fragment ] ? = nil , baseType: String ? = nil , arrayMode: Bool ? = nil ) {
176
+ self . fragments = fragments
177
+ self . baseType = baseType
178
+ self . arrayMode = arrayMode
179
+ }
180
+ }
132
181
}
0 commit comments