mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 08:56:36 +08:00
ee7809e8a8
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.
225 lines
8.0 KiB
Ruby
225 lines
8.0 KiB
Ruby
# frozen_string_literal: true
|
|
require 'swagger_helper'
|
|
|
|
describe 'private messages' do
|
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
before do
|
|
Jobs.run_immediately!
|
|
sign_in(admin)
|
|
end
|
|
|
|
path '/topics/private-messages/{username}.json' do
|
|
|
|
get 'Get a list of private messages for a user' do
|
|
tags 'Private Messages'
|
|
operationId 'listUserPrivateMessages'
|
|
parameter name: :username, in: :path, schema: { type: :string }
|
|
|
|
produces 'application/json'
|
|
response '200', 'private messages' 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 },
|
|
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: [:string, :null] },
|
|
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: [:string, :null] },
|
|
pinned_globally: { type: :boolean },
|
|
featured_link: { type: [:string, :null] },
|
|
allowed_user_count: { type: :integer },
|
|
posters: {
|
|
type: :array,
|
|
items: {
|
|
type: :object,
|
|
properties: {
|
|
extras: { type: :string },
|
|
description: { type: :string },
|
|
user_id: { type: :integer },
|
|
primary_group_id: { type: [:string, :null] },
|
|
}
|
|
},
|
|
},
|
|
participants: {
|
|
type: :array,
|
|
items: {
|
|
type: :object,
|
|
properties: {
|
|
extras: { type: :string },
|
|
description: { type: [:string, :null] },
|
|
user_id: { type: :integer },
|
|
primary_group_id: { type: [:string, :null] },
|
|
}
|
|
},
|
|
},
|
|
}
|
|
},
|
|
},
|
|
}
|
|
},
|
|
}
|
|
|
|
let(:username) { Fabricate(:user).username }
|
|
run_test!
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
path '/topics/private-messages-sent/{username}.json' do
|
|
|
|
get 'Get a list of private messages sent for a user' do
|
|
tags 'Private Messages'
|
|
operationId 'getUserSentPrivateMessages'
|
|
parameter name: :username, in: :path, schema: { type: :string }
|
|
|
|
produces 'application/json'
|
|
response '200', 'private messages' do
|
|
schema type: :object, properties: {
|
|
users: {
|
|
type: :array,
|
|
items: {
|
|
type: :object,
|
|
properties: {
|
|
id: { type: :integer },
|
|
username: { type: :string },
|
|
name: { type: [:string, :null] },
|
|
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 },
|
|
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: [:string, :null] },
|
|
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: [:string, :null] },
|
|
pinned_globally: { type: :boolean },
|
|
featured_link: { type: [:string, :null] },
|
|
allowed_user_count: { type: :integer },
|
|
posters: {
|
|
type: :array,
|
|
items: {
|
|
type: :object,
|
|
properties: {
|
|
extras: { type: :string },
|
|
description: { type: :string },
|
|
user_id: { type: :integer },
|
|
primary_group_id: { type: [:string, :null] },
|
|
}
|
|
},
|
|
},
|
|
participants: {
|
|
type: :array,
|
|
items: {
|
|
},
|
|
},
|
|
}
|
|
},
|
|
},
|
|
}
|
|
},
|
|
}
|
|
|
|
let(:username) { Fabricate(:user).username }
|
|
run_test!
|
|
end
|
|
end
|
|
end
|
|
end
|