swagger入门
2015-12-31 18:55
197 查看
优点
可调试容易编写
swagger 驱动api开发
开发流程
swagger-editor:http://editor.swagger.io/ 或静态服务生成
user.yaml,如下面的示例,并放在静太服务器上
swagger-ui:下载并放在静态服务上
swagger-ui加上
user.yaml
文档
关键字定义参考1
参考2
示例
swagger: '2.0' info: title: My Demo API description: 举个栗子,关于用户注册登录 version: 1.0.0 contact: name: 王东文 email: wangdongwen@meicai.cn url: http://www.meicai.cn host: api.uber.com schemes: - https - http basePath: /v1 consumes: - application/x-www-form-urlencoded produces: - application/json paths: /user/login: get: summary: 用户登录 description: | 用户登录模块 parameters: - name: username in: formData description: 用户名 required: true type: string format: phone - name: password in: formData description: 密码 required: true type: string format: password tags: - User responses: '200': description: 登录成功 schema: $ref: '#/definitions/LoginOk' default: description: Unexpected error schema: $ref: '#/definitions/Error' definitions: LoginOk: type: object properties: token: type: string description: 登录成功后,产生的访问token message: type: string description: 登录成功提示 Error: type: object properties: code: type: integer format: int32 description: 错误码 message: type: string description: 错误信息描述
相关文章推荐
- iOS: SegmentControl 实现页面切换的四种方法
- [Android]使用Dagger 2依赖注入 - API(翻译)
- android 通知栏背景颜色跟随app导航栏背景颜色变化而变化
- 设计模式与协议
- IOS UISegmentedControl
- 支付宝 激活开发者模式
- 2015跨年夜,启航
- 第三方控件选择
- 猿题库 iOS 客户端架构设计
- Windows应用程序快捷方式创建工具
- ServletConfig与ServletContext对象
- Android Support兼容包详解使用
- 有向图遍历,十字链表存储,深度遍历,广度遍历。
- poj1408(求线段交点)
- [机器视觉设计]wpf的研究和反思
- ndk的平台兼容性
- 用Radeon RAMDisk在Windows 10中创建关机或重启不消失的内存虚拟盘
- JavaScript 中的 replace 方法
- C语言中把数字转换为字符串 【转】
- Linux系统常用设置