三引号中的文档字符串不适用于head
方法。我正在使用包flassger。我无法在head
方法中使用docstring来实现swagger ui。但是,它适用于patch
,post
,put
和get
方法。
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
"""
答案 0 :(得分:0)
默认情况下会忽略HEAD和OPTION。
您可以使用
app.config['SWAGGER'] = {'ignore_verbs': []}
传递一个空列表以忽略