Browse Source

Merge pull request #221 from provokateurin/feature/dynamite-deprecated-operations

dynamite: Support deprecated operations
pull/223/head
Kate 2 years ago committed by GitHub
parent
commit
8e5d3681d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      packages/dynamite/lib/src/models/operation.dart
  2. 13
      packages/dynamite/lib/src/models/operation.g.dart
  3. 3
      packages/dynamite/lib/src/openapi_builder.dart

3
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<String>? tags;
final List<Parameter>? parameters;

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

@ -9,12 +9,22 @@ part of 'operation.dart';
Operation _$OperationFromJson(Map<String, dynamic> 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<dynamic>?)?.map((e) => e as String).toList(),
parameters:
(json['parameters'] as List<dynamic>?)?.map((e) => Parameter.fromJson(e as Map<String, dynamic>)).toList(),
@ -37,6 +47,7 @@ Map<String, dynamic> _$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());

3
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';

Loading…
Cancel
Save