为什么head方法不能在使用docsstring的摇摆中工作?

时间:2017-03-16 06:32:25

标签: python flask swagger-ui swagger-2.0

三引号中的文档字符串不适用于head方法。我正在使用包flassger。我无法在head方法中使用docstring来实现swagger ui。但是,它适用于patchpostputget方法。

from flasgger import Swagger

@app.route('/flight/<flight_no>', methods=['HEAD'])
    def get_flight_exist(flight_no):
        """
            show Flight Existence
            This resource returns flight exist response
            ---
            tags:
              - hello
            parameters:
            - name: flight_no
              in: path
              type: string
              description: Flight_no
              required: true


            responses:
                '200':
                  description: Flight data  response
                  schema:
                     description: Flight object
                     properties:
                       flight_name:
                         type: string
                         description: name of the flight
                       flight_no:
                         type: string
                         description: flight number
                       total_seat:
                         type: integer
                     required:
                       - flight_name
                       - flight_no
                       - total_seat

                '404':
                  description: Flight not found

            """

1 个答案:

答案 0 :(得分:0)

默认情况下会忽略HEAD和OPTION。

您可以使用

app.config['SWAGGER'] = {'ignore_verbs': []}

传递一个空列表以忽略