openapi: 3.0.0
info:
  title: GNUBoat Mapservice API
  contact:
    name: EngSaS - Engineering Solutions and Services Langenbach
    url: 'http://www.engsas.com'
    email: info@engsas.de
  license:
    name: GPL 3
    url: 'https://www.gnu.org/licenses/gpl-3.0.en.html'
  version: v1
  description: API to upload log files with water depth to GNUBoat server
servers:
  - url: 'https://gnuboat.engsas.com/mapservice/{version}'
    description: The production API server
    variables:
      version:
        default: v1
  - url: 'http://localhost:8080/mapservice/{version}'
    description: The local flask development url
    variables:
      version:
        default: v1
paths:
  /user:
    get:
      description: Returns information of current/authorized user
      tags:
        - users
      summary: Returns info of a user
      operationId: usersGet
      security:
        - basicAuth: []
        - apiKeyAuth: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
              examples:
                User:
                  $ref: '#/components/examples/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      description: Registers a new user
      tags:
        - users
      summary: Registers a new user
      operationId: usersRegister
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserCreation'
            examples:
              Water:
                $ref: '#/components/examples/UserCreation'
      responses:
        '201':
          description: Userr created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
              examples:
                Water:
                  $ref: '#/components/examples/User'
        '400':
          $ref: '#/components/responses/BadRequest'
    options:
      description: Used by CORS preflight
      tags:
        - users
      responses:
        '200':
          description: CORS prefilght requests should return 200 as status code
          content:
            application/json: {}
  /user/apikey_create:
    get:
      description: Generates and returns a new API key for current user
      tags:
        - users
      summary: Returns a new API key
      operationId: usersApiKeyCreate
      security:
        - basicAuth: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiKeys'
              example: NewApiKey4711
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  '/user/{api_key}':
    delete:
      description: Deletes given API key and returns remaining API keys of the user
      tags:
        - users
      summary: Deletes API key
      operationId: usersApiKeyDelete
      security:
        - basicAuth: []
      parameters:
        - name: api_key
          in: path
          description: API key
          required: true
          schema:
            $ref: '#/components/schemas/apiKey'
          example: DelApiKey4711
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiKeys'
              example: ApiKey4711
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  '/user/activate/{activation_code}':
    get:
      description: Activates a user account
      tags:
        - users
      summary: Activates a user account
      operationId: usersActivate
      parameters:
        - name: activation_code
          in: path
          description: Activation code
          required: true
          schema:
            $ref: '#/components/schemas/activationCode'
          example: dac9630aec642a428cd73f4be0a03569
      responses:
        '302':
          description: OK or not OK
          headers:
            Location:
              schema:
                type: string
              description: 'URL to the website, showing the result of the activation'
  /waters:
    get:
      description: Returns all waters
      tags:
        - waters
      summary: Find waters by id
      operationId: watersGet
      parameters:
        - name: name
          in: query
          schema:
            $ref: '#/components/schemas/itemName'
          example: Missi
        - name: manager
          in: query
          schema:
            $ref: '#/components/schemas/username'
          example: jane
        - $ref: '#/components/parameters/orderBy'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/waters'
              examples:
                Waters:
                  $ref: '#/components/examples/waters'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      description: Adds a new water to the database
      tags:
        - waters
      summary: Add a new water
      operationId: watersCreate
      security:
        - basicAuth: []
        - apiKeyAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WaterCreation'
            example:
              name: Rhein
              osmId: 1756854
              osmType: Relation
      responses:
        '201':
          description: Water created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Water'
              examples:
                Water:
                  $ref: '#/components/examples/Water'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  '/waters/{id}':
    get:
      description: Returns the water identified by id
      tags:
        - waters
      summary: Represents a water
      operationId: watersGetById
      parameters:
        - name: id
          in: path
          description: Item ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Water'
              examples:
                Water:
                  $ref: '#/components/examples/Water'
        '404':
          $ref: '#/components/responses/NotFound'
  '/waters/{water_id}/gauges':
    get:
      description: Returns all gauges of water waterId
      tags:
        - waters
      summary: Find gauges of water waterId by gaugeId
      operationId: watersGaugesGet
      parameters:
        - name: water_id
          in: path
          description: Water ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
        - name: name
          in: query
          schema:
            $ref: '#/components/schemas/itemName'
          example: Missi
        - name: manager
          in: query
          schema:
            $ref: '#/components/schemas/username'
          example: jane
        - $ref: '#/components/parameters/orderBy'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Gauges'
              examples:
                Gauges:
                  $ref: '#/components/examples/Gauges'
            application/geo+json:
              schema:
                $ref: '#/components/schemas/GaugesGeoJson'
              examples:
                Gauge:
                  $ref: '#/components/examples/GaugesGeoJson'
    post:
      description: Adds a new gauge for water waterId to the database
      tags:
        - waters
      summary: Add a new water
      operationId: watersGaugeCreate
      parameters:
        - name: water_id
          in: path
          description: Water ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
      security:
        - basicAuth: []
        - apiKeyAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GaugeCreation'
            example:
              name: New Orleans
              location:
                - 90.136111
                - 29.934722
      responses:
        '201':
          description: Gauge created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Gauge'
              examples:
                Gauge:
                  $ref: '#/components/examples/Gauge'
            application/geo+json:
              schema:
                $ref: '#/components/schemas/GaugeGeoJson'
              examples:
                Gauge:
                  $ref: '#/components/examples/GaugeGeoJson'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  '/waters/{water_id}/gauges/{gauge_id}':
    get:
      description: Returns the gauge identified by id
      tags:
        - waters
      summary: Represents a gauge
      operationId: watersGaugeGetById
      parameters:
        - name: water_id
          in: path
          description: Water ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
        - name: gauge_id
          in: path
          description: Gauge ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Gauge'
              examples:
                Gauge:
                  $ref: '#/components/examples/Gauge'
            application/geo+json:
              schema:
                $ref: '#/components/schemas/GaugeGeoJson'
              examples:
                Gauge:
                  $ref: '#/components/examples/GaugeGeoJson'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
  /devices:
    get:
      description: Returns all devices of user
      tags:
        - devices
      summary: Find devices by id
      operationId: devicesGet
      security:
        - basicAuth: []
        - apiKeyAuth: []
      parameters:
        - name: name
          in: query
          schema:
            $ref: '#/components/schemas/itemName'
          example: Love
        - $ref: '#/components/parameters/orderBy'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/devices'
              examples:
                Devices:
                  $ref: '#/components/examples/devices'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      description: Adds a new device to the database
      tags:
        - devices
      summary: Add a new device
      operationId: devicesCreate
      security:
        - basicAuth: []
        - apiKeyAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeviceCreation'
            example:
              name: Lovely Boat
              sensorDepth: 2
      responses:
        '201':
          description: Device created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Device'
              examples:
                Device:
                  $ref: '#/components/examples/Device'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  '/devices/{id}':
    get:
      description: Returns the device identified by id
      tags:
        - devices
      summary: Represents a device
      operationId: devicesGetById
      security:
        - basicAuth: []
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          description: Item ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Device'
              examples:
                Water:
                  $ref: '#/components/examples/Device'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      description: Deletes given device and returns remaining devices of the user
      tags:
        - devices
      summary: Deletes device
      operationId: devicesDeviceDelete
      security:
        - basicAuth: []
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          description: Item id
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
          example: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/devices'
              example:
                Devices:
                  $ref: '#/components/examples/devices'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /logs:
    get:
      description: Returns all log metadata
      tags:
        - logs
      summary: Find logs by id
      operationId: logsGet
      parameters:
        - name: submitter
          in: query
          schema:
            $ref: '#/components/schemas/username'
          example: jane
        - $ref: '#/components/parameters/orderBy'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/logs'
              examples:
                Logs:
                  $ref: '#/components/examples/logs'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      description: Creates a new log from given meta data. The log entries itself, must be uploaded per /logs/{log_id}
      tags:
        - logs
      summary: Add a new log
      operationId: logsLogCreate
      security:
        - basicAuth: []
        - apiKeyAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LogCreation'
      responses:
        '201':
          description: Log created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogMetaData'
              examples:
                LogMetaData:
                  $ref: '#/components/examples/LogMetaData'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  '/logs/{log_id}':
    get:
      description: Returns the log identified by id
      tags:
        - logs
      summary: Represents a log
      operationId: logsLogGetById
      parameters:
        - name: log_id
          in: path
          description: Log ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Log'
              examples:
                Log:
                  $ref: '#/components/examples/Log'
            application/geo+json:
              schema:
                $ref: '#/components/schemas/LogGeoJson'
              examples:
                Log:
                  $ref: '#/components/examples/LogGeoJson'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      description: Adds log entries from uploaded file to current Log
      tags:
        - logs
      summary: Add a new log entries
      operationId: logsLogUpload
      parameters:
        - name: log_id
          in: path
          description: Log ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
      security:
        - basicAuth: []
        - apiKeyAuth: []
      requestBody:
        content:
          text/plain:
            schema:
              type: string
              format: binary
      responses:
        '201':
          description: Logs uploaded
          content:
            application/geo+json:
              schema:
                $ref: '#/components/schemas/LogGeoJson'
              examples:
                Log:
                  $ref: '#/components/examples/LogGeoJson'
            application/json:
              schema:
                $ref: '#/components/schemas/Log'
              examples:
                Log:
                  $ref: '#/components/examples/Log'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
    delete:
      description: Deletes given log and returns remaining logs of the gauge
      tags:
        - logs
      summary: Deletes log
      operationId: logsLogDelete
      security:
        - basicAuth: []
        - apiKeyAuth: []
      parameters:
        - name: log_id
          in: path
          description: Log ID
          required: true
          schema:
            $ref: '#/components/schemas/itemId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/logs'
              example:
                Devices:
                  $ref: '#/components/examples/logs'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      x-basicInfoFunc: openapi_server.server_impl.security.Security.auth_basic
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      x-apikeyInfoFunc: openapi_server.server_impl.security.Security.auth_api
  schemas:
    username:
      title: Username
      type: string
    apiKey:
      title: API Key
      type: string
    apiKeys:
      title: Array of API keys
      type: array
      items:
        $ref: '#/components/schemas/apiKey'
    activationCode:
      title: Activation code for a User
      type: string
    itemId:
      title: Item ID
      type: integer
      format: int32
    itemName:
      title: Item Name
      type: string
    itemBase:
      title: 'Basic, generic item data'
      type: object
      properties:
        label:
          type: string
          description: >-
            A representative name, for the item, which could be understand by
            the user. Mostly it should be the itemName
        id:
          $ref: '#/components/schemas/itemId'
        url:
          type: string
          format: url
          description: 'Url, where details of the object could be retrieved'
      required:
        - label
        - id
    order:
      title: order
      enum:
        - desc
        - asc
      type: string
      default: asc
      description: |
        Sort order:
          * `asc` - Ascending, from A to Z
          * `desc` - Descending, from Z to A
      example: asc
    osmType:
      title: OSM type of item (N|W|R)
      type: string
      enum:
        - Node
        - Way
        - Relation
    comment:
      title: Comment of an item
      type: string
    point:
      title: 'Point of type [longitude, latitude]'
      type: array
      maxItems: 2
      minItems: 2
      items:
        type: number
    geoJsonType:
      title: Type of GeoJSON objects
      type: string
      enum:
        - Feature
        - Point
        - LineString
    geoJsonPoint:
      type: object
      description: GeoJson geometry
      externalDocs:
        url: 'http://geojson.org/geojson-spec.html#id2'
      properties:
        type:
          type: string
        coordinates:
          $ref: '#/components/schemas/point'
    geoJsonLineString:
      type: object
      description: GeoJson geometry
      externalDocs:
        url: 'http://geojson.org/geojson-spec.html#id3'
      properties:
        type:
          type: string
        coordinates:
          type: array
          items:
            $ref: '#/components/schemas/point'
    sensorDepth:
      type: number
      title: Depth of sensor beneath water level in cm (positive means below water)
      minimum: 0
    User:
      title: User
      type: object
      properties:
        username:
          $ref: '#/components/schemas/username'
        email:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        activated:
          type: boolean
        licenseAccepted:
          type: boolean
        apiKeys:
          $ref: '#/components/schemas/apiKeys'
    UserCreation:
      title: User
      type: object
      properties:
        username:
          $ref: '#/components/schemas/username'
        email:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        password:
          type: string
        licenseAccepted:
          type: boolean
      required:
        - username
        - email
        - firstName
        - lastName
        - password
        - licenseAccepted
    Water:
      title: Water
      type: object
      properties:
        waterId:
          $ref: '#/components/schemas/itemId'
        name:
          $ref: '#/components/schemas/itemName'
        manager:
          $ref: '#/components/schemas/username'
        osmId:
          $ref: '#/components/schemas/itemId'
        osmType:
          $ref: '#/components/schemas/osmType'
        gauges:
          $ref: '#/components/schemas/Gauges'
        logs:
          $ref: '#/components/schemas/logs'
      required:
        - waterId
        - name
    WaterCreation:
      title: Water for Creation
      type: object
      properties:
        name:
          $ref: '#/components/schemas/itemName'
        osmId:
          $ref: '#/components/schemas/itemId'
        osmType:
          $ref: '#/components/schemas/osmType'
      required:
        - name
    waters:
      title: waters
      type: array
      items:
        $ref: '#/components/schemas/Water'
    Gauge:
      title: Gauge
      type: object
      properties:
        gaugeId:
          $ref: '#/components/schemas/itemId'
        name:
          $ref: '#/components/schemas/itemName'
        manager:
          $ref: '#/components/schemas/username'
        location:
          $ref: '#/components/schemas/point'
        logs:
          $ref: '#/components/schemas/logs'
        comment:
          $ref: '#/components/schemas/comment'
      required:
        - gaugeId
        - name
        - location
    GaugeCreation:
      title: Gauge for Creation
      type: object
      properties:
        name:
          $ref: '#/components/schemas/itemName'
        location:
          $ref: '#/components/schemas/point'
        water:
          $ref: '#/components/schemas/itemBase'
        comment:
          $ref: '#/components/schemas/comment'
      required:
        - name
        - location
    Gauges:
      title: Gauges
      type: array
      items:
        $ref: '#/components/schemas/Gauge'
    GaugeGeoJson:
      title: Gauge in GeoJson format
      type: object
      properties:
        type:
          $ref: '#/components/schemas/geoJsonType'
        geometry:
          $ref: '#/components/schemas/geoJsonPoint'
        properties:
          type: object
          properties:
            name:
              $ref: '#/components/schemas/itemName'
            manager:
              $ref: '#/components/schemas/username'
            comment:
              $ref: '#/components/schemas/comment'
          required:
            - name
      required:
        - type
        - geometry
        - properties
    GaugesGeoJson:
      title: Gauges in GeoJson format
      type: array
      items:
        $ref: '#/components/schemas/GaugeGeoJson'
    Device:
      title: Device
      type: object
      properties:
        deviceId:
          $ref: '#/components/schemas/itemId'
        name:
          $ref: '#/components/schemas/itemName'
        sensorDepth:
          $ref: '#/components/schemas/sensorDepth'
        logs:
          $ref: '#/components/schemas/logs'
        comment:
          $ref: '#/components/schemas/comment'
      required:
        - deviceId
        - name
        - sensorDepth
    DeviceCreation:
      title: Device for Creation
      type: object
      properties:
        name:
          $ref: '#/components/schemas/itemName'
        sensorDepth:
          $ref: '#/components/schemas/sensorDepth'
        comment:
          $ref: '#/components/schemas/comment'
      required:
        - name
        - sensorDepth
    devices:
      title: Devices
      type: array
      items:
        $ref: '#/components/schemas/Device'
    GaugeLevel:
      title: 'Absolute Level of the gauge, at the time of measuring'
      type: number
      format: float
    LogEntry:
      title: Measurement in a Log
      type: object
      properties:
        datetime:
          type: string
          format: date-time
        location:
          $ref: '#/components/schemas/point'
        waterDepth:
          title: Measured water depth at current position
          type: number
          format: float
      required:
        - datetime
        - location
    LogMetaData:
      title: 'Metadata of a log, without log entries'
      type: object
      properties:
        logId:
          $ref: '#/components/schemas/itemId'
        submitter:
          $ref: '#/components/schemas/username'
        water:
          $ref: '#/components/schemas/itemBase'
        device:
          $ref: '#/components/schemas/itemBase'
        gauge:
          $ref: '#/components/schemas/itemBase'
        gaugeLevel:
          $ref: '#/components/schemas/GaugeLevel'
        start:
          title: Date and Time of the first log entry in UTC timezone
          type: string
          format: date-time
        end:
          title: Date and Time of the last log entry in UTC timezone
          type: string
          format: date-time
        processingState:
            $ref: '#/components/schemas/itemBase'
        entriesCount:
          title: Number of measurings in the log
          type: integer
          format: int64
        comment:
          $ref: '#/components/schemas/comment'
      required:
        - gaugeLevel
        - start
        - end
        - entriesCount
    Log:
      title: A collection of LogEntries
      type: object
      properties:
        metaData:
          $ref: '#/components/schemas/LogMetaData'
        entries:
          title: Log entries
          type: array
          items:
            $ref: '#/components/schemas/LogEntry'
      required:
        - metaData
        - entries
    LogCreation:
      title: Log for Creation
      type: object
      properties:
        water:
          $ref: '#/components/schemas/itemId'
        device:
          $ref: '#/components/schemas/itemId'
        gauge:
          $ref: '#/components/schemas/itemId'
        gaugeLevel:
          $ref: '#/components/schemas/GaugeLevel'
        comment:
          $ref: '#/components/schemas/comment'
      required:
        - water
        - device
        - gauge
        - gaugeLevel
    logs:
      title: Logs
      type: array
      items:
        $ref: '#/components/schemas/LogMetaData'
    LogGeoJson:
      title: Log in GeoJson format
      type: object
      properties:
        type:
          $ref: '#/components/schemas/geoJsonType'
        geometry:
          $ref: '#/components/schemas/geoJsonLineString'
        properties:
          type: object
          additionalProperties:
            type: object
            properties:
              name:
                type: string
              item:
                title: >-
                  LogEntry as GeoJson property ordered in same order as geometry
                  coordinates
                type: object
                properties:
                  datetime:
                    type: string
                    format: date-time
                  waterDepth:
                    $ref: '#/components/schemas/itemName'
                  comment:
                    $ref: '#/components/schemas/comment'
                required:
                  - datetime
                  - waterDepth
      required:
        - type
        - geometry
        - properties
    HttpError:
      title: HTTP Error Response Object
      type: object
      properties:
        type:
          type: string
        title:
          type: string
        detail:
          type: string
        instance:
          type: string
      required:
        - type
        - title
        - detail
        - instance
  parameters:
    orderBy:
      name: order_by
      in: query
      description: 'Order by field: name'
      schema:
        type: string
        default: name
        example: name
    order:
      name: order
      in: query
      description: Order
      schema:
        $ref: '#/components/schemas/order'
      example: ''
    offset:
      name: offset
      in: query
      description: >-
        Skip over a number of elements by specifying an offset value for the
        query
      schema:
        type: integer
        format: int32
        default: 0
        example: 0
    limit:
      name: limit
      in: query
      description: Limit the number of elements on the response
      style: form
      explode: true
      schema:
        type: integer
        format: int32
        default: 10
        example: 10
  examples:
    User:
      value:
        username: jane
        email: jane@example.org
        firstName: Jane
        lastName: Doe
        activated: true
        apiKeys:
          - ApiKey4701
    UserCreation:
      value:
        username: richard
        email: richard@examle.org
        firstName: Richard
        lastName: Roe
        password: sdfl.1238_ASDkeil?
        licenseAccepted: true
    Water:
      value:
        waterId: 1
        name: Mississippi
        osmId: 1756854
        osmType: R
      summary: A water example object
    WaterCreation:
      value:
        name: Mississippi
        osmId: 1756854
        osmType: Relation
      summary: A water example object for creation of a water
    waters:
      value:
        - waterId: 1
          name: Mississippi
          osmId: 1756854
          osmType: Relation
        - waterId: 2
          name: Bodensee
      summary: A sample list with waters
    Gauge:
      value:
        gaugeId: 1
        name: New Orleans
        manager: jane
        location:
          - 90.136111
          - 29.934722
        comment: Gauge for Mississippi in New Orleans
    Gauges:
      value:
        - gaugeId: 1
          name: New Orleans
          manager: jane
          location:
            - 90.136111
            - 29.934722
      summary: A sample list of gauges
    GaugeGeoJson:
      value:
        type: Feature
        geometry:
          type: Point
          coordinates:
            - 90.136111
            - 29.934722
          properties:
            name: New Orleans
            manager: jane
            comment: Gauge for Mississippi in New Orleans
    GaugesGeoJson:
      value:
        - type: Feature
          geometry:
            type: Point
            coordinates:
              - 90.136111
              - 29.934722
            properties:
              name: New Orleans
              manager: jane
              comment: Gauge for Mississippi in New Orleans
      summary: A sample list of gauges in GeoJson format
    Device:
      value:
        deviceId: 1
        name: Lovely Boat
        sensorDepth: 0.2
        comment: Really a pleasure to measure
      summary: A sample device
    devices:
      value:
        - deviceId: 1
          name: Lovely Boat
          sensorDepth: 0.2
          comment: Really a pleasure to measure
    LogMetaData:
      value:
        logId: 1
        submitter:
          userId: 1
          name: Jane
        device:
          deviceId: 1
          name: Lovely Boat
          sensorDepth: 0.2
        gauge:
          gaugeId: 1
          name: New Orleans
          manager: jane
          location:
            - 90.136111
            - 29.934722
        gaugeLevel: 8
        start: 2017-07-21T10:32:28.000Z
        end: 2017-07-21T17:32:28.000Z
        entriesCount: 12600
    Log:
      value:
        metaData:
          logId: 1
          submitter:
            userId: 1
            name: Jane
          device:
            deviceId: 1
            name: Lovely Boat
            sensorDepth: 0.2
          gauge:
            gaugeId: 1
            name: New Orleans
            manager: jane
            location:
              - 90.136111
              - 29.934722
          gaugeLevel: 8
          start: 2017-07-21T10:32:28.000Z
          end: 2017-07-21T17:32:28.000Z
          entriesCount: 1
        entries:
          - datetime: null
            location:
              - 90.136111
              - 29.934722
            waterDepth: 10
    LogGeoJson:
      value:
        type: Feature
        geometry:
          type: LineString
          coordinates:
            - - 90.136111
              - 29.934722
            - - 90.236111
              - 30.034722
          properties:
            prop0:
              datetime: 2017-07-21T10:32:28.000Z
              waterDepth: 10
            prop1:
              datetime: 2017-07-21T11:32:28.000Z
              waterDepth: 5
    logs:
      value:
        - logId: 1
          submitter:
            userId: 1
            name: Jane
          device:
            deviceId: 1
            name: Lovely Boat
            sensorDepth: 0.2
          gauge:
            gaugeId: 1
            name: New Orleans
            manager: jane
            location:
              - 90.136111
              - 29.934722
          gaugeLevel: 8
          start: 2017-07-21T10:32:28.000Z
          end: 2017-07-21T17:32:28.000Z
          entriesCount: 12600
    HttpError:
      value:
        type: 'http://example.com/waters/not-found'
        title: Water 1 not found
        detail: There is no water with id 1 in database
        instance: 'http://example.net/waters/1'
  responses:
    BadRequest:
      description: Bad Request (400)
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HttpError'
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
    Unauthorized:
      description: Unauthorized (401) acces to resource
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HttpError'
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
    NotFound:
      description: Water with given Id not found
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HttpError'
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
tags:
  - name: waters
    description: >-
      A water is a river (like Mississippi, lake (Lake Ontario), or a sea (North
      Sea)
  - name: users
    description: All actions used to manage users and api keys
  - name: devices
    description: All actions used to manage devices of an user
  - name: logs
    description: 'All actions used to manage logs of an water, device, gauge or user'
