Return the swagger-formatted method descriptions
482724
def get_resource_operations(cls):
        ''''''
        operations = []
        for http, callback in cls.implemented_methods.items():
            # Parse docstring
            summary, notes = utils.parse_docstring(callback)
            # Parse return annotations
            responses = utils.parse_return_annotation(callback)
            ok_result_model = responses[200]['responseModel']
            operations.append({
                'method': http,
                'nickname': callback.__name__,
                'type': ok_result_model,
                'parameters': cls.parse_signature(callback),
                'summary': summary.strip(),
                'notes': notes.strip(),
                'responseMessages': list(responses.values())
            })
        return operations
376042
def _format_method_nodes(self, task_method, modulename, classname):
        
        methodname = task_method.__name__
        fullname = '.'.join((modulename, classname, methodname))

        # The signature term
        signature = Signature(task_method, bound_method=True)
        desc_sig_node = self._format_signature(
            signature, modulename, classname, fullname, 'py:meth')

        # The content is the one-sentence summary.
        content_node = desc_content()
        content_node += self._create_doc_summary(task_method, fullname,
                                                 'py:meth')

        desc_node = desc()
        desc_node['noindex'] = True
        desc_node['domain'] = 'py'
        desc_node['objtype'] = 'method'
        desc_node += desc_sig_node
        desc_node += content_node
        return desc_node
672625
def resource_listing(cls, request) -> [(200, 'Ok', ResourceListingModel)]:
        ''''''
        apis = [api.get_swagger_fragment() for api in Api if not api.private]
        Respond(200, {
            'apiVersion': cls.api.version,
            'swaggerVersion': cls.api.swagger_version,
            'apis': apis
        })
1326272
function getMethodHtml(method) {
    var params = method.getParams();

    return [
        '<h3>', method.getName(), '</h3>',
        method.getOption('executeOnServerOnly') &&
            '<span class="label label-primary" style="font-size:0.5em;vertical-align:middle">server only</span>',
        '<p>', method.getDescription(), '</p>',
         Object.keys(params).length &&
            [
                '<table class="table table-bordered table-condensed">',
                    '<thead>',
                        '<tr>',
                            '<th class="col-md-2">Name</th>',
                            '<th class="col-md-2">Type</th>',
                            '<th>Description</th>',
                        '</tr>',
                    '</thead>',
                    '<tbody>',
                        Object.keys(params).map(function (key) {
                            return getMethodParamHtml(key, params[key]);
                        }).join(''),
                    '</tbody>',
                '</table>'
            ].join('')
    ].filter(Boolean).join('');
}
1337337
def get_method_name(resource, method_type):
        
        return '{}_{}'.format(method_type.lower(), resource.Meta.name.lower())
348593
def get_arg_descriptions_from_docstring(cls, obj):
    """"""

    ret = OrderedDict()
    name = ''
    doc = obj.__doc__ or ''
    lines = [s.strip() for s in doc.split('\n')]
    stanza_first_line_re = cls._get_stanza_first_line_re()
    for line in lines:
      m = stanza_first_line_re.match(line)
      if m and m.group(1) == 'param':
        # If first line of a parameter description, set name and description.
        name, description = m.group(3, 4)
        ret[name] = description
      elif m and m.group(1) != 'param':
        # If first line of a description of an item other than a parameter, clear name.
        name = ''
      elif name and line:
        # If subsequent line of a parameter description, add to existing description (if any) for
        # that parameter.
        ret[name] += (' ' + line) if ret[name] else line
      # Ignore subsequent lines of descriptions of items other than parameters.
    return ret
1192344
def get_include_methods(request):
    
    methods = request.get("include_methods", "")
    include_methods = [
        x.strip() for x in methods.split(",") if x.strip()]
    return include_methods
1001565
def get_swagger_fragment(cls):
        ''''''
        if cls.__swagger_fragment:
            return cls.__swagger_fragment
        cls.__swagger_fragment = {
            'path': cls.endpoint_path.replace('<', '{').replace('>', '}'),
            'description': cls.description,
            'operations': cls.get_resource_operations(),
        }
        return cls.__swagger_fragment
661963
def get_swagger_operation(self, context=default_context):
        
        consumes = produces = context.contenttype_serializers.keys()
        parameters = get_swagger_parameters(self.parameters, context)
        responses = {
            "400": Response(
                {
                    "description": "invalid input received",
                    "schema": Schema(
                        {
                            "title": "FailureObject",
                            "type": "object",
                            "properties": {
                                "success": {"type": "boolean"},
                                "result": {"type": "string"},
                            },
                            "required": ["success", "result"],
                        }
                    ),
                }
            )
        }

        for code, details in self.response_types.items():
            responses[str(code)] = details.swagger_definition(context)

        return Operation(
            {
                "summary": self.summary,
                "description": self.description,
                "consumes": consumes,
                "produces": produces,
                "parameters": parameters,
                "responses": responses,
                "operationId": self.raw_func.__name__,
                "tags": self.tags,
            }
        )
604850
def to_dict(self):
        """"""
        result = {}

        for attr, _ in six.iteritems(self.swagger_types):
            value = getattr(self, attr)
            if isinstance(value, list):
                result[attr] = list(map(
                    lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
                    value
                ))
            elif hasattr(value, "to_dict"):
                result[attr] = value.to_dict()
            elif isinstance(value, dict):
                result[attr] = dict(map(
                    lambda item: (item[0], item[1].to_dict())
                    if hasattr(item[1], "to_dict") else item,
                    value.items()
                ))
            else:
                result[attr] = value
        if issubclass(Payment, dict):
            for key, value in self.items():
                result[key] = value

        return result
