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

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

From the openapi spec:

OpenAPI Specification v3.1.0 | Introduction, Definitions, & More

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.

diff --git a/spec/requests/api/backups_spec.rb b/spec/requests/api/backups_spec.rb
index 9b52492..27317a4 100644
--- a/spec/requests/api/backups_spec.rb
+++ b/spec/requests/api/backups_spec.rb
@@ -36,6 +36,7 @@ describe 'backups' do
   path '/admin/backups.json' do
     get 'List backups' do
       tags 'Backups'
+      operationId 'getBackups'
       consumes 'application/json'
       expected_request_schema = nil
 
@@ -53,6 +54,7 @@ describe 'backups' do
 
     post 'Create backup' do
       tags 'Backups'
+      operationId 'createBackup'
       consumes 'application/json'
       expected_request_schema = load_spec_schema('backups_create_request')
       parameter name: :params, in: :body, schema: expected_request_schema
@@ -81,6 +83,7 @@ describe 'backups' do
   path '/admin/backups/{filename}' do
     put 'Send download backup email' do
       tags 'Backups'
+      operationId 'sendDownloadBackupEmail'
       consumes 'application/json'
       expected_request_schema = nil
       parameter name: :filename, in: :path, type: :string, required: true
@@ -100,6 +103,7 @@ describe 'backups' do
 
     get 'Download backup' do
       tags 'Backups'
+      operationId 'downloadBackup'
       consumes 'application/json'
       expected_request_schema = nil
       parameter name: :filename, in: :path, type: :string, required: true
diff --git a/spec/requests/api/badges_spec.rb b/spec/requests/api/badges_spec.rb
index 92a8ad5..4a891a1 100644
--- a/spec/requests/api/badges_spec.rb
+++ b/spec/requests/api/badges_spec.rb
@@ -15,6 +15,7 @@ describe 'badges' do
 
     get 'List badges' do
       tags 'Badges'
+      operationId 'adminListBadges'
       consumes 'application/json'
       expected_request_schema = nil
 
@@ -32,6 +33,7 @@ describe 'badges' do
 
     post 'Create badge' do
       tags 'Badges'
+      operationId 'createBadge'
       consumes 'application/json'
       expected_request_schema = load_spec_schema('badge_create_request')
       parameter name: :params, in: :body, schema: expected_request_schema
@@ -58,6 +60,7 @@ describe 'badges' do
 
     put 'Update badge' do
       tags 'Badges'
+      operationId 'updateBadge'
       consumes 'application/json'
       expected_request_schema = load_spec_schema('badge_update_request')
       parameter name: :id, in: :path, schema: { type: :integer }
@@ -84,6 +87,7 @@ describe 'badges' do
 
     delete 'Delete badge' do
       tags 'Badges'
+      operationId 'deleteBadge'
       consumes 'application/json'
       expected_request_schema = nil
       parameter name: :id, in: :path, schema: { type: :integer }
diff --git a/spec/requests/api/categories_spec.rb b/spec/requests/api/categories_spec.rb
index e131112..2d34f25 100644
--- a/spec/requests/api/categories_spec.rb
+++ b/spec/requests/api/categories_spec.rb
@@ -15,6 +15,7 @@ describe 'categories' do
 
     post 'Creates a category' do
       tags 'Categories'
+      operationId 'createCategory'
       consumes 'application/json'
       expected_request_schema = load_spec_schema('category_create_request')
       parameter name: :params, in: :body, schema: expected_request_schema
@@ -35,6 +36,7 @@ describe 'categories' do
 
     get 'Retrieves a list of categories' do
       tags 'Categories'
+      operationId 'listCategories'
       consumes 'application/json'
       expected_request_schema = nil
 
@@ -55,6 +57,7 @@ describe 'categories' do
 
     put 'Updates a category' do
       tags 'Categories'
+      operationId 'updateCategory'
       consumes 'application/json'
       expected_request_schema = load_spec_schema('category_create_request')
       parameter name: :id, in: :path, schema: { type: :integer }
@@ -80,6 +83,7 @@ describe 'categories' do
 
     get 'List topics' do
       tags 'Categories'
+      operationId 'listCategoryTopics'
       produces 'application/json'
       parameter name: :slug, in: :path, schema: { type: :string }
       parameter name: :id, in: :path, schema: { type: :integer }
