OpenAPIDocument class
An OpenAPI document for some service with raw content parsed in content.
Note: this class wraps decoded JSON Object from a JSON document containing OpenAPI definition. To utilize such data JSON Object tree in content must be traversed as needed.
In future this class might containg also helper methods to access certain objects and fields according to the OpenAPI schema. Currently there is only the openapi member, other elements must be accessed from raw data.
See also:
- https://www.openapis.org/
- https://spec.openapis.org/oas/latest.html
- https://swagger.io/specification/
Example:
void _printOpenAPI(OpenAPIDocument document) {
print('OpenAPI ${document.openapi}');
final servers = document.content['servers'] as Iterable<dynamic>;
for (final s in servers) {
final server = s as Map<String, dynamic>;
final url = server['url'] as String;
final desc = server['description'] as String?;
print(' $url : $desc');
}
}
- Annotations
-
- @immutable
Constructors
-
OpenAPIDocument.fromJson(Map<
String, dynamic> content) -
Parses Open API document for a service from Open API data in
content
.factory
Properties
-
content
→ Map<
String, dynamic> -
The OpenAPI document as a data object (ie. data from a JSON Object).
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- openapi → String
-
The version number of the OpenAPI Specification that this OpenAPI document
uses.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override