diff --git a/otc_metadata/services.py b/otc_metadata/services.py index f62ca3c0..95c2492f 100644 --- a/otc_metadata/services.py +++ b/otc_metadata/services.py @@ -115,12 +115,12 @@ class Services(object): def service_types_with_doc_types(self, environment=None): """Retrieve type and title from services and corresponding docs. - As well as a list of all doc_types. + As well as a list of all available doc types with title. :param str environment: Optional service environment. """ service_list = [] - doc_types = [] + docs = [] for service in self.all_services: if not service["service_title"]: @@ -139,8 +139,13 @@ class Services(object): "type": doc["type"] }) - if doc["type"] not in doc_types: - doc_types.append(doc["type"]) + new_doc = { + "type": doc["type"], + "title": doc["title"] + } + type_exists = any(doc_dict["type"] == new_doc["type"] for doc_dict in docs) + if not type_exists: + docs.append(new_doc) service_list.append({ "service_title": service["service_title"], @@ -150,7 +155,7 @@ class Services(object): res = { "services": service_list, - "doc_types": doc_types + "docs": docs } return res