OpenAPI constructor

  1. @JsonSerializable.new(includeIfNull: false, explicitToJson: true)
const OpenAPI({
  1. @Default.new('2.0') String swagger,
  2. Info? info,
  3. String? host,
  4. String? basePath,
  5. List<String>? schemes,
  6. List<String>? consumes,
  7. List<String>? produces,
  8. @Default.new({}) Map<String, PathItem> paths,
  9. @Default.new({}) Map<String, Schema> definitions,
  10. @Default.new({}) Map<String, SecurityScheme> securityDefinitions,
  11. @Default.new([]) List<SecurityRequirement> security,
  12. ExternalDocs? externalDocs,
  13. @Default.new([]) List<Tag> tags,
  14. @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({
  /// The version of the Swagger specification.
  @Default('2.0') String swagger,

  /// Metadata about the API.
  Info? info,

  /// The host serving the API.
  String? host,

  /// The base path for all API paths.
  String? basePath,

  /// The transfer protocols to be used.
  List<String>? schemes,

  /// A list of MIME types the API can consume.
  List<String>? consumes,

  /// A list of MIME types the API can produce.
  List<String>? produces,

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

  /// An object to hold reusable schema definitions.
  @Default({}) Map<String, Schema> definitions,

  /// A declaration of security schemes used in the API.
  @Default({}) Map<String, SecurityScheme> securityDefinitions,

  /// A declaration of which security schemes are required for the entire API.
  @Default([]) List<SecurityRequirement> security,

  /// External documentation for the API.
  ExternalDocs? externalDocs,

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

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