Skip to content

Commit

Permalink
feat(dynamite): add doc comments someOf extensions
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolas Rimikis <[email protected]>
  • Loading branch information
Leptopoda committed Dec 29, 2023
1 parent c4600a3 commit 23646f3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/dynamite/dynamite/lib/src/builder/generate_ofs.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:code_builder/code_builder.dart';
import 'package:dynamite/src/builder/state.dart';
import 'package:dynamite/src/helpers/built_value.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';
Expand All @@ -16,18 +17,15 @@ Iterable<Spec> buildOfsExtensions(
continue;
}

final serializerMethod = Method(
(final b) => b
..static = true
..returns = refer('Serializer<${result.className}>')
..type = MethodType.getter
..name = 'serializer'
..lambda = true
..body = Code('${result.typeName}Extension._serializer'),
);
final serializerMethod = buildSerializer(result.className, '${result.typeName}Extension._serializer');

final toJson = Method(
(final b) => b
..docs.addAll([
'/// Creates a new object from the given [json] data.',
'///',
'/// Use `toJson` to serialize it back into json.',
])
..static = true
..returns = refer(result.className)
..name = 'fromJson'
Expand All @@ -44,6 +42,7 @@ Iterable<Spec> buildOfsExtensions(

yield Extension(
(final b) => b
..docs.add('/// @nodoc')
..name = '\$${result.className}Extension'
..on = refer(result.className)
..methods.addAll([
Expand Down Expand Up @@ -93,6 +92,7 @@ Iterable<Spec> generateSomeOf(

final oneOfValidator = Method((final b) {
b
..docs.add('/// {@macro Dynamite.validateOneOf}')
..name = 'validateOneOf'
..returns = refer('void')
..lambda = true
Expand All @@ -101,6 +101,7 @@ Iterable<Spec> generateSomeOf(

final anyOfValidator = Method((final b) {
b
..docs.add('/// {@macro Dynamite.validateAnyOf}')
..name = 'validateAnyOf'
..returns = refer('void')
..lambda = true
Expand Down Expand Up @@ -135,6 +136,11 @@ Iterable<Spec> generateSomeOf(

final toJson = Method(
(final b) => b
..docs.addAll([
'/// Parses this object into a json like map.',
'///',
'/// Use the fromJson factory to revive it again.',
])
..name = 'toJson'
..returns = refer('Object?')
..lambda = true
Expand Down

0 comments on commit 23646f3

Please sign in to comment.