Browse Source

refactor(dynamite): supply a full version for the minimum supported openapi version

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/1023/head
Nikolas Rimikis 1 year ago
parent
commit
d11e0d0ca8
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 11
      packages/dynamite/dynamite/lib/src/openapi_builder.dart

11
packages/dynamite/dynamite/lib/src/openapi_builder.dart

@ -22,6 +22,12 @@ class OpenAPIBuilder implements Builder {
'.openapi.yaml': ['.openapi.dart'],
};
/// The minimum openapi version supported by this builder.
static final Version minSupportedVersion = Version(3, 0, 0);
/// The maximum openapi version supported by this builder.
static final Version maxSupportedVersion = minSupportedVersion.incrementMajor();
@override
Future<void> build(final BuildStep buildStep) async {
try {
@ -45,8 +51,9 @@ class OpenAPIBuilder implements Builder {
_ => throw StateError('Openapi specs can only be yaml or json.'),
};
if (Version.parse(spec.version).major != 3) {
throw Exception('Only OpenAPI 3.0.0 and later are supported');
final version = Version.parse(spec.version);
if (version < minSupportedVersion || version > maxSupportedVersion) {
throw Exception('Only OpenAPI between $minSupportedVersion and $maxSupportedVersion are supported.');
}
final state = State();

Loading…
Cancel
Save