Browse Source

dynamite: Support operation description and summary

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

6
packages/dynamite/lib/src/models/operation.dart

@ -10,6 +10,8 @@ part 'operation.g.dart';
class Operation {
Operation({
this.operationId,
this.summary,
this.description,
this.tags,
this.parameters,
this.requestBody,
@ -21,6 +23,10 @@ class Operation {
final String? operationId;
final String? summary;
final String? description;
final List<String>? tags;
final List<Parameter>? parameters;

6
packages/dynamite/lib/src/models/operation.g.dart

@ -9,10 +9,12 @@ part of 'operation.dart';
Operation _$OperationFromJson(Map<String, dynamic> json) {
$checkKeys(
json,
allowedKeys: const ['operationId', 'tags', 'parameters', 'requestBody', 'responses'],
allowedKeys: const ['operationId', 'summary', 'description', 'tags', 'parameters', 'requestBody', 'responses'],
);
return Operation(
operationId: json['operationId'] as String?,
summary: json['summary'] as String?,
description: json['description'] as String?,
tags: (json['tags'] as List<dynamic>?)?.map((e) => e as String).toList(),
parameters:
(json['parameters'] as List<dynamic>?)?.map((e) => Parameter.fromJson(e as Map<String, dynamic>)).toList(),
@ -33,6 +35,8 @@ Map<String, dynamic> _$OperationToJson(Operation instance) {
}
writeNotNull('operationId', instance.operationId);
writeNotNull('summary', instance.summary);
writeNotNull('description', instance.description);
writeNotNull('tags', instance.tags);
writeNotNull('parameters', instance.parameters?.map((e) => e.toJson()).toList());
writeNotNull('requestBody', instance.requestBody?.toJson());

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

@ -550,7 +550,18 @@ class OpenAPIBuilder implements Builder {
final methodName = _toDartName(operationId);
b
..name = methodName
..modifier = MethodModifier.async;
..modifier = MethodModifier.async
..docs.addAll([
if (operation.summary != null) ...[
operation.summary!,
],
if (operation.summary != null && operation.description != null) ...[
'',
],
if (operation.description != null) ...[
operation.description!,
],
]);
final code = StringBuffer('''
var path = '$path';

Loading…
Cancel
Save