Browse Source

dynamite: Output tag descriptions

pull/203/head
jld3103 2 years ago
parent
commit
643df5cf67
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 3
      packages/dynamite/lib/src/models/tag.dart
  2. 16
      packages/dynamite/lib/src/models/tag.g.dart
  3. 6
      packages/dynamite/lib/src/openapi_builder.dart

3
packages/dynamite/lib/src/models/tag.dart

@ -6,10 +6,13 @@ part 'tag.g.dart';
class Tag { class Tag {
Tag({ Tag({
required this.name, required this.name,
this.description,
}); });
factory Tag.fromJson(final Map<String, dynamic> json) => _$TagFromJson(json); factory Tag.fromJson(final Map<String, dynamic> json) => _$TagFromJson(json);
Map<String, dynamic> toJson() => _$TagToJson(this); Map<String, dynamic> toJson() => _$TagToJson(this);
final String name; final String name;
final String? description;
} }

16
packages/dynamite/lib/src/models/tag.g.dart

@ -9,13 +9,25 @@ part of 'tag.dart';
Tag _$TagFromJson(Map<String, dynamic> json) { Tag _$TagFromJson(Map<String, dynamic> json) {
$checkKeys( $checkKeys(
json, json,
allowedKeys: const ['name'], allowedKeys: const ['name', 'description'],
); );
return Tag( return Tag(
name: json['name'] as String, name: json['name'] as String,
description: json['description'] as String?,
); );
} }
Map<String, dynamic> _$TagToJson(Tag instance) => <String, dynamic>{ Map<String, dynamic> _$TagToJson(Tag instance) {
final val = <String, dynamic>{
'name': instance.name, 'name': instance.name,
}; };
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('description', instance.description);
return val;
}

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

@ -536,8 +536,14 @@ class OpenAPIBuilder implements Builder {
), ),
); );
} }
final matchedTags = spec.tags?.where((final t) => t.name == tag).toList();
b b
..name = '$prefix${isRootClient ? 'Client' : _clientName(tag)}' ..name = '$prefix${isRootClient ? 'Client' : _clientName(tag)}'
..docs.addAll(
_descriptionToDocs(
matchedTags != null && matchedTags.isNotEmpty ? matchedTags.single.description : null,
),
)
..methods.addAll( ..methods.addAll(
[ [
for (final path in paths.keys) ...[ for (final path in paths.keys) ...[

Loading…
Cancel
Save