Description
As of cyclonedx-python-lib
4.0.0
there appears to be a serialization error when the provided (valid) Model has more than one license added.
Example:
bom = Bom()
...
bom.metadata.licenses = [LicenseChoice(license=License(
id='Apache-2.0', text=AttachedText(
content='VGVzdCBjb250ZW50IC0gdGhpcyBpcyBub3QgdGhlIEFwYWNoZSAyLjAgbGljZW5zZSE=', encoding=Encoding.BASE_64
), url=XsUri('https://www.apache.org/licenses/LICENSE-2.0.txt')
)), LicenseChoice(license=License(name='OSI_APACHE'))]
produces
...
<ns0:licenses>
<ns0:license>
<ns0:id>Apache-2.0</ns0:id>
<ns0:text content-type="text/plain" encoding="base64">
VGVzdCBjb250ZW50IC0gdGhpcyBpcyBub3QgdGhlIEFwYWNoZSAyLjAgbGljZW5zZSE=
</ns0:text>
<ns0:url>https://www.apache.org/licenses/LICENSE-2.0.txt</ns0:url>
</ns0:license>
</ns0:licenses>
<ns0:licenses>
<ns0:license>
<ns0:name>OSI_APACHE</ns0:name>
</ns0:license>
</ns0:licenses>
...
Which is invalid as per the CycloneDX schema.
this CDX schema discrepancy was fixed via CycloneDX/specification#204
important for the fix:
#365 (comment)