[WIP] API Explorer back-end

Review Request #7904 — Created Jan. 24, 2016 and discarded

adilally
Djblets
master
7905
djblets

An API Explorer allows developers to make requests to the Web API from their browsers without having to download XML or JSON files. The API Explorer will display the response as syntax highlighted JSON in order to be understandable and facilitate development and understanding of the Web API.

In the future, users will be able to make POST, PUT and DELETE requests from a provided form and view documentation related to the resource.

This patch focuses on creating an HTML Encoder that will retrieve the payload and determine the resource being accessed.

Modifications to the way the Web API handles requests are also made to ensure that requests can also be made from a web browser.

Tested /api/users/<user_name> and /api/users/ which returned the correct information, in the proper format which displayed correctly in a web browser.

Description From Last Updated

Two blank lines between these.

brenniebrennie

This should have: from __future__ import unicode literals

brenniebrennie

Docstring?

brenniebrennie

Alphabetize.

brenniebrennie

Docstring.

brenniebrennie

Docstring.

brenniebrennie

Docstring.

brenniebrennie

Can we reforamt this as: return render_to_string( 'webapi/explorer.html', { 'payload': o, })

brenniebrennie

Single quotes for strings.

brenniebrennie

Alphabetize these.

brenniebrennie

Can you change all these to use single quotes?

brenniebrennie

Please format this as: if (self.mimetype == 'text/plain' or is_mimetype_a(self.mimetype, 'application/json')): # ...

brenniebrennie

Can you change this to all use single quotes?

brenniebrennie

Single quotes.

brenniebrennie

We already import json above. Lets just use json.dumps.

brenniebrennie

So our import layout is as follows: from __future__ import unicode_literals # Always first. # Standard library imports. import json ...

brenniebrennie

'datetime' imported but unused

reviewbotreviewbot

Col: 80 E501 line too long (86 > 79 characters)

reviewbotreviewbot

'Directive' imported but unused

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (110 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (113 > 79 characters)

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
AD
AD
AD
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
brennie
  1. 
      
  2. djblets/util/templatetags/djblets_webapi.py (Diff revision 2)
     
     
     
     

    Two blank lines between these.

  3. This should have:

    from __future__ import unicode literals
    
    1. For reference: dblets_webapi.py is going to be removed as it is no longer used.
  4. djblets/webapi/encoders.py (Diff revision 2)
     
     
     
     
     

    Alphabetize.

  5. djblets/webapi/encoders.py (Diff revision 2)
     
     

    Docstring.

  6. djblets/webapi/encoders.py (Diff revision 2)
     
     

    Docstring.

  7. djblets/webapi/encoders.py (Diff revision 2)
     
     

    Docstring.

  8. djblets/webapi/encoders.py (Diff revision 2)
     
     
     

    Can we reforamt this as:

    return render_to_string(
        'webapi/explorer.html',
        {
            'payload': o,
        })
    
  9. djblets/webapi/encoders.py (Diff revision 2)
     
     

    Single quotes for strings.

  10. djblets/webapi/responses.py (Diff revision 2)
     
     
     

    Alphabetize these.

  11. djblets/webapi/responses.py (Diff revision 2)
     
     
     
     
     
     

    Can you change all these to use single quotes?

  12. djblets/webapi/responses.py (Diff revision 2)
     
     
     

    Please format this as:

    if (self.mimetype == 'text/plain' or
        is_mimetype_a(self.mimetype, 'application/json')):
        # ...
    
  13. djblets/webapi/responses.py (Diff revision 2)
     
     
     
     
     
     
     
     

    Can you change this to all use single quotes?

  14. djblets/webapi/responses.py (Diff revision 2)
     
     
     
     
     

    Single quotes.

  15. 
      
AD
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
brennie
  1. 
      
  2. djblets/webapi/encoders.py (Diff revision 3)
     
     

    We already import json above. Lets just use json.dumps.

  3. djblets/webapi/encoders.py (Diff revision 3)
     
     
     
     
     

    So our import layout is as follows:

    from __future__ import unicode_literals  # Always first.
    
    # Standard library imports.
    import json
    from xml.foo import bar
    
    # 3-rd party library imports.
    from django.conf import settings
    # ...
    from pygments import hilight
    
    # Our current project imports
    from djblets import foobar
    

    We put full imports import foo above partial imports (from foo import bar),

    1. Ohhh, that makes sense thanks.

  4. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/templatetags/djblets_webapi.py
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. djblets/webapi/encoders.py (Diff revision 5)
     
     
     'datetime' imported but unused
    
  3. djblets/webapi/encoders.py (Diff revision 5)
     
     
    Col: 80
     E501 line too long (86 > 79 characters)
    
  4. djblets/webapi/resources/base.py (Diff revision 5)
     
     
     'Directive' imported but unused
    
  5. 
      
AD
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Col: 80
     E501 line too long (110 > 79 characters)
    
  3. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Col: 80
     E501 line too long (110 > 79 characters)
    
  4. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Col: 80
     E501 line too long (113 > 79 characters)
    
  5. djblets/webapi/resources/base.py (Diff revision 6)
     
     
    Col: 80
     E501 line too long (113 > 79 characters)
    
  6. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Col: 80
     E501 line too long (110 > 79 characters)
    
  3. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Col: 80
     E501 line too long (110 > 79 characters)
    
  4. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Col: 80
     E501 line too long (113 > 79 characters)
    
  5. djblets/webapi/resources/base.py (Diff revision 7)
     
     
    Col: 80
     E501 line too long (113 > 79 characters)
    
  6. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources/base.py
        djblets/webapi/responses.py
        djblets/webapi/encoders.py
    
    
  2. 
      
AD
david
Review request changed

Status: Discarded

Loading...