Browse Source

OpenAPI doc changed to use components as parameters

Lukas Cerny 1 year ago
parent
commit
ac950f80e8
1 changed files with 194 additions and 536 deletions
  1. 194 536
      src/main/resources/openAPISpec.yaml

+ 194 - 536
src/main/resources/openAPISpec.yaml

@@ -29,23 +29,8 @@ paths:
       operationId: campaignsGET
       summary: Publish info about all campaigns
       parameters:
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON array of basic info of each campaign
@@ -67,30 +52,9 @@ paths:
       operationId: campaignIdGET
       summary: Publish info about a campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON object containing info about a campaign
@@ -110,30 +74,9 @@ paths:
       operationId: campaignIdUnitsGET
       summary: Publish info about the campaign's units
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Array containing info about campaign's units
@@ -155,53 +98,13 @@ paths:
       operationId: campaignIdUnitsObservationsGET
       summary: Publish info about all data of units merged together within the campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: query
-          name: from
-          schema:
-            type: string
-            format: date-time
-          required: false
-        - in: query
-          name: to
-          schema:
-            type: string
-            format: date-time
-          required: false
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: offset
-          schema:
-            type: integer
-            format: int64
-        - in: query
-          name: limit
-          schema:
-            type: integer
-            format: int64
-          required: false
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/fromParam'
+        - $ref: '#/components/parameters/toParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/offsetParam'
+        - $ref: '#/components/parameters/limitParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON containing stream of telemetry data
@@ -221,65 +124,13 @@ paths:
       operationId: campaignIdUnitsObservationsLocationsGET
       summary: Publish info about all data of units merged together within the campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: query
-          name: limitPerUnit
-          required: true
-          schema:
-            type: integer
-            default: 1
-          examples:
-            Last locations:
-              value: 1
-              summary: Last Locations of each unit
-        - in: query
-          name: from
-          schema:
-            type: string
-            format: date-time
-          required: false
-          example: 2017-07-21T17:32:28Z
-        - in: query
-          name: to
-          schema:
-            type: string
-            format: date-time
-          required: false
-          example: 2017-07-21T17:32:28Z
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: sort
-          schema:
-            type: string
-            enum: [asc, desc]
-            default: asc
-          examples:
-            Descending Order:
-              value: desc
-            Ascending Order:
-              value: asc
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/limitPerUnitParam'
+        - $ref: '#/components/parameters/fromParam'
+        - $ref: '#/components/parameters/toParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/sortParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON containing stream of telemetry data
@@ -299,35 +150,10 @@ paths:
       operationId: campaignIdUnitIdGET
       summary: Publish info about the unit within its campaign's scope
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-          required: true
-          description: Numeric ID of the unit to get
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Object containing info about the unit within its campaign' scope
@@ -347,61 +173,14 @@ paths:
       operationId: campaignIdUnitIdObservationsGET
       summary: Publish info about all data of the unit within the campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the unit to get
-        - in: query
-          name: from
-          schema:
-            type: string
-            format: date-time
-          required: false
-        - in: query
-          name: to
-          schema:
-            type: string
-            format: date-time
-          required: false
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: offset
-          schema:
-            type: integer
-            format: int64
-          required: false
-        - in: query
-          name: limit
-          schema:
-            type: integer
-            format: int64
-          required: false
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/fromParam'
+        - $ref: '#/components/parameters/toParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/offsetParam'
+        - $ref: '#/components/parameters/limitParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON containing stream of telemetry data
@@ -421,79 +200,15 @@ paths:
       operationId: campaignIdUnitIdLocationsGET
       summary: Publish locations of the unit within the campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          example: 1
