diff --git a/packages/dynamite/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/dynamite/lib/src/openapi_builder.dart index 5e42b4d77b9..427f9836fb2 100644 --- a/packages/dynamite/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/dynamite/lib/src/openapi_builder.dart @@ -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 build(final BuildStep buildStep) async { try { @@ -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'); }