mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Add swagger specs for tracked months and visited cities
This commit is contained in:
parent
d9930521c9
commit
81dc03f7c9
4 changed files with 113 additions and 6 deletions
|
|
@ -1,7 +1,17 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe "Api::V1::Countries::VisitedCities", type: :request do
|
RSpec.describe 'Api::V1::Countries::VisitedCities', type: :request do
|
||||||
describe "GET /index" do
|
describe 'GET /index' do
|
||||||
pending "add some examples (or delete) #{__FILE__}"
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe "Api::V1::Points::TrackedMonths", type: :request do
|
RSpec.describe 'Api::V1::Points::TrackedMonths', type: :request do
|
||||||
describe "GET /index" do
|
describe 'GET /index' do
|
||||||
pending "add some examples (or delete) #{__FILE__}"
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
39
spec/swagger/api/v1/points/tracked_months_controller_spec.rb
Normal file
39
spec/swagger/api/v1/points/tracked_months_controller_spec.rb
Normal 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
|
||||||
|
|
@ -538,6 +538,56 @@ paths:
|
||||||
- photoprism
|
- photoprism
|
||||||
'404':
|
'404':
|
||||||
description: photo not found
|
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":
|
"/api/v1/points":
|
||||||
get:
|
get:
|
||||||
summary: Retrieves all points
|
summary: Retrieves all points
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue