open_api 2.0.1

open_api_dart #

Reads and writes OpenAPI (Swagger) specifications.

Example #

final file = new File("test/specs/kubernetes.json");
final contents = await file.readAsString();
final doc = new APIDocument.fromJSON(contents);

final output = JSON.encode(doc.asMap());

Changelog #

2.0.1 #

  • Fix bug when merging APIResponse bodies

2.0.0 #

  • Update for Dart 2

1.0.2 #

  • Adds APIResponse.addHeader and APIResponse.addContent.
  • Adds APIOperation.addResponse.

1.0.1 #

  • Adds APISchemaObject.isFreeForm and related support for free-form schema objects.

1.0.0 #

  • Adds support for OpenAPI 3.0
  • Splits Swagger (2.0) and OpenAPI (3.0) into 'package:open_api/v2.dart' and 'package:open_api/v3.dart'.

0.9.1 #

  • Moves shared properties from APISchema, APIHeader and APIParameter into APIProperty.

0.9.0 #

  • Initial data structures
  • Parsing specifications
  • Writing specifications to disk

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  open_api: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:open_api/v2.dart';
import 'package:open_api/v3.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
68
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

Fix lib/src/v3/schema.dart. (-1 points)

Analysis of lib/src/v3/schema.dart reported 2 hints:

line 25 col 74: Use = to separate a named parameter from its default value.

line 46 col 45: Use = to separate a named parameter from its default value.

Fix lib/src/object.dart. (-0.50 points)

Analysis of lib/src/object.dart reported 1 hint:

line 23 col 9: Use isNotEmpty instead of length

Fix lib/src/v2/security.dart. (-0.50 points)

Analysis of lib/src/v2/security.dart reported 1 hint:

line 50 col 94: Use = to separate a named parameter from its default value.

Fix additional 14 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/src/v3/components.dart (1 hint)
  • lib/src/v3/request_body.dart (1 hint)
  • lib/src/v3/response.dart (1 hint)
  • lib/src/v2/document.dart (Run dartfmt to format lib/src/v2/document.dart.)
  • lib/src/v2/schema.dart (Run dartfmt to format lib/src/v2/schema.dart.)
  • lib/src/v3/callback.dart (Run dartfmt to format lib/src/v3/callback.dart.)
  • lib/src/v3/document.dart (Run dartfmt to format lib/src/v3/document.dart.)
  • lib/src/v3/encoding.dart (Run dartfmt to format lib/src/v3/encoding.dart.)
  • lib/src/v3/metadata.dart (Run dartfmt to format lib/src/v3/metadata.dart.)
  • lib/src/v3/operation.dart (Run dartfmt to format lib/src/v3/operation.dart.)
  • lib/src/v3/parameter.dart (Run dartfmt to format lib/src/v3/parameter.dart.)
  • lib/src/v3/path.dart (Run dartfmt to format lib/src/v3/path.dart.)
  • lib/src/v3/security.dart (Run dartfmt to format lib/src/v3/security.dart.)
  • lib/src/v3/server.dart (Run dartfmt to format lib/src/v3/server.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and open_api.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
codable ^1.0.0 1.0.0
meta ^1.1.5 1.1.7
Dev dependencies
test ^1.3.0

Admin