diff --git a/packages/dynamite/lib/src/models/operation.dart b/packages/dynamite/lib/src/models/operation.dart index 54b9d696..6e9677de 100644 --- a/packages/dynamite/lib/src/models/operation.dart +++ b/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? tags; final List? parameters; diff --git a/packages/dynamite/lib/src/models/operation.g.dart b/packages/dynamite/lib/src/models/operation.g.dart index 41d0abf9..278779b4 100644 --- a/packages/dynamite/lib/src/models/operation.g.dart +++ b/packages/dynamite/lib/src/models/operation.g.dart @@ -9,10 +9,12 @@ part of 'operation.dart'; Operation _$OperationFromJson(Map 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?)?.map((e) => e as String).toList(), parameters: (json['parameters'] as List?)?.map((e) => Parameter.fromJson(e as Map)).toList(), @@ -33,6 +35,8 @@ Map _$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()); diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index dac09eaf..4425c395 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/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';