ItemPathOpenApi.from constructor

ItemPathOpenApi.from({
  1. String? summary,
  2. String? description,
  3. required Map<String, OperationOpenApi> operations,
})

Implementation

factory ItemPathOpenApi.from({
  String? summary,
  String? description,
  required Map<String, OperationOpenApi> operations,
}) {
  final usedOperations = operations.map((key, value) => MapEntry(key.toLowerCase(), value));
  final instance = ItemPathOpenApi(
    summary: summary,
    description: description,
    get: usedOperations.remove('get'),
    put: usedOperations.remove('put'),
    post: usedOperations.remove('post'),
    delete: usedOperations.remove('delete'),
    head: usedOperations.remove('head'),
    patch: usedOperations.remove('patch'),
  );
  if (usedOperations.isNotEmpty) {
    // ignore: avoid_print
    print('[WARNING] Not consumed all item path methods: ${usedOperations.keys}');
  }
  return instance;
}