Schema class abstract
The Schema Object allows the definition of input and output data types for OpenAPI 3.1.
It describes the data type, format, constraints, and structure of properties, request bodies, and other parts of the OpenAPI specification.
- Available extensions
- Annotations
-
- @Freezed.new(copyWith: true, fromJson: true, toJson: false, equal: true)
Constructors
-
Schema({@JsonKey.new(name: r'$ref') String? ref, @JsonKey.new(includeFromJson: false, includeToJson: true) dynamic type, String? format, String? title, String? description, @JsonKey.new(name: 'required') List<
String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, List? examples, @JsonKey.new(name: 'enum') List? enumValues, @JsonKey.new(name: 'default') dynamic $default, Xml? xml, dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? readOnly, bool? writeOnly, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, int? maxProperties, int? minProperties, num? multipleOf, @JsonKey.new(name: 'deprecated') bool? $deprecated, @JsonKey.new(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<String, dynamic> ? extensions, String? $id, String? $schema, String? $vocabulary, String? $anchor, String? $dynamicAnchor, String? $dynamicRef, Map<String, Schema> ? $defs, String? contentMediaType, String? contentEncoding, @JsonKey.new(name: 'swagger-extension') bool? swaggerExtension, @JsonKey.new(name: 'const') dynamic const$, Map<String, Schema> ? patternProperties, bool? unevaluatedProperties}) -
Creates a Schema object.
constfactory
-
Schema.allOf(List<
Schema> schemas) -
Creates a Schema for a union where all schemas must be valid.
factory
-
Schema.anyOf(List<
Schema> schemas) -
Creates a Schema for a union where any of the schemas must be valid.
factory
- Schema.array({String? title, String? description, Schema? items, List? examples, bool? readOnly, bool? writeOnly, int? maxItems, int? minItems, bool? uniqueItems, String? collectionFormat, bool? allowEmptyValue, List? $default})
-
Creates a Schema for an array.
factory
- Schema.boolean({String? title, String? description, List? examples, bool? readOnly, bool? writeOnly, bool? $default})
-
Creates a Schema for a boolean.
factory
- Schema.constant(dynamic value)
-
Creates a Schema with a constant value.
factory
-
Schema.fromJson(Map<
String, dynamic> json) -
Creates a Schema from a JSON object.
factory
- Schema.integer({String? format, String? title, String? description, List? examples, num? maximum, num? minimum, num? multipleOf, num? exclusiveMaximum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, int? $default})
-
Creates a Schema for an integer.
factory
- Schema.nullableArray({String? title, String? description, Schema? items, List? examples, bool? readOnly, bool? writeOnly, int? maxItems, int? minItems, bool? uniqueItems, String? collectionFormat, bool? allowEmptyValue, List? $default})
-
Creates a Schema for a nullable array.
factory
- Schema.nullableBoolean({String? title, String? description, List? examples, bool? readOnly, bool? writeOnly, bool? $default})
-
Creates a Schema for a nullable boolean.
factory
- Schema.nullableInteger({String? format, String? title, String? description, List? examples, num? maximum, num? minimum, num? multipleOf, num? exclusiveMaximum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, int? $default})
-
Creates a Schema for a nullable integer.
factory
- Schema.nullableNumber({String? format, String? title, String? description, List? examples, num? maximum, num? minimum, num? multipleOf, num? exclusiveMaximum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, num? $default})
-
Creates a Schema for a nullable number (float or double).
factory
-
Schema.nullableObject({String? title, String? description, List<
String> ? $required, Map<String, Schema> ? properties, dynamic additionalProperties, Map<String, Schema> ? patternProperties, bool? unevaluatedProperties, List? examples, bool? readOnly, bool? writeOnly, int? maxProperties, int? minProperties, Map<String, dynamic> ? $default}) -
Creates a Schema for a nullable object.
factory
- Schema.nullableString({String? format, String? title, String? description, List? examples, bool? readOnly, bool? writeOnly, String? $default, int? maxLength, int? minLength, String? pattern})
-
Creates a Schema for a string.
factory
- Schema.number({String? format, String? title, String? description, List? examples, num? maximum, num? minimum, num? multipleOf, num? exclusiveMaximum, num? exclusiveMinimum, bool? readOnly, bool? writeOnly, num? $default})
-
Creates a Schema for a number (float or double).
factory
-
Schema.object({String? title, String? description, List<
String> ? $required, Map<String, Schema> ? properties, dynamic additionalProperties, Map<String, Schema> ? patternProperties, bool? unevaluatedProperties, List? examples, bool? readOnly, bool? writeOnly, int? maxProperties, int? minProperties, Map<String, dynamic> ? $default}) -
Creates a Schema for an object.
factory
-
Schema.oneOf(List<
Schema> schemas) -
Creates a Schema for a union of multiple schemas.
factory
- Schema.ref(String ref)
-
Creates a Schema for a reference to another schema.
factory
- Schema.string({String? format, String? title, String? description, List? examples, bool? readOnly, bool? writeOnly, String? $default, int? maxLength, int? minLength, String? pattern})
-
Creates a Schema for a string.
factory
Properties
- $anchor → String?
-
An anchor for this schema.
no setterinherited
- $default → dynamic
-
The default value for the schema.
no setterinherited
-
$defs
→ Map<
String, Schema> ? -
A map of definitions that can be referenced internally.
no setterinherited
- $deprecated → bool?
-
Declares this schema as deprecated.
no setterinherited
- $dynamicAnchor → String?
-
A dynamic anchor for dynamic references.
no setterinherited
- $dynamicRef → String?
-
A dynamic reference to a dynamic anchor.
no setterinherited
- $id → String?
-
A unique identifier for the schema.
no setterinherited
-
$required
→ List<
String> ? -
A list of properties that must be present in the object.
no setterinherited
- $schema → String?
-
The schema dialect used.
no setterinherited
- $vocabulary → String?
-
A vocabulary identifier.
no setterinherited
- additionalProperties → dynamic
-
Specifies the schema for any additional properties in the 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
- const$ → dynamic
-
A constant value for the schema.
no setterinherited
- contentEncoding → String?
-
The content encoding of a string.
no setterinherited
- contentMediaType → String?
-
The media type of a string.
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
- examples → List?
-
A list of example values 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
truevalue indicates that bothnullvalues and values of the specifiedtypeare 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
-
patternProperties
→ Map<
String, Schema> ? -
A map of regular expressions to schemas for pattern-based properties.
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
componentssection.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- swaggerExtension → bool?
-
A vendor-specific swagger extension.
no setterinherited
- title → String?
-
A title for the schema.
no setterinherited
- type → dynamic
-
The data type of the schema (e.g., 'string', 'number', 'array').
In OpenAPI 3.1, this can be a single type or a list of types.
no setterinherited
- unevaluatedProperties → bool?
-
https://stackoverflow.com/questions/79247662/exact-definition-of-unevaluatedproperties-in-jsonschema
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 ofmapthat 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 ofmapthat fallback to returningorElse. -
maybeWhen<
TResult extends Object?> (TResult $default(String? ref, dynamic type, String? format, String? title, String? description, List< String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, List? examples, List? enumValues, dynamic $default, Xml? xml, dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? readOnly, bool? writeOnly, 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, String? $id, String? $schema, String? $vocabulary, String? $anchor, String? $dynamicAnchor, String? $dynamicRef, Map<String, Schema> ? $defs, String? contentMediaType, String? contentEncoding, bool? swaggerExtension, dynamic const$, Map<String, Schema> ? patternProperties, bool? unevaluatedProperties)?, {required TResult orElse()}) → TResult -
Available on Schema, provided by the SchemaPatterns extension
A variant ofwhenthat fallback to anorElsecallback. -
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, dynamic type, String? format, String? title, String? description, List< String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, List? examples, List? enumValues, dynamic $default, Xml? xml, dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? readOnly, bool? writeOnly, 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, String? $id, String? $schema, String? $vocabulary, String? $anchor, String? $dynamicAnchor, String? $dynamicRef, Map<String, Schema> ? $defs, String? contentMediaType, String? contentEncoding, bool? swaggerExtension, dynamic const$, Map<String, Schema> ? patternProperties, bool? unevaluatedProperties)) → TResult -
Available on Schema, provided by the SchemaPatterns extension
Aswitch-like method, using callbacks. -
whenOrNull<
TResult extends Object?> (TResult? $default(String? ref, dynamic type, String? format, String? title, String? description, List< String> ? $required, Map<String, Schema> ? properties, Schema? items, dynamic example, List? examples, List? enumValues, dynamic $default, Xml? xml, dynamic additionalProperties, num? maximum, num? exclusiveMaximum, num? minimum, num? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema> ? allOf, List<Schema> ? oneOf, List<Schema> ? anyOf, Schema? not, bool? nullable, bool? readOnly, bool? writeOnly, 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, String? $id, String? $schema, String? $vocabulary, String? $anchor, String? $dynamicAnchor, String? $dynamicRef, Map<String, Schema> ? $defs, String? contentMediaType, String? contentEncoding, bool? swaggerExtension, dynamic const$, Map<String, Schema> ? patternProperties, bool? unevaluatedProperties)?) → TResult? -
Available on Schema, provided by the SchemaPatterns extension
A variant ofwhenthat fallback to returningnull
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited