Field class
Customizes schema generation for a specific field or parameter.
Apply this annotation to class fields or constructor parameters to provide additional schema metadata.
@Spectra()
class User {
@Field(
description: 'User email address',
format: StringFormat.email,
)
final String email;
@Field(
description: 'User age',
minimum: 0,
maximum: 150,
)
final int age;
}
Constructors
-
Field({String? name, String? description, bool deprecated = false, List<
Object> ? examples, int? minLength, int? maxLength, String? pattern, StringFormat? format, num? minimum, num? maximum, bool exclusiveMinimum = false, bool exclusiveMaximum = false, num? multipleOf, int? minItems, int? maxItems, bool uniqueItems = false}) -
Creates a new Field annotation.
const
Properties
- deprecated → bool
-
Mark this field as deprecated.
final
- description → String?
-
Description of this field.
final
-
examples
→ List<
Object> ? -
Example values for this field.
final
- exclusiveMaximum → bool
-
Whether the maximum is exclusive.
final
- exclusiveMinimum → bool
-
Whether the minimum is exclusive.
final
- format → StringFormat?
-
Format hint for string values.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maximum → num?
-
Maximum value for numeric types.
final
- maxItems → int?
-
Maximum number of items in an array.
final
- maxLength → int?
-
Maximum length for string values.
final
- minimum → num?
-
Minimum value for numeric types.
final
- minItems → int?
-
Minimum number of items in an array.
final
- minLength → int?
-
Minimum length for string values.
final
- multipleOf → num?
-
Value must be a multiple of this number.
final
- name → String?
-
Override the property name in the schema.
final
- pattern → String?
-
Regular expression pattern for string validation.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- uniqueItems → bool
-
Whether array items must be unique.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited