DataSchema.fromJson constructor
DataSchema.fromJson(])
Creates a new DataSchema from a json
object.
Implementation
factory DataSchema.fromJson(
Map<String, dynamic> json,
PrefixMapping prefixMapping, [
Set<String>? parsedFields,
]) {
parsedFields = parsedFields ?? {};
final atType =
json.parseArrayField<String>("@type", parsedFields: parsedFields);
final title = json.parseField<String>("title", parsedFields);
final titles = json.parseMapField<String>("titles", parsedFields);
final description = json.parseField<String>("description", parsedFields);
final descriptions =
json.parseMapField<String>("descriptions", parsedFields);
final constant = json.parseField<Object>("constant", parsedFields);
final defaultValue = json.parseField<Object>("default", parsedFields);
final enumeration = json.parseArrayField<Object?>(
"enum",
parsedFields: parsedFields,
minimalSize: 1,
);
final readOnly = json.parseField<bool>("readOnly", parsedFields);
final writeOnly = json.parseField<bool>("writeOnly", parsedFields);
final format = json.parseField<String>("format", parsedFields);
final unit = json.parseField<String>("unit", parsedFields);
final type = json.parseField<String>("type", parsedFields);
final minimum = json.parseField<num>("minimum", parsedFields);
final exclusiveMinimum =
json.parseField<num>("exclusiveMinimum", parsedFields);
final maximum = json.parseField<num>("maximum", parsedFields);
final exclusiveMaximum =
json.parseField<num>("exclusiveMaximum", parsedFields);
final multipleOf = json.parseField<num>("multipleOf", parsedFields);
final items =
json.parseDataSchemaArrayField("items", prefixMapping, parsedFields);
final minItems = json.parseField<int>("minItems", parsedFields);
final maxItems = json.parseField<int>("maxItems", parsedFields);
final required =
json.parseArrayField<String>("required", parsedFields: parsedFields);
final minLength = json.parseField<int>("minLength", parsedFields);
final maxLength = json.parseField<int>("maxLength", parsedFields);
final pattern = json.parseField<String>("pattern", parsedFields);
final contentEncoding =
json.parseField<String>("contentEncoding", parsedFields);
final contentMediaType =
json.parseField<String>("contentMediaType", parsedFields);
final oneOf =
json.parseDataSchemaArrayField("oneOf", prefixMapping, parsedFields);
final properties =
json.parseDataSchemaMapField("properties", prefixMapping, parsedFields);
final additionalFields =
json.parseAdditionalFields(prefixMapping, parsedFields);
return DataSchema(
atType: atType,
title: title,
titles: titles,
description: description,
descriptions: descriptions,
constant: constant,
defaultValue: defaultValue,
enumeration: enumeration,
readOnly: readOnly,
writeOnly: writeOnly,
format: format,
unit: unit,
type: type,
minimum: minimum,
exclusiveMinimum: exclusiveMinimum,
maximum: maximum,
exclusiveMaximum: exclusiveMaximum,
multipleOf: multipleOf,
items: items,
minItems: minItems,
maxItems: maxItems,
required: required,
minLength: minLength,
maxLength: maxLength,
pattern: pattern,
contentEncoding: contentEncoding,
contentMediaType: contentMediaType,
oneOf: oneOf,
properties: properties,
additionalFields: additionalFields,
);
}