• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Package spdx contains the struct definition for an SPDX Document
2// and its constituent parts.
3// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
4package v2_1
5
6import "github.com/spdx/tools-golang/spdx/common"
7
8// ExternalDocumentRef is a reference to an external SPDX document
9// as defined in section 2.6 for version 2.1 of the spec.
10type ExternalDocumentRef struct {
11	// DocumentRefID is the ID string defined in the start of the
12	// reference. It should _not_ contain the "DocumentRef-" part
13	// of the mandatory ID string.
14	DocumentRefID string `json:"externalDocumentId"`
15
16	// URI is the URI defined for the external document
17	URI string `json:"spdxDocument"`
18
19	// Checksum is the actual hash data
20	Checksum common.Checksum `json:"checksum"`
21}
22
23// Document is an SPDX Document for version 2.1 of the spec.
24// See https://spdx.org/sites/cpstandard/files/pages/files/spdxversion2.1.pdf
25type Document struct {
26	// 2.1: SPDX Version; should be in the format "SPDX-2.1"
27	// Cardinality: mandatory, one
28	SPDXVersion string `json:"spdxVersion"`
29
30	// 2.2: Data License; should be "CC0-1.0"
31	// Cardinality: mandatory, one
32	DataLicense string `json:"dataLicense"`
33
34	// 2.3: SPDX Identifier; should be "DOCUMENT" to represent
35	//      mandatory identifier of SPDXRef-DOCUMENT
36	// Cardinality: mandatory, one
37	SPDXIdentifier common.ElementID `json:"SPDXID"`
38
39	// 2.4: Document Name
40	// Cardinality: mandatory, one
41	DocumentName string `json:"name"`
42
43	// 2.5: Document Namespace
44	// Cardinality: mandatory, one
45	DocumentNamespace string `json:"documentNamespace"`
46
47	// 2.6: External Document References
48	// Cardinality: optional, one or many
49	ExternalDocumentReferences []ExternalDocumentRef `json:"externalDocumentRefs,omitempty"`
50
51	// 2.11: Document Comment
52	// Cardinality: optional, one
53	DocumentComment string `json:"comment,omitempty"`
54
55	CreationInfo  *CreationInfo   `json:"creationInfo"`
56	Packages      []*Package      `json:"packages,omitempty"`
57	Files         []*File         `json:"files,omitempty"`
58	OtherLicenses []*OtherLicense `json:"hasExtractedLicensingInfos,omitempty"`
59	Relationships []*Relationship `json:"relationships,omitempty"`
60	Annotations   []*Annotation   `json:"annotations,omitempty"`
61	Snippets      []Snippet       `json:"snippets,omitempty"`
62
63	// DEPRECATED in version 2.0 of spec
64	Reviews []*Review `json:"-"`
65}
66