From 19a1acb38b66c9d9f6e1ca937c9f163c4ffe9194 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 21 Aug 2024 16:54:59 +0200 Subject: [PATCH] Add `api_versions` to `/api/v2/instance` (#31354) --- app/serializers/rest/instance_serializer.rb | 8 +++++++- spec/requests/api/v2/instance_spec.rb | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 8df79db6c7..5475bd12b4 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -11,7 +11,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer attributes :domain, :title, :version, :source_url, :description, :usage, :thumbnail, :languages, :configuration, - :registrations + :registrations, :api_versions has_one :contact, serializer: ContactSerializer has_many :rules, serializer: REST::RuleSerializer @@ -94,6 +94,12 @@ class REST::InstanceSerializer < ActiveModel::Serializer } end + def api_versions + { + mastodon: 1, + } + end + private def registrations_enabled? diff --git a/spec/requests/api/v2/instance_spec.rb b/spec/requests/api/v2/instance_spec.rb index 5c464f09a7..2636970d6e 100644 --- a/spec/requests/api/v2/instance_spec.rb +++ b/spec/requests/api/v2/instance_spec.rb @@ -18,6 +18,7 @@ describe 'Instances' do expect(body_as_json) .to be_present .and include(title: 'Mastodon') + .and include_api_versions .and include_configuration_limits end end @@ -32,6 +33,7 @@ describe 'Instances' do expect(body_as_json) .to be_present .and include(title: 'Mastodon') + .and include_api_versions .and include_configuration_limits end end @@ -53,5 +55,13 @@ describe 'Instances' do ) ) end + + def include_api_versions + include( + api_versions: include( + mastodon: anything + ) + ) + end end end