@@ -105,6 +109,7 @@ describe 'categories' do
 
     get 'Show category' do
       tags 'Categories'
+      operationId 'getCategory'
       consumes 'application/json'
       parameter name: :id, in: :path, schema: { type: :integer }
       expected_request_schema = nil
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 3973ec9..4662e89 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -13,6 +13,7 @@ describe 'groups' do
   path '/admin/groups.json' do
     post 'Creates a group' do
       tags 'Groups'
+      operationId 'createGroup'
       consumes 'application/json'
       parameter name: :group, in: :body, schema: {
         type: :object,
@@ -78,6 +79,7 @@ describe 'groups' do
   path '/admin/groups/{id}.json' do
     delete 'Delete a group' do
       tags 'Groups'
+      operationId 'deleteGroup'
       consumes 'application/json'
       parameter name: :id, in: :path, type: :integer
       expected_request_schema = nil
@@ -99,6 +101,7 @@ describe 'groups' do
   path '/groups/{id}.json' do
     put 'Update a group' do
       tags 'Groups'
+      operationId 'updateGroup'
       consumes 'application/json'
       parameter name: :id, in: :path, type: :integer
       parameter name: :group, in: :body, schema: {
@@ -128,6 +131,7 @@ describe 'groups' do
 
     get 'Get a group' do
       tags 'Groups'
+      operationId 'getGroup'
       consumes 'application/json'
       parameter name: :id, in: :path, type: :string, example: 'name', description: "Use group name instead of id"
       expected_request_schema = nil
@@ -150,6 +154,7 @@ describe 'groups' do
   path '/groups/{id}/members.json' do
     get 'List group members' do
       tags 'Groups'
+      operationId 'listGroupMembers'
       consumes 'application/json'
       parameter name: :id, in: :path, type: :string, example: 'name', description: "Use group name instead of id"
       expected_request_schema = nil
@@ -170,6 +175,7 @@ describe 'groups' do
 
     put 'Add group members' do
       tags 'Groups'
+      operationId 'addGroupMembers'
       consumes 'application/json'
       parameter name: :id, in: :path, type: :integer
       expected_request_schema = load_spec_schema('group_add_members_request')
@@ -195,6 +201,7 @@ describe 'groups' do
 
     delete 'Remove group members' do
       tags 'Groups'
+      operationId 'removeGroupMembers'
       consumes 'application/json'
       parameter name: :id, in: :path, type: :integer
       expected_request_schema = load_spec_schema('group_remove_members_request')
@@ -222,6 +229,7 @@ describe 'groups' do
   path '/groups.json' do
     get 'List groups' do
       tags 'Groups'
+      operationId 'listGroups'
       consumes 'application/json'
       expected_request_schema = nil
 
diff --git a/spec/requests/api/invites_spec.rb b/spec/requests/api/invites_spec.rb
index 1ed7d22..3e7d1e4 100644
--- a/spec/requests/api/invites_spec.rb
+++ b/spec/requests/api/invites_spec.rb
@@ -9,6 +9,7 @@ describe 'invites' do
   path '/invites.json' do
     post 'Create an invite' do
       tags 'Invites'
+      operationId 'createInvite'
       consumes 'application/json'
       parameter name: 'Api-Key', in: :header, type: :string, required: true
       parameter name: 'Api-Username', in: :header, type: :string, required: true
diff --git a/spec/requests/api/notifications_spec.rb b/spec/requests/api/notifications_spec.rb
index 4100b49..efde83f 100644
--- a/spec/requests/api/notifications_spec.rb
+++ b/spec/requests/api/notifications_spec.rb
@@ -15,6 +15,7 @@ describe 'notifications' do
 
     get 'Get the notifications that belong to the current user' do
       tags 'Notifications'
+      operationId 'getNotifications'
 
       produces 'application/json'
       response '200', 'notifications' do
@@ -60,6 +61,7 @@ describe 'notifications' do
 
     put 'Mark notifications as read' do
       tags 'Notifications'
+      operationId 'markNotificationsAsRead'

[... diff too long, it was truncated ...]

GitHub sha: ee7809e8a8057682240500234161125c1b47e2f5

This commit appears in #14235 which was approved by martin. It was merged by blake.