diff --git a/jpndlpy/client.py b/jpndlpy/client.py index af96365..68eb3c8 100644 --- a/jpndlpy/client.py +++ b/jpndlpy/client.py @@ -86,15 +86,17 @@ def search_text( items : json 複数の図書情報 """ - data, errs = self.validation_serializer(kwargs) - if not errs: + if not errs and len(data) > 1: self.response = self.get(data) return self.response else: - erros_mes = ''.join( - [key + ' : ' + errs[key][0] + '\n' for key in errs] - ) + if errs: + erros_mes = ''.join( + [key + ' : ' + errs[key][0] + '\n' for key in errs] + ) + else: + erros_mes = 'Missing data.' raise Exception(erros_mes) def validation_serializer(self, kwargs)->tuple: diff --git a/jpndlpy/response.py b/jpndlpy/response.py index deae18f..f918a1d 100644 --- a/jpndlpy/response.py +++ b/jpndlpy/response.py @@ -103,6 +103,8 @@ def extract_items(self, items): ''' item情報を抽出する ''' + if type(items) is not list: + items = [items] for item in items: """ Entity Object """ item_object = ItemEntity() diff --git a/jpndlpy/validator.py b/jpndlpy/validator.py index 9643080..7fc3236 100644 --- a/jpndlpy/validator.py +++ b/jpndlpy/validator.py @@ -12,7 +12,7 @@ class SearchTextSchema(Schema): dpid = fields.String() dpgroupid = fields.String() - title = fields.String(required=True) + title = fields.String() creator = fields.String() digitized_publisher = fields.String() ndc = fields.String()