为什么 head 方法不能在烧瓶中使用 docsstring 大摇大摆地工作?

Why head method is not working in swagger using docsstring in flask?

三引号中的文档字符串在 head 方法中不起作用。我正在使用包 flassger。我无法在 head 方法中使用 docstring for 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

            """

默认忽略 HEAD 和 OPTION。

您可以使用

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

将空列表传递给忽略