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.new(copyWith: true, fromJson: true, toJson: true, equal: true)

Constructors

Schema({@JsonKey.new(name: r'$ref') String? ref, String? type, String? format, String? title, String? description, @JsonKey.new(name: 'required') List<String>? $required, Map<String, Schema>? properties, Schema? items, dynamic example, @JsonKey.new(name: 'enum') List? enumValues, @JsonKey.new(name: 'default') dynamic $default, Xml? xml, Schema? additionalProperties, num? maximum, bool? exclusiveMaximum, num? minimum, bool? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema>? allOf, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, num? multipleOf, @JsonKey.new(name: 'deprecated') bool? $deprecated})
Creates a Schema object.
const
factory
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 → Schema?
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
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 → bool?
The exclusive maximum value for a number.
no setterinherited
exclusiveMinimum → bool?
The exclusive minimum value for a number.
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
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
multipleOf → num?
See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.1.
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
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
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

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>(TResult? $default(_Schema value)?) → TResult?

Available on Schema, provided by the SchemaPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>(TResult $default(_Schema value)?, {required TResult orElse()}) → TResult

Available on Schema, provided by the SchemaPatterns extension

A variant of map that fallback to returning orElse.
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, Schema? additionalProperties, num? maximum, bool? exclusiveMaximum, num? minimum, bool? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema>? allOf, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, num? multipleOf, bool? $deprecated)?, {required TResult orElse()}) → TResult

Available on Schema, provided by the SchemaPatterns extension

A variant of when that fallback to an orElse 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, Schema? additionalProperties, num? maximum, bool? exclusiveMaximum, num? minimum, bool? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema>? allOf, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, num? multipleOf, bool? $deprecated)) → TResult

Available on Schema, provided by the SchemaPatterns extension

A switch-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, Schema? additionalProperties, num? maximum, bool? exclusiveMaximum, num? minimum, bool? exclusiveMinimum, ExternalDocs? externalDocs, Discriminator? discriminator, List<Schema>? allOf, bool? allowEmptyValue, String? collectionFormat, int? maxLength, int? minLength, int? maxItems, int? minItems, String? pattern, bool? uniqueItems, num? multipleOf, bool? $deprecated)?) → TResult?

Available on Schema, provided by the SchemaPatterns extension

A variant of when that fallback to returning null

Operators

operator ==(Object other) → bool
The equality operator.
inherited