@@ -167,19 +167,21 @@ public final class Schema: Sendable {
167
167
/// - Parameters:
168
168
/// - description: An optional description of what the string should contain or represent; may
169
169
/// use Markdown format.
170
+ /// - title: An optional human-readable name/summary for the schema.
170
171
/// - nullable: If `true`, instructs the model that it *may* generate `null` instead of a
171
172
/// string; defaults to `false`, enforcing that a string value is generated.
172
173
/// - format: An optional modifier describing the expected format of the string. Currently no
173
174
/// formats are officially supported for strings but custom values may be specified using
174
175
/// ``StringFormat/custom(_:)``, for example `.custom("email")` or `.custom("byte")`; these
175
176
/// provide additional hints for how the model should respond but are not guaranteed to be
176
177
/// 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 {
179
180
return self . init (
180
181
type: . string,
181
182
format: format? . rawValue,
182
183
description: description,
184
+ title: title,
183
185
nullable: nullable
184
186
)
185
187
}
@@ -202,15 +204,17 @@ public final class Schema: Sendable {
202
204
/// - values: The list of string values that may be generated by the model.
203
205
/// - description: An optional description of what the `values` contain or represent; may use
204
206
/// Markdown format.
207
+ /// - title: An optional human-readable name/summary for the schema.
205
208
/// - nullable: If `true`, instructs the model that it *may* generate `null` instead of one of
206
209
/// the strings specified in `values`; defaults to `false`, enforcing that one of the string
207
210
/// values is generated.
208
211
public static func enumeration( values: [ String ] , description: String ? = nil ,
209
- nullable: Bool = false ) -> Schema {
212
+ title : String ? = nil , nullable: Bool = false ) -> Schema {
210
213
return self . init (
211
214
type: . string,
212
215
format: " enum " ,
213
216
description: description,
217
+ title: title,
214
218
nullable: nullable,
215
219
enumValues: values
216
220
)
@@ -229,18 +233,20 @@ public final class Schema: Sendable {
229
233
/// - Parameters:
230
234
/// - description: An optional description of what the number should contain or represent; may
231
235
/// use Markdown format.
236
+ /// - title: An optional human-readable name/summary for the schema.
232
237
/// - nullable: If `true`, instructs the model that it may generate `null` instead of a number;
233
238
/// defaults to `false`, enforcing that a number is generated.
234
239
/// - minimum: If specified, instructs the model that the value should be greater than or
235
240
/// equal to the specified minimum.
236
241
/// - maximum: If specified, instructs the model that the value should be less than or equal
237
242
/// 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 ,
239
244
minimum: Float ? = nil , maximum: Float ? = nil ) -> Schema {
240
245
return self . init (
241
246
type: . number,
242
247
format: " float " ,
243
248
description: description,
249
+ title: title,
244
250
nullable: nullable,
245
251
minimum: minimum. map { Double ( $0) } ,
246
252
maximum: maximum. map { Double ( $0) }
@@ -255,17 +261,20 @@ public final class Schema: Sendable {
255
261
/// - Parameters:
256
262
/// - description: An optional description of what the number should contain or represent; may
257
263
/// use Markdown format.
264
+ /// - title: An optional human-readable name/summary for the schema.
258
265
/// - nullable: If `true`, instructs the model that it may return `null` instead of a number;
259
266
/// defaults to `false`, enforcing that a number is returned.
260
267
/// - minimum: If specified, instructs the model that the value should be greater than or
261
268
/// equal to the specified minimum.
262
269
/// - maximum: If specified, instructs the model that the value should be less than or equal
263
270
/// 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 ,
265
273
minimum: Double ? = nil , maximum: Double ? = nil ) -> Schema {
266
274
return self . init (
267
275
type: . number,
268
276
description: description,
277
+ title: title,
269
278
nullable: nullable,
270
279
minimum: minimum,
271
280
maximum: maximum
@@ -287,6 +296,7 @@ public final class Schema: Sendable {
287
296
/// - Parameters:
288
297
/// - description: An optional description of what the integer should contain or represent; may
289
298
/// use Markdown format.
299
+ /// - title: An optional human-readable name/summary for the schema.
290
300
/// - nullable: If `true`, instructs the model that it may return `null` instead of an integer;
291
301
/// defaults to `false`, enforcing that an integer is returned.
292
302
/// - format: An optional modifier describing the expected format of the integer. Currently the
@@ -296,13 +306,14 @@ public final class Schema: Sendable {
296
306
/// equal to the specified minimum.
297
307
/// - maximum: If specified, instructs the model that the value should be less than or equal
298
308
/// 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 ,
301
311
minimum: Int ? = nil , maximum: Int ? = nil ) -> Schema {
302
312
return self . init (
303
313
type: . integer,
304
314
format: format? . rawValue,
305
315
description: description,
316
+ title: title,
306
317
nullable: nullable. self,
307
318
minimum: minimum. map { Double ( $0) } ,
308
319
maximum: maximum. map { Double ( $0) }
@@ -317,10 +328,12 @@ public final class Schema: Sendable {
317
328
/// - Parameters:
318
329
/// - description: An optional description of what the boolean should contain or represent; may
319
330
/// use Markdown format.
331
+ /// - title: An optional human-readable name/summary for the schema.
320
332
/// - nullable: If `true`, instructs the model that it may return `null` instead of a boolean;
321
333
/// 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)
324
337
}
325
338
326
339
/// Returns a `Schema` representing an array.
@@ -334,17 +347,20 @@ public final class Schema: Sendable {
334
347
/// - items: The `Schema` of the elements that the array will hold.
335
348
/// - description: An optional description of what the array should contain or represent; may
336
349
/// use Markdown format.
350
+ /// - title: An optional human-readable name/summary for the schema.
337
351
/// - nullable: If `true`, instructs the model that it may return `null` instead of an array;
338
352
/// defaults to `false`, enforcing that an array is returned.
339
353
/// - minItems: Instructs the model to produce at least the specified minimum number of elements
340
354
/// in the array; defaults to `nil`, meaning any number.
341
355
/// - maxItems: Instructs the model to produce at most the specified maximum number of elements
342
356
/// 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 {
345
360
return self . init (
346
361
type: . array,
347
362
description: description,
363
+ title: title,
348
364
nullable: nullable,
349
365
items: items,
350
366
minItems: minItems,
@@ -384,7 +400,7 @@ public final class Schema: Sendable {
384
400
/// generated JSON string. See ``propertyOrdering`` for details.
385
401
/// - description: An optional description of what the object should contain or represent; may
386
402
/// 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.
388
404
/// - nullable: If `true`, instructs the model that it may return `null` instead of an object;
389
405
/// defaults to `false`, enforcing that an object is returned.
390
406
public static func object( properties: [ String : Schema ] , optionalProperties: [ String ] = [ ] ,
0 commit comments