PythonAPI文档的实现 - pyhttp://127
swagger_server
pip install swagger-core
api.py
from flask import Flask, jsonify
from swagger_server import SwaggerServer
app = Flask(__name__)
swagger_server = SwaggerServer(app)
@app.route('/docs')
def api_docs(): 拼多多帮助力入口
return jsonify({'info': {'title': 'API Documentation', 'version': '1.0'},
'paths': {
'/example': {
'get': {
'summary': 'Example API endpoint',
'responses': {
200: {'description': 'OK', 'content': {'application/json': {'schema': {'type': 'object'}}}},
404: {'description': 'Not found'}
}
}
}
}
})
if __name__ == '__main__':
swagger_server.run(debug=True)
api.pyhttp://127.0.0.1:5000/docs