fix map schema - woot it works

This commit is contained in:
Devin Howard 2016-10-29 22:19:04 +08:00
parent 1fbfd56d57
commit 139963e533
2 changed files with 77 additions and 0 deletions

View file

@ -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" ] }
]
}
]
}

View file

@ -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