OpenAPI class abstract

The root document object of the OpenAPI 2.0 (Swagger) specification.

This class represents the top-level structure of an OpenAPI 2.0 document, including metadata, definitions, paths, and security schemes.

Available extensions
Annotations
  • @Freezed.new(copyWith: true, fromJson: true, toJson: false, equal: true)

Constructors

OpenAPI({@Default.new('2.0') String swagger, Info? info, String? host, String? basePath, List<String>? schemes, List<String>? consumes, List<String>? produces, @Default.new({}) Map<String, PathItem> paths, @Default.new({}) Map<String, Schema> definitions, @Default.new({}) Map<String, SecurityScheme> securityDefinitions, @Default.new([]) List<SecurityRequirement> security, ExternalDocs? externalDocs, @Default.new([]) List<Tag> tags, @JsonKey.new(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<String, dynamic>? extensions})
Creates an OpenAPI with the given parameters.
const
factory
OpenAPI.fromJson(Map<String, dynamic> json)
Creates an OpenAPI from a JSON-like map.
factory

Properties

basePath String?
The base path for all API paths.
no setterinherited
consumes List<String>?
A list of MIME types the API can consume.
no setterinherited
copyWith → $OpenAPICopyWith<OpenAPI>
Create a copy of OpenAPI with the given fields replaced by the non-null parameter values.
no setterinherited
definitions Map<String, Schema>
An object to hold reusable schema definitions.
no setterinherited
extensions Map<String, dynamic>?
Vendor extensions (keys like x-*).
no setterinherited
externalDocs ExternalDocs?
External documentation for the API.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
host String?
The host serving the API.
no setterinherited
info Info?
Metadata about the API.
no setterinherited
paths Map<String, PathItem>
The available paths and their operations.
no setterinherited
produces List<String>?
A list of MIME types the API can produce.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schemes List<String>?
The transfer protocols to be used.
no setterinherited
security List<SecurityRequirement>
A declaration of which security schemes are required for the entire API.
no setterinherited
securityDefinitions Map<String, SecurityScheme>
A declaration of security schemes used in the API.
no setterinherited
swagger String
The version of the Swagger specification.
no setterinherited
tags List<Tag>
A list of tags for API documentation.
no setterinherited

Methods

map<TResult extends Object?>(TResult $default(_OpenAPI value)) → TResult

Available on OpenAPI, provided by the OpenAPIPatterns extension

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

Available on OpenAPI, provided by the OpenAPIPatterns extension

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

Available on OpenAPI, provided by the OpenAPIPatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>(TResult $default(String swagger, Info? info, String? host, String? basePath, List<String>? schemes, List<String>? consumes, List<String>? produces, Map<String, PathItem> paths, Map<String, Schema> definitions, Map<String, SecurityScheme> securityDefinitions, List<SecurityRequirement> security, ExternalDocs? externalDocs, List<Tag> tags, Map<String, dynamic>? extensions)?, {required TResult orElse()}) → TResult

Available on OpenAPI, provided by the OpenAPIPatterns 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 this OpenAPI to JSON.
toString() String
A string representation of this object.
inherited
when<TResult extends Object?>(TResult $default(String swagger, Info? info, String? host, String? basePath, List<String>? schemes, List<String>? consumes, List<String>? produces, Map<String, PathItem> paths, Map<String, Schema> definitions, Map<String, SecurityScheme> securityDefinitions, List<SecurityRequirement> security, ExternalDocs? externalDocs, List<Tag> tags, Map<String, dynamic>? extensions)) → TResult

Available on OpenAPI, provided by the OpenAPIPatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>(TResult? $default(String swagger, Info? info, String? host, String? basePath, List<String>? schemes, List<String>? consumes, List<String>? produces, Map<String, PathItem> paths, Map<String, Schema> definitions, Map<String, SecurityScheme> securityDefinitions, List<SecurityRequirement> security, ExternalDocs? externalDocs, List<Tag> tags, Map<String, dynamic>? extensions)?) → TResult?

Available on OpenAPI, provided by the OpenAPIPatterns extension

A variant of when that fallback to returning null

Operators

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