OpenAPILicense.fromJson constructor

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

Wraps decoded JSON.

Implementation

factory OpenAPILicense.fromJson(Map<String, Object?> json) {
  final identifier = optionalString(json, 'identifier', scope: 'openapi');
  final url = optionalString(json, 'url', scope: 'openapi');
  try {
    _validateExclusiveFields(
      identifier: identifier,
      url: url,
      scope: 'OpenAPILicense',
    );
  } catch (error) {
    throw FormatException('Invalid openapi license: $error', error);
  }
  return OpenAPILicense._({
    'name': requireString(json, 'name', scope: 'openapi'),
    'identifier': ?identifier,
    'url': ?url,
    ...extractExtensions(json),
  });
}