Harmonize handling of missing information in responses
Closed this issue · 3 comments
The information that a value is not available is not consistent across the API JSON responses and even not with a single endpoint, e.g.
- If a digital source URL "sourceUrl" is not available, the endpoint
/corpora/{corpusname}
returns an empty string. - If there is no information on a year (written,printed,premiered,normalized), null is returned.
I am working on marshmallow schemas to validate the response against. In case of the field "sourceUrl" I expected the return value to be a valid URL. This I can check within the schema:
sourceUrl = fields.Url(allow_none=True)
I set allow_none to True
because I figured, that if there are no dates, the value of the respective field is null, so this works:
yearWritten = fields.Str(allow_none=True)
I expected, that if no URL is available, it would also return Null/None, but
sourceUrl = fields.Url(allow_none=True)
throws an error:
ValidationError: {'dramas': {1: {'sourceUrl': ['Not a valid URL.']}
In CalDraCor, for example, you find:
"wikidataId": null,
"yearPremiered": null,
"source": "",
"yearWritten": "1681",
"id": "cal000152",
"title": "La divina Filotea",
"sourceUrl": "",
I am putting the schemas here: https://github.com/dracor-org/dracor-schema/blob/api_response_schemas/api_responses/dracor_api_response_schemas.py
and use this notebook to check:
https://github.com/dracor-org/dracor-schema/blob/api_response_schemas/api_responses/test_dracor_api_response_schemas.ipynb
In 2cb885e the string properties source
and sourceUrl
have been replaced by and object source
with the properties name
and url
. If a play has only partial or no source information at all the respective properties are currently omitted.
@ingoboerner Does this solution work with the marshmallow schemas? If so, I'd suggest to close this issue. If there are other properties showing the same problem, let's open a new issue explicitly naming the properties in question.
Closing this. Please open a new issue if there is a need for or plan of how to further harmonise this.