Exemplo n.º 1
0
    def get(self, request):
        links = {}
        for path in NotificationsDocs.get_types():
            links.update(NotificationsDocs.generate_notifications_docs(path))

        schema = coreapi.Document(url=self.request.build_absolute_uri(), title="Notifications Docs", content=links)
        return Response(schema)
Exemplo n.º 2
0
    def test_document_with_link_named_data(self):
        """
        Ref #5395: Doc's `document.data` would fail with a Link named "data".
            As per #4972, use templatetag instead.
        """
        document = coreapi.Document(title='Data Endpoint API',
                                    url='https://api.example.org/',
                                    content={
                                        'data':
                                        coreapi.Link(
                                            url='/data/',
                                            action='get',
                                            fields=[],
                                            description='Return data.')
                                    })

        factory = APIRequestFactory()
        request = factory.get('/')

        renderer = DocumentationRenderer()

        html = renderer.render(document,
                               accepted_media_type="text/html",
                               renderer_context={"request": request})
        assert '<h1>Data Endpoint API</h1>' in html
Exemplo n.º 3
0
async def get_users(request: web.Request) -> web.Response:
    """View for GET /users/, just describes that a POST is possible.
    """
    hostname = request.app["settings"]["server"]["hostname"]
    return serialize(
        request,
        coreapi.Document(
            url=f"{hostname}/users/",
            title="Users",
            content={
                "users": [],
                "register_user":
                coreapi.Link(
                    action="post",
                    title="Register a new user",
                    description="POSTing to this endpoint creates a new user",
                    fields=[
                        coreapi.Field(name="username", required=True),
                        coreapi.Field(name="password", required=True),
                        coreapi.Field(name="email", required=True),
                    ],
                ),
            },
        ),
    )
Exemplo n.º 4
0
    def test_encode_generates_swagger_object_when_given_valid_document(self):
        expected = {'fizz': 'buzz'}
        with patch('rest_framework_swagger.renderers.generate_swagger_object',
                   return_value={'fizz': 'buzz'}):
            result = self.sut(coreapi.Document())

        self.assertEqual(force_bytes(json.dumps(expected)), result)
Exemplo n.º 5
0
def schema_view(request):
    # print("---inside schema view-----")
    # noinspection PyArgumentList
    schema = coreapi.Document(
        title='Your Title',
        url='Your host url',
        content={
            'search':
            coreapi.Link(
                url='/search/',
                action='get',
                fields=[
                    coreapi.Field(name='from',
                                  required=True,
                                  location='query',
                                  description='City name or airport code.'),
                    coreapi.Field(name='to',
                                  required=True,
                                  location='query',
                                  description='City name or airport code.'),
                    coreapi.Field(
                        name='date',
                        required=True,
                        location='query',
                        description='Flight date in "YYYY-MM-DD" format.')
                ],
                description='Return flight availability and prices.')
        })
    # schema = generator.get_schema(request)
    return response.Response(schema)
Exemplo n.º 6
0
    def test_encode_adds_extra_data_provided_to_swagger_object(self):
        expected = {'foo': 'bar'}
        with patch('rest_framework_swagger.renderers.generate_swagger_object',
                   return_value={}):
            result = self.sut(coreapi.Document(), **expected)

        self.assertEqual(force_bytes(json.dumps(expected)), result)
Exemplo n.º 7
0
async def get_forgotten_passwords(request: web.Request) -> web.Response:
    """Get forgotten password view, just describes that a POST is possible.
    """
    hostname = request.app["settings"]["server"]["hostname"]
    return serialize(
        request,
        coreapi.Document(
            url=f"{hostname}/forgotten-passwords/",
            title="Forgotten password management",
            content={
                "reset-password":
                coreapi.Link(
                    action="post",
                    title="",
                    description="""
                        POSTing to this endpoint subscribe for a forgotten password
                    """,
                    fields=[
                        coreapi.Field(name="login"),
                        coreapi.Field(name="email")
                    ],
                )
            },
        ),
    )
Exemplo n.º 8
0
def schema_view(request):
    schema = coreapi.Document(
        title='Text recognition API',
        content={
            'api': {
                'run_tesseract': coreapi.Link(
                    title='Image',
                    url='/api/ocr/',
                    action='post',
                    fields=[
                        coreapi.Field(
                            name='image',
                            required=True,
                            location="form",
                            description='Upload image',
                            type='file',
                        )
                    ],
                    encoding="multipart/form-data",
                    description='Run tesseract algorithm'
                )
            }
        },
        description='API document'
    )

    return response.Response(schema)
