getsling / flask-swagger

A swagger 2.0 spec extractor for flask
MIT License
457 stars 91 forks source link

Different documentation for each method of a endpoint #30

Open alejoar opened 8 years ago

alejoar commented 8 years ago

How would one go about adding different documentation for each method of the same endpoint?

For example, this code:

@app.route('/some/endpoint', methods=['PUT', 'GET'])
def some_path():
    """
    Some Endpoint
    ---
    tags:
        - some endpoint
    responses:
        200:
            description: success
    """
    (...)

will generate the same documentation for both PUT and GET methods.

How can I specify a particular definition for each method?

atlithorn commented 8 years ago

Currently you cannot.

alejoar commented 8 years ago

@atlithorn ok, thanks.

I was thinking something like this might be easily implementable:

@app.route('/some/endpoint', methods=['PUT', 'GET'])
def some_path():
    """
    Some Endpoint
    ---
    tags:
        - some endpoint
    get:
        responses:
            200:
                description: item obtained
    put:
        parameters:
              - name: someParam
                in: formData
                type: integer
                required: true
        responses:
            202:
                description: item updated
    """
    (...)

When I get some free time, I'll look into flask-swagger's code and try to implement it.