Update swagger docs with missing page and per_page query parameters

This commit is contained in:
Eugene Burmakin 2024-08-28 20:34:08 +02:00
parent 914ecd2f2d
commit 932c9016d7
3 changed files with 195 additions and 4 deletions

View file

@ -11,15 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `PATCH /api/v1/settings` endpoint to update user settings with swagger docs
- `GET /api/v1/settings` endpoint to get user settings with swagger docs
- Missing `page` and `per_page` query parameters to the `GET /api/v1/points` endpoint swagger docs
### Changed
- Map settings moved to the map itself and are available in the top right corner of the map under the gear icon.
### Removed
- Swagger docs for removed `/api/v1/points` endpoint
## [0.12.1] — 2024-08-25
### Fixed

View file

@ -0,0 +1,83 @@
# frozen_string_literal: true
require 'swagger_helper'
describe 'Points API', type: :request do
path '/api/v1/points' do
get 'Retrieves all points' do
tags 'Points'
produces 'application/json'
parameter name: :api_key, in: :query, type: :string, required: true, description: 'API Key'
parameter name: :start_at, in: :query, type: :string,
description: 'Start date (i.e. 2024-02-03T13:00:03Z or 2024-02-03)'
parameter name: :end_at, in: :query, type: :string,
description: 'End date (i.e. 2024-02-03T13:00:03Z or 2024-02-03)'
parameter name: :page, in: :query, type: :integer, description: 'Page number'
parameter name: :per_page, in: :query, type: :integer, description: 'Number of points per page'
response '200', 'points found' do
schema type: :array,
items: {
type: :object,
properties: {
id: { type: :integer },
battery_status: { type: :number },
ping: { type: :number },
battery: { type: :number },
tracker_id: { type: :string },
topic: { type: :string },
altitude: { type: :number },
longitude: { type: :number },
velocity: { type: :number },
trigger: { type: :string },
bssid: { type: :string },
ssid: { type: :string },
connection: { type: :string },
vertical_accuracy: { type: :number },
accuracy: { type: :number },
timestamp: { type: :number },
latitude: { type: :number },
mode: { type: :number },
inrids: { type: :array },
in_regions: { type: :array },
raw_data: { type: :string },
import_id: { type: :string },
city: { type: :string },
country: { type: :string },
created_at: { type: :string },
updated_at: { type: :string },
user_id: { type: :integer },
geodata: { type: :string },
visit_id: { type: :string }
}
}
let(:user) { create(:user) }
let(:areas) { create_list(:area, 3, user:) }
let(:api_key) { user.api_key }
let(:start_at) { Time.zone.now - 1.day }
let(:end_at) { Time.zone.now }
let(:points) { create_list(:point, 10, user:, timestamp: 2.hours.ago) }
run_test!
end
end
end
path '/api/v1/points/{id}' do
delete 'Deletes a point' do
tags 'Points'
produces 'application/json'
parameter name: :api_key, in: :query, type: :string, required: true, description: 'API Key'
parameter name: :id, in: :path, type: :string, required: true, description: 'Point ID'
response '200', 'point deleted' do
let(:user) { create(:user) }
let(:point) { create(:point, user:) }
let(:api_key) { user.api_key }
let(:id) { point.id }
run_test!
end
end
end
end

View file

@ -304,6 +304,117 @@ paths:
isorcv: '2024-02-03T13:00:03Z'
isotst: '2024-02-03T13:00:03Z'
disptst: '2024-02-03 13:00:03'
"/api/v1/points":
get:
summary: Retrieves all points
tags:
- Points
parameters:
- name: api_key
in: query
required: true
description: API Key
schema:
type: string
- name: start_at
in: query
description: Start date (i.e. 2024-02-03T13:00:03Z or 2024-02-03)
schema:
type: string
- name: end_at
in: query
description: End date (i.e. 2024-02-03T13:00:03Z or 2024-02-03)
schema:
type: string
responses:
'200':
description: points found
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
battery_status:
type: number
ping:
type: number
battery:
type: number
tracker_id:
type: string
topic:
type: string
altitude:
type: number
longitude:
type: number
velocity:
type: number
trigger:
type: string
bssid:
type: string
ssid:
type: string
connection:
type: string
vertical_accuracy:
type: number
accuracy:
type: number
timestamp:
type: number
latitude:
type: number
mode:
type: number
inrids:
type: array
in_regions:
type: array
raw_data:
type: string
import_id:
type: string
city:
type: string
country:
type: string
created_at:
type: string
updated_at:
type: string
user_id:
type: integer
geodata:
type: string
visit_id:
type: string
"/api/v1/points/{id}":
delete:
summary: Deletes a point
tags:
- Points
parameters:
- name: api_key
in: query
required: true
description: API Key
schema:
type: string
- name: id
in: path
required: true
description: Point ID
schema:
type: string
responses:
'200':
description: point deleted
"/api/v1/settings":
patch:
summary: Updates user settings