Ejemplo n.º 1
0
    def build_param(self, wadl_param):
        self.logger.debug("Found param: %s" % wadl_param.name)

        param = OrderedDict()
        param['name'] = wadl_param.name
        param['required'] = wadl_param.is_required
        param['in'] = self.style_to_in(wadl_param.style)

        wadl_type = wadl_param.tag.get('type', 'string')
        json_type = self.xsd_to_json_type(wadl_type)
        if json_type is None:
            self.logger.warn("Unknown type: %s for param %s", wadl_type,
                             wadl_param.name)
            if self.autofix:
                self.logger.warn("Using string for %s", wadl_type)
                json_type = "string"
            else:
                json_type = wadl_type
        if isinstance(json_type, dict):
            param.update(json_type)
        else:
            param["type"] = json_type

        if self.autofix:
            if param['in'] == 'body':
                self.logger.warn(
                    "Ignoring body parameter, converting these is not yet supported..."
                )
                return None
            if param['in'] == 'path':
                if param['required'] is not True:
                    self.logger.warn(
                        "Autofix: path parameters must be required in Swagger (%s)",
                        param['name'])
                    param['required'] = True

        if self.options.nodoc is not True:
            if DocHelper.doc_tag(wadl_param) is not None and DocHelper.doc_tag(
                    wadl_param).text is not None:
                description = DocHelper.docbook_to_markdown(
                    DocHelper.doc_tag(wadl_param))
                # Cleanup whitespace...
                description = textwrap.dedent(description)
                param["description"] = folded(description)
        return param
Ejemplo n.º 2
0
    def build_response(self, wadl_response):
        status = wadl_response.tag.attrib['status']
        try:
            description = ' '.join(
                DocHelper.doc_tag(wadl_response).text.split())
        except:
            description = "%s response" % status

        return {"description": folded(description)}
Ejemplo n.º 3
0
    def build_response(self, wadl_response):
        status = wadl_response.tag.attrib['status']
        try:
            description = ' '.join(
                DocHelper.doc_tag(wadl_response).text.split())
        except:
            description = "%s response" % status

        return {
            "description": folded(description)
        }
Ejemplo n.º 4
0
    def build_param(self, wadl_param):
        self.logger.debug("Found param: %s" % wadl_param.name)

        param = OrderedDict()
        param['name'] = wadl_param.name
        param['required'] = wadl_param.is_required
        param['in'] = self.style_to_in(wadl_param.style)

        wadl_type = wadl_param.tag.get('type', 'string')
        json_type = self.xsd_to_json_type(wadl_type)
        if json_type is None:
            self.logger.warn("Unknown type: %s for param %s", wadl_type, wadl_param.name)
            if self.autofix:
                self.logger.warn("Using string for %s", wadl_type)
                json_type = "string"
            else:
                json_type = wadl_type
        if isinstance(json_type, dict):
            param.update(json_type)
        else:
            param["type"] = json_type

        if self.autofix:
            if param['in'] == 'body':
                self.logger.warn("Ignoring body parameter, converting these is not yet supported...")
                return None
            if param['in'] == 'path':
                if param['required'] is not True:
                    self.logger.warn("Autofix: path parameters must be required in Swagger (%s)", param['name'])
                    param['required'] = True

        if self.options.nodoc is not True:
            if DocHelper.doc_tag(wadl_param) is not None and DocHelper.doc_tag(wadl_param).text is not None:
                description = DocHelper.docbook_to_markdown(
                    DocHelper.doc_tag(wadl_param))
                # Cleanup whitespace...
                description = textwrap.dedent(description)
                param["description"] = folded(description)
        return param
Ejemplo n.º 5
0
 def build_summary(self, documented_wadl_object):
     return DocHelper.doc_tag(documented_wadl_object).attrib['title']
Ejemplo n.º 6
0
 def build_summary(self, documented_wadl_object):
     return DocHelper.doc_tag(documented_wadl_object).attrib['title']