fix map schema - woot it works
This commit is contained in:
parent
1fbfd56d57
commit
139963e533
2 changed files with 77 additions and 0 deletions
|
@ -30,35 +30,68 @@
|
||||||
"user_id": {
|
"user_id": {
|
||||||
"$ref": "_id.json"
|
"$ref": "_id.json"
|
||||||
},
|
},
|
||||||
|
"user": {
|
||||||
|
"$ref": "_user.json"
|
||||||
|
},
|
||||||
"topic_ids": {
|
"topic_ids": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "_id.json"
|
"$ref": "_id.json"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"topics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "_topic.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
"synapse_ids": {
|
"synapse_ids": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "_id.json"
|
"$ref": "_id.json"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"synapses": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "_synapse.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
"mapping_ids": {
|
"mapping_ids": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "_id.json"
|
"$ref": "_id.json"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mappings": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "_mapping.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
"contributor_ids": {
|
"contributor_ids": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "_id.json"
|
"$ref": "_id.json"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"contributors": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "_user.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
"collaborator_ids": {
|
"collaborator_ids": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "_id.json"
|
"$ref": "_id.json"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"collaborators": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "_user.json"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -70,5 +103,43 @@
|
||||||
"starred",
|
"starred",
|
||||||
"created_at",
|
"created_at",
|
||||||
"updated_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" ] }
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ RSpec.describe 'maps API', type: :request do
|
||||||
post "/api/v2/maps/#{map.id}/stars", params: { access_token: token }
|
post "/api/v2/maps/#{map.id}/stars", params: { access_token: token }
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(response).to match_json_schema(:map)
|
expect(response).to match_json_schema(:map)
|
||||||
|
expect(response).to match_json_schema(:map_starred)
|
||||||
expect(user.stars.count).to eq 1
|
expect(user.stars.count).to eq 1
|
||||||
expect(map.stars.count).to eq 1
|
expect(map.stars.count).to eq 1
|
||||||
end
|
end
|
||||||
|
@ -78,6 +79,7 @@ RSpec.describe 'maps API', type: :request do
|
||||||
context 'RAML example' do
|
context 'RAML example' do
|
||||||
let(:resource) { get_json_example(:map) }
|
let(:resource) { get_json_example(:map) }
|
||||||
let(:collection) { get_json_example(:maps) }
|
let(:collection) { get_json_example(:maps) }
|
||||||
|
let(:starred) { get_json_example(:map_starred) }
|
||||||
|
|
||||||
it 'resource matches schema' do
|
it 'resource matches schema' do
|
||||||
expect(resource).to match_json_schema(:map)
|
expect(resource).to match_json_schema(:map)
|
||||||
|
@ -86,5 +88,9 @@ RSpec.describe 'maps API', type: :request do
|
||||||
it 'collection matches schema' do
|
it 'collection matches schema' do
|
||||||
expect(collection).to match_json_schema(:maps)
|
expect(collection).to match_json_schema(:maps)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'starred resource matches schema' do
|
||||||
|
expect(starred).to match_json_schema(:map)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue