Form.fromJson constructor

Form.fromJson(
  1. Map<String, dynamic> json,
  2. PrefixMapping prefixMapping
)

Creates a new Form from a json object.

Implementation

factory Form.fromJson(
  Map<String, dynamic> json,
  PrefixMapping prefixMapping,
) {
  final Set<String> parsedFields = {};
  final href = json.parseRequiredUriField("href", parsedFields);

  final subprotocol = json.parseField<String>("subprotocol", parsedFields);

  final op = json.parseOperationTypes(parsedFields);

  final contentType = json.parseField<String>("contentType", parsedFields) ??
      "application/json";

  final contentCoding =
      json.parseField<String>("contentCoding", parsedFields);

  final security = json.parseArrayField<String>(
    "security",
    parsedFields: parsedFields,
    minimalSize: 1,
  );
  final scopes =
      json.parseArrayField<String>("scopes", parsedFields: parsedFields);
  final response = json.parseExpectedResponse(prefixMapping, parsedFields);

  final additionalResponses = json.parseAdditionalExpectedResponse(
    prefixMapping,
    contentType,
    parsedFields,
  );

  final additionalFields =
      json.parseAdditionalFields(prefixMapping, parsedFields);

  return Form(
    href,
    contentType: contentType,
    contentCoding: contentCoding,
    subprotocol: subprotocol,
    op: op,
    scopes: scopes,
    security: security,
    response: response,
    additionalResponses: additionalResponses,
    additionalFields: additionalFields,
  );
}