Add swagger specs for tracked months and visited cities

This commit is contained in:
Eugene Burmakin 2024-12-16 15:22:34 +01:00
parent d9930521c9
commit 81dc03f7c9
4 changed files with 113 additions and 6 deletions

View file

@ -1,7 +1,17 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe "Api::V1::Countries::VisitedCities", type: :request do
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
RSpec.describe 'Api::V1::Countries::VisitedCities', type: :request do
describe 'GET /index' do
let(:user) { create(:user) }
let(:start_at) { '2023-01-01' }
let(:end_at) { '2023-12-31' }
it 'returns visited cities' do
get "/api/v1/countries/visited_cities?api_key=#{user.api_key}&start_at=#{start_at}&end_at=#{end_at}"
expect(response).to have_http_status(:ok)
end
end
end

View file

@ -1,7 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe "Api::V1::Points::TrackedMonths", type: :request do
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
RSpec.describe 'Api::V1::Points::TrackedMonths', type: :request do
describe 'GET /index' do
let(:user) { create(:user) }
it 'returns tracked months' do
get "/api/v1/points/tracked_months?api_key=#{user.api_key}"
expect(response).to have_http_status(:ok)
end
end
end

View file

@ -0,0 +1,39 @@
# frozen_string_literal: true
require 'swagger_helper'
describe 'Points Tracked Months API', type: :request do
path '/api/v1/points/tracked_months' do
get 'Returns list of tracked years and months' do
tags 'Points'
produces 'application/json'
parameter name: :api_key, in: :query, type: :string, required: true, description: 'API Key'
response '200', 'years and months found' do
schema type: :array,
items: {
type: :object,
properties: {
year: { type: :integer, description: 'Year in YYYY format' },
months: {
type: :array,
items: { type: :string, description: 'Three-letter month abbreviation' }
}
},
required: %w[year months]
},
example: [{
year: 2024,
months: %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec]
}]
let(:api_key) { create(:user).api_key }
run_test!
end
response '401', 'unauthorized' do
let(:api_key) { 'invalid' }
run_test!
end
end
end
end

View file

@ -538,6 +538,56 @@ paths:
- photoprism
'404':
description: photo not found
"/api/v1/points/tracked_months":
get:
summary: Returns list of tracked years and months
tags:
- Points
parameters:
- name: api_key
in: query
required: true
description: API Key
schema:
type: string
responses:
'200':
description: years and months found
content:
application/json:
schema:
type: array
items:
type: object
properties:
year:
type: integer
description: Year in YYYY format
months:
type: array
items:
type: string
description: Three-letter month abbreviation
required:
- year
- months
example:
- year: 2024
months:
- Jan
- Feb
- Mar
- Apr
- May
- Jun
- Jul
- Aug
- Sep
- Oct
- Nov
- Dec
'401':
description: unauthorized
"/api/v1/points":
get:
summary: Retrieves all points