Add reading_time to articles api responses (#13446)
* Add reading_time to articles api responses Fixes #13436 * Update api docs to match changes to the articles response * Follow up docs updates - increment api docs version - add reading_time to articles/me responses - add reading time to the show response example format * Change reading_time attribute to reading_time_minutes Update the article builder to use `article.reading_time` and present it as `"reading_time_minutes"`. Update the api spec to expect the new property name instead of the attribute. * Update api documentation to reflect the new name - Change reading_time -> reading_time_minutes. - I decided to keep the (possibly redundant) description text here.
This commit is contained in:
parent
ba1c13bbb6
commit
2f1dad4e37
4 changed files with 22 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ module Api
|
|||
title description main_image published_at crossposted_at social_image
|
||||
cached_tag_list slug path canonical_url comments_count
|
||||
public_reactions_count created_at edited_at last_comment_at published
|
||||
updated_at video_thumbnail_url
|
||||
updated_at video_thumbnail_url reading_time
|
||||
].freeze
|
||||
|
||||
SHOW_ATTRIBUTES_FOR_SERIALIZATION = [
|
||||
|
|
|
|||
|
|
@ -24,3 +24,4 @@ json.edited_at utc_iso_timestamp(article.edited_at)
|
|||
json.crossposted_at utc_iso_timestamp(article.crossposted_at)
|
||||
json.published_at utc_iso_timestamp(article.published_at)
|
||||
json.last_comment_at utc_iso_timestamp(article.last_comment_at)
|
||||
json.reading_time_minutes article.reading_time
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ info:
|
|||
Dates and date times, unless otherwise specified, must be in
|
||||
the [RFC 3339](https://tools.ietf.org/html/rfc3339) format.
|
||||
|
||||
version: "0.9.5"
|
||||
version: "0.9.6"
|
||||
termsOfService: https://dev.to/terms
|
||||
contact:
|
||||
name: DEV Team
|
||||
|
|
@ -186,6 +186,7 @@ components:
|
|||
- last_comment_at
|
||||
- published_timestamp
|
||||
- user
|
||||
- reading_time_minutes
|
||||
properties:
|
||||
type_of:
|
||||
type: string
|
||||
|
|
@ -254,6 +255,10 @@ components:
|
|||
format: date-time
|
||||
user:
|
||||
$ref: "#/components/schemas/SharedUser"
|
||||
reading_time_minutes:
|
||||
description: Reading time, in minutes
|
||||
type: integer
|
||||
format: int32
|
||||
organization:
|
||||
$ref: "#/components/schemas/SharedOrganization"
|
||||
flare_tag:
|
||||
|
|
@ -287,6 +292,7 @@ components:
|
|||
- body_html
|
||||
- body_markdown
|
||||
- user
|
||||
- reading_time_minutes
|
||||
properties:
|
||||
type_of:
|
||||
type: string
|
||||
|
|
@ -359,6 +365,10 @@ components:
|
|||
type: string
|
||||
user:
|
||||
$ref: "#/components/schemas/SharedUser"
|
||||
reading_time_minutes:
|
||||
description: Reading time, in minutes
|
||||
type: integer
|
||||
format: int32
|
||||
organization:
|
||||
$ref: "#/components/schemas/SharedOrganization"
|
||||
flare_tag:
|
||||
|
|
@ -516,6 +526,7 @@ components:
|
|||
- published_timestamp
|
||||
- body_markdown
|
||||
- user
|
||||
- reading_time_minutes
|
||||
properties:
|
||||
type_of:
|
||||
type: string
|
||||
|
|
@ -571,6 +582,10 @@ components:
|
|||
type: string
|
||||
user:
|
||||
$ref: "#/components/schemas/SharedUser"
|
||||
reading_time_minutes:
|
||||
description: Reading time, in minutes
|
||||
type: integer
|
||||
format: int32
|
||||
organization:
|
||||
$ref: "#/components/schemas/SharedOrganization"
|
||||
flare_tag:
|
||||
|
|
@ -1240,6 +1255,7 @@ components:
|
|||
published_at: '2019-10-24T13:52:17Z'
|
||||
last_comment_at: '2019-10-25T08:12:43Z'
|
||||
published_timestamp: '2019-10-24T13:52:17Z'
|
||||
reading_time_minutes: 15
|
||||
user:
|
||||
name: Ben Halpern
|
||||
username: ben
|
||||
|
|
@ -1284,6 +1300,7 @@ components:
|
|||
published_at: "2019-08-01T15:47:54Z"
|
||||
last_comment_at: "2019-08-06T16:48:10Z"
|
||||
published_timestamp: "2019-08-01T15:47:54Z"
|
||||
reading_time_minutes: 15
|
||||
body_html: |+
|
||||
<p>Today's episode of Byte Sized is about Leonhard Euler and the creation of <a href="https://en.wikipedia.org/wiki/Graph_theory">Graph Theory</a>.</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ RSpec.describe "Api::V0::Articles", type: :request do
|
|||
type_of id title description cover_image readable_publish_date social_image
|
||||
tag_list tags slug path url canonical_url comments_count public_reactions_count positive_reactions_count
|
||||
collection_id created_at edited_at crossposted_at published_at last_comment_at
|
||||
published_timestamp user organization flare_tag
|
||||
published_timestamp user organization flare_tag reading_time_minutes
|
||||
]
|
||||
|
||||
expect(response.parsed_body.first.keys).to match_array index_keys
|
||||
|
|
@ -334,7 +334,7 @@ RSpec.describe "Api::V0::Articles", type: :request do
|
|||
type_of id title description cover_image readable_publish_date social_image
|
||||
tag_list tags slug path url canonical_url comments_count public_reactions_count positive_reactions_count
|
||||
collection_id created_at edited_at crossposted_at published_at last_comment_at
|
||||
published_timestamp body_html body_markdown user organization flare_tag
|
||||
published_timestamp body_html body_markdown user organization flare_tag reading_time_minutes
|
||||
]
|
||||
|
||||
expect(response.parsed_body.keys).to match_array show_keys
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue