From 6e7a8b75d1e0a28ba51337bf2e8ae003c62eda20 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 03:45:29 +0530 Subject: [swagger] Add /calendar and Calendar definitions --- swagger.json | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/swagger.json b/swagger.json index 0f298f161..eacc589b3 100644 --- a/swagger.json +++ b/swagger.json @@ -1010,6 +1010,81 @@ } } } + }, + "/calendars": { + "get": { + "summary": "Fetch a list of Calendars", + "description": "Without params, it returns a list of Calendars the user has access to", + "parameters": [ + { + "$ref": "#/parameters/all" + }, + { + "$ref": "#/parameters/userId" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Calendar" + } + } + } + } + }, + "post": { + "summary": "Create a Calendar", + "parameters": [ + { + "$ref": "#/parameters/Calendar" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Calendar" + } + } + } + } + }, + "/calendars/{id}": { + "put": { + "summary": "Update a Calendar", + "parameters": [ + { + "$ref": "#/parameters/entityId" + }, + { + "$ref": "#/parameters/Calendar" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Calendar" + } + } + } + }, + "delete": { + "summary": "Delete a Calendar", + "parameters": [ + { + "$ref": "#/parameters/entityId" + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } } }, "definitions": { @@ -1490,6 +1565,21 @@ "description": "in meters" } } + }, + "Calendar": { + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "data": { + "type": "string", + "description": "base64 encoded file in iCalendar format" + }, + "atributes": {} + } } }, "parameters": { @@ -1502,7 +1592,7 @@ "all": { "name": "all", "in": "query", - "description": "Can only be used by admin users to fetch all entities", + "description": "Can only be used by admins or managers to fetch all entities", "type": "boolean" }, "userId": { -- cgit v1.2.3 From bc44f365301c094d6698e2af8e73ac022c0008ef Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 03:51:30 +0530 Subject: [swagger] Add /permissions/calendar and define CalendarPermission --- swagger.json | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/swagger.json b/swagger.json index eacc589b3..e2ce04847 100644 --- a/swagger.json +++ b/swagger.json @@ -384,6 +384,37 @@ } } }, + "/permissions/calendars": { + "post": { + "summary": "Link a Calendar to a User", + "parameters": [ + { + "$ref": "#/parameters/CalendarPermission" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/CalendarPermission" + } + } + } + }, + "delete": { + "summary": "Remove a Calendar from a User", + "parameters": [ + { + "$ref": "#/parameters/CalendarPermission" + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, "/positions": { "get": { "summary" : "Fetches a list of Positions", @@ -1354,6 +1385,16 @@ } } }, + "CalendarPermission": { + "properties": { + "userId": { + "type": "integer" + }, + "calendarId": { + "type": "integer" + } + } + }, "GroupGeofence": { "properties": { "groupId": { @@ -1579,7 +1620,7 @@ "description": "base64 encoded file in iCalendar format" }, "atributes": {} - } + } } }, "parameters": { @@ -1663,6 +1704,14 @@ "$ref": "#/definitions/GeofencePermission" } }, + "CalendarPermission": { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CalendarPermission" + } + }, "User": { "name": "body", "in": "body", -- cgit v1.2.3 From 95e2076ef12286ffaff882ec709d0813794d3aa9 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 04:26:38 +0530 Subject: [swagger] Update /positions with alternate content types --- swagger.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/swagger.json b/swagger.json index e2ce04847..ba036f99f 100644 --- a/swagger.json +++ b/swagger.json @@ -1617,7 +1617,7 @@ }, "data": { "type": "string", - "description": "base64 encoded file in iCalendar format" + "description": "base64 encoded in iCalendar format" }, "atributes": {} } @@ -1736,6 +1736,14 @@ "$ref": "#/definitions/AttributeAlias" } }, + "Calendar": { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Calendar" + } + }, "deviceIdArray": { "name": "deviceId", "in": "query", -- cgit v1.2.3 From 7787e848c93035678d36531da4d420896c836da8 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 04:27:42 +0530 Subject: [swagger] Fix typo and define Calendar params --- swagger.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/swagger.json b/swagger.json index ba036f99f..98bb7e774 100644 --- a/swagger.json +++ b/swagger.json @@ -419,6 +419,16 @@ "get": { "summary" : "Fetches a list of Positions", "description" : "Without any params, it returns a list of last known positions for all the user's Devices. _from_ and _to_ fields are not required with _id_", + "consumes": [ + "application/json", + "text/csv", + "application/gpx+xml" + ], + "produces": [ + "application/json", + "text/csv", + "application/gpx+xml" + ], "parameters": [ { "name": "deviceId", -- cgit v1.2.3 From b52cc02972b671f0a794901c00a4a1f303dcf1e8 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 04:32:22 +0530 Subject: [swagger] Update /reports/* with alternate content types --- swagger.json | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/swagger.json b/swagger.json index 98bb7e774..11358878c 100644 --- a/swagger.json +++ b/swagger.json @@ -827,6 +827,14 @@ "get": { "summary": "Fetch a list of Positions within the time period for the Devices or Groups", "description": "At least one _deviceId_ or one _groupId_ must be passed", + "consumes": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], + "produces": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], "parameters": [ { "$ref": "#/parameters/deviceIdArray" @@ -858,6 +866,14 @@ "get": { "summary": "Fetch a list of Events within the time period for the Devices or Groups", "description": "At least one _deviceId_ or one _groupId_ must be passed", + "consumes": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], + "produces": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], "parameters": [ { "$ref": "#/parameters/deviceIdArray" @@ -898,6 +914,14 @@ "get": { "summary": "Fetch a list of ReportSummary within the time period for the Devices or Groups", "description": "At least one _deviceId_ or one _groupId_ must be passed", + "consumes": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], + "produces": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], "parameters": [ { "$ref": "#/parameters/deviceIdArray" @@ -929,6 +953,14 @@ "get": { "summary": "Fetch a list of ReportTrips within the time period for the Devices or Groups", "description": "At least one _deviceId_ or one _groupId_ must be passed", + "consumes": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], + "produces": [ + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ], "parameters": [ { "$ref": "#/parameters/deviceIdArray" -- cgit v1.2.3 From e3378e2c70bf030cbf0124ff8bf5e5ae87ffc965 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 04:43:50 +0530 Subject: [swagger] Update /session with params {token} --- swagger.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/swagger.json b/swagger.json index 11358878c..41d15fd31 100644 --- a/swagger.json +++ b/swagger.json @@ -509,12 +509,20 @@ } } }, - "/session": { + "/session/{token}": { "get": { "summary": "Fetch Session information", "consumes": [ "application/x-www-form-urlencoded" ], + "parameters": [ + { + "name": "token", + "in": "path", + "required": false, + "type": "string" + } + ], "responses": { "200": { "description": "OK", -- cgit v1.2.3 From 9a5b0f0f8cf6ace7ef642eacfed848dbfb11d369 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 04:53:15 +0530 Subject: [swagger] Add /permissions/users and UserPermission definition --- swagger.json | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/swagger.json b/swagger.json index 41d15fd31..58dcb9cfd 100644 --- a/swagger.json +++ b/swagger.json @@ -415,6 +415,37 @@ } } }, + "/permissions/users": { + "post": { + "summary": "Link a User to a manager User", + "parameters": [ + { + "$ref": "#/parameters/UserPermission" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/UserPermission" + } + } + } + }, + "delete": { + "summary": "Remove a User from a manager User", + "parameters": [ + { + "$ref": "#/parameters/UserPermission" + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, "/positions": { "get": { "summary" : "Fetches a list of Positions", @@ -1762,6 +1793,14 @@ "$ref": "#/definitions/CalendarPermission" } }, + "UserPermission": { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UserPermission" + } + }, "User": { "name": "body", "in": "body", -- cgit v1.2.3 From ebc2ec28d63be9e1533f8b55c28080c885884c53 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 05:00:45 +0530 Subject: [swagger] Update /users with params --- swagger.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/swagger.json b/swagger.json index 58dcb9cfd..f2647ef84 100644 --- a/swagger.json +++ b/swagger.json @@ -614,6 +614,15 @@ "/users": { "get": { "summary": "Fetch a list of Users", + "parameters": [ + { + "name": "userId", + "in": "query", + "description": "Can only be used by admin or manger users", + "required": false, + "type": "string" + } + ], "responses": { "200": { "description": "OK", @@ -1476,6 +1485,16 @@ } } }, + "UserPermission": { + "properties": { + "userId": { + "type": "integer" + }, + "managedUserId": { + "type": "integer" + } + } + }, "GroupGeofence": { "properties": { "groupId": { -- cgit v1.2.3 From b1f40290839aab44ece75e8ffdf012593090badb Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 05:01:46 +0530 Subject: [swagger] Fix incorrect params in /session --- swagger.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swagger.json b/swagger.json index f2647ef84..47728d8ed 100644 --- a/swagger.json +++ b/swagger.json @@ -540,7 +540,7 @@ } } }, - "/session/{token}": { + "/session": { "get": { "summary": "Fetch Session information", "consumes": [ @@ -549,7 +549,7 @@ "parameters": [ { "name": "token", - "in": "path", + "in": "query", "required": false, "type": "string" } -- cgit v1.2.3 From f3699c403d113b0d1a2aecea2e43b687b0719740 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 05:41:01 +0530 Subject: [swagger] Update model definitions --- swagger.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/swagger.json b/swagger.json index 47728d8ed..9af241dd0 100644 --- a/swagger.json +++ b/swagger.json @@ -1260,6 +1260,12 @@ "address": { "type": "string" }, + "accuracy": { + "type": "number" + }, + "network": { + "type": "string" + }, "attributes": {} } }, @@ -1318,6 +1324,12 @@ "deviceLimit": { "type": "integer" }, + "userLimit": { + "type": "integer" + }, + "deviceReadonly": { + "type": "boolean" + }, "token": { "type": "string" }, @@ -1536,6 +1548,9 @@ "area": { "type": "string" }, + "calendarId": { + "type": "integer" + }, "attributes": {} } }, @@ -1550,6 +1565,12 @@ "userId": { "type": "integer" }, + "web": { + "type": "boolean" + }, + "mail": { + "type": "boolean" + }, "attributes": {} } }, -- cgit v1.2.3 From 6b75d0e26d106590494240afff586204d34e4588 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 06:42:47 +0530 Subject: Update script to sort by method --- tools/swagger2html.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/swagger2html.py b/tools/swagger2html.py index a3488835c..1121f04c9 100755 --- a/tools/swagger2html.py +++ b/tools/swagger2html.py @@ -224,11 +224,17 @@ def make_responses_table(responses): except KeyError as e: handleException('KeyError', e) +def sorted_by_method(section): + sorting_function = lambda x: [ 'GET', 'POST', 'PUT', 'DELETE' ].index( + x['title'].split(' ')[0] + ) + return sorted(sorted(section), key=sorting_function) + def make_paths(sections, json_data): md = '

Paths

\n' for key in sorted(sections): md += '

{0}

\n'.format(key) - for section in sections[key]: + for section in sorted_by_method(sections[key]): md += '

{}

\n'.format( section['href'], section['title'] ) @@ -256,7 +262,7 @@ def make_contents(path_section, json_data): for key in sorted(path_section): md += '
  • {0}\n'.format(key) md += '
      \n' - for section in path_section[key]: + for section in sorted_by_method(path_section[key]): md += '
    • {}
    • \n'.format( section['href'], section['title'] ) -- cgit v1.2.3 From 49bfc0f90243046e658775016d8461b5982817f0 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 06:43:32 +0530 Subject: [swagger] Change version to 3.10 - fix typos --- swagger.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/swagger.json b/swagger.json index 9af241dd0..0857138e2 100644 --- a/swagger.json +++ b/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "3.9", + "version": "3.10", "title": "traccar" }, "host": "demo.traccar.org", @@ -618,7 +618,7 @@ { "name": "userId", "in": "query", - "description": "Can only be used by admin or manger users", + "description": "Can only be used by admin or manager users", "required": false, "type": "string" } @@ -877,11 +877,11 @@ "description": "At least one _deviceId_ or one _groupId_ must be passed", "consumes": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "produces": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "parameters": [ { @@ -916,11 +916,11 @@ "description": "At least one _deviceId_ or one _groupId_ must be passed", "consumes": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "produces": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "parameters": [ { @@ -964,11 +964,11 @@ "description": "At least one _deviceId_ or one _groupId_ must be passed", "consumes": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "produces": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "parameters": [ { @@ -1003,11 +1003,11 @@ "description": "At least one _deviceId_ or one _groupId_ must be passed", "consumes": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "produces": [ "application/json", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], "parameters": [ { -- cgit v1.2.3