奶瓶+APISPEC+棉花糖集成
bottle-apispec的Python项目详细描述
瓶子符合规范
简单的插件,很容易使集成瓶,APISpec和棉花糖。
示例
frombottleimportBottle,runfrombottle_apispecimportAPISpecPluginfrommarshmallowimportSchemafrommarshmallow.fieldsimportStringapp=Bottle()classMySchema(Schema):id=String()value=String()@app.get('/')defindex():"""API endpoint that return MySchema --- get: description: API endpoint that return MySchema responses: 200: description: It works!!!! schema: MySchema """data,error=MySchema.load('id','value')returndataapp.install(APISpecPlugin(title='Example API',version='1.0.0',openapi_version='2.0',scan_package='.'))run(app)