-          description: Numeric ID of the campaign to get
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          example: 25
-          description: Numeric ID of the unit to get
-        - in: query
-          name: from
-          schema:
-            type: string
-            format: date-time
-          required: false
-          example: 2017-07-21T17:32:28Z
-        - in: query
-          name: to
-          schema:
-            type: string
-            format: date-time
-          required: false
-          example: 2017-07-21T17:32:28Z
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: offset
-          schema:
-            type: integer
-            format: int64
-          required: false
-          example: 50
-        - in: query
-          name: limit
-          schema:
-            type: integer
-            format: int64
-          required: false
-          example: 100
-        - in: query
-          name: filter
-          schema:
-            type: string
-          required: false
-          examples:
-            Value of Sensor ID 105 > 10:
-              value: sensorId(105)gt10
-              summary: Filter locations of units having value of sensor id 105 > 10
-            Value :
-              value: driverId(34245)eq3
-              summary: Filter locations of units driven by Driver ID 34245 == Activity 3
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/fromParam'
+        - $ref: '#/components/parameters/toParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/offsetParam'
+        - $ref: '#/components/parameters/limitParam'
+        - $ref: '#/components/parameters/filterParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON containing stream of locations
@@ -513,26 +228,9 @@ paths:
       operationId: campaignIdUnitIdSensorsGET
       summary: Publish info about all sensors of the unit within the campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the unit to get
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON containing information of sensors assigned to the unit within its campaign
@@ -554,32 +252,10 @@ paths:
       operationId: campaignIdUnitIdSensorIdGET
       summary: Publish info about all sensors asociated with the unit and the campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the unit to get
-        - in: path
-          name: sensorId
-          schema:
-            type: integer
-          required: true
-          description: Numeric ID of the sensor to get
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/sensorIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Object containing info about the sensor
@@ -599,54 +275,13 @@ paths:
       operationId: campaignIdUnitIdSensorIdObservationsGET
       summary: Publish info about all data of the unit within the campaign
       parameters:
-        - in: path
-          name: campaignId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the campaign to get
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the unit to get
-        - in: path
-          name: sensorId
-          schema:
-            type: integer
-          required: true
-          description: Numeric ID of the sensor to get
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: offset
-          schema:
-            type: integer
-            format: int64
-        - in: query
-          name: limit
-          schema:
-            type: integer
-            format: int64
-          required: false
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/campaignIdParam'
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/sensorIdParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/offsetParam'
+        - $ref: '#/components/parameters/limitParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON containing stream of telemetry data
@@ -666,12 +301,7 @@ paths:
       operationId: unitsGET
       summary: Publish info about all units
       parameters:
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON array of basic info of each unit
@@ -693,13 +323,8 @@ paths:
       operationId: unitIdGET
       summary: Publish info about the unit
       parameters:
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the unit to get
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Object of info of the unit
@@ -719,19 +344,8 @@ paths:
       operationId: unitIdSensorsGET
       summary: Publish info about sensors assigned to the unit
       parameters:
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the unit to get
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Array of info of the sensors
@@ -753,30 +367,9 @@ paths:
       operationId: unitIdCampaignsGET
       summary: Publish info about campaigns where the unit was/is assigned
       parameters:
-        - in: path
-          name: unitId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the unit to get
-        - in: query
-          name: zone
-          schema:
-            type: string
-            default: UTC
-          required: false
-          examples:
-            UTC:
-              value: UTC
-            GMT:
-              value: GMT
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/unitIdParam'
+        - $ref: '#/components/parameters/zoneParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Array of info about campaigns
@@ -798,12 +391,7 @@ paths:
       operationId: sensorsGET
       summary: Publish info about all sensors
       parameters:
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Array of info about sensors
@@ -825,19 +413,8 @@ paths:
       operationId: sensorIdGET
       summary: Publish info about the sensor
       parameters:
-        - in: path
-          name: sensorId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the sensor to get
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/sensorIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Object of info about the sensor
@@ -857,19 +434,8 @@ paths:
       operationId: sensorIdUnitsGET
       summary: Publish info about units to whom the sensor is assigned
       parameters:
