Skip to content

Commit eb8fd79

Browse files
authored
Merge pull request spdx#1 from davaya/template
Template
2 parents e1d1998 + e9e4a60 commit eb8fd79

File tree

10 files changed

+187
-1
lines changed

10 files changed

+187
-1
lines changed

README.md

+79-1
Large diffs are not rendered by default.

ex/annotation1.py

Whitespace-only changes.

json1/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# JSON examples based on JSON-LD
2+
3+
[PR #376](https://github.com/spdx/spdx-3-model/pull/376)

json2/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# JSON serialization 375
2+
3+
[PR #375](https://github.com/spdx/spdx-3-model/pull/375)

json3/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Simplified JSON Serialization

jsonld/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Native JSON-LD Serialization
2+
3+
RDF-based JSON-LD examples

model/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Individual Element Examples
2+
3+
The model directory contains Python example templates generated from the
4+
[SPDX model]() files, along with the code to generate those templates.
5+
## Model Types
6+
* `parse_model.py` reads the model files from GitHub and writes a local snapshot file `model_types.json`
7+
in the output directory, by default called `generated`.
8+
* `make_types.py` reads the model snapshot and generates a Python class file for each type defined in the model.
9+
These Python files are templates used to create logical examples of each type.
10+
11+
## Individual Element Examples
12+
To create a new logical example, copy the type template (e.g. `person.py` into the [ex](../ex) folder,
13+
give it an example name (e.g., `person1.py`) and fill in each of the property values
14+
for that example.

model/USING.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Using the Serialization Playground
2+
3+
## Structure
4+
The playground directory structure has three components:
5+
1. A directory of Python [template classes](generated), with one template for each type defined by the model.
6+
Each template lists just the properties of the type, with no property values.
7+
2. A directory of Python [example classes](../ex) with property values from a template class filled in,
8+
3. A directory of serialized examples for each proposed serialization format, e.g., [JSON1](../json1).
9+
10+
### Template Classes
11+
The template classes are generated from the logical model:
12+
```
13+
class Sbom:
14+
sbomType: SBOMType = None
15+
context: str = None
16+
element: AnyUri = None
17+
rootElement: AnyUri = None
18+
namespaces: NamespaceMap = None
19+
imports: ExternalMap = None
20+
spdxId: AnyUri = None
21+
name: str = None
22+
summary: str = None
23+
description: str = None
24+
comment: str = None
25+
creationInfo: CreationInfo = None
26+
verifiedUsing: IntegrityMethod = None
27+
externalReference: ExternalReference = None
28+
externalIdentifier: ExternalIdentifier = None
29+
extension: Extension = None
30+
```
31+
32+
### Example Logical Values
33+
One example for each of the use cases listed in the [README](README.md).
34+
Each example logical value is a copy of the template for that type with property values filled in.
35+
Many of the model types will not have a use case, and a few types will have several use cases / examples.
36+
Contributors may propose additional example logical values to accompany corresponding serialized data.
37+
38+
These are the logical values to be serialized into various serialization formats.
39+
All required properties must have a value; optional properties may be left empty (Python None).
40+
```
41+
class Sbom:
42+
sbomType: SBOMType = 'source'
43+
context: str = None
44+
... TBSL ...
45+
```
46+
### Serialized Examples
47+
The contributor of a format shows how an example logical value is serialized and parsed
48+
to/from the serialized value for that use case.

rdf/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# RDF Serialization

use_cases.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Serialization Use Cases
2+
Mapping from spdx-3-model [use case list](https://github.com/spdx/spdx-3-model/blob/main/serialization/README.md)
3+
to Element Examples
4+
5+
- **Person:** [Person1](ex/person1.md) with minimal CreationInfo
6+
- **Agent:** [Agent1](ex/agent.md)
7+
- **Annotation:** [Annotation1](ex/annotation1.md)
8+
- **File:** [File1](ex/file1.md)
9+
- **Package:** [Package1](ex/package1.md) with [File1](ex/file1.md) and [File2](ex/file2.md)
10+
- **Package:** [Package2](ex/package2.md) with ExternalIdentifier
11+
- **Package:** [Package3](ex/package3.md) with ExternalReference
12+
- **Relationship:** [Relationship1](ex/relationship1.md) with [Package1](ex/package1.md) contains two Files
13+
- **Relationship:** [Relationship2](ex/relationship2.md) with time properties
14+
- **SBOM:** [Sbom1](ex/sbom1.md) with two Files
15+
- **SpdxDocument:** [SpdxDocument1](ex/spdxdocument1.md) with two Files
16+
- **SpdxDocument:** [SpdxDocument3](ex/spdxdocument3.md) with NamespaceMap
17+
- **SpdxDocument:** [SpdxDocument4](ex/spdxdocument4.md) with ExternalMap
18+
- **Person:** [Person3](ex/person3.md) with no CreationInfo *NOTE: invalid after model update*
19+
- **Person:** [Person1](ex/person1.md) with minimal CreationInfo
20+
- **Person:** [Person2](ex/person2.md) with full CreationInfo
21+
- **Bundle:** [Bundle1](ex/bundle1.md) *Note: with no elements?*
22+
- **two Persons:** [Person1](ex/person1.md) and [Person2](ex/person2.md)
23+
- **Bundle:** [Bundle2](ex/bundle2.md) of [Person1](ex/person1.md) and [Person2](ex/person2.md)
24+
25+
Licensing use cases:
26+
- single artifact under one listed license: [License1](ex/license1.md)?
27+
- single artifact under one custom license: [CustomLicense1](ex/customlicense1.md)?
28+
- single artifact under license expression of listed licenses: [LicenseExpression1](ex/licenseexpression1.md)?
29+
- single artifact under license expression of listed and custom licenses: [LicenseExpression2](ex/licenseexpression2.md)?
30+
- two artifacts under same license expression of listed and custom licenses: [LicenseExpression3](ex/licenseexpression3.md)?
31+
32+
*NOTE: need list of element types required by each licensing use case, specify which artifact examples*
33+
34+
- security use cases to be added here
35+
- build use cases to be added here

0 commit comments

Comments
 (0)