716677
def get_routing_tuples(cls):
        ''''''
        for callback in cls.callbacks:
            ep_name = '{}.{}'.format(cls.api.__name__, callback.__name__)
            yield (Rule(cls.endpoint_path,
                        endpoint=ep_name,
                        methods=callback.swagger_ops),
                   callback)
744309
def build_method_summary_list(path_prefix = "")
      collect_methods unless @methods

      @methods.sort.map do |meth|
        {
          "name" => CGI.escapeHTML(meth.name),
          "aref" => "##{meth.aref}"
        }
      end
    end
498661
def _get_method_kwargs(self):
        
        method_kwargs = {
            'user': self.user,
            'content_type': self.ctype,
            'object_id': self.content_object.pk,
        }
        return method_kwargs
387493
def profiling_request_formatter(view, context, model, name):
    """"""
    document = model[name]
    return Markup(
        ''.join(
            [
                '<p class="profiling-request">',
                '<a href="{}">'.format(document.get_admin_url(_external=True)),
                http_method_formatter(view, context, document, 'method'),
                '&nbsp;',
                document.path,
                '</a>',
                '</p>',
            ]
        )
    )
313433
def swaggerify(app, parse_module_info=True, **kwargs):
    

    async def swagger_handler(request):
        """
        Request handler to serve swagger json config for given app
        """
        return web.json_response(app["_swagger_config"])

    # Populate configs for paths from app routes
    paths_config = defaultdict(dict)
    for r in app.router.routes():
        # Title and description are retrieved from docstring of a handler
        docstrings = parse_docstring(r.handler.__doc__ or "")
        if len(docstrings["title"]) > 120:
            # TODO: logging
            docstrings["title"] = docstrings["title"][:120]

        # Some information is just hardcoded as we have strict requirements
        # to input and output format of ws endpoints
        desc = {
            "summary": docstrings["title"],
            "description": docstrings["description"],
            "consumes": ["application/json"],
            "produces": ["application/json"],
            "responses": {
                "400": {"description": "Request is malformed or invalid"},
                "500": {"description": "Response malformed or invalid"},
                "405": {"description": "Method is not allowed"},
            }
        }

        if hasattr(r.handler, "_request_schema"):
            desc["parameters"] = [{
                "in": "body",
                "name": "body",
                "required": True,
                "schema": r.handler._request_schema
            }]
        else:
            desc["parameters"] = [{
                "in": "body",
                "name": "body"
            }]

        if hasattr(r.handler, "_swg_input"):
            desc["parameters"][0].update(r.handler._swg_input)

        if hasattr(r.handler, "_response_schema"):
            desc["responses"]["200"] = {
                # TODO: think how to override
                "description": "Results of the request",
                "schema": r.handler._response_schema
            }
        else:
            desc["responses"]["200"] = {
                "description": "Results of the request"
            }

        if hasattr(r.handler, "_swg_output"):
            desc["responses"]["200"].update(r.handler._swg_output)

        if hasattr(r.handler, "_swg_info"):
            desc.update(r.handler._swg_info)

        paths_config[r._resource._path][r.method.lower()] = desc

    # Populate complete config

    # Get optional information that overrides info part of the config
    swagger_config_info = kwargs.pop("info", {})
    # Some sane defaults
    swagger_config = {
        "swagger": "2.0",
        "schemes": ["http"],
        "paths": paths_config
    }

    # That can be overriden with kwargs
    swagger_config.update(kwargs)

    # Some sane defaults for info part of the config
    swagger_config_info_default = {
        "version": "1.0.0",
    }

    # Which we now can try to extend using introspection, docstrings and
    # global variables of the main module of the app
    if parse_module_info:
        try:
            caller = inspect.currentframe().f_back
            mod = sys.modules[caller.f_globals['__name__']]

            # Try to pull information from docstrings
            swagger_config_info_default.update(parse_docstring(mod.__doc__))

            # As well as global variables
            if hasattr(mod, "__version__"):
                swagger_config_info_default["version"] = mod.__version__

            if hasattr(mod, "__license__"):
                swagger_config_info_default["license"] = {
                    "name": mod.__license__
                    # TODO: add urls for well-known licenses
                }

            # And map it to swagger definitions
            contact_info = {}
            if hasattr(mod, "__author__"):
                contact_info["name"] = mod.__author__
            if hasattr(mod, "__maintainer__"):
                contact_info["name"] = mod.__maintainer__
            if hasattr(mod, "__email__"):
                contact_info["email"] = mod.__email__

            if contact_info:
                swagger_config_info_default["contact"] = contact_info
        except:
            # TODO: logging
            pass

    swagger_config["info"] = swagger_config_info_default

    # override it with data from kwargs["info"]
    swagger_config["info"].update(swagger_config_info)

    app["_swagger_config"] = swagger_config

    app.router.add_route("GET", "/swagger.json", swagger_handler)

    return app
666889
private static Map<RouteDefinition, Method> getDefinitions(Class clazz) {

		Assert.notNull(clazz, "Missing class with JAX-RS annotations!");

		// base
		RouteDefinition root = new RouteDefinition(clazz);

		// go over methods ...
		Map<RouteDefinition, Method> output = new LinkedHashMap<>();
		for (Method method : clazz.getMethods()) {

			if (isRestCompatible(method)) { // Path must be present

				try {
					RouteDefinition definition = new RouteDefinition(root, method);
					output.put(definition, method);
				}
				catch (IllegalArgumentException e) {

					throw new IllegalArgumentException(getClassMethod(clazz, method) + " - " + e.getMessage());
				}
			}
		}

		return output;
	}
912874
def asdict(self):
        
        return {
            "methods": {m.name: m.asdict() for m in self.methods},
            "protocols": self.protocols,
            "notifications": {n.name: n.asdict() for n in self.notifications},
        }