diff --git a/packages/dynamite/lib/src/models/operation.dart b/packages/dynamite/lib/src/models/operation.dart index 6e9677de..cc5fa669 100644 --- a/packages/dynamite/lib/src/models/operation.dart +++ b/packages/dynamite/lib/src/models/operation.dart @@ -12,6 +12,7 @@ class Operation { this.operationId, this.summary, this.description, + this.deprecated, this.tags, this.parameters, this.requestBody, @@ -27,6 +28,8 @@ class Operation { final String? description; + final bool? deprecated; + 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 278779b4..7b1ad93b 100644 --- a/packages/dynamite/lib/src/models/operation.g.dart +++ b/packages/dynamite/lib/src/models/operation.g.dart @@ -9,12 +9,22 @@ part of 'operation.dart'; Operation _$OperationFromJson(Map json) { $checkKeys( json, - allowedKeys: const ['operationId', 'summary', 'description', 'tags', 'parameters', 'requestBody', 'responses'], + allowedKeys: const [ + 'operationId', + 'summary', + 'description', + 'deprecated', + 'tags', + 'parameters', + 'requestBody', + 'responses' + ], ); return Operation( operationId: json['operationId'] as String?, summary: json['summary'] as String?, description: json['description'] as String?, + deprecated: json['deprecated'] as bool?, tags: (json['tags'] as List?)?.map((e) => e as String).toList(), parameters: (json['parameters'] as List?)?.map((e) => Parameter.fromJson(e as Map)).toList(), @@ -37,6 +47,7 @@ Map _$OperationToJson(Operation instance) { writeNotNull('operationId', instance.operationId); writeNotNull('summary', instance.summary); writeNotNull('description', instance.description); + writeNotNull('deprecated', instance.deprecated); 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 f73f49d2..8a89894d 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -583,6 +583,9 @@ class OpenAPIBuilder implements Builder { ], ..._descriptionToDocs(operation.description), ]); + if (operation.deprecated ?? false) { + b.annotations.add(refer('Deprecated').call([refer("''")])); + } final code = StringBuffer(''' var path = '$path';