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

Experimental dataset JSON GET API doesn't return multi-valued fields as arrays #9495

Open
vera opened this issue Apr 5, 2023 · 2 comments
Open
Labels
Feature: API GREI 6 Connect Digital Objects Type: Bug a defect User Role: API User Makes use of APIs

Comments

@vera
Copy link
Contributor

vera commented Apr 5, 2023

What steps does it take to reproduce the issue?

  1. Create dataset with multi-valued field, e.g. subject in the citation block
  2. Use experimental GET API to retrieve dataset https://guides.dataverse.org/en/latest/developers/dataset-semantic-metadata-api.html#get-dataset-metadata e.g. GET /api/datasets/42/metadata
  • What happens?

The multi-valued field values are not returned as arrays, e.g. 'subject': 'Medicine, Health and Life Sciences'

Side note, the non-experimental API https://guides.dataverse.org/en/latest/api/native-api.html#get-json-representation-of-a-dataset does not have this bug: {'typeName': 'subject', 'multiple': True, 'typeClass': 'controlledVocabulary', 'value': ['Medicine, Health and Life Sciences']}

  • What did you expect to happen?

The multi-valued field values to be returned as arrays, e.g. 'subject': ['Medicine, Health and Life Sciences']

Which version of Dataverse are you using?

v5.13

Any related open or closed issues to this bug report?

/

Screenshots:

/

@qqmyers
Copy link
Member

qqmyers commented Apr 5, 2023

FWIW: That API (and the ORE export) suppresses using an array when there is only one value, but it does use an array when there is more than one value. The relevant line is

return (valArray.size() != 1) ? valArray : valArray.get(0);
. To change it you'd need to keep track of whether the field allows multiple values or not (since single value fields still shouldn't use an array). Any PR for this should include a release note about the backward incompatibility being introduced.

@pdurbin
Copy link
Member

pdurbin commented Apr 5, 2023

I'm in favor of the predictability of the subject always being an array. We could always put this in new field (rather than changing the field that is sometimes a string an sometimes an array) for backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: API GREI 6 Connect Digital Objects Type: Bug a defect User Role: API User Makes use of APIs
Projects
Status: No status
Development

No branches or pull requests

4 participants