예제 #1
0
    def get_content(self, swagger, base_url, schema_definitions):
        """
        Return all the links in the document, layed out by tag and operationId.
        """
        links_by_tag = dict_type()
        links = []

        for path, path_info in swagger.get('paths', {}).items():
            operations = {
                key: path_info[key]
                for key in path_info if key in METHODS
            }
            for operation, operation_info in operations.items():
                tag = lookup(operation_info, ['tags', 0])
                link = self.get_link(base_url, path, path_info, operation,
                                     operation_info, schema_definitions)
                if link is None:
                    continue

                if tag is None:
                    links.append(link)
                elif tag not in links_by_tag:
                    links_by_tag[tag] = [link]
                else:
                    links_by_tag[tag].append(link)

        sections = [
            Section(name=_simple_slugify(tag),
                    title=tag.title(),
                    content=links) for tag, links in links_by_tag.items()
        ]
        return links + sections
예제 #2
0
 def generate_section(self, routes, name):
     content = self.generate_content(routes)
     return Section(name=name, content=content)