OpenApi class
The OpenAPI Specification (OAS) defines a standard,language-agnostic interface to RESTful APIs
This Dart class is a container around the spec in order to parse and generate clients, servers, component schemas, and documentation
- Annotations
-
- @freezed
Constructors
-
OpenApi.new({@Default('3.0.3') @JsonKey(name: 'openapi') String version, required Info info, ExternalDocs? externalDocs, String? jsonSchemaDialect, List<
Server> ? servers, List<Tag> ? tags, Map<String, PathItem> ? paths, Map<String, PathItem> ? webhooks, Components? components, List<Security> ? security, @Default({}) Map<String, List< extraSchemaMapping})String> > -
constfactory
- OpenApi.fromFile({required String source})
-
Create an OpenApi object from an existing JSON/YAML OpenAPI spec file
factory
-
OpenApi.fromJson(Map<
String, dynamic> json) -
Create an OpenApi object from a JSON representation of an OpenAPI
factory
- OpenApi.fromString({required String source, required OpenApiFormat? format})
-
Create an OpenApi object from a JSON/YAML string
The format will be inferred from the file extension
When the format is not provided, we will try both JSON and YAML
factory
Properties
- components → Components?
-
An element to hold various schemas for the document.
no setterinherited
-
copyWith
→ $OpenApiCopyWith<
OpenApi> -
Create a copy of OpenApi
with the given fields replaced by the non-null parameter values.
no setterinherited
- externalDocs → ExternalDocs?
-
Additional external documentation.
no setterinherited
-
extraSchemaMapping
→ Map<
String, List< String> > -
A mapping of any extra schemas that this generator created and the parent schema
that they were created from. This is used to improve the generated schema library
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- info → Info
-
Provides metadata about the API.
The metadata MAY be used by tooling as required.
no setterinherited
- jsonSchemaDialect → String?
-
The default value for the $schema keyword within
Schema Objects contained within this OAS document
This must be in the form of a URI.
no setterinherited
-
paths
→ Map<
String, PathItem> ? -
The available paths and operations for the API.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
security
→ List<
Security> ? -
A declaration of which security mechanisms can be used across the API.
The list of values includes alternative security requirement objects
that can be used. Only one of the security requirement objects need
to be satisfied to authorize a request. Individual operations can override
this definition. To make security optional, an empty security requirement ({})
can be included in the array.
no setterinherited
-
servers
→ List<
Server> ? -
An array of Server objects, which provide connectivity information to a target server.
If the servers property is not provided, or is an empty array,
the default value would be a Server object with a url value of
/
.no setterinherited -
can be included in the array.
no setterinherited
- version → String
-
This string must be the version number of the
OpenAPI Specification that the OpenAPI document uses.
This is not related to the API
Info.version
string. By default, this generator uses3.0.3
.no setterinherited -
webhooks
→ Map<
String, PathItem> ? -
The incoming webhooks that may be received as part of this
API and that the API consumer MAY choose to implement.
Closely related to the callbacks feature, this section describes
requests initiated other than by an API call, for example by an out of
band registration. The key name is a unique string to refer to each
webhook, while the (optionally referenced) path Item Object describes a
request that may be initiated by the API provider and the expected responses.
no setterinherited
Methods
-
centralizedSpec(
) → OpenApi - Return a centralized OpenAPI spec.
-
generate(
{String package = 'my_api', required String destination, bool formatOutput = true, bool quiet = false, bool replace = false, SchemaGeneratorOptions schemaOptions = const SchemaGeneratorOptions(), ClientGeneratorOptions clientOptions = const ClientGeneratorOptions(), ServerGeneratorOptions serverOptions = const ServerGeneratorOptions()}) → Future< void> - Generate code from the OpenApi object
-
map<
TResult extends Object?> (TResult $default(_OpenApi value)) → TResult -
inherited
-
mapOrNull<
TResult extends Object?> (TResult? $default(_OpenApi value)?) → TResult? -
inherited
-
maybeMap<
TResult extends Object?> (TResult $default(_OpenApi value)?, {required TResult orElse()}) → TResult -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Convert the OpenApi object to a JSON spec representation
-
toJsonFile(
{required String destination}) → void - Convert the OpenApi object to a JSON spec file Will overwrite the existing file if it exists
-
toString(
) → String -
A string representation of this object.
inherited
-
toSwaggerUI(
{required String destination, String? title, bool replace = false, String? favicon16x16, String? favicon32x32, bool quiet = false, String? url = '/openapi.json'}) → Future< void> - Generate a static Swagger UI website from OpenApi object
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited