Schema constructor

  1. @JsonSerializable.new(includeIfNull: false, explicitToJson: true)
const Schema({
  1. @JsonKey.new(name: r'$ref') String? ref,
  2. @JsonKey.new(includeFromJson: false, includeToJson: true) dynamic type,
  3. String? format,
  4. String? title,
  5. String? description,
  6. @JsonKey.new(name: 'required') List<String>? $required,
  7. Map<String, Schema>? properties,
  8. Schema? items,
  9. dynamic example,
  10. List? examples,
  11. @JsonKey.new(name: 'enum') List? enumValues,
  12. @JsonKey.new(name: 'default') dynamic $default,
  13. Xml? xml,
  14. dynamic additionalProperties,
  15. num? maximum,
  16. num? exclusiveMaximum,
  17. num? minimum,
  18. num? exclusiveMinimum,
  19. ExternalDocs? externalDocs,
  20. Discriminator? discriminator,
  21. List<Schema>? allOf,
  22. List<Schema>? oneOf,
  23. List<Schema>? anyOf,
  24. Schema? not,
  25. bool? nullable,
  26. bool? readOnly,
  27. bool? writeOnly,
  28. bool? allowEmptyValue,
  29. String? collectionFormat,
  30. int? maxLength,
  31. int? minLength,
  32. int? maxItems,
  33. int? minItems,
  34. String? pattern,
  35. bool? uniqueItems,
  36. int? maxProperties,
  37. int? minProperties,
  38. num? multipleOf,
  39. @JsonKey.new(name: 'deprecated') bool? $deprecated,
  40. @JsonKey.new(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<String, dynamic>? extensions,
  41. String? $id,
  42. String? $schema,
  43. String? $vocabulary,
  44. String? $anchor,
  45. String? $dynamicAnchor,
  46. String? $dynamicRef,
  47. Map<String, Schema>? $defs,
  48. String? contentMediaType,
  49. String? contentEncoding,
  50. @JsonKey.new(name: 'swagger-extension') bool? swaggerExtension,
  51. @JsonKey.new(name: 'const') dynamic const$,
  52. Map<String, Schema>? patternProperties,
  53. bool? unevaluatedProperties,
})

Creates a Schema object.

Implementation

@JsonSerializable(includeIfNull: false, explicitToJson: true)
const factory Schema({
  /// A reference to another Schema Object, typically in the `components`
  /// section.
  @JsonKey(name: r'$ref') String? ref,

  /// 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.
  @JsonKey(includeFromJson: false, includeToJson: true) dynamic type,

  /// The format of the data type (e.g., 'int32', 'date-time', 'email').
  String? format,

  /// A title for the schema.
  String? title,

  /// A brief description of the schema.
  String? description,

  /// A list of properties that must be present in the object.
  @JsonKey(name: 'required') List<String>? $required,

  /// A map of property names to their respective [Schema] objects.
  Map<String, Schema>? properties,

  /// For array types, this describes the type of items in the array.
  Schema? items,

  /// An example value for the schema.
  dynamic example,

  /// A list of example values for the schema.
  List<dynamic>? examples,

  /// A list of possible values for an enum.
  @JsonKey(name: 'enum') List<dynamic>? enumValues,

  /// The default value for the schema.
  @JsonKey(name: 'default') dynamic $default,

  /// 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.
  Xml? xml,

  /// Specifies the schema for any additional properties in the object.
  dynamic additionalProperties,

  /// The maximum value for a number.
  num? maximum,

  /// The exclusive maximum value for a number.
  num? exclusiveMaximum,

  /// The minimum value for a number.
  num? minimum,

  /// The exclusive minimum value for a number.
  num? exclusiveMinimum,

  /// A URL to external documentation for this schema.
  ExternalDocs? externalDocs,

  /// A **Discriminator** object for handling polymorphism.
  Discriminator? discriminator,

  /// An array of schemas where the data must be valid against all of
  /// the schemas.
  List<Schema>? allOf,

  /// An array of schemas where the data must be valid against one of
  /// the schemas.
  List<Schema>? oneOf,

  /// An array of schemas where the data must be valid against any of
  /// the schemas.
  List<Schema>? anyOf,

  /// A schema where the data must not be valid against this schema.
  Schema? not,

  /// A `true` value indicates that both `null` values and values of the
  /// specified `type` are allowed.
  bool? nullable,

  /// Relevant only for Schema Object properties definitions.
  /// Declares the property as "read only".
  bool? readOnly,

  /// Relevant only for Schema Object properties definitions.
  /// Declares the property as "write only".
  bool? writeOnly,

  /// Sets the ability to pass empty-valued parameters.
  bool? allowEmptyValue,

  /// Determines the format of the array if type array is used.
  String? collectionFormat,

  /// See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.1.
  int? maxLength,

  /// integer See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.2.
  int? minLength,

  /// See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.2.
  int? maxItems,

  /// See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.3.
  int? minItems,

  /// string  See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3.
  String? pattern,

  /// See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.3.
  bool? uniqueItems,

  /// See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.1
  int? maxProperties,

  /// See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.2
  int? minProperties,

  /// See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.1.
  num? multipleOf,

  /// Declares this schema as deprecated.
  @JsonKey(name: 'deprecated') bool? $deprecated,

  /// Vendor extensions (keys like `x-*`).
  @JsonKey(includeIfNull: false, includeFromJson: false, includeToJson: false)
  Map<String, dynamic>? extensions,

  /// A unique identifier for the schema.
  String? $id,

  /// The schema dialect used.
  String? $schema,

  /// A vocabulary identifier.
  String? $vocabulary,

  /// An anchor for this schema.
  String? $anchor,

  /// A dynamic anchor for dynamic references.
  String? $dynamicAnchor,

  /// A dynamic reference to a dynamic anchor.
  String? $dynamicRef,

  /// A map of definitions that can be referenced internally.
  Map<String, Schema>? $defs,

  /// The media type of a string.
  String? contentMediaType,

  /// The content encoding of a string.
  String? contentEncoding,

  /// A vendor-specific swagger extension.
  @JsonKey(name: 'swagger-extension') bool? swaggerExtension,

  /// A constant value for the schema.
  @JsonKey(name: 'const') dynamic const$,

  /// A map of regular expressions to schemas for pattern-based properties.
  Map<String, Schema>? patternProperties,

  /// https://stackoverflow.com/questions/79247662/exact-definition-of-unevaluatedproperties-in-jsonschema
  bool? unevaluatedProperties,
}) = _Schema;