|
38 | 38 | from ..exception.serialization import ( |
39 | 39 | CycloneDxDeserializationException, |
40 | 40 | SerializationOfUnexpectedValueException, |
| 41 | + SerializationOfUnsupportedComponentIdentityEvidenceFieldException, |
41 | 42 | SerializationOfUnsupportedComponentTypeException, |
42 | 43 | ) |
43 | 44 | from ..schema.schema import ( |
@@ -237,10 +238,11 @@ class _ComponentIdentityEvidenceFieldSerializationHelper(serializable.helpers.Ba |
237 | 238 | } |
238 | 239 |
|
239 | 240 | @classmethod |
240 | | - def __normalize(cls, cs: ComponentIdentityEvidenceField, view: Type[serializable.ViewType]) -> Optional[str]: |
241 | | - return cs.value \ |
242 | | - if cs in cls.__CASES.get(view, ()) \ |
243 | | - else None |
| 241 | + def __normalize(cls, cief: ComponentIdentityEvidenceField, view: Type[serializable.ViewType]) -> Optional[str]: |
| 242 | + if cief in cls.__CASES.get(view, ()): |
| 243 | + return cief.value |
| 244 | + raise SerializationOfUnsupportedComponentIdentityEvidenceFieldException( |
| 245 | + f'unsupported {cief!r} for view {view!r}') |
244 | 246 |
|
245 | 247 | @classmethod |
246 | 248 | def json_normalize(cls, o: Any, *, |
@@ -492,7 +494,7 @@ def confidence(self, confidence: Optional[float]) -> None: |
492 | 494 | self._confidence = confidence |
493 | 495 |
|
494 | 496 | @property |
495 | | - @serializable.type_mapping(ComponentIdentityEvidenceMethod) |
| 497 | + @serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'method') |
496 | 498 | @serializable.xml_sequence(3) |
497 | 499 | def methods(self) -> 'SortedSet[ComponentIdentityEvidenceMethod]': |
498 | 500 | """ |
@@ -572,7 +574,7 @@ def __init__( |
572 | 574 | @property |
573 | 575 | @serializable.view(SchemaVersion1Dot5) |
574 | 576 | @serializable.view(SchemaVersion1Dot6) |
575 | | - @serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'identity') |
| 577 | + @serializable.xml_array(serializable.XmlArraySerializationType.FLAT, 'identity') |
576 | 578 | @serializable.xml_sequence(1) |
577 | 579 | def identity(self) -> 'SortedSet[ComponentIdentityEvidence]': |
578 | 580 | """ |
|
0 commit comments