Exemplo n.º 9
0
 def setUp(self):
     self.document = coreapi.Document(
         title='Example API',
         url='https://www.example.com/',
         description='Example description.',
     )
     self.swagger = generate_swagger_object(self.document)
Exemplo n.º 10
0
 def setUp(self):
     self.path = '/users/'
     self.document = coreapi.Document(
         content={
             'users': {
                 'create': coreapi.Link(action='post', url=self.path),
                 'list': coreapi.Link(action='get', url=self.path)
             }
         })
     self.swagger = generate_swagger_object(self.document)
Exemplo n.º 11
0
    def test_get_openapi_specification(self, json_mock, codec_mock):
        """
        Asserts that the returned value is a Python representation
        of the OpenAPICodec's `dump` method.
        """
        data = coreapi.Document()
        self.sut.get_openapi_specification(data)

        codec_mock.assert_called_once_with(data)
        json_mock.assert_called_once_with(codec_mock.return_value)
Exemplo n.º 12
0
    def test_render_encodes_customizations(self, encode_mock):
        data = coreapi.Document()
        renderer_context = {
            'request': MagicMock(),
            'response': MagicMock(status_code=200)
        }
        with patch.object(self.sut, 'get_customizations') as mock:
            self.sut.render(data, renderer_context=renderer_context)

        encode_mock.assert_called_once_with(data, **mock.return_value)
Exemplo n.º 13
0
def test_reload(monkeypatch):
    def mockreturn(self, request):
        return MockResponse(b'{"_type": "document", "example": 123}')

    monkeypatch.setattr(requests.Session, 'send', mockreturn)

    client = coreapi.Client()
    doc = coreapi.Document(url='http://example.org')
    doc = client.reload(doc)
    assert doc == {'example': 123}
Exemplo n.º 14
0
 def setUp(self):
     self.path = '/users'
     self.document = coreapi.Document(
         content={
             'users': {
                 'create': coreapi.Link(action='post', url=self.path),
                 'list': coreapi.Link(action='get', url=self.path)
             }
         })
     self.sut = codecs.DocumentToSwaggerConverter(self.document) \
         ._get_paths_object()
Exemplo n.º 15
0
def test_corejson_renderer():
    doc = coreapi.Document(title='Example', content={'hello': 'world'})

    renderer = corejson_renderer()
    assert renderer(
        doc
    ) == b'{"_type":"document","_meta":{"title":"Example"},"hello":"world"}'

    renderer = corejson_renderer(verbose=True)
    assert renderer(
        doc
    ) == b'{\n    "_type": "document",\n    "_meta": {\n        "title": "Example"\n    },\n    "hello": "world"\n}'
Exemplo n.º 16
0
        def decorator(func):
            endpoint = options.pop('endpoint', func.__name__)
            func.link = get_link(url, method, func)

            if not exclude_from_schema:
                if tag:
                    if tag not in self.links:
                        self.links[tag] = {}
                    self.links[tag][endpoint] = func.link
                else:
                    self.links[endpoint] = func.link
                self.schema = coreapi.Document(title=self.title,
                                               content=self.links)

            def wrapper(request, response, **params):
                for field in func.link.fields:
                    if field.location == 'form':
                        if field.name in request.data:
                            params[field.name] = request.data[field.name]
                    elif field.location == 'query':
                        if field.name in request.params:
                            params[field.name] = request.params[field.name]
                    elif field.location == 'body':
                        params[field.name] = request.data

                if renderers is not None:
                    request.renderers = renderers
                if parsers is not None:
                    request.parsers = parsers
                if authenticators is not None:
                    request.authenticators = authenticators

                if permissions is not None:
                    check_permissions(request, permissions)

                data = func(**params)

                # TODO: Handle case where APIResponse is returned.
                content, content_type = render(request, data)
                if content_type is not None:
                    response.set_header('Content-Type', content_type)
                response.body = content

            # Setup the app routing each time `@app.<method>()` is called.
            if url not in self._registered:
                self._registered[url] = {}
            self._registered[url][method] = wrapper
            self._router._roots = []
            self._setup()
            return func
