Skip to content

Commit

Permalink
feat(spec1-5): add support for license properties
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <nscuro@protonmail.com>
  • Loading branch information
nscuro committed May 21, 2023
1 parent b7a6c14 commit 56f6336
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cyclonedx.go
Expand Up @@ -313,10 +313,11 @@ const (
)

type License struct {
ID string `json:"id,omitempty" xml:"id,omitempty"`
Name string `json:"name,omitempty" xml:"name,omitempty"`
Text *AttachedText `json:"text,omitempty" xml:"text,omitempty"`
URL string `json:"url,omitempty" xml:"url,omitempty"`
ID string `json:"id,omitempty" xml:"id,omitempty"`
Name string `json:"name,omitempty" xml:"name,omitempty"`
Text *AttachedText `json:"text,omitempty" xml:"text,omitempty"`
URL string `json:"url,omitempty" xml:"url,omitempty"`
Properties *[]Property `json:"properties,omitempty" xml:"properties>property,omitempty"`
}

type Licenses []LicenseChoice
Expand Down
Expand Up @@ -28,6 +28,31 @@
"type": "library",
"name": "acme-library",
"version": "1.0.0",
"licenses": [
{
"license": {
"id": "Apache-2.0",
"properties": [
{
"name": "Foo",
"value": "Bar"
},
{
"name": "Foo",
"value": "You"
},
{
"name": "Foo",
"value": "Two"
},
{
"name": "Bar",
"value": "Foo"
}
]
}
}
],
"properties": [
{
"name": "Foo",
Expand Down
Expand Up @@ -12,6 +12,17 @@
<component type="library">
<name>acme-library</name>
<version>1.0.0</version>
<licenses>
<license>
<id>Apache-2.0</id>
<properties>
<property name="Foo">Bar</property>
<property name="Foo">You</property>
<property name="Foo">Two</property>
<property name="Bar">Foo</property>
</properties>
</license>
</licenses>
<properties>
<property name="Foo">Bar</property>
<property name="Bar">Foo</property>
Expand Down
25 changes: 25 additions & 0 deletions testdata/valid-properties.json
Expand Up @@ -28,6 +28,31 @@
"type": "library",
"name": "acme-library",
"version": "1.0.0",
"licenses": [
{
"license": {
"id": "Apache-2.0",
"properties": [
{
"name": "Foo",
"value": "Bar"
},
{
"name": "Foo",
"value": "You"
},
{
"name": "Foo",
"value": "Two"
},
{
"name": "Bar",
"value": "Foo"
}
]
}
}
],
"properties": [
{
"name": "Foo",
Expand Down
11 changes: 11 additions & 0 deletions testdata/valid-properties.xml
Expand Up @@ -12,6 +12,17 @@
<component type="library">
<name>acme-library</name>
<version>1.0.0</version>
<licenses>
<license>
<id>Apache-2.0</id>
<properties>
<property name="Foo">Bar</property>
<property name="Foo">You</property>
<property name="Foo">Two</property>
<property name="Bar">Foo</property>
</properties>
</license>
</licenses>
<properties>
<property name="Foo">Bar</property>
<property name="Bar">Foo</property>
Expand Down

0 comments on commit 56f6336

Please sign in to comment.