mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
DEV: Update api docs to update username and to get post replies (#15881)
Added api docs for: - update username - get post replies
This commit is contained in:
parent
803fd7289d
commit
e66241af7f
@ -318,6 +318,33 @@ describe 'posts' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
path '/posts/{id}/replies.json' do
|
||||||
|
get 'List replies to a post' do
|
||||||
|
tags 'Posts'
|
||||||
|
operationId 'postReplies'
|
||||||
|
consumes 'application/json'
|
||||||
|
expected_request_schema = nil
|
||||||
|
parameter name: :id, in: :path, schema: { type: :string }
|
||||||
|
|
||||||
|
produces 'application/json'
|
||||||
|
response '200', 'post replies' do
|
||||||
|
expected_response_schema = load_spec_schema('post_replies_response')
|
||||||
|
schema expected_response_schema
|
||||||
|
|
||||||
|
fab!(:user) { Fabricate(:user) }
|
||||||
|
fab!(:topic) { Fabricate(:topic) }
|
||||||
|
fab!(:post) { Fabricate(:post, topic: topic, user: user) }
|
||||||
|
let!(:reply) { PostCreator.new(user, raw: "this is some text for my post", topic_id: topic.id, reply_to_post_number: post.post_number).create }
|
||||||
|
let!(:id) { post.id }
|
||||||
|
|
||||||
|
it_behaves_like "a JSON endpoint", 200 do
|
||||||
|
let(:expected_response_schema) { expected_response_schema }
|
||||||
|
let(:expected_request_schema) { expected_request_schema }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
path '/posts/{id}/locked.json' do
|
path '/posts/{id}/locked.json' do
|
||||||
put 'Lock a post from being edited' do
|
put 'Lock a post from being edited' do
|
||||||
tags 'Posts'
|
tags 'Posts'
|
||||||
|
268
spec/requests/api/schemas/json/post_replies_response.json
Normal file
268
spec/requests/api/schemas/json/post_replies_response.json
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"uniqueItems": true,
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"avatar_template": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"cooked": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"post_number": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"post_type": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"reply_count": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"reply_to_post_number": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"quote_count": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"incoming_link_count": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"reads": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"readers_count": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"score": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"yours": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"topic_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"topic_slug": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"display_username": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primary_group_name": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flair_name": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flair_url": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flair_bg_color": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flair_color": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"can_edit": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"can_delete": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"can_recover": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"can_wiki": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"user_title": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reply_to_user": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"avatar_template": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"username",
|
||||||
|
"avatar_template"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"bookmarked": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"actions_summary": {
|
||||||
|
"type": "array",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"can_act": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"can_act"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"moderator": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"admin": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"staff": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"hidden": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"trust_level": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"user_deleted": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"edit_reason": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"can_view_edit_history": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"wiki": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"reviewable_id": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reviewable_score_count": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"reviewable_score_pending_count": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"username",
|
||||||
|
"avatar_template",
|
||||||
|
"created_at",
|
||||||
|
"cooked",
|
||||||
|
"post_number",
|
||||||
|
"post_type",
|
||||||
|
"updated_at",
|
||||||
|
"reply_count",
|
||||||
|
"reply_to_post_number",
|
||||||
|
"quote_count",
|
||||||
|
"incoming_link_count",
|
||||||
|
"reads",
|
||||||
|
"readers_count",
|
||||||
|
"score",
|
||||||
|
"yours",
|
||||||
|
"topic_id",
|
||||||
|
"topic_slug",
|
||||||
|
"display_username",
|
||||||
|
"primary_group_name",
|
||||||
|
"flair_name",
|
||||||
|
"flair_url",
|
||||||
|
"flair_bg_color",
|
||||||
|
"flair_color",
|
||||||
|
"version",
|
||||||
|
"can_edit",
|
||||||
|
"can_delete",
|
||||||
|
"can_recover",
|
||||||
|
"can_wiki",
|
||||||
|
"user_title",
|
||||||
|
"reply_to_user",
|
||||||
|
"bookmarked",
|
||||||
|
"actions_summary",
|
||||||
|
"moderator",
|
||||||
|
"admin",
|
||||||
|
"staff",
|
||||||
|
"user_id",
|
||||||
|
"hidden",
|
||||||
|
"trust_level",
|
||||||
|
"deleted_at",
|
||||||
|
"user_deleted",
|
||||||
|
"edit_reason",
|
||||||
|
"can_view_edit_history",
|
||||||
|
"wiki",
|
||||||
|
"reviewable_id",
|
||||||
|
"reviewable_score_count",
|
||||||
|
"reviewable_score_pending_count"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"new_username": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"new_username"
|
||||||
|
]
|
||||||
|
}
|
@ -176,7 +176,6 @@ describe 'users' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
path '/u/{username}/preferences/email.json' do
|
path '/u/{username}/preferences/email.json' do
|
||||||
|
|
||||||
put 'Update email' do
|
put 'Update email' do
|
||||||
tags 'Users'
|
tags 'Users'
|
||||||
operationId 'updateEmail'
|
operationId 'updateEmail'
|
||||||
@ -201,7 +200,33 @@ describe 'users' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
path '/u/{username}/preferences/username.json' do
|
||||||
|
put 'Update username' do
|
||||||
|
tags 'Users'
|
||||||
|
operationId 'updateUsername'
|
||||||
|
consumes 'application/json'
|
||||||
|
expected_request_schema = load_spec_schema('user_update_username_request')
|
||||||
|
|
||||||
|
parameter name: :username, in: :path, type: :string, required: true
|
||||||
|
parameter name: :params, in: :body, schema: expected_request_schema
|
||||||
|
|
||||||
|
produces 'application/json'
|
||||||
|
response '200', 'username updated' do
|
||||||
|
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
let(:username) { user.username }
|
||||||
|
let(:params) { { 'new_username' => "#{user.username}1" } }
|
||||||
|
|
||||||
|
expected_response_schema = nil
|
||||||
|
|
||||||
|
it_behaves_like "a JSON endpoint", 200 do
|
||||||
|
let(:expected_response_schema) { expected_response_schema }
|
||||||
|
let(:expected_request_schema) { expected_request_schema }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
path '/directory_items.json' do
|
path '/directory_items.json' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user