[关闭]
@JunQiu 2018-09-18T17:33:13.000000Z 字数 3463 阅读 1549

yaml,openApi、服务开发流程

summary_2018/06 standard think


1、日常工作

1、使用openApi规范完成facebook_insight_status service 的编写,及重构
2、openApi规范学习
3、YAML(一种通用的数据串行化格式)
4、服务开发流程


2、技术学习

1、openApi规范学习

  1. #### Metadata
  2. //每个OpenAPI规范都以openapi提到规范格式版本的关键字开始。该版本定义了API规范的整体结构 - 您可以记录什么以及如何记录它。
  3. openapi: 3.0.0
  4. //info部分包含API信息:title,description(可选)version
  5. info:
  6. title: Sample API
  7. description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  8. version: 0.1.9
  9. #### Servers
  10. //The servers section specifies the API server and base URL. You can define one or several servers, such as production and sandbox.
  11. servers:
  12. - url: http://api.example.com/v1
  13. description: Optional server description, e.g. Main (production) server
  14. - url: http://staging-api.example.com
  15. description: Optional server description, e.g. Internal staging server for testing
  16. #### Paths
  17. The paths section defines individual endpoints (paths) in your API, and the HTTP methods (operations) supported by these endpoints.
  18. paths:
  19. /users:
  20. get:
  21. summary: Returns a list of users.
  22. description: Optional extended description in CommonMark or HTML
  23. #### Parameters
  24. parameters:
  25. - name: petId
  26. in: path
  27. description: ID of pet that needs to be updated
  28. required: true
  29. schema:
  30. type: string
  31. #### Request Body
  32. requestBody:
  33. content:
  34. application/octet-stream:
  35. # any media type is accepted, functionally equivalent to `*/*`
  36. schema:
  37. # a binary file of any type
  38. type: string
  39. format: binary
  40. #### Responses
  41. paths:
  42. /user/{userId}:
  43. get:
  44. summary: Returns a user by ID.
  45. parameters:
  46. - name: userId
  47. in: path
  48. required: true
  49. description: The ID of the user to return.
  50. schema:
  51. type: integer
  52. format: int64
  53. minimum: 1
  54. responses:
  55. '200':
  56. description: A user object.
  57. content:
  58. application/json:
  59. schema:
  60. type: object
  61. properties:
  62. id:
  63. type: integer
  64. format: int64
  65. example: 4
  66. name:
  67. type: string
  68. example: Jessica Smith
  69. '400':
  70. description: The specified user ID is invalid (not a number).
  71. '404':
  72. description: A user with the specified ID was not found.
  73. default:
  74. description: Unexpected error
  75. Example:
  76. openapi: 3.0.0
  77. info:
  78. title: 'xxx'
  79. description: 'xxx'
  80. version: "1.0.0"
  81. tags:
  82. - name: 'adInsightAndAction'
  83. description: 'xxx'
  84. paths:
  85. /insights:
  86. get:
  87. tags:
  88. - 'adInsightAndAction'
  89. description: ''
  90. operationId: 'getAdInsightAndAction'
  91. parameters:
  92. - in: 'query'
  93. name: 'access_token'
  94. schema:
  95. type: 'string'
  96. example: 'xxxxxx'
  97. description: 'xxx'
  98. required: true
  99. - in: 'query'
  100. name: 'ids'
  101. schema:
  102. type: 'string'
  103. example: '<id1>,<id2>....'
  104. description: 'ids of you need query'
  105. required: true
  106. responses:
  107. 200:
  108. description: |
  109. - level:
  110. - 50 : id not exist or other error
  111. - 30 : get data successfully
  112. content:
  113. application/json:
  114. schema:
  115. type: 'array'
  116. items:
  117. type: 'object'
  118. properties:
  119. level:
  120. type: 'integer'
  121. example: 30
  122. message:
  123. type: 'object'
  124. properties:
  125. ad_id:
  126. type: 'string'
  127. example: '23842921610'
  128. spend:
  129. type: 'string'
  130. example: '287.29'
  131. action:
  132. type: 'array'
  133. items:
  134. type: 'object'
  135. properties:
  136. action_type:
  137. type: 'string'
  138. example: 'app_custom_event.fb_mobile'
  139. value:
  140. type: 'string'
  141. example: '251'
  142. date_start:
  143. type: 'string'
  144. example: '2018-05-22'
  145. date_stop:
  146. type: 'string'
  147. example: '2018-05-22'
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注