Skip to content

Commit

Permalink
refactor(dynamite): supply a full version for the minimum supported o…
Browse files Browse the repository at this point in the history
…penapi version

Signed-off-by: Nikolas Rimikis <[email protected]>
  • Loading branch information
Leptopoda committed Oct 25, 2023
1 parent 50f1466 commit f1f467a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/dynamite/dynamite/lib/src/openapi_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class OpenAPIBuilder implements Builder {
'.openapi.yaml': ['.openapi.dart'],
};

/// The minimum openapi version supported by this builder.
static final minSupportedVersion = Version(3, 0, 0);

@override
Future<void> build(final BuildStep buildStep) async {
try {
Expand All @@ -45,7 +48,8 @@ class OpenAPIBuilder implements Builder {
_ => throw StateError('Openapi specs can only be yaml or json.'),
};

if (Version.parse(spec.version).major != 3) {
final version = Version.parse(spec.version);
if (version < minSupportedVersion || version > minSupportedVersion.incrementMajor()) {
throw Exception('Only OpenAPI 3.0.0 and later are supported');
}

Expand Down

0 comments on commit f1f467a

Please sign in to comment.