Exemplo n.º 17
0
    def get(self, request):
        links_set = dict(self.unprotected_links)

        if request.user.is_superuser:
            for links_group_key in self.protected_links:
                if links_group_key in links_set:
                    links_set[links_group_key] = dict(
                        links_set[links_group_key])
                else:
                    links_set[links_group_key] = {}
                links_set[links_group_key].update(
                    self.protected_links[links_group_key])

        schema = coreapi.Document(title='Example API', content=links_set)
        return Response(schema)
Exemplo n.º 18
0
        def decorator(func):
            endpoint = options.pop('endpoint', func.__name__)
            # Convert a Flask URL string to a URI templated string.
            url = _rule_to_url(rule)
            # Construct a CoreAPI `Link` object that refers to the view function.
            func.link = get_link(url, method, func)

            if not exclude_from_schema:
                if tag:
                    if tag not in self.links:
                        self.links[tag] = {}
                    self.links[tag][endpoint] = func.link
                else:
                    self.links[endpoint] = func.link
                self.schema = coreapi.Document(title=self.title,
                                               content=self.links)

            def wrapper(**params):
                for field in func.link.fields:
                    if field.location == 'form':
                        if field.name in request.data:
                            params[field.name] = request.data[field.name]
                    elif field.location == 'query':
                        if field.name in request.args:
                            params[field.name] = request.args[field.name]
                    elif field.location == 'body':
                        params[field.name] = request.data

                if renderers is not None:
                    request.renderers = renderers
                if parsers is not None:
                    request.parsers = parsers
                if authenticators is not None:
                    request.authenticators = authenticators

                if permissions is not None:
                    check_permissions(request, permissions)

                return func(**params)

            self.add_url_rule(rule,
                              endpoint,
                              wrapper,
                              methods=[method],
                              **options)
            return func
Exemplo n.º 19
0
def get_custom_schema(title=None,
                      url=None,
                      description=None,
                      urlconf=None,
                      renderer_classes=None,
                      public=False):
    links = get_custom_links()
    if not links:
        return None

    schema = coreapi.Document(
        title=title,
        url=url,
        description=description,
        content=links,
    )
    return schema
Exemplo n.º 20
0
async def post_jwt(request: web.Request) -> web.Response:
    """A user is asking for a JWT.
    """
    data = await request.json()
    if "login" not in data or "password" not in data:
        raise web.HTTPUnprocessableEntity(reason="Missing login or password.")
    logger.debug("Trying to identify user %s", data["login"])
    user = await request.app["identity_backend"].identify(
        data["login"], data["password"])
    if user is None:
        raise web.HTTPForbidden(reason="Failed identification for kisee.")
    jti = shortuuid.uuid()
    return serialize(
        request,
        coreapi.Document(
            url="/jwt/",
            title="JSON Web Tokens",
            content={
                "tokens": [
                    jwt.encode(
                        {
                            "iss": request.app["settings"]["jwt"]["iss"],
                            "sub": user.user_id,
                            "exp": datetime.utcnow() + timedelta(hours=1),
                            "jti": jti,
                        },
                        request.app["settings"]["jwt"]["private_key"],
                        algorithm="ES256",
                    ).decode("utf8")
                ],
                "add_token":
                coreapi.Link(
                    action="post",
                    title="Create a new JWT",
                    description="POSTing to this endpoint create JWT tokens.",
                    fields=[
                        coreapi.Field(name="login", required=True),
                        coreapi.Field(name="password", required=True),
                    ],
                ),
            },
        ),
        status=201,
        headers={"Location": "/jwt/" + jti},
    )
Exemplo n.º 21
0
def schema_view(request):
    schema = coreapi.Document(
        title='NewPee API Documentation',
        url='https://newpee.herokuapp.com/',
        content={
            'search':
            coreapi.Link(
                url='api/posts/',
                action='get',
                fields=[
                    coreapi.Field(
                        name='UUID',
                        required=True,
                        location='query',
                        description='A string that represents a UUID'),
                ],
                description='Return all authors')
        })
    # schema = generator.get_schema(request)
    return response.Response(schema)
