RefProperty.fromJson constructor

RefProperty.fromJson(
  1. Map<String, dynamic> json
)

Creates a RefProperty from a JSON Schema fragment containing $ref.

Implementation

factory RefProperty.fromJson(Map<String, dynamic> json) {
  return RefProperty(
    ref: (json['\$ref'] as String?)?.replaceAll("#/components/schemas/", ""),
    format: json['format'] as String?,
    defaultValue: json['default'],
    nullable: json['nullable'] ?? false,
    enumValues: (json['enum'] as List<dynamic>? ?? [])
        .map((e) => e.toString())
        .toList(),
  );
}