Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: read shortcut fields: documentDescribes and hasFiles #201

Merged
merged 2 commits into from
Mar 6, 2023

Conversation

kzantow
Copy link
Collaborator

@kzantow kzantow commented Mar 4, 2023

The JSON schema has fields documentDescribes and hasFiles for packages. These are not part of the Go data model and are duplicates of using relationships. However, some tools are outputting these fields today and we need to be able to decode them. This PR adds support for decoding these fields and translating them into the appropriate relationships.

Fixes: #166
Fixes: #171

Copy link
Collaborator

@lumjjb lumjjb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super cool implementation! lgtm

func (p *Package) UnmarshalJSON(b []byte) error {
type pkg Package
type extras struct {
HasFiles []common.DocElementID `json:"hasFiles"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh i see this trick to pass the hasFiles up to unexposed fields, this is very cool :)

@kzantow kzantow merged commit 3ccd09f into spdx:main Mar 6, 2023
@kzantow kzantow deleted the fix/read-shortcut-fields branch March 6, 2023 15:07
@puerco
Copy link
Contributor

puerco commented Mar 9, 2023

This is great! Thanks @kzantow 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON readers are missing hasFiles handling Update to add documentDescribes field to follow 2.2.2 spec
3 participants