Skip to content

Make creators attribute mandatory in JSON schema#660

Closed
dmholtz wants to merge 1 commit into
spdx:development/v2.2.2from
dmholtz:development/v2.2.2
Closed

Make creators attribute mandatory in JSON schema#660
dmholtz wants to merge 1 commit into
spdx:development/v2.2.2from
dmholtz:development/v2.2.2

Conversation

@dmholtz

@dmholtz dmholtz commented Apr 20, 2022

Copy link
Copy Markdown

In the JSON schema, the creators field of createrInfo was not listed as a required although the latest specification denotes the creator as mandatory (cp. 2.8.3 Cardinality, p. 19, SPEC).

@goneall

goneall commented Apr 20, 2022

Copy link
Copy Markdown
Member

I was assuming the "minItems" : 1 in the creators property provided the same validation of required.

After thinking about this, I am likely wrong in this assumption and will need to add any list with a minimum number of elements >=1 to the required list of properties.

@dmholtz let me know if agree my old assumption was wrong.

@dmholtz

dmholtz commented Apr 20, 2022

Copy link
Copy Markdown
Author

Thank you very much for the quick response!

In JSON schema, setting "minItems" : 1 has slightly different semantics: It means, that we must not provide an empty array for the creators field. However, omitting the creators property is perfectly fine with this schema. Example:

"creationInfo" : {
    "created" : "2010-01-29T18:30:22Z"
}

However, an empty creators array is not allowed:

"creationInfo" : {
    "created" : "2010-01-29T18:30:22Z"
    "creators": []
}

I think the idea of the specification is that a creator is always listed, and my PR should fix this. Nonetheless, we still need "minitems:" 1 to avoid empty lists.

Signed-off-by: dmholtz <56723830+dmholtz@users.noreply.github.com>
@dmholtz
dmholtz force-pushed the development/v2.2.2 branch from 9f2019d to eeef8e1 Compare April 20, 2022 18:58
@goneall

goneall commented Apr 20, 2022

Copy link
Copy Markdown
Member

@dmholtz Thanks for the detailed answer.

The JSON file is generated from the RDF OWL document. I'll fix the generator code to add the required parameter. This will probably result in a few more changes.

I'll probably just amend PR #659 to include this fix as well once it is regenerated.

Let's leave this PR open to track the issue until it is resolved in the other PR.

@dmholtz

dmholtz commented Apr 21, 2022

Copy link
Copy Markdown
Author

@goneall Thanks, I'll leave the PR open. Of course, combining both fixes is more efficient. From skimming the project, I didn't notice that schema has been generated :)

@kestewart kestewart added this to the 2.2.2 milestone Apr 26, 2022
@kestewart

Copy link
Copy Markdown
Contributor

Other has been merged. Closing.

@kestewart kestewart closed this Apr 26, 2022
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.

3 participants