DEV: Add API Doc specs for topic endpoints

DEV: Add API Doc specs for topic endpoints

Added some more specs that will be used to auto generate the api docs.

diff --git a/spec/requests/api/posts_spec.rb b/spec/requests/api/posts_spec.rb
index d232cae..bb9e7ee 100644
--- a/spec/requests/api/posts_spec.rb
+++ b/spec/requests/api/posts_spec.rb
@@ -90,7 +90,7 @@ describe 'posts' do
     end
 
     post 'Creates a new topic, a new post, or a private message' do
-      tags 'Posts'
+      tags 'Posts', 'Topics'
       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/topics_spec.rb b/spec/requests/api/topics_spec.rb
new file mode 100644
index 0000000..c216e31
--- /dev/null
+++ b/spec/requests/api/topics_spec.rb
@@ -0,0 +1,852 @@
+# frozen_string_literal: true
+require 'swagger_helper'
+
+describe 'posts' do
+
+  let(:'Api-Key') { Fabricate(:api_key).key }
+  let(:'Api-Username') { 'system' }
+
+  path '/t/{id}/posts.json' do
+    get 'Get specific posts from a topic' 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
+      parameter name: :id, in: :path, schema: { type: :string }
+
+      parameter name: :post_body, in: :body, schema: {
+        type: :object,
+        properties: {
+          'post_ids[]': { type: :integer}
+        }, required: [ 'post_ids[]' ]
+      }
+
+      produces 'application/json'
+      response '200', 'specific posts' do
+        schema type: :object, properties: {
+          post_stream: {
+            type: :object,
+            properties: {
+              posts: {
+                type: :array,
+                items: {
+                  type: :object,
+                  properties: {
+                    id: { type: :integer },
+                    name: { type: :string, nullable: true },
+                    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: :string, nullable: true },
+                    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, nullable: true },
+                    primary_group_name: { type: :string, nullable: true },
+                    primary_group_flair_url: { type: :string, nullable: true },
+                    primary_group_flair_bg_color: { type: :string, nullable: true },
+                    primary_group_flair_color: { type: :string, nullable: true },
+                    version: { type: :integer },
+                    can_edit: { type: :boolean },
+                    can_delete: { type: :boolean },
+                    can_recover: { type: :boolean },
+                    can_wiki: { type: :boolean },
+                    read: { type: :boolean },
+                    user_title: { type: :string, nullable: true },
+                    actions_summary: {
+                      type: :array,
+                      items: {
+                        type: :object,
+                        properties: {
+                          id: { type: :integer },
+                          can_act: { type: :boolean },
+                        }
+                      },
+                    },
+                    moderator: { type: :boolean },
+                    admin: { type: :boolean },
+                    staff: { type: :boolean },
+                    user_id: { type: :integer },
+                    hidden: { type: :boolean },
+                    trust_level: { type: :integer },
+                    deleted_at: { type: :string, nullable: true },
+                    user_deleted: { type: :boolean },
+                    edit_reason: { type: :string, nullable: true },
+                    can_view_edit_history: { type: :boolean },
+                    wiki: { type: :boolean },
+                    reviewable_id: { type: :integer },
+                    reviewable_score_count: { type: :integer },
+                    reviewable_score_pending_count: { type: :integer },
+                  }
+                },
+              },
+            }
+          },
+          id: { type: :integer },
+        }
+
+        let(:post_body) { { 'post_ids[]': 1 } }
+        let(:id) { Fabricate(:topic).id }
+
+        run_test!
+      end
+    end
+  end
+
+  path '/t/{id}.json' do
+    get 'Get a single topic' 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
+      parameter name: :id, in: :path, schema: { type: :string }
+
+      produces 'application/json'
+      response '200', 'specific posts' do
+
+        schema type: :object, properties: {
+          post_stream: {
+            type: :object,
+            properties: {
+              posts: {
+                type: :array,
+                items: {
+                  type: :object,
+                  properties: {
+                    id: { type: :integer },
+                    name: { type: :string },
+                    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: :string, nullable: true },
+                    quote_count: { type: :integer },
+                    incoming_link_count: { type: :integer },
+                    reads: { type: :integer },
+                    readers_count: { type: :integer },
+                    score: { type: :number },
+                    yours: { type: :boolean },
+                    topic_id: { type: :integer },
+                    topic_slug: { type: :string },
+                    display_username: { type: :string },
+                    primary_group_name: { type: :string, nullable: true },
+                    primary_group_flair_url: { type: :string, nullable: true },
+                    primary_group_flair_bg_color: { type: :string, nullable: true },
+                    primary_group_flair_color: { type: :string, nullable: true },
+                    version: { type: :integer },
+                    can_edit: { type: :boolean },
+                    can_delete: { type: :boolean },
+                    can_recover: { type: :boolean },
+                    can_wiki: { type: :boolean },
+                    link_counts: {
+                      type: :array,
+                      items: {
+                        type: :object,
+                        properties: {
+                          url: { type: :string },
+                          internal: { type: :boolean },
+                          reflection: { type: :boolean },
+                          clicks: { type: :integer },
+                        }
+                      },
+                    },
+                    read: { type: :boolean },

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

GitHub sha: 3314654a

1 Like