From 2711469968d0d5bea30a1ae74f8063b3fa22d393 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 23:12:44 +0200 Subject: [PATCH] feat(dynamite): support all openapi specs v3 Signed-off-by: Nikolas Rimikis --- packages/dynamite/dynamite/lib/src/openapi_builder.dart | 6 +++--- packages/dynamite/dynamite/pubspec.yaml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/dynamite/lib/src/openapi_builder.dart index 3eaad791..4788cac8 100644 --- a/packages/dynamite/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/dynamite/lib/src/openapi_builder.dart @@ -13,6 +13,7 @@ import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; +import 'package:version/version.dart'; class OpenAPIBuilder implements Builder { @override @@ -44,9 +45,8 @@ class OpenAPIBuilder implements Builder { _ => throw StateError('Openapi specs can only be yaml or json.'), }; - final supportedVersions = ['3.0.3', '3.1.0']; - if (!supportedVersions.contains(spec.version)) { - throw Exception('Only OpenAPI ${supportedVersions.join(', ')} are supported'); + if (Version.parse(spec.version).major != 3) { + throw Exception('Only OpenAPI 3.0.0 and later are supported'); } final state = State(spec.info.title); diff --git a/packages/dynamite/dynamite/pubspec.yaml b/packages/dynamite/dynamite/pubspec.yaml index 3d98048c..8f460503 100644 --- a/packages/dynamite/dynamite/pubspec.yaml +++ b/packages/dynamite/dynamite/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: intersperse: ^2.0.0 meta: ^1.9.1 path: ^1.8.3 + version: ^3.0.2 dev_dependencies: build_runner: ^2.4.6