Пример #1
0
def generate_api_schema(swagger_base_spec):
    # type: (Dict[str, Union[str, List[str]]]) -> JSON
    """
    Return JSON Swagger specifications of Cowbird REST API.

    Uses Cornice Services and Schemas to return swagger specification.

    :param swagger_base_spec: dictionary that specifies the 'host' and list of HTTP 'schemes' to employ.
    """
    generator = CorniceSwagger(get_services())
    # function docstrings are used to create the route's summary in Swagger-UI
    generator.summary_docstrings = True
    generator.default_security = get_security
    swagger_base_spec.update(SecurityDefinitionsAPI)
    generator.swagger = swagger_base_spec
    json_api_spec = generator.generate(title=TitleAPI,
                                       version=__meta__.__version__,
                                       info=InfoAPI)
    for tag in json_api_spec["tags"]:
        tag["description"] = TAG_DESCRIPTIONS[tag["name"]]
    return json_api_spec
Пример #2
0
def openAPI_spec(request):
    my_generator = CorniceSwagger(services=get_services())
    my_generator.summary_docstrings = True
    return my_generator.generate('Catalog Manager', '1.0.0')