OpenAPIOutput.fromJson constructor

OpenAPIOutput.fromJson(
  1. Map<String, Object?> json
)

Wraps decoded JSON.

Implementation

factory OpenAPIOutput.fromJson(Map<String, Object?> json) {
  final type = requireString(json, 'type', scope: 'openapi.output');
  final path = requireString(json, 'path', scope: 'openapi.output');
  return switch (type) {
    'route' => OpenAPIOutput.route(path),
    'local' => OpenAPIOutput.local(path),
    _ => throw FormatException(
      'Invalid openapi.output.type: expected `route` or `local`.',
    ),
  };
}