From cc3c8fdd6345c7f390c907049459ed81fee69523 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Fri, 15 Nov 2024 19:42:59 +0100 Subject: [PATCH] Improve documentation of groups endpoint --- app/queries/groups/summary_query.rb | 2 +- spec/requests/groups_spec.rb | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/queries/groups/summary_query.rb b/app/queries/groups/summary_query.rb index 637a508..70fc234 100644 --- a/app/queries/groups/summary_query.rb +++ b/app/queries/groups/summary_query.rb @@ -10,7 +10,7 @@ module Groups def query <<~SQL.squish - SELECT#{' '} + SELECT groups.id, groups.name, groups.icon, diff --git a/spec/requests/groups_spec.rb b/spec/requests/groups_spec.rb index eb96268..8bf622b 100644 --- a/spec/requests/groups_spec.rb +++ b/spec/requests/groups_spec.rb @@ -5,15 +5,26 @@ require 'swagger_helper' RSpec.describe 'groups', type: :request do path '/groups' do get('list groups') do + produces 'application/json' response(200, 'successful') do - - after do |example| - example.metadata[:response][:content] = { - 'application/json' => { - example: JSON.parse(response.body, symbolize_names: true) - } - } - end + schema type: :array, + items: { + type: :object, + required: %i[id name icon parent_id color total considered invited confirmed declined tentative], + properties: { + id: { type: :string, format: :uuid, required: true }, + name: { type: :string }, + icon: { type: :string, example: 'pi pi-crown', description: 'The CSS classes used by the icon' }, + parent_id: { type: :string, format: :uuid }, + color: { type: :string, pattern: '^#(?:[0-9a-fA-F]{3}){1,2}$' }, + total: { type: :integer, minimum: 0, description: 'Total number of guests in any status' }, + considered: { type: :integer, minimum: 0 }, + invited: { type: :integer, minimum: 0 }, + confirmed: { type: :integer, minimum: 0 }, + declined: { type: :integer, minimum: 0 }, + tentative: { type: :integer, minimum: 0 } + } + } run_test! end end