Browse Source

feat(dynamite): support all specs based on openapi 3.0.0 and later

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

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

@ -13,6 +13,7 @@ import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:dynamite/src/models/open_api.dart'; import 'package:dynamite/src/models/open_api.dart';
import 'package:dynamite/src/models/serializers.dart'; import 'package:dynamite/src/models/serializers.dart';
import 'package:dynamite/src/type_result/type_result.dart'; import 'package:dynamite/src/type_result/type_result.dart';
import 'package:pub_semver/pub_semver.dart';
class OpenAPIBuilder implements Builder { class OpenAPIBuilder implements Builder {
@override @override
@ -36,9 +37,8 @@ class OpenAPIBuilder implements Builder {
json.decode(await buildStep.readAsString(inputId)), json.decode(await buildStep.readAsString(inputId)),
)!; )!;
final supportedVersions = ['3.0.3', '3.1.0']; if (Version.parse(spec.version).major != 3) {
if (!supportedVersions.contains(spec.version)) { throw Exception('Only OpenAPI 3.0.0 and later are supported');
throw Exception('Only OpenAPI ${supportedVersions.join(', ')} are supported');
} }
final state = State(spec.info.title); final state = State(spec.info.title);

1
packages/dynamite/dynamite/pubspec.yaml

@ -14,6 +14,7 @@ dependencies:
intersperse: ^2.0.0 intersperse: ^2.0.0
meta: ^1.9.1 meta: ^1.9.1
path: ^1.8.3 path: ^1.8.3
pub_semver: ^2.1.4
dev_dependencies: dev_dependencies:
build_runner: ^2.4.6 build_runner: ^2.4.6

Loading…
Cancel
Save