@@ -167,19 +167,21 @@ public final class Schema: Sendable {
167167 /// - Parameters:
168168 /// - description: An optional description of what the string should contain or represent; may
169169 /// use Markdown format.
170+ /// - title: An optional human-readable name/summary for the schema.
170171 /// - nullable: If `true`, instructs the model that it *may* generate `null` instead of a
171172 /// string; defaults to `false`, enforcing that a string value is generated.
172173 /// - format: An optional modifier describing the expected format of the string. Currently no
173174 /// formats are officially supported for strings but custom values may be specified using
174175 /// ``StringFormat/custom(_:)``, for example `.custom("email")` or `.custom("byte")`; these
175176 /// provide additional hints for how the model should respond but are not guaranteed to be
176177 /// adhered to.
177- public static func string( description: String ? = nil , nullable : Bool = false ,
178- format: StringFormat ? = nil ) -> Schema {
178+ public static func string( description: String ? = nil , title : String ? = nil ,
179+ nullable : Bool = false , format: StringFormat ? = nil ) -> Schema {
179180 return self . init (
180181 type: . string,
181182 format: format? . rawValue,
182183 description: description,
184+ title: title,
183185 nullable: nullable
184186 )
185187 }
@@ -202,15 +204,17 @@ public final class Schema: Sendable {
202204 /// - values: The list of string values that may be generated by the model.
203205 /// - description: An optional description of what the `values` contain or represent; may use
204206 /// Markdown format.
207+ /// - title: An optional human-readable name/summary for the schema.
205208 /// - nullable: If `true`, instructs the model that it *may* generate `null` instead of one of
206209 /// the strings specified in `values`; defaults to `false`, enforcing that one of the string
207210 /// values is generated.
208211 public static func enumeration( values: [ String ] , description: String ? = nil ,
209- nullable: Bool = false ) -> Schema {
212+ title : String ? = nil , nullable: Bool = false ) -> Schema {
210213 return self . init (
211214 type: . string,
212215 format: " enum " ,
213216 description: description,
217+ title: title,
214218 nullable: nullable,
215219 enumValues: values
216220 )
@@ -229,18 +233,20 @@ public final class Schema: Sendable {
229233 /// - Parameters:
230234 /// - description: An optional description of what the number should contain or represent; may
231235 /// use Markdown format.
236+ /// - title: An optional human-readable name/summary for the schema.
232237 /// - nullable: If `true`, instructs the model that it may generate `null` instead of a number;
233238 /// defaults to `false`, enforcing that a number is generated.
234239 /// - minimum: If specified, instructs the model that the value should be greater than or
235240 /// equal to the specified minimum.
236241 /// - maximum: If specified, instructs the model that the value should be less than or equal
237242 /// to the specified maximum.
238- public static func float( description: String ? = nil , nullable: Bool = false ,
243+ public static func float( description: String ? = nil , title : String ? = nil , nullable: Bool = false ,
239244 minimum: Float ? = nil , maximum: Float ? = nil ) -> Schema {
240245 return self . init (
241246 type: . number,
242247 format: " float " ,
243248 description: description,
249+ title: title,
244250 nullable: nullable,
245251 minimum: minimum. map { Double ( $0) } ,
246252 maximum: maximum. map { Double ( $0) }
@@ -255,17 +261,20 @@ public final class Schema: Sendable {
255261 /// - Parameters:
256262 /// - description: An optional description of what the number should contain or represent; may
257263 /// use Markdown format.
264+ /// - title: An optional human-readable name/summary for the schema.
258265 /// - nullable: If `true`, instructs the model that it may return `null` instead of a number;
259266 /// defaults to `false`, enforcing that a number is returned.
260267 /// - minimum: If specified, instructs the model that the value should be greater than or
261268 /// equal to the specified minimum.
262269 /// - maximum: If specified, instructs the model that the value should be less than or equal
263270 /// to the specified maximum.
264- public static func double( description: String ? = nil , nullable: Bool = false ,
271+ public static func double( description: String ? = nil , title: String ? = nil ,
272+ nullable: Bool = false ,
265273 minimum: Double ? = nil , maximum: Double ? = nil ) -> Schema {
266274 return self . init (
267275 type: . number,
268276 description: description,
277+ title: title,
269278 nullable: nullable,
270279 minimum: minimum,
271280 maximum: maximum
@@ -287,6 +296,7 @@ public final class Schema: Sendable {
287296 /// - Parameters:
288297 /// - description: An optional description of what the integer should contain or represent; may
289298 /// use Markdown format.
299+ /// - title: An optional human-readable name/summary for the schema.
290300 /// - nullable: If `true`, instructs the model that it may return `null` instead of an integer;
291301 /// defaults to `false`, enforcing that an integer is returned.
292302 /// - format: An optional modifier describing the expected format of the integer. Currently the
@@ -296,13 +306,14 @@ public final class Schema: Sendable {
296306 /// equal to the specified minimum.
297307 /// - maximum: If specified, instructs the model that the value should be less than or equal
298308 /// to the specified maximum.
299- public static func integer( description: String ? = nil , nullable : Bool = false ,
300- format: IntegerFormat ? = nil ,
309+ public static func integer( description: String ? = nil , title : String ? = nil ,
310+ nullable : Bool = false , format: IntegerFormat ? = nil ,
301311 minimum: Int ? = nil , maximum: Int ? = nil ) -> Schema {
302312 return self . init (
303313 type: . integer,
304314 format: format? . rawValue,
305315 description: description,
316+ title: title,
306317 nullable: nullable. self,
307318 minimum: minimum. map { Double ( $0) } ,
308319 maximum: maximum. map { Double ( $0) }
@@ -317,10 +328,12 @@ public final class Schema: Sendable {
317328 /// - Parameters:
318329 /// - description: An optional description of what the boolean should contain or represent; may
319330 /// use Markdown format.
331+ /// - title: An optional human-readable name/summary for the schema.
320332 /// - nullable: If `true`, instructs the model that it may return `null` instead of a boolean;
321333 /// defaults to `false`, enforcing that a boolean is returned.
322- public static func boolean( description: String ? = nil , nullable: Bool = false ) -> Schema {
323- return self . init ( type: . boolean, description: description, nullable: nullable)
334+ public static func boolean( description: String ? = nil , title: String ? = nil ,
335+ nullable: Bool = false ) -> Schema {
336+ return self . init ( type: . boolean, description: description, title: title, nullable: nullable)
324337 }
325338
326339 /// Returns a `Schema` representing an array.
@@ -334,17 +347,20 @@ public final class Schema: Sendable {
334347 /// - items: The `Schema` of the elements that the array will hold.
335348 /// - description: An optional description of what the array should contain or represent; may
336349 /// use Markdown format.
350+ /// - title: An optional human-readable name/summary for the schema.
337351 /// - nullable: If `true`, instructs the model that it may return `null` instead of an array;
338352 /// defaults to `false`, enforcing that an array is returned.
339353 /// - minItems: Instructs the model to produce at least the specified minimum number of elements
340354 /// in the array; defaults to `nil`, meaning any number.
341355 /// - maxItems: Instructs the model to produce at most the specified maximum number of elements
342356 /// in the array.
343- public static func array( items: Schema , description: String ? = nil , nullable: Bool = false ,
344- minItems: Int ? = nil , maxItems: Int ? = nil ) -> Schema {
357+ public static func array( items: Schema , description: String ? = nil , title: String ? = nil ,
358+ nullable: Bool = false , minItems: Int ? = nil ,
359+ maxItems: Int ? = nil ) -> Schema {
345360 return self . init (
346361 type: . array,
347362 description: description,
363+ title: title,
348364 nullable: nullable,
349365 items: items,
350366 minItems: minItems,
@@ -384,7 +400,7 @@ public final class Schema: Sendable {
384400 /// generated JSON string. See ``propertyOrdering`` for details.
385401 /// - description: An optional description of what the object should contain or represent; may
386402 /// use Markdown format.
387- /// - title: An optional human-readable name/summary for the object schema.
403+ /// - title: An optional human-readable name/summary for the schema.
388404 /// - nullable: If `true`, instructs the model that it may return `null` instead of an object;
389405 /// defaults to `false`, enforcing that an object is returned.
390406 public static func object( properties: [ String : Schema ] , optionalProperties: [ String ] = [ ] ,
0 commit comments