diff --git a/doc/api/schemas/_map.json b/doc/api/schemas/_map.json index 76586914..d8d9c138 100644 --- a/doc/api/schemas/_map.json +++ b/doc/api/schemas/_map.json @@ -30,35 +30,68 @@ "user_id": { "$ref": "_id.json" }, + "user": { + "$ref": "_user.json" + }, "topic_ids": { "type": "array", "items": { "$ref": "_id.json" } }, + "topics": { + "type": "array", + "items": { + "$ref": "_topic.json" + } + }, "synapse_ids": { "type": "array", "items": { "$ref": "_id.json" } }, + "synapses": { + "type": "array", + "items": { + "$ref": "_synapse.json" + } + }, "mapping_ids": { "type": "array", "items": { "$ref": "_id.json" } }, + "mappings": { + "type": "array", + "items": { + "$ref": "_mapping.json" + } + }, "contributor_ids": { "type": "array", "items": { "$ref": "_id.json" } }, + "contributors": { + "type": "array", + "items": { + "$ref": "_user.json" + } + }, "collaborator_ids": { "type": "array", "items": { "$ref": "_id.json" } + }, + "collaborators": { + "type": "array", + "items": { + "$ref": "_user.json" + } } }, "required": [ @@ -70,5 +103,43 @@ "starred", "created_at", "updated_at" + ], + "allOf": [ + { + "oneOf": [ + { "required": [ "user_id" ] }, + { "required": [ "user" ] } + ] + }, + { + "oneOf": [ + { "required": [ "topic_ids" ] }, + { "required": [ "topics" ] } + ] + }, + { + "oneOf": [ + { "required": [ "synapse_ids" ] }, + { "required": [ "synapses" ] } + ] + }, + { + "oneOf": [ + { "required": [ "mapping_ids" ] }, + { "required": [ "mappings" ] } + ] + }, + { + "oneOf": [ + { "required": [ "contributor_ids" ] }, + { "required": [ "contributors" ] } + ] + }, + { + "oneOf": [ + { "required": [ "collaborator_ids" ] }, + { "required": [ "collaborators" ] } + ] + } ] } diff --git a/spec/api/v2/maps_api_spec.rb b/spec/api/v2/maps_api_spec.rb index 5f5e9b83..596ae6bb 100644 --- a/spec/api/v2/maps_api_spec.rb +++ b/spec/api/v2/maps_api_spec.rb @@ -62,6 +62,7 @@ RSpec.describe 'maps API', type: :request do post "/api/v2/maps/#{map.id}/stars", params: { access_token: token } expect(response).to have_http_status(:success) expect(response).to match_json_schema(:map) + expect(response).to match_json_schema(:map_starred) expect(user.stars.count).to eq 1 expect(map.stars.count).to eq 1 end @@ -78,6 +79,7 @@ RSpec.describe 'maps API', type: :request do context 'RAML example' do let(:resource) { get_json_example(:map) } let(:collection) { get_json_example(:maps) } + let(:starred) { get_json_example(:map_starred) } it 'resource matches schema' do expect(resource).to match_json_schema(:map) @@ -86,5 +88,9 @@ RSpec.describe 'maps API', type: :request do it 'collection matches schema' do expect(collection).to match_json_schema(:maps) end + + it 'starred resource matches schema' do + expect(starred).to match_json_schema(:map) + end end end