def get(self, request, *args, **kwargs): path = request.path path = path[:request.path.find('/api-docs')] apis = self.get_apis(path) generator = DocumentationGenerator(for_user=request.user) info = copy.deepcopy(rfs.SWAGGER_SETTINGS.get('info', { 'contact': {}, 'description': '', 'license': {'name': ''}, 'termsOfService': '', 'title': '', 'version': '', })) if 'version' not in info or info['version'] == '': matches = version_re.search(path) if matches is not None: info['version'] = matches.groups()[0] return Response({ 'swagger': '2.0', 'basePath': path, 'paths': generator.generate(apis), 'definitions': generator.get_models(apis), 'info': info, 'tags': rfs.SWAGGER_SETTINGS.get('tags', []) })
def get(self, request, path): apis = self.get_api_for_resource(path) generator = DocumentationGenerator() return Response({ 'apis': generator.generate(apis), 'models': generator.get_models(apis), 'basePath': self.api_full_uri, })
def get(self, request, path): apis = self.get_api_for_resource(path) generator = DocumentationGenerator() return Response({ 'apis': generator.generate(apis), 'models': generator.get_models(apis), 'basePath': self.api_full_uri.rstrip('/'), })
def get(self, request, path, *args, **kwargs): apis = self.get_apis_for_resource(path) generator = DocumentationGenerator(for_user=request.user) return Response({ 'apiVersion': rfs.SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', 'basePath': self.api_full_uri.rstrip('/'), 'resourcePath': '/' + path, 'apis': generator.generate(apis), 'models': generator.get_models(apis), })
def get(self, request, path): apis = self.get_api_for_resource(path) generator = DocumentationGenerator() return Response({ 'apiVersion': SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', "resourcePath": "/{}".format(path), 'apis': generator.generate(apis), 'models': generator.get_models(apis), 'basePath': self.api_full_uri.rstrip('/'), })
def get(self, request, path): apis = self.get_api_for_resource(path) generator = DocumentationGenerator() return Response({ 'apiVersion': SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', 'basePath': get_full_base_path(request), 'resourcePath': path, 'apis': generator.generate(apis), 'models': generator.get_models(apis), })
def get(self, request, path): apis = self.get_api_for_resource(path) generator = DocumentationGenerator() return Response({ 'apiVersion': SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', "resourcePath": "/{}".format(path), 'apis': generator.generate(apis), 'models': generator.get_models(apis), 'basePath': self.api_full_uri.rstrip('/'), })
def get(self, request, path): apis = self.get_api_for_resource(path) generator = DocumentationGenerator() return Response({ 'apiVersion': rfs.SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', 'basePath': self.api_full_uri.rstrip('/'), 'resourcePath': '/' + path, 'apiCustomHeaders': rfs.SWAGGER_SETTINGS.get('custom_headers', {}), 'apis': generator.generate(apis), 'models': generator.get_models(apis), })
def get(self, request, path, *args, **kwargs): apis = self.get_apis_for_resource(path) generator = DocumentationGenerator(for_user=request.user) return Response( { "apiVersion": rfs.SWAGGER_SETTINGS.get("api_version", ""), "swaggerVersion": "1.2", "basePath": self.api_full_uri.rstrip("/"), "resourcePath": "/" + path, "apis": generator.generate(apis), "models": generator.get_models(apis), } )
def get_api_declaration(self, path, urlconf): api_full_uri = SWAGGER_SETTINGS.get('api_full_uri') apis = self.get_api_for_resource(path, urlconf=urlconf) generator = DocumentationGenerator() return { 'apiVersion': SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', 'basePath': api_full_uri.rstrip('/'), 'resourcePath': '/' + path, 'apis': generator.generate(apis), 'models': generator.get_models(apis), }
def get_api_declaration(self, path): api_full_uri = SWAGGER_SETTINGS.get('api_full_uri') apis = self.get_api_for_resource(path) generator = DocumentationGenerator() return { 'apiVersion': SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', 'basePath': api_full_uri.rstrip('/'), 'resourcePath': '/' + path, 'apis': generator.generate(apis), 'models': generator.get_models(apis), }
def get(self, request, path): apis = self.get_api_for_resource(path) apis = [api for api in apis if self.handle_resource_access(request, api['pattern'])] generator = DocumentationGenerator() return Response({ 'apiVersion': rfs.SWAGGER_SETTINGS.get('api_version', ''), 'swaggerVersion': '1.2', 'basePath': self.api_full_uri.rstrip('/'), 'resourcePath': '/' + path, 'apis': generator.generate(apis), 'models': generator.get_models(apis), })
def get(self, request, *args, **kwargs): apis = [] resources = self.get_resources() for path in resources: apis.append( self.get_api_for_resource(path) ) generator = DocumentationGenerator() tags = {} paths = {} # TODO: reformat the contents that come from generator, don't # post-process it here. for path in generator.generate(apis): mypath = {} try: tag = path['path'].split('/')[2] except IndexError: tag = None for operation in path.get('operations', []): method = operation['method'].lower() mypath[method] = { 'description': operation['notes'], 'summary': operation['summary'], 'produces': [ 'application/json' ], 'responses': { 'default': { 'description': 'Unknown', # 'schema': { # '$ref': "#/definitions/ErrorModel" # } }, 200: { 'description': 'Success' } } } if tag: mypath[method]["tags"] = [tag] if tag and tag not in tags: tags[tag] = { 'name': tag, 'description': tag } paths[path['path']] = mypath tag_list = [] for tag in tags: tag_list.append(tag) definitions = {} parameters = {} responses = {} securityDefinitions = {} security = [] tags = [] externalDocs = {} full_uri = self.api_full_uri.rstrip('/').split('/') scheme = full_uri[0].rstrip(':') host = '/'.join(full_uri[2:3]) basePath = "/" + '/'.join(full_uri[3:]) return Response({ 'swagger': '2.0', 'info': rfs.SWAGGER_SETTINGS['info'], 'host': host, 'basePath': basePath, 'schemes': [scheme], 'consumes': ['application/json'], 'produces': ['application/json'], 'paths': paths, 'definitions': definitions, 'parameters': parameters, 'responses': responses, 'securityDefinitions': securityDefinitions, 'security': security, 'tags': tag_list, 'externalDocs': externalDocs # 'apiVersion': rfs.SWAGGER_SETTINGS.get('api_version', ''), # 'swaggerVersion': '2.0', # 'apis': generator.generate(apis), # 'models': generator.get_models(apis), })
def get(self, request, *args, **kwargs): apis = [] resources = self.get_resources() for path in resources: apis.append( self.get_api_for_resource(path) ) generator = DocumentationGenerator() #parameters = generator.get_models(apis) tags = {} paths = {} # TODO: reformat the contents that come from generator, don't # post-process it here. for path in generator.generate(apis): mypath = {} try: tag = path['path'].split('/')[2] except IndexError: tag = None for operation in path.get('operations', []): # { # 'parameters': [ # {'name': 'cigar', 'paramType': 'form', 'required': True, 'type': 'string', 'description': ''}, # {'name': 'jambalaya', 'paramType': 'form', 'required': True, 'type': 'string', 'description': ''} # ], # 'nickname': u'Drop_Cigar_In_Jambalaya_POST', # 'notes': u'<p>Make a cigar jambalaya</p>', # 'summary': u'Make a cigar jambalaya', # 'type': 'CigarJambalayaSerializer', # 'method': 'POST' # }", responses = {} response_messages = operation.get('responseMessages', []) if len(response_messages) == 0: responses['default'] = {'description': 'Unknown'} for response in response_messages: responses[response['code']] = { 'description': response['message'] } # TODO : this is almost certainly wrong if response['responseModel']: response[response['code']]['schema'] = { "$ref": response['responseModel'] } method = operation['method'].lower() mypath[method] = { #'debug': operation, 'description': operation['notes'], 'summary': operation['summary'], 'operationId': operation['nickname'], 'produces': [ 'application/json' ], 'parameters': operation.get('parameters', []), 'responses': responses } if tag: mypath[method]["tags"] = [tag] if tag and tag not in tags: tags[tag] = { 'name': tag, 'description': tag } paths[path['path']] = mypath tag_list = [] for tag in tags: tag_list.append(tag) definitions = {} securityDefinitions = {} security = [] externalDocs = {} full_uri = self.api_full_uri.rstrip('/').split('/') scheme = full_uri[0].rstrip(':') host = '/'.join(full_uri[2:3]) basePath = "/" + '/'.join(full_uri[3:]) return Response({ 'swagger': '2.0', 'info': rfs.SWAGGER_SETTINGS['info'], 'host': host, 'basePath': basePath, 'schemes': [scheme], 'consumes': ['application/json'], 'produces': ['application/json'], 'paths': paths, 'definitions': definitions, #'parameters': parameters, 'responses': {}, 'securityDefinitions': securityDefinitions, 'security': security })