@@ -184,7 +184,6 @@ enum FunctionCallingMode {
184
184
/// Represents a select subset of an
185
185
/// [OpenAPI 3.0 schema object] (https://spec.openapis.org/oas/v3.0.3#schema).
186
186
final class Schema {
187
- // TODO: Add named constructors for the types?
188
187
/// Constructor
189
188
Schema (
190
189
this .type, {
@@ -197,6 +196,93 @@ final class Schema {
197
196
this .requiredProperties,
198
197
});
199
198
199
+ /// Construct a schema for an object with one or more properties.
200
+ Schema .object ({
201
+ required Map <String , Schema > properties,
202
+ List <String >? requiredProperties,
203
+ String ? description,
204
+ bool ? nullable,
205
+ }) : this (
206
+ SchemaType .object,
207
+ properties: properties,
208
+ requiredProperties: requiredProperties,
209
+ description: description,
210
+ nullable: nullable,
211
+ );
212
+
213
+ /// Construct a schema for an array of values with a specified type.
214
+ Schema .array ({
215
+ required Schema items,
216
+ String ? description,
217
+ bool ? nullable,
218
+ }) : this (
219
+ SchemaType .array,
220
+ description: description,
221
+ nullable: nullable,
222
+ items: items,
223
+ );
224
+
225
+ /// Construct a schema for bool value.
226
+ Schema .boolean ({
227
+ String ? description,
228
+ bool ? nullable,
229
+ }) : this (
230
+ SchemaType .boolean,
231
+ description: description,
232
+ nullable: nullable,
233
+ );
234
+
235
+ /// Construct a schema for an integer number.
236
+ ///
237
+ /// The [format] may be "int32" or "int64".
238
+ Schema .integer ({
239
+ String ? description,
240
+ bool ? nullable,
241
+ String ? format,
242
+ }) : this (
243
+ SchemaType .integer,
244
+ description: description,
245
+ nullable: nullable,
246
+ format: format,
247
+ );
248
+
249
+ /// Construct a schema for a non-integer number.
250
+ ///
251
+ /// The [format] may be "float" or "double".
252
+ Schema .number ({
253
+ String ? description,
254
+ bool ? nullable,
255
+ String ? format,
256
+ }) : this (
257
+ SchemaType .number,
258
+ description: description,
259
+ nullable: nullable,
260
+ format: format,
261
+ );
262
+
263
+ /// Construct a schema for String value with enumerated possible values.
264
+ Schema .enumString ({
265
+ required List <String > enumValues,
266
+ String ? description,
267
+ bool ? nullable,
268
+ }) : this (
269
+ SchemaType .string,
270
+ enumValues: enumValues,
271
+ description: description,
272
+ nullable: nullable,
273
+ format: 'enum' ,
274
+ );
275
+
276
+ /// Construct a schema for a String value.
277
+ Schema .string ({
278
+ String ? description,
279
+ bool ? nullable,
280
+ }) : this (
281
+ SchemaType .string,
282
+ description: description,
283
+ nullable: nullable,
284
+ );
285
+
200
286
/// The type of this value.
201
287
SchemaType type;
202
288
0 commit comments