Schema class abstract
The Schema Object allows the definition of input and output data types for OpenAPI 2.0.
It describes the data type, format, constraints, and structure of properties, request bodies, and other parts of the OpenAPI specification.
- Available extensions
- Annotations
-
- @Freezed(copyWith: true, fromJson: true, toJson: false, equal: true)
Constructors
-
Schema.new({@JsonKey(name: r'$ref') String? ref, String? type, String? format, String? title, String? description, @JsonKey(name: 'required') List<
String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, @JsonKey(name: 'enum') List? enumValues, @JsonKey(name: 'default') dynamic $default, Xml? xml, @JsonKey(includeFromJson: false, includeToJson: false) dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, int? maxProperties, int? minProperties, num? multipleOf, @JsonKey(name: 'deprecated') bool? $deprecated, @JsonKey(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<String, dynamic> ? extensions}) -
Creates a Schema object.
constfactory
-
Schema.fromJson(Map<
String, dynamic> json) -
Creates a Schema from a JSON object.
factory
Properties
- $default → dynamic
-
The default value for the schema.
no setterinherited
- $deprecated → bool?
-
Declares this schema as deprecated.
no setterinherited
-
$required
→ List<
String> ? -
A list of properties that must be present in the object.
no setterinherited
- additionalProperties → dynamic
-
Specifies the schema for any additional properties in the object.
The value can be a boolean or a Schema object.
no setterinherited
-
allOf
→ List<
Schema> ? -
An array of schemas where the data must be valid against all of
the schemas.
no setterinherited
- allowEmptyValue → bool?
-
Sets the ability to pass empty-valued parameters.
no setterinherited
-
anyOf
→ List<
Schema> ? -
An array of schemas where the data must be valid against any of
the schemas.
no setterinherited
- collectionFormat → String?
-
Determines the format of the array if type array is used.
no setterinherited
-
copyWith
→ $SchemaCopyWith<
Schema> -
Create a copy of Schema
with the given fields replaced by the non-null parameter values.
no setterinherited
- description → String?
-
A brief description of the schema.
no setterinherited
- discriminator → Discriminator?
-
A Discriminator object for handling polymorphism.
no setterinherited
- enumValues → List?
-
A list of possible values for an enum.
no setterinherited
- example → dynamic
-
An example value for the schema.
no setterinherited
- exclusiveMaximum → num?
-
The exclusive maximum value for a number.
no setterinherited
- exclusiveMinimum → num?
-
The exclusive minimum value for a number.
no setterinherited
-
extensions
→ Map<
String, dynamic> ? -
Vendor extensions (keys like
x-*
).no setterinherited - externalDocs → ExternalDocs?
-
A URL to external documentation for this schema.
no setterinherited
- format → String?
-
The format of the data type (e.g., 'int32', 'date-time', 'email').
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- items → Schema?
-
For array types, this describes the type of items in the array.
no setterinherited
- maximum → num?
-
The maximum value for a number.
no setterinherited
- maxItems → int?
-
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.2.
no setterinherited
- maxLength → int?
-
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.1.
no setterinherited
- maxProperties → int?
-
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.1
no setterinherited
- minimum → num?
-
The minimum value for a number.
no setterinherited
- minItems → int?
-
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.3.
no setterinherited
- minLength → int?
-
integer See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.2.
no setterinherited
- minProperties → int?
-
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.2
no setterinherited
- multipleOf → num?
-
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.1.
no setterinherited
- not → Schema?
-
A schema where the data must not be valid against this schema.
no setterinherited
- nullable → bool?
-
A
true
value indicates that bothnull
values and values of the specifiedtype
are allowed.no setterinherited -
oneOf
→ List<
Schema> ? -
An array of schemas where the data must be valid against one of
the schemas.
no setterinherited
- pattern → String?
-
string See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3.
no setterinherited
-
properties
→ Map<
String, Schema> ? -
A map of property names to their respective Schema objects.
no setterinherited
- readOnly → bool?
-
Relevant only for Schema Object properties definitions.
Declares the property as "read only".
no setterinherited
- ref → String?
-
A reference to another Schema Object, typically in the
components
section.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- title → String?
-
A title for the schema.
no setterinherited
- type → String?
-
The data type of the schema (e.g., 'string', 'number', 'array').
no setterinherited
- uniqueItems → bool?
-
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.3.
no setterinherited
- writeOnly → bool?
-
Relevant only for Schema Object properties definitions.
Declares the property as "write only".
no setterinherited
- xml → Xml?
-
This MAY be used only on properties schemas.
It has no effect on root schemas.
Adds Additional metadata to describe the XML representation format of
this property.
no setterinherited
Methods
-
map<
TResult extends Object?> (TResult $default(_Schema value)) → TResult -
Available on Schema, provided by the SchemaPatterns extension
Aswitch
-like method, using callbacks. -
mapOrNull<
TResult extends Object?> (TResult? $default(_Schema value)?) → TResult? -
Available on Schema, provided by the SchemaPatterns extension
A variant ofmap
that fallback to returningnull
. -
maybeMap<
TResult extends Object?> (TResult $default(_Schema value)?, {required TResult orElse()}) → TResult -
Available on Schema, provided by the SchemaPatterns extension
A variant ofmap
that fallback to returningorElse
. -
maybeWhen<
TResult extends Object?> (TResult $default(String? ref, String? type, String? format, String? title, String? description, List< String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, List? enumValues, dynamic $default, Xml? xml, dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, int? maxProperties, int? minProperties, num? multipleOf, bool? $deprecated, Map<String, dynamic> ? extensions)?, {required TResult orElse()}) → TResult -
Available on Schema, provided by the SchemaPatterns extension
A variant ofwhen
that fallback to anorElse
callback. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts a Schema to a JSON object.
-
toString(
) → String -
A string representation of this object.
inherited
-
when<
TResult extends Object?> (TResult $default(String? ref, String? type, String? format, String? title, String? description, List< String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, List? enumValues, dynamic $default, Xml? xml, dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, int? maxProperties, int? minProperties, num? multipleOf, bool? $deprecated, Map<String, dynamic> ? extensions)) → TResult -
Available on Schema, provided by the SchemaPatterns extension
Aswitch
-like method, using callbacks. -
whenOrNull<
TResult extends Object?> (TResult? $default(String? ref, String? type, String? format, String? title, String? description, List< String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, List? enumValues, dynamic $default, Xml? xml, dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, int? maxProperties, int? minProperties, num? multipleOf, bool? $deprecated, Map<String, dynamic> ? extensions)?) → TResult? -
Available on Schema, provided by the SchemaPatterns extension
A variant ofwhen
that fallback to returningnull
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited