v3-tipitaka-reading-channel.yaml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-tipitaka-reading-channel.yaml
  2. get:
  3. summary: 读取译文
  4. tags:
  5. - tipitaka-reading
  6. operationId: get_api_v3_tipitaka_reading_channel_
  7. description: |-
  8. 取这个 channel 已经翻译的段落,按 (book, para) 升序,用游标分块。
  9. 不带任何查询串就是从头取整个 channel——下载场景要的就是这个;
  10. 阅读场景用 `book` + `chapter` 或 `book` + `para`/`to` 把范围收窄。
  11. 续传把 `meta.next_cursor` 原样传回 `after` 即可,它为 null 表示取完了。
  12. **不要自己拼游标**:它的内部形式(`{book}-{para}`)是实现细节,会变。
  13. `total` / `remaining` 只在带了 `book` 过滤时才给:不带过滤时结果集是整个
  14. channel(实测最大的有 52 万段、跨 217 本书),每翻一页都去 count 一次不划算。
  15. 无过滤时用 `next_cursor` 是否为 null 判断结束,不要指望百分比。
  16. 实现:`V3\TipitakaReadingController@__invoke`
  17. security:
  18. - { }
  19. -
  20. bearerAuth: []
  21. parameters:
  22. -
  23. name: channel
  24. in: path
  25. required: true
  26. schema:
  27. type: string
  28. description: '译文 channel 的 uuid'
  29. -
  30. name: book
  31. in: query
  32. schema:
  33. type: integer
  34. description: '典籍 id。与 chapter / para / to 一起用时必填'
  35. example: 9002
  36. -
  37. name: chapter
  38. in: query
  39. schema:
  40. type: integer
  41. description: '章节起始段落号,服务端按 chapter_len 展开成段落区间。 与 para / to 互斥'
  42. -
  43. name: para
  44. in: query
  45. schema:
  46. type: integer
  47. description: 起始段落号
  48. -
  49. name: to
  50. in: query
  51. schema:
  52. type: integer
  53. description: '结束段落号(含)。不传则等于 para,即只取一段'
  54. -
  55. name: after
  56. in: query
  57. schema:
  58. type: string
  59. description: '游标,取 meta.next_cursor 原样回传'
  60. example: 9002-15
  61. -
  62. name: page_size
  63. in: query
  64. schema:
  65. type: integer
  66. default: 10
  67. description: '每块大小,含义由 unit 决定。上限 unit=para 时 200、 unit=byte 时 5000,超出不报错按上限算,meta.page_size 回实际生效的值'
  68. -
  69. name: unit
  70. in: query
  71. schema:
  72. type: string
  73. enum:
  74. - para
  75. - byte
  76. default: para
  77. description: '每块大小的单位:para 按段落数,byte 按段落长度累加。 两种单位下每块都至少一段、至多 200 段'
  78. -
  79. name: format
  80. in: query
  81. schema:
  82. type: string
  83. enum:
  84. - html
  85. - markdown
  86. - react
  87. - text
  88. default: html
  89. description: 内容格式
  90. -
  91. name: include
  92. in: query
  93. schema:
  94. type: string
  95. enum:
  96. - display
  97. - sentences
  98. - all
  99. default: display
  100. description: '输出口径:display 整段合并,sentences 逐句,all 两者都给。 不叫 view 是因为 v2 的 `view=` 是必填互斥的业务路径开关,名字撞上会误导'
  101. responses:
  102. 200:
  103. description: 成功
  104. content:
  105. application/json:
  106. schema:
  107. type: object
  108. properties:
  109. data:
  110. type: array
  111. items:
  112. type: object
  113. properties:
  114. para:
  115. type: integer
  116. display:
  117. type: string
  118. book:
  119. type: integer
  120. meta:
  121. type: object
  122. properties:
  123. page_size:
  124. type: integer
  125. description: '每块大小(按 unit 计)'
  126. page_size_unit:
  127. type: string
  128. description: '每块大小的单位:para 或 byte'
  129. next_cursor:
  130. type: string
  131. description: '下一块的游标,原样传回 after;为 null 表示取完'
  132. total:
  133. type: integer
  134. description: '过滤范围内已翻译的段落总数。仅在带了 book 过滤时出现'
  135. remaining:
  136. type: integer
  137. description: '本块之后过滤范围内还剩多少段。仅在带了 book 过滤时出现'
  138. 404:
  139. description: '指定的 chapter 在 pali_texts 里不存在'
  140. content:
  141. application/problem+json:
  142. schema:
  143. $ref: '../../main.yaml#/components/schemas/ProblemDetails'
  144. 422:
  145. $ref: '../../main.yaml#/components/responses/ProblemValidation'