Created
November 9, 2019 06:48
-
-
Save sri-teja/1c7100ec3b13dc0ab1d59db2c4f36da8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, jsonify | |
from flasgger import Swagger | |
from flasgger import swag_from | |
app = Flask(__name__) | |
## this is required to give openapi version | |
## separately in the app.config | |
## even though we mention it in docs.yml | |
app.config['SWAGGER'] = { | |
"openapi": "3.0.0" | |
} | |
## docs.yml is the swagger documentation file | |
swagger = Swagger(app, template_file='docs.yml') | |
## using decorator @swag_form we can refer to the paths | |
## that we need to mention in docs.yml | |
@app.route('/helloworld', method=["GET"]) | |
@swag_from | |
def hello_world: | |
print("Hello World") | |
return jsonify({"success": True, "message": "Done"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment