DEV: Add missing operationIds to the api docs (#14235)

From the openapi spec:

 https://spec.openapis.org/oas/latest.html#fixed-fields-7

each endpoint needs to have an `operationId`:

> Unique string used to identify the operation. The id MUST be unique
> among all operations described in the API. The operationId value is
> case-sensitive. Tools and libraries MAY use the operationId to uniquely
> identify an operation, therefore, it is RECOMMENDED to follow common
> programming naming conventions.

Running the linter on our openapi.json file with this command:

`npx @redocly/openapi-cli lint openapi.json`

produced the following warning on all of our endpoints:

> Operation object should contain `operationId` field

This commit resolves these warnings by adding an operationId field to
each endpoint.
This commit is contained in:
Blake Erickson
2021-09-03 07:39:29 -06:00
committed by GitHub
parent 85c31c73ba
commit ee7809e8a8
14 changed files with 70 additions and 97 deletions

View File

@ -9,6 +9,7 @@ describe 'topics' do
path '/t/{id}/posts.json' do
get 'Get specific posts from a topic' do
tags 'Topics'
operationId 'getSpecificPostsFromTopic'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -107,6 +108,7 @@ describe 'topics' do
path '/t/{id}.json' do
get 'Get a single topic' do
tags 'Topics'
operationId 'getTopic'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -375,6 +377,7 @@ describe 'topics' do
delete 'Remove a topic' do
tags 'Topics'
operationId 'removeTopic'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -392,6 +395,7 @@ describe 'topics' do
path '/t/-/{id}.json' do
put 'Update a topic' do
tags 'Topics'
operationId 'updateTopic'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -440,6 +444,7 @@ describe 'topics' do
path '/t/{id}/invite.json' do
post 'Invite to topic' do
tags 'Topics', 'Invites'
operationId 'inviteToTopic'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -482,6 +487,7 @@ describe 'topics' do
path '/t/{id}/bookmark.json' do
put 'Bookmark topic' do
tags 'Topics'
operationId 'bookmarkTopic'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -501,6 +507,7 @@ describe 'topics' do
path '/t/{id}/status.json' do
put 'Update the status of a topic' do
tags 'Topics'
operationId 'updateTopicStatus'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -543,6 +550,7 @@ describe 'topics' do
path '/latest.json' do
get 'Get the latest topics' do
tags 'Topics'
operationId 'listLatestTopics'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -649,106 +657,10 @@ describe 'topics' do
end
end
path '/top.json' do
get 'Get the top topics' do
tags 'Topics'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
produces 'application/json'
response '200', 'topic updated' do
schema type: :object, properties: {
users: {
type: :array,
items: {
type: :object,
properties: {
id: { type: :integer },
username: { type: :string },
name: { type: :string },
avatar_template: { type: :string },
}
},
},
primary_groups: {
type: :array,
items: {
},
},
topic_list: {
type: :object,
properties: {
can_create_topic: { type: :boolean },
draft: { type: [:string, :null] },
draft_key: { type: :string },
draft_sequence: { type: :integer },
for_period: { type: :string },
per_page: { type: :integer },
topics: {
type: :array,
items: {
type: :object,
properties: {
id: { type: :integer },
title: { type: :string },
fancy_title: { type: :string },
slug: { type: :string },
posts_count: { type: :integer },
reply_count: { type: :integer },
highest_post_number: { type: :integer },
image_url: { type: [:string, :null] },
created_at: { type: :string },
last_posted_at: { type: :string },
bumped: { type: :boolean },
bumped_at: { type: :string },
archetype: { type: :string },
unseen: { type: :boolean },
last_read_post_number: { type: :integer },
unread_posts: { type: :integer },
pinned: { type: :boolean },
unpinned: { type: :boolean },
visible: { type: :boolean },
closed: { type: :boolean },
archived: { type: :boolean },
notification_level: { type: :integer },
bookmarked: { type: :boolean },
liked: { type: :boolean },
views: { type: :integer },
like_count: { type: :integer },
has_summary: { type: :boolean },
last_poster_username: { type: :string },
category_id: { type: :integer },
op_like_count: { type: :integer },
pinned_globally: { type: :boolean },
featured_link: { type: [:string, :null] },
posters: {
type: :array,
items: {
type: :object,
properties: {
extras: { type: [:string, :null] },
description: { type: :string },
user_id: { type: :integer },
primary_group_id: { type: [:string, :null] },
}
},
},
}
},
},
}
},
}
run_test!
end
end
end
path '/top.json' do
get 'Get the top topics filtered by period' do
tags 'Topics'
operationId 'listTopTopics'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -853,6 +765,7 @@ describe 'topics' do
path '/t/{id}/notifications.json' do
post 'Set notification level' do
tags 'Topics'
operationId 'setNotificationLevel'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -885,6 +798,7 @@ describe 'topics' do
path '/t/{id}/change-timestamp.json' do
put 'Update topic timestamp' do
tags 'Topics'
operationId 'updateTopicTimestamp'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true
@ -918,6 +832,7 @@ describe 'topics' do
path '/t/{id}/timer.json' do
post 'Create topic timer' do
tags 'Topics'
operationId 'createTopicTimer'
consumes 'application/json'
parameter name: 'Api-Key', in: :header, type: :string, required: true
parameter name: 'Api-Username', in: :header, type: :string, required: true