def decode_raml(bytestring, base_url=None):
    loader = RAMLLoader(base_url)
    data = loader.load(bytestring)
    config = setup_config()
    config['validate'] = False
    raml = parse_raml(data, config)

    content = {}
    for resource in raml.resources:
        fields = []
        encoding = ''

        for param in resource.uri_params or []:
            field = coreapi.Field(param.name, param.required, location='path')
            fields.append(field)

        for param in resource.query_params or []:
            field = coreapi.Field(param.name, param.required, location='query')
            fields.append(field)

        if resource.body:
            body = resource.body[0]
            encoding = body.mime_type

            for form_param in body.form_params or []:
                field = coreapi.Field(param.name,
                                      param.required,
                                      location='form')
                fields.append(field)

            if body.schema:
                schema_fields = expand_schema(body.schema)
                fields.extend(schema_fields)

        link = coreapi.Link(url=resource.absolute_uri,
                            action=resource.method.lower(),
                            encoding=encoding,
                            fields=fields)
        content[resource.display_name] = link

    return coreapi.Document(title=raml.title, url=base_url, content=content)
Exemplo n.º 23
0
def schema_view(request):
    schema = coreapi.Document(
        title='Occurrence Search API',
        content={
            'create':
            coreapi.Link(
                url='/api/occurrence/',
                action='get',
                fields=[
                    coreapi.Field(
                        name='urls',
                        required=True,
                        schema=coreschema.Array(),
                        description='Lista de sites iniciado com http ou https.'
                    ),
                    coreapi.Field(name='word',
                                  required=True,
                                  description='Palavra buscada.'),
                ],
                description='Count specific word occurrence on pages.')
        })
    # schema = generator.get_schema(request)
    return response.Response(schema)
Exemplo n.º 24
0
async def get_jwts(request: web.Request) -> web.Response:
    """Handlers for GET /jwt/, just describes that a POST is possible.
    """
    hostname = request.app["settings"]["server"]["hostname"]
    return serialize(
        request,
        coreapi.Document(
            url=f"{hostname}/jwt/",
            title="JSON Web Tokens",
            content={
                "tokens": [],
                "add_token":
                coreapi.Link(
                    action="post",
                    title="Create a new JWT",
                    description="POSTing to this endpoint create JWT tokens.",
                    fields=[
                        coreapi.Field(name="login", required=True),
                        coreapi.Field(name="password", required=True),
                    ],
                ),
            },
        ),
    )
Exemplo n.º 25
0
import coreapi


flight_document = coreapi.Document(
    title = 'Flight Search API',
    url = 'https://api.flight.com'
    content = {
        'search': coreapi.Link(
            url='/search',
            action='GET',
            method='get_flight_details',
            fields=[
                coreapi.Field(
                    name='from',
                    required=True,
                    location='query',
                    description="City name or Airport code"
                ),
                coreapi.Field(
                    name='to',
                    required=True,
                    location='query',
                    description="City name or Airport code"
                ),
                coreapi.Field(
                    name='schedule',
                    required=True,
                    location='query',
                    description="Flight date"
                )
            ]
Exemplo n.º 26
0
def schema_view(request):
    schema = coreapi.Document(
        title='Zementis Modeler',
        url='http://localhost:8000',
        content={
            'Model': {
                'listOfModels':
                coreapi.Link(url='/api/v1/models',
                             action='get',
                             description='Get the list of loaded models.'),
                'loadModel':
                coreapi.Link(
                    url='/api/v1/models',
                    action='post',
                    fields=[
                        coreapi.Field(
                            name='filePath',
                            required=True,
                            location='formData',
                            description='Path of the model (PMML) to be loaded.'
                        )
                    ],
                    description='Loads a model into memory for scoring data.'),
                'unloadModel':
                coreapi.Link(
                    url='/api/v1/models/{modelName}',
                    action='delete',
                    fields=[
                        coreapi.Field(
                            name='modelName',
                            required=True,
                            location='path',
                            description='Name of the model to be unloaded.')
                    ],
                    description='Unloads a model from memory.'),
                'scoreMultipleData':
                coreapi.Link(
                    url='/api/v1/models/{modelName}/score',
                    action='post',
                    fields=[
                        coreapi.Field(
                            name='modelName',
                            required=True,
                            location='path',
                            description=
                            'Name of the loaded model to be used for scoring.'
                        ),
                        coreapi.Field(
                            name='filePath',
                            required=False,
                            location='formData',
                            description='Path of the data file to be predicted.'
                        )
                    ],
                    description='Prediction of multiple record data.'),
                'scoreSingleData':
                coreapi.Link(
                    url='/api/v1/models/{modelName}/score',
                    action='get',
                    fields=[
                        coreapi.Field(
                            name='modelName',
                            required=True,
                            location='path',
                            description=
                            'Name of the loaded model to be used for scoring.'
                        ),
                        coreapi.Field(
                            name='jsonRecord',
                            required=False,
                            location='query',
                            description=
                            'The record in json format.\nExample: {"sepal_length":5,"sepal_width":4,"petal_length":4,"petal_width":5}'
                        )
                    ],
                    description='Prediction of single record data.')
            },
            'PMML': {
                'getDetailsOfPMML':
                coreapi.Link(url='/api/v1/pmml',
                             action='get',
                             fields=[
                                 coreapi.Field(
                                     name='filePath',
                                     required=True,
                                     location='query',
                                     description='The path of the PMML')
                             ],
                             description='Returns the details of a PMML'),
                'getGlobal':
                coreapi.Link(
                    url='/api/v1/pmml/getGlobal/memory',
                    action='get',
                    description=
                    'Returns all available models (PMMLs) in JSON format.'),
                'addArchitechToGlobalMemory':
                coreapi.Link(
                    url='/api/v1/pmml/{projectID}',
                    action='post',
                    fields=[
                        coreapi.Field(
                            name='projectID',
                            required=True,
                            location='path',
                            description=
                            'Create an unique project Id for that PMML.'),
                        coreapi.Field(name='filePath',
                                      required=True,
                                      location='formData',
                                      description='Path of the PMML file.')
                    ],
                    description='Adds the PMML to the global memory as JSON.'),
                'addOrUpdateLayer':
                coreapi.Link(
                    url='/api/v1/pmml/{projectID}/layer',
                    action='put',
                    fields=[
                        coreapi.Field(
                            name='projectID',
                            required=True,
                            location='path',
                            description='Project id for the PMML model.'),
                        coreapi.Field(
                            name='layerToUpdate',
                            required=True,
                            location='body',
                            description=
                            'The JSON payload of the layer/section/template to be added/update.'
                        )
                    ],
                    description=
                    'For Modifying a DeepNetwork PMML. Adds or updates a layer/section/template.'
                ),
                'deleteLayer':
                coreapi.Link(
                    url='/api/v1/pmml/{projectID}/layer',
                    action='delete',
                    fields=[
                        coreapi.Field(
                            name='projectID',
                            required=True,
                            location='path',
                            description='Project id for the PMML model.'),
                        coreapi.Field(
                            name='layerDelete',
                            required=True,
                            location='body',
                            description=
                            'The JSON payload of the layer/section to be deleted.'
                        )
                    ],
                    description='Deletes a layer/section from the PMML model.')
            },
            'Running Tasks': {
                'runningTasksList':
                coreapi.Link(url='/api/v1/runningTasks',
                             action='get',
                             description='Get a list of running tasks.'),
                'statusOfModel':
                coreapi.Link(url='/api/v1/runningTasks/{id_for_task}',
                             action='get',
                             fields=[
                                 coreapi.Field(name='id_for_task',
                                               required=True,
                                               location='path',
                                               description='Id for the task.')
                             ],
                             description='Get the status of a running task.'),
                'deleteTask':
                coreapi.Link(
                    url='/api/v1/runningTasks/{id_for_task}',
                    action='delete',
                    fields=[
                        coreapi.Field(name='id_for_task',
                                      required=True,
                                      location='path',
                                      description='Id for the task')
                    ],
                    description='Removes a task from the running tasks list.')
            },
            'Train Model': {
                'autoMLsendData':
                coreapi.Link(
                    url='/api/v1/trainAutoMLModel',
                    action='get',
                    fields=[
                        coreapi.Field(
                            name='filePath',
                            required=True,
                            location='query',
                            description='Path of the data file to be uploaded')
                    ],
                    description='Uploads data for AutoML.'),
                'trainAutoML':
                coreapi.Link(
                    url='/api/v1/trainAutoMLModel',
                    action='post',
                    fields=[
                        coreapi.Field(
                            name='payload',
                            required=True,
                            location='body',
                            description=
                            'Payload for training of AutoML. (Pass the JSON payload)'
                        )
                    ],
                    description=
                    'For a given dataset, generates a model using AutoML.'),
                'trainNNModel':
                coreapi.Link(
                    url='/api/v1/trainNNModel',
                    action='post',
                    fields=[
                        coreapi.Field(
                            name='payload',
                            required=True,
                            location='body',
                            description=
                            'Payload for training of DeepNetwork Model. (Pass the JSON payload)'
                        )
                    ],
                    description='Trains a DeepNetwork model.')
            },
            'Utility': {
                'downloadFile':
                coreapi.Link(
                    url='/api/v1/downloadFile',
                    action='get',
                    fields=[
                        coreapi.Field(
                            name='filePath',
                            required=True,
                            location='query',
                            description='Path of the file to be downloaded.')
                    ],
                    description='Downloads a file.'),
                'listOfLayers':
                coreapi.Link(
                    url='/api/v1/listOfLayers',
                    action='get',
                    description=
                    'Returns a list of layers and architectures supported by Zementis Modeler.'
                )
            }
        })

    # schema = generator.get_schema(request)
    return response.Response(schema)
Exemplo n.º 27
0
 def setUp(self):
     self.document = coreapi.Document(title='Example API')
     converter = codecs.DocumentToSwaggerConverter(self.document)
     self.sut = converter._get_info_object()
Exemplo n.º 28
0
                              required=True,
                              location='path',
                              description='City name or airport code.'),
                coreapi.Field(name='date',
                              required=True,
                              location='form',
                              type='number',
                              example='88687',
                              description='Fecha en timestamp'),
                coreapi.Field(name='destinos',
                              required=True,
                              location='form',
                              description='City name or airport code.',
                              type={"$ref": "Menu"})
            ],
            description='Return flight availability and prices.'),
    }
}

