您可以使用模型来定义一个示例,就像这样:
...
# define model with example
example_response = api.model('ExampleResponse', {
'field_you_want': fields.String(example="Example Value")
})
@api.route("/")
class Example(Resource):
@api.marshal_with(example_response)
def get(self):
response = get_response()
return response, 200
...