From pypi

Give it a try

short Flask example

fromdatetimeimportdatetimeimportflaskimportmarshmallowimporthapicfromhapic.ext.flaskimportFlaskContextimportjsonhapic=hapic.Hapic()app=flask.Flask(__name__)classUriPathSchema(marshmallow.Schema):# schema describing the URI and allowed valuesname=marshmallow.fields.String(required=True)age=marshmallow.fields.Integer(required=False)classHelloResponseSchema(marshmallow.Schema):# schema of the API responsename=marshmallow.fields.String(required=True)now=marshmallow.fields.DateTime(required=False)greetings=marshmallow.fields.String(required=False)@app.route('/hello/<name>')# flask route. must always be before hapic decorators@hapic.with_api_doc()# the first hapic decorator. Register the method for auto-documentation@hapic.input_path(UriPathSchema())# validate the URI structure@hapic.output_body(HelloResponseSchema())# define output structuredefhello(name='<No name>',hapic_data=None):return{'name':name,'now':datetime.now(),'dummy':{'some':'dummy'}# will be ignored}classUriPathSchemaWithAge(marshmallow.Schema):# schema describing the URI and allowed valuesname=marshmallow.fields.String(required=True)age=marshmallow.fields.Integer(required=False)@app.route('/hello/<name>/age/<age>')@hapic.with_api_doc()@hapic.input_path(UriPathSchemaWithAge())@hapic.output_body(HelloResponseSchema())defhello2(name='<No name>',age=42,hapic_data=None):return{'name':name,'age':age,'greetings':'Hello {name}, it looks like you are {age}'.format(name=name,age=age),'now':datetime.now(),'dummy':{'some':'dummy'}# will be ignored}hapic.set_context(FlaskContext(app))print(json.dumps(hapic.generate_doc(title='API Doc',description='doc desc.')))# Generate the documentationapp.run('127.0.0.1',8080,debug=True)