Browse Source

Merge pull request #186 from provokateurin/feature/operation-description-summary

dynamite: Support operation description and summary
pull/187/head
Kate 2 years ago committed by GitHub
parent
commit
e5ec9ffc17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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 { class Operation {
Operation({ Operation({
this.operationId, this.operationId,
this.summary,
this.description,
this.tags, this.tags,
this.parameters, this.parameters,
this.requestBody, this.requestBody,
@ -21,6 +23,10 @@ class Operation {
final String? operationId; final String? operationId;
final String? summary;
final String? description;
final List<String>? tags; final List<String>? tags;
final List<Parameter>? parameters; 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) { Operation _$OperationFromJson(Map<String, dynamic> json) {
$checkKeys( $checkKeys(
json, json,
allowedKeys: const ['operationId', 'tags', 'parameters', 'requestBody', 'responses'], allowedKeys: const ['operationId', 'summary', 'description', 'tags', 'parameters', 'requestBody', 'responses'],
); );
return Operation( return Operation(
operationId: json['operationId'] as String?, 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(), tags: (json['tags'] as List<dynamic>?)?.map((e) => e as String).toList(),
parameters: parameters:
(json['parameters'] as List<dynamic>?)?.map((e) => Parameter.fromJson(e as Map<String, dynamic>)).toList(), (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('operationId', instance.operationId);
writeNotNull('summary', instance.summary);
writeNotNull('description', instance.description);
writeNotNull('tags', instance.tags); writeNotNull('tags', instance.tags);
writeNotNull('parameters', instance.parameters?.map((e) => e.toJson()).toList()); writeNotNull('parameters', instance.parameters?.map((e) => e.toJson()).toList());
writeNotNull('requestBody', instance.requestBody?.toJson()); 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); final methodName = _toDartName(operationId);
b b
..name = methodName ..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(''' final code = StringBuffer('''
var path = '$path'; var path = '$path';

Loading…
Cancel
Save