(cls, data: Mapping[str, Any])
| 25 | |
| 26 | @classmethod |
| 27 | def from_mapping(cls, data: Mapping[str, Any]) -> "Breadcrumb": |
| 28 | node = str(data.get("node")) if data.get("node") else "" |
| 29 | if not node: |
| 30 | raise SchemaResolutionError("breadcrumb entry missing 'node'") |
| 31 | field = data.get("field") |
| 32 | if field is not None: |
| 33 | field = str(field) |
| 34 | index = data.get("index") |
| 35 | if index is not None and not isinstance(index, int): |
| 36 | raise SchemaResolutionError("breadcrumb 'index' must be integer when provided") |
| 37 | value = data.get("value") |
| 38 | return cls(node=node, field=field, value=value) |
| 39 | |
| 40 | def to_json(self) -> Dict[str, Any]: |
| 41 | payload: Dict[str, Any] = {"node": self.node} |
no test coverage detected