-        - in: path
-          name: sensorId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the sensor to get
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/sensorIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Array of info about the units
@@ -892,12 +458,7 @@ paths:
       operationId: phenomenonsGET
       summary: Publish info about all phenomenons
       parameters:
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Array of info about phenomenons
@@ -919,19 +480,8 @@ paths:
       operationId: phenomenonIdGET
       summary: Publish info about the phenomenon
       parameters:
-        - in: path
-          name: phenomenonId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the phenomenon to get
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/phenomenonIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Object of info about the phenomenon
@@ -951,19 +501,8 @@ paths:
       operationId: phenomenonIdSensorsGET
       summary: Publish info about sensors of the phenomenon
       parameters:
-        - in: path
-          name: phenomenonId
-          schema:
-            type: integer
-            format: int64
-          required: true
-          description: Numeric ID of the phenomenon to get
-        - in: query
-          name: navigationLinks
-          schema:
-            type: boolean
-            default: true
-          description: Option to disable @NavigationLinks in a response
+        - $ref: '#/components/parameters/phenomenonIdParam'
+        - $ref: '#/components/parameters/navigationLinksParam'
       responses:
         200:
           description: JSON Array of info about sensors
@@ -982,6 +521,125 @@ paths:
 
 
 components:
+  parameters:
+    campaignIdParam:
+      in: path
+      name: campaignId
+      schema:
+        type: integer
+        format: int64
+      required: true
+      description: Numeric ID of the campaign to get
+    unitIdParam:
+      in: path
+      name: unitId
+      schema:
+        type: integer
+      required: true
+      description: Numeric ID of the unit to get
+    sensorIdParam:
+      in: path
+      name: sensorId
+      schema:
+        type: integer
+      required: true
+      description: Numeric ID of the sensor to get
+    phenomenonIdParam:
+      in: path
+      name: phenomenonId
+      schema:
+        type: integer
+        format: int64
+      required: true
+      description: Numeric ID of the phenomenon to get
+    zoneParam:
+      in: query
+      name: zone
+      schema:
+        type: string
+        default: UTC
+      required: false
+      examples:
+        UTC:
+          value: UTC
+        GMT:
+          value: GMT
+    navigationLinksParam:
+      in: query
+      name: navigationLinks
+      schema:
+        type: boolean
+        default: true
+      description: Option to disable @NavigationLinks in a response
+    limitParam:
+      in: query
+      name: limit
+      schema:
+        type: integer
+        format: int64
+      required: false
+      example: 100
+    offsetParam:
+      in: query
+      name: offset
+      schema:
+        type: integer
+        format: int64
+      example: 100
+    fromParam:
+      in: query
+      name: from
+      schema:
+        type: string
+        format: date-time
+      required: false
+      example: 2017-07-21T17:32:28Z
+    toParam:
+      in: query
+      name: to
+      schema:
+        type: string
+        format: date-time
+      required: false
+      example: 2017-07-21T17:32:28Z
+    limitPerUnitParam:
+      in: query
+      name: limitPerUnit
+      required: true
+      schema:
+        type: integer
+        default: 1
+      examples:
+        One locations:
+          value: 1
+          summary: One location of each unit
+    sortParam:
+      in: query
+      name: sort
+      schema:
+        type: string
+        enum: [ asc, desc ]
+        default: asc
+      examples:
+        Descending Order:
+          value: desc
+          summary: Last location of the units. Last location is combination of sort=desc & limitPerUnit=1
+        Ascending Order:
+          value: asc
+    filterParam:
+      in: query
+      name: filter
+      schema:
+        type: string
+      required: false
+      examples:
+        Value of Sensor ID 105 > 10:
+          value: sensorId(105)gt10
+          summary: Filter locations of units having value of sensor id 105 > 10
+        Value:
+          value: driverId(34245)eq3
+          summary: Filter locations of units driven by Driver ID 34245 == Activity 3
+
   schemas:
     CampaignBasicInfo:
       type: object