@JunQiu
2018-09-18T09:33:13.000000Z
字数 3463
阅读 1914
summary_2018/06 standard think
1、使用openApi规范完成facebook_insight_status service 的编写,及重构
2、openApi规范学习
3、YAML(一种通用的数据串行化格式)
4、服务开发流程
1、openApi规范学习
#### Metadata//每个OpenAPI规范都以openapi提到规范格式版本的关键字开始。该版本定义了API规范的整体结构 - 您可以记录什么以及如何记录它。openapi: 3.0.0//info部分包含API信息:title,description(可选)versioninfo:title: Sample APIdescription: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.version: 0.1.9#### Servers//The servers section specifies the API server and base URL. You can define one or several servers, such as production and sandbox.servers:- url: http://api.example.com/v1description: Optional server description, e.g. Main (production) server- url: http://staging-api.example.comdescription: Optional server description, e.g. Internal staging server for testing#### PathsThe paths section defines individual endpoints (paths) in your API, and the HTTP methods (operations) supported by these endpoints.paths:/users:get:summary: Returns a list of users.description: Optional extended description in CommonMark or HTML#### Parametersparameters:- name: petIdin: pathdescription: ID of pet that needs to be updatedrequired: trueschema:type: string#### Request BodyrequestBody:content:application/octet-stream:# any media type is accepted, functionally equivalent to `*/*`schema:# a binary file of any typetype: stringformat: binary#### Responsespaths:/user/{userId}:get:summary: Returns a user by ID.parameters:- name: userIdin: pathrequired: truedescription: The ID of the user to return.schema:type: integerformat: int64minimum: 1responses:'200':description: A user object.content:application/json:schema:type: objectproperties:id:type: integerformat: int64example: 4name:type: stringexample: Jessica Smith'400':description: The specified user ID is invalid (not a number).'404':description: A user with the specified ID was not found.default:description: Unexpected errorExample:openapi: 3.0.0info:title: 'xxx'description: 'xxx'version: "1.0.0"tags:- name: 'adInsightAndAction'description: 'xxx'paths:/insights:get:tags:- 'adInsightAndAction'description: ''operationId: 'getAdInsightAndAction'parameters:- in: 'query'name: 'access_token'schema:type: 'string'example: 'xxxxxx'description: 'xxx'required: true- in: 'query'name: 'ids'schema:type: 'string'example: '<id1>,<id2>....'description: 'ids of you need query'required: trueresponses:200:description: |- level:- 50 : id not exist or other error- 30 : get data successfullycontent:application/json:schema:type: 'array'items:type: 'object'properties:level:type: 'integer'example: 30message:type: 'object'properties:ad_id:type: 'string'example: '23842921610'spend:type: 'string'example: '287.29'action:type: 'array'items:type: 'object'properties:action_type:type: 'string'example: 'app_custom_event.fb_mobile'value:type: 'string'example: '251'date_start:type: 'string'example: '2018-05-22'date_stop:type: 'string'example: '2018-05-22'
2、服务开发流程
3、思考总结
