There are cases where /hsapi/resource/ (the endpoint HydroShare.search wraps) returns an authors field that is either None or [<Author>, None, ...]. The current ResourcePreview handles the case when there are no authors (authors: None), however, it does not handle the case when there is None in a list of authors. See the example below:
from hsclient.json_models import ResourcePreview
ResourcePreview(authors=None) # ok
ResourcePreview(authors=[]) # ok
ResourcePreview(authors=[None]) # fails
ResourcePreview(authors=["some author", None]) # fails
In a perfect world, the /hsapi/resource/ endpoint would only return a list of valid authors or the empty list, but for now, I think it is acceptable to implement a solution that covers this case and does not cause a parsing exception.
My proposed solution is to filter the list of authors and remove any None authors. Ill open a PR that adds the functionality and ref it here.
There are cases where
/hsapi/resource/
(the endpointHydroShare.search
wraps) returns anauthors
field that is eitherNone
or[<Author>, None, ...]
. The currentResourcePreview
handles the case when there are no authors (authors: None
), however, it does not handle the case when there isNone
in a list ofauthors
. See the example below:In a perfect world, the
/hsapi/resource/
endpoint would only return a list of valid authors or the empty list, but for now, I think it is acceptable to implement a solution that covers this case and does not cause a parsing exception.My proposed solution is to filter the list of authors and remove any
None
authors. Ill open a PR that adds the functionality and ref it here.