From 932c9016d79c8be602ecea783d718f6329a92737 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Wed, 28 Aug 2024 20:34:08 +0200 Subject: [PATCH] Update swagger docs with missing page and per_page query parameters --- CHANGELOG.md | 5 +- spec/swagger/api/v1/points_controller_spec.rb | 83 +++++++++++++ swagger/v1/swagger.yaml | 111 ++++++++++++++++++ 3 files changed, 195 insertions(+), 4 deletions(-) create mode 100644 spec/swagger/api/v1/points_controller_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index c2a464f1..0bc7aadb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/spec/swagger/api/v1/points_controller_spec.rb b/spec/swagger/api/v1/points_controller_spec.rb new file mode 100644 index 00000000..3bfe9696 --- /dev/null +++ b/spec/swagger/api/v1/points_controller_spec.rb @@ -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 diff --git a/swagger/v1/swagger.yaml b/swagger/v1/swagger.yaml index 9b2a1505..99ed29b9 100644 --- a/swagger/v1/swagger.yaml +++ b/swagger/v1/swagger.yaml @@ -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