content = {**TRAVEL, **DESTINATION}

schema = coreapi.Document(title='Flight Search API',
                          url='https://api.example.org/',
                          content=content)


@api_view()
@renderer_classes([SwaggerUIRenderer, OpenAPIRenderer])
def schema_view(request):
    return Response(schema)
from rest_framework.decorators import api_view, renderer_classes
from rest_framework import renderers, response, schemas
from rest_framework_swagger.renderers import OpenAPIRenderer, SwaggerUIRenderer

schema = coreapi.Document(
    title='Sample API',
    content={
        'sample':
        coreapi.Link(
            url='/sample/',
            action='post',
            fields=[
                coreapi.Field(name='from',
                              required=True,
                              location='query',
                              description='City name or airport code.'),
                coreapi.Field(name='to',
                              required=True,
                              location='query',
                              description='City name or airport code.'),
                coreapi.Field(
                    name='date',
                    required=True,
                    location='query',
                    description='Flight date in "YYYY-MM-DD" format.')
            ],
            description='Create partner')
    })

# @api_view()
# @renderer_classes([renderers.CoreJSONRenderer])
# def schema_view(request):
Exemplo n.º 30
0
def schema_view(request):
    print("---inside schema view-----")
    schema = coreapi.Document(
        title='Price aggregator',
        url='34.92.149.102',
        description=
        'User can get the latest second hand product information in this website, the search engine is a meta search engine. user can also record down the product data. the search api and recent product is opened for public.',
        content={
            #search the second product
            "SearchingAPI": {
                'search':
                coreapi.Link(
                    url='/find_my_product/Search/',
                    action='get',
                    fields=[
                        coreapi.Field(
                            name='Keyword',
                            required=True,
                            location='query',
                            description=
                            'Input the keyword to search the second-hand product',
                        ),
                        coreapi.Field(
                            name='seach_type',
                            location='query',
                            description=
                            'Input the Product type of what second-hand product you want to search'
                        ),
                        coreapi.Field(
                            name='minarea',
                            location='query',
                            description=
                            'Input the minimum   of  Product price of what second-hand product you want to search'
                        ),
                        coreapi.Field(
                            name='maxarea',
                            location='query',
                            description=
                            'Input the maximum   of  Product price of what second-hand product you want to search'
                        ),
                    ],
                    description=
                    'Return the searching resuit of second-hand from different selling website API'
                )
            },

            #operation about user
            "UserAPI": {
                'login':
                coreapi.Link(
                    url='/user/login/',
                    action='post',
                    fields=[
                        coreapi.Field(name='email',
                                      required=True,
                                      location='form',
                                      description='login with email'),
                        coreapi.Field(
                            name='password',
                            required=True,
                            location='form',
                            description=
                            "The Password which match the user's email"),
                    ],
                    encoding="multipart/form-data",
                    description=
                    'Return Login success if the email and password is match.'
                ),
                'logout':
                coreapi.Link(
                    url='/user/logout/',
                    action='post',
                    description=
                    'Logout the existance account without any Parameters'),
                'DeleteAccount':
                coreapi.Link(
                    url='/api/user/',
                    action='delete',
                    description=
                    'Delete your account of existance login with using delete request without any Parameters'
                ),
                'GetUserInfo':
                coreapi.Link(
                    url='/api/user/',
                    action='get',
                    description=
                    'Get your account infomation of existance login without any Parameters '
                ),
                'SignUP':
                coreapi.Link(
                    url='/api/user/',
                    action='post',
                    fields=[
                        coreapi.Field(name='first_name',
                                      location='form',
                                      description='Input first name'),
                        coreapi.Field(name='last_name',
                                      location='form',
                                      description="Input  last name"),
                        coreapi.Field(name='email',
                                      required=True,
                                      location='form',
                                      description="Input the email"),
                        coreapi.Field(
                            name='password1',
                            required=True,
                            location='form',
                            description=
                            "Input the first password , it may match the second password"
                        ),
                        coreapi.Field(
                            name='password2',
                            required=True,
                            location='form',
                            description=
                            "Input the second password , it may match the first password"
                        ),
                    ],
                    encoding="multipart/form-data",
                    description=
                    'Return signup success if the signup information no any mistake.'
                ),
                'UserUpdate':
                coreapi.Link(
                    url='/api/user/',
                    action='PUT',
                    fields=[
                        coreapi.Field(
                            name='first_name',
                            location='form',
                            description='Input the updated first name'),
                        coreapi.Field(
                            name='last_name',
                            location='form',
                            description="Input the updated last name"),
                        coreapi.Field(
                            name='existing_pw',
                            required=True,
                            location='form',
                            description=
                            "Input the existance password for validation"),
                        coreapi.Field(name='password1',
                                      required=True,
                                      location='form',
                                      description="Input the new password "),
                        coreapi.Field(
                            name='password2',
                            required=True,
                            location='form',
                            description=
                            "Input the new password again, two new password must be matched"
                        ),
                    ],
                    encoding="multipart/form-data",
                    description=
                    'Return user information update success if the all information no any mistake.'
                ),
            },
            #operation about user
            "RecentProductAPI": {
                'InsertRecentProduct':
                coreapi.Link(
                    url='/api/product/',
                    action='post',
                    description=
                    'no any parameters. The Api will create a table for insert recent product list from selling website, user can use get request to get a list of recent product, and use put request to update the recent product '
                ),
                'GetRecentProduct':
                coreapi.Link(
                    url='/api/product/',
                    action='get',
                    description=
                    'no any parameters. it return all latest recent product data from database, moreover, it will return the recent product table is null if you are not create the recent product table with using post request'
                ),
                'UpdateRecentProduct':
                coreapi.Link(
                    url='/api/product/',
                    action='put',
                    description=
                    'no any parameters. it return recent product table update success, when user want to get the latest recent product data, you should using the put request first for update the data'
                )
            },
            #operation about user's Favourite product
            "UserFavouriteProductAPI": {
                'InsertUserFavouriteProduct':
                coreapi.Link(
                    url='/api/Favourite/',
                    action='post',
                    fields=[
                        coreapi.Field(
                            name='price',
                            required=True,
                            location='form',
                            description=
                            "insert the price of favourtite product to the database."
                        ),
                        coreapi.Field(
                            name='name',
                            required=True,
                            location='form',
                            description=
                            "insert the name of favourtite product to the database."
                        ),
                        coreapi.Field(
                            name='link',
                            required=True,
                            location='form',
                            description=
                            "insert the selling link of favourtite product to the database."
                        )
                    ],
                    encoding="multipart/form-data",
                    description='User can record down his favourtite product '
                ),
                'DeleteUserFavouriteProduct':
                coreapi.Link(
                    url='/api/Favourite/',
                    action='delete',
                    fields=[
                        coreapi.Field(
                            name='ProductID',
                            required=True,
                            location='form',
                            description=
                            "according the ID of the User Favourite Product in the databas to delete the record"
                        ),
                    ],
                    encoding="multipart/form-data",
                    description='User can record down his favourtite product '
                ),
                'GetAllUserFavouriteProduct':
                coreapi.Link(
                    url='/api/Favourite/',
                    action='get',
                    description=
                    "Get the existance login user's favourtite product ")
            }
        })
    print(dir(schema))
    # schema = generator.get_schema(request)
    return response.Response(schema)