|
|
|
@ -3,7 +3,6 @@ import 'package:dynamite/src/builder/resolve_type.dart';
|
|
|
|
|
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'; |
|
|
|
|
|
|
|
|
|
Iterable<Spec> generateSchemas( |
|
|
|
|
final openapi.OpenAPI spec, |
|
|
|
@ -12,27 +11,13 @@ Iterable<Spec> generateSchemas(
|
|
|
|
|
if (spec.components?.schemas != null) { |
|
|
|
|
for (final schema in spec.components!.schemas!.entries) { |
|
|
|
|
final identifier = toDartName(schema.key, uppercaseFirstCharacter: true); |
|
|
|
|
if (schema.value.type == null && schema.value.ref == null && schema.value.ofs == null) { |
|
|
|
|
yield TypeDef( |
|
|
|
|
(final b) => b |
|
|
|
|
..name = identifier |
|
|
|
|
..definition = refer('dynamic'), |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
final result = resolveType( |
|
|
|
|
spec, |
|
|
|
|
state, |
|
|
|
|
identifier, |
|
|
|
|
schema.value, |
|
|
|
|
); |
|
|
|
|
if (result is TypeResultBase) { |
|
|
|
|
yield TypeDef( |
|
|
|
|
(final b) => b |
|
|
|
|
..name = identifier |
|
|
|
|
..definition = refer(result.name), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
resolveType( |
|
|
|
|
spec, |
|
|
|
|
state, |
|
|
|
|
identifier, |
|
|
|
|
schema.value, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|