Skip to content

Instantly share code, notes, and snippets.

@sri-teja
Created November 9, 2019 06:48
Show Gist options
  • Save sri-teja/1c7100ec3b13dc0ab1d59db2c4f36da8 to your computer and use it in GitHub Desktop.
Save sri-teja/1c7100ec3b13dc0ab1d59db2c4f36da8 to your computer and use it in GitHub Desktop.
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