open_api 2.0.1

  • Readme
  • Changelog
  • Installing
  • 62

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]
64
Health:
Code health derived from static analysis. [more]
59
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
63
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health suggestions

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

Analysis of lib/src/v3/schema.dart reported 13 hints, including:

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

line 27 col 34: Unnecessary new keyword.

line 33 col 13: Unnecessary new keyword.

line 38 col 15: Unnecessary new keyword.

line 42 col 13: Unnecessary new keyword.

Fix lib/src/v3/components.dart. (-5.84 points)

Analysis of lib/src/v3/components.dart reported 12 hints, including:

line 49 col 13: Unnecessary new keyword.

line 53 col 13: Unnecessary new keyword.

line 56 col 9: Don't explicitly initialize variables to null.

line 68 col 13: Unnecessary new keyword.

line 76 col 13: Unnecessary new keyword.

Fix lib/src/v2/document.dart. (-3.93 points)

Analysis of lib/src/v2/document.dart reported 8 hints, including:

line 21 col 18: Unnecessary new keyword.

line 60 col 46: Unnecessary new keyword.

line 61 col 47: Unnecessary new keyword.

line 62 col 51: Unnecessary new keyword.

line 63 col 59: Unnecessary new keyword.

Fix additional 21 files with analysis or formatting issues. (-35.72 points)

Additional issues in the following files:

  • lib/src/v3/security.dart (8 hints)
  • lib/src/v3/response.dart (7 hints)
  • lib/src/v3/document.dart (6 hints)
  • lib/src/v3/operation.dart (6 hints)
  • lib/src/v3/metadata.dart (5 hints)
  • lib/src/v2/metadata.dart (4 hints)
  • lib/src/v3/parameter.dart (4 hints)
  • lib/src/v3/request_body.dart (4 hints)
  • lib/src/v3/server.dart (4 hints)
  • lib/src/v2/schema.dart (3 hints)
  • lib/src/v3/callback.dart (3 hints)
  • lib/src/object.dart (2 hints)
  • lib/src/v2/operation.dart (2 hints)
  • lib/src/v2/parameter.dart (2 hints)
  • lib/src/v2/path.dart (2 hints)
  • lib/src/v2/response.dart (2 hints)
  • lib/src/v2/security.dart (2 hints)
  • lib/src/v3/media_type.dart (2 hints)
  • lib/src/v3/path.dart (2 hints)
  • lib/src/v2/header.dart (1 hint)
  • lib/src/v3/encoding.dart (1 hint)

Maintenance suggestions

Package is getting outdated. (-27.12 points)

The package was last published 66 weeks ago.

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.8
Dev dependencies
test ^1.3.0