Browse Source

Merge pull request #872 from nextcloud/feat/dynamite/openapi_v3

support all openapi specs v3
pull/585/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
046b52d2c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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/builder/state.dart';
import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/openapi.dart' as openapi;
import 'package:dynamite/src/models/type_result.dart'; import 'package:dynamite/src/models/type_result.dart';
import 'package:version/version.dart';
class OpenAPIBuilder implements Builder { class OpenAPIBuilder implements Builder {
@override @override
@ -44,9 +45,8 @@ class OpenAPIBuilder implements Builder {
_ => throw StateError('Openapi specs can only be yaml or json.'), _ => throw StateError('Openapi specs can only be yaml or json.'),
}; };
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

@ -15,6 +15,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
version: ^3.0.2
dev_dependencies: dev_dependencies:
build_runner: ^2.4.6 build_runner: ^2.4.6

Loading…
Cancel
Save