def get(self, request, group_by='app'):
            generator = CustomSchemaGenerator()
            schema = generator.get_schema(request=request)

            if not schema:
                raise exceptions.ValidationError(
                    'The schema generator did not return a schema Document')

            # regroup data according to passed "group_by" param
            _data = schema._data
            if 'api' in _data:
                if group_by == 'version':
                    _data.update(_data['api'])
                else:
                    for app_name in _data['api'].data.keys():
                        _data.update(_data['api'].data[app_name])
                _data.pop('api', None)
                schema._data = _data

            if 'download' in request.GET:
                return download_xls(generator.get_simple_links(request),
                                    file_name='contraxsuite-api',
                                    sheet_name='api')

            return Response(schema)
Esempio n. 2
0
 def export(self, data, source_name, fmt='xlsx'):
     data = pd.DataFrame(data).fillna('')
     data = self.process_export_data(data)
     if fmt == 'xlsx':
         return download_xls(data, file_name=source_name)
     else:
         return download_csv(data, file_name=source_name)