OpenAPI constructor

  1. @JsonSerializable.new(includeIfNull: false, explicitToJson: true)
const OpenAPI({
  1. required Info info,
  2. required String openapi,
  3. List<Server>? servers,
  4. @Default.new({}) Map<String, PathItem> paths,
  5. Components? components,
  6. String? jsonSchemaDialect,
  7. @Default.new([]) List<SecurityRequirement> security,
  8. @Default.new([]) List<Tag> tags,
  9. ExternalDocs? externalDocs,
  10. @Default.new({}) Map<String, PathItem> webhooks,
  11. @JsonKey.new(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<String, dynamic>? extensions,
})

Creates an OpenAPI with the given parameters.

Implementation

@JsonSerializable(includeIfNull: false, explicitToJson: true)
const factory OpenAPI({
  /// Provides metadata about the API.
  required Info info,

  /// This string MUST be the semantic version number of the OpenAPI
  /// Specification version that the OpenAPI document uses.
  required String openapi,

  /// An array of Server Objects, which provide connectivity information \
  /// to a target server.
  List<Server>? servers,

  /// The available paths and operations for the API.
  @Default({}) Map<String, PathItem> paths,

  /// An element to hold reusable objects for the specification.
  Components? components,

  /// The default value for the $schema keyword within Schema Objects
  /// contained within this OAS document. This MUST be in the form of a URI.
  String? jsonSchemaDialect,

  /// A declaration of which security schemes are applied to the API
  /// as a whole.
  @Default([]) List<SecurityRequirement> security,

  /// A list of tags for API documentation control.
  @Default([]) List<Tag> tags,

  /// Additional external documentation.
  ExternalDocs? externalDocs,

  /// The incoming webhooks that MAY be received by the API.
  @Default({}) Map<String, PathItem> webhooks,

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