JsonSchema.fromMap constructor

JsonSchema.fromMap(
  1. Map<String, dynamic> map
)

Given a Map in conformance with the JSON Schema Spec of a JSON Schema Document,
this constructor will parse it and return a JsonSchema instance.

Implementation

JsonSchema.fromMap(Map<String, dynamic> map)
    : type = stringToJsonSchemaType[map['type']] ?? JsonSchemaType.none,
      annotations = {},
      title = map['title'],
      description = map['description'],
      required = map['required'] is List
          ? (map['required'] as List).whereType<String>().toList()
          : List.empty(),
      userInterface = map['userInterface'] ?? {},
      readOnly = map['readOnly'] ?? false,
      writeOnly = map['writeOnly'] ?? false,
      enum_ = map['enum'],
      _source = map,
      properties = map['properties'] is Map<String, dynamic>
          ? (map['properties'] as Map<String, dynamic>)
              .map<String, JsonSchema>(
              (key, value) => MapEntry(
                key,
                JsonSchema.fromMap(
                  value,
                ),
              ),
            )
          : {};