openapi: 3.0.0
info:
  contact:
    email: info@engsas.de
    name: EngSaS - Engineering Solutions and Services Langenbach
    url: http://www.engsas.com
  description: API to upload log files with water depth to GNUBoat server
  license:
    name: GPL 3
    url: https://www.gnu.org/licenses/gpl-3.0.en.html
  title: GNUBoat Mapservice API
  version: v1
servers:
- description: The production API server
  url: https://gnuboat.engsas.com/mapservice/{version}
  variables:
    version:
      default: v1
- description: The local flask development url
  url: http://localhost:8080/mapservice/{version}
  variables:
    version:
      default: v1
tags:
- description: A water is a river (like Mississippi, lake (Lake Ontario), or a sea
    (North Sea)
  name: waters
- description: All actions used to manage users and api keys
  name: users
paths:
  /user:
    get:
      description: Returns information of current/authorized user
      operationId: users_get
      responses:
        200:
          content:
            application/json:
              examples:
                User:
                  $ref: '#/components/examples/User'
              schema:
                $ref: '#/components/schemas/User'
          description: OK
        400:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Bad Request (400)
        401:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Unauthorized (401) acces to resource
      security:
      - basicAuth: []
      - apiKeyAuth: []
      summary: Returns info of a user
      tags:
      - users
      x-openapi-router-controller: openapi_server.controllers.users_controller
    options:
      description: Used by CORS preflight
      operationId: user_options
      responses:
        200:
          content:
            application/json: {}
          description: CORS prefilght requests should return 200 as status code
      tags:
      - users
      x-openapi-router-controller: openapi_server.controllers.users_controller
    post:
      description: Registers a new user
      operationId: users_register
      requestBody:
        content:
          application/json:
            examples:
              Water:
                $ref: '#/components/examples/UserCreation'
            schema:
              $ref: '#/components/schemas/UserCreation'
      responses:
        201:
          content:
            application/json:
              examples:
                Water:
                  $ref: '#/components/examples/User'
              schema:
                $ref: '#/components/schemas/User'
          description: Userr created
        400:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Bad Request (400)
      summary: Registers a new user
      tags:
      - users
      x-openapi-router-controller: openapi_server.controllers.users_controller
  /user/activate/{activation_code}:
    get:
      description: Activates a user account
      operationId: users_activate
      parameters:
      - description: Activation code
        example: dac9630aec642a428cd73f4be0a03569
        explode: false
        in: path
        name: activation_code
        required: true
        schema:
          $ref: '#/components/schemas/activationCode'
        style: simple
      responses:
        302:
          description: OK or not OK
          headers:
            Location:
              description: URL to the website, showing the result of the activation
              explode: false
              schema:
                type: string
              style: simple
      summary: Activates a user account
      tags:
      - users
      x-openapi-router-controller: openapi_server.controllers.users_controller
  /user/apikey_create:
    get:
      description: Generates and returns a new API key for current user
      operationId: users_api_key_create
      responses:
        200:
          content:
            application/json:
              example: NewApiKey4711
              schema:
                $ref: '#/components/schemas/apiKeys'
          description: OK
        400:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Bad Request (400)
        401:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Unauthorized (401) acces to resource
      security:
      - basicAuth: []
      summary: Returns a new API key
      tags:
      - users
      x-openapi-router-controller: openapi_server.controllers.users_controller
  /user/{api_key}:
    delete:
      description: Deletes given API key and returns remaining API keys of the user
      operationId: users_api_key_delete
      parameters:
      - description: API key
        example: DelApiKey4711
        explode: false
        in: path
        name: api_key
        required: true
        schema:
          $ref: '#/components/schemas/apiKey'
        style: simple
      responses:
        200:
          content:
            application/json:
              example: ApiKey4711
              schema:
                $ref: '#/components/schemas/apiKeys'
          description: OK
        400:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Bad Request (400)
        401:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Unauthorized (401) acces to resource
        404:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Water with given Id not found
      security:
      - basicAuth: []
      summary: Deletes API key
      tags:
      - users
      x-openapi-router-controller: openapi_server.controllers.users_controller
  /waters:
    get:
      description: Returns all waters
      operationId: waters_get
      parameters:
      - example: Missi
        explode: true
        in: query
        name: name
        required: false
        schema:
          $ref: '#/components/schemas/itemName'
        style: form
      - example: jane
        explode: true
        in: query
        name: manager
        required: false
        schema:
          $ref: '#/components/schemas/username'
        style: form
      - description: 'Order by field: name'
        explode: true
        in: query
        name: orderBy
        required: false
        schema:
          default: name
          example: name
          type: string
        style: form
      - description: Skip over a number of elements by specifying an offset value
          for the query
        explode: true
        in: query
        name: offset
        required: false
        schema:
          default: 0
          example: 0
          format: int32
          type: integer
        style: form
      - description: Limit the number of elements on the response
        explode: true
        in: query
        name: limit
        required: false
        schema:
          default: 10
          example: 10
          format: int32
          type: integer
        style: form
      responses:
        200:
          content:
            application/json:
              examples:
                Waters:
                  $ref: '#/components/examples/waters'
              schema:
                $ref: '#/components/schemas/waters'
          description: OK
        404:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Water with given Id not found
      summary: Find waters by id
      tags:
      - waters
      x-openapi-router-controller: openapi_server.controllers.waters_controller
    post:
      description: Adds a new water to the database
      operationId: waters_create
      requestBody:
        content:
          application/json:
            example:
              name: Rhein
              osmId: 1756854
              osmType: Relation
            schema:
              $ref: '#/components/schemas/WaterCreation'
      responses:
        201:
          content:
            application/json:
              examples:
                Water:
                  $ref: '#/components/examples/Water'
              schema:
                $ref: '#/components/schemas/Water'
          description: Water created
        400:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Bad Request (400)
        401:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Unauthorized (401) acces to resource
      security:
      - basicAuth: []
      - apiKeyAuth: []
      summary: Add a new water
      tags:
      - waters
      x-openapi-router-controller: openapi_server.controllers.waters_controller
  /waters/{id}:
    get:
      description: Returns the water identified by id
      operationId: waters_get_by_id
      parameters:
      - description: Item ID
        explode: false
        in: path
        name: id
        required: true
        schema:
          $ref: '#/components/schemas/itemId'
        style: simple
      responses:
        200:
          content:
            application/json:
              examples:
                Water:
                  $ref: '#/components/examples/Water'
              schema:
                $ref: '#/components/schemas/Water'
          description: OK
        404:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Water with given Id not found
      summary: Represents a water
      tags:
      - waters
      x-openapi-router-controller: openapi_server.controllers.waters_controller
  /waters/{water_id}/gauges:
    get:
      description: Returns all gauges of water waterId
      operationId: waters_gauges_get
      parameters:
      - description: Water ID
        explode: false
        in: path
        name: water_id
        required: true
        schema:
          $ref: '#/components/schemas/itemId'
        style: simple
      - example: Missi
        explode: true
        in: query
        name: name
        required: false
        schema:
          $ref: '#/components/schemas/itemName'
        style: form
      - example: jane
        explode: true
        in: query
        name: manager
        required: false
        schema:
          $ref: '#/components/schemas/username'
        style: form
      - description: 'Order by field: name'
        explode: true
        in: query
        name: orderBy
        required: false
        schema:
          default: name
          example: name
          type: string
        style: form
      - description: Skip over a number of elements by specifying an offset value
          for the query
        explode: true
        in: query
        name: offset
        required: false
        schema:
          default: 0
          example: 0
          format: int32
          type: integer
        style: form
      - description: Limit the number of elements on the response
        explode: true
        in: query
        name: limit
        required: false
        schema:
          default: 10
          example: 10
          format: int32
          type: integer
        style: form
      responses:
        200:
          content:
            application/json:
              examples:
                Gauges:
                  $ref: '#/components/examples/Gauges'
              schema:
                $ref: '#/components/schemas/Gauges'
            application/geo+json:
              examples:
                Gauge:
                  $ref: '#/components/examples/GaugesGeoJson'
              schema:
                $ref: '#/components/schemas/GaugesGeoJson'
          description: OK
      summary: Find gauges of water waterId by gaugeId
      tags:
      - waters
      x-openapi-router-controller: openapi_server.controllers.waters_controller
    post:
      description: Adds a new gauge for water waterId to the database
      operationId: waters_gauge_create
      parameters:
      - description: Water ID
        explode: false
        in: path
        name: water_id
        required: true
        schema:
          $ref: '#/components/schemas/itemId'
        style: simple
      requestBody:
        content:
          application/json:
            example:
              name: New Orleans
              location:
              - 90.136111
              - 29.934722
            schema:
              $ref: '#/components/schemas/GaugeCreation'
      responses:
        201:
          content:
            application/json:
              examples:
                Gauge:
                  $ref: '#/components/examples/Gauge'
              schema:
                $ref: '#/components/schemas/Gauge'
            application/geo+json:
              examples:
                Gauge:
                  $ref: '#/components/examples/GaugeGeoJson'
              schema:
                $ref: '#/components/schemas/GaugeGeoJson'
          description: Gauge created
        400:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Bad Request (400)
        401:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Unauthorized (401) acces to resource
      security:
      - basicAuth: []
      - apiKeyAuth: []
      summary: Add a new water
      tags:
      - waters
      x-openapi-router-controller: openapi_server.controllers.waters_controller
  /waters/{water_id}/gauges/{gauge_id}:
    get:
      description: Returns the gauge identified by id
      operationId: waters_gauge_get_by_id
      parameters:
      - description: Water ID
        explode: false
        in: path
        name: water_id
        required: true
        schema:
          $ref: '#/components/schemas/itemId'
        style: simple
      - description: Gauge ID
        explode: false
        in: path
        name: gauge_id
        required: true
        schema:
          $ref: '#/components/schemas/itemId'
        style: simple
      responses:
        200:
          content:
            application/json:
              examples:
                Gauge:
                  $ref: '#/components/examples/Gauge'
              schema:
                $ref: '#/components/schemas/Gauge'
            application/geo+json:
              examples:
                Gauge:
                  $ref: '#/components/examples/GaugeGeoJson'
              schema:
                $ref: '#/components/schemas/GaugeGeoJson'
          description: OK
        400:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Bad Request (400)
        404:
          content:
            application/json:
              examples:
                HttpError:
                  $ref: '#/components/examples/HttpError'
              schema:
                $ref: '#/components/schemas/HttpError'
          description: Water with given Id not found
      summary: Represents a gauge
      tags:
      - waters
      x-openapi-router-controller: openapi_server.controllers.waters_controller
components:
  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?
    Water:
      summary: A water example object
      value:
        waterId: 1
        name: Mississippi
        osmId: 1756854
        osmType: R
    WaterCreation:
      summary: A water example object for creation of a water
      value:
        name: Mississippi
        osmId: 1756854
        osmType: Relation
    waters:
      summary: A sample list with waters
      value:
      - waterId: 1
        name: Mississippi
        osmId: 1756854
        osmType: Relation
      - waterId: 2
        name: Bodensee
    Gauge:
      value:
        gaugeId: 1
        name: New Orleans
        manager: jane
        location:
        - 90.136111
        - 29.934722
        comment: Gauge for Mississippi in New Orleans
    Gauges:
      summary: A sample list of gauges
      value:
      - gaugeId: 1
        name: New Orleans
        manager: jane
        location:
        - 90.136111
        - 29.934722
    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:
      summary: A sample list of gauges in GeoJson format
      value:
      - type: Feature
        geometry:
          type: Point
          coordinates:
          - 90.136111
          - 29.934722
          properties:
            name: New Orleans
            manager: jane
            comment: Gauge for Mississippi in New Orleans
    HttpError:
      value:
        code: 404
        message: Water with id 999999 not found
  parameters:
    orderBy:
      description: 'Order by field: name'
      explode: true
      in: query
      name: orderBy
      required: false
      schema:
        default: name
        example: name
        type: string
      style: form
    order:
      description: Order
      explode: true
      in: query
      name: order
      required: false
      schema:
        $ref: '#/components/schemas/order'
      style: form
    offset:
      description: Skip over a number of elements by specifying an offset value for
        the query
      explode: true
      in: query
      name: offset
      required: false
      schema:
        default: 0
        example: 0
        format: int32
        type: integer
      style: form
    limit:
      description: Limit the number of elements on the response
      explode: true
      in: query
      name: limit
      required: false
      schema:
        default: 10
        example: 10
        format: int32
        type: integer
      style: form
  responses:
    BadRequest:
      content:
        application/json:
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
          schema:
            $ref: '#/components/schemas/HttpError'
      description: Bad Request (400)
    Unauthorized:
      content:
        application/json:
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
          schema:
            $ref: '#/components/schemas/HttpError'
      description: Unauthorized (401) acces to resource
    NotFound:
      content:
        application/json:
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
          schema:
            $ref: '#/components/schemas/HttpError'
      description: Water with given Id not found
  schemas:
    username:
      title: Username
      type: string
    apiKey:
      title: API Key
      type: string
    apiKeys:
      items:
        $ref: '#/components/schemas/apiKey'
      title: Array of API keys
      type: array
    activationCode:
      title: Activation code for a User
      type: string
    itemId:
      format: int32
      title: Item ID
      type: integer
    itemName:
      title: Item Name
      type: string
    order:
      default: asc
      description: |
        Sort order:
          * `asc` - Ascending, from A to Z
          * `desc` - Descending, from Z to A
      enum:
      - desc
      - asc
      example: asc
      title: order
      type: string
    osmType:
      enum:
      - Node
      - Way
      - Relation
      title: OSM type of item (N|W|R)
      type: string
    comment:
      title: Comment of an item
      type: string
    point:
      items:
        type: number
      maxItems: 2
      minItems: 2
      title: Point of type [longitude, latitude]
      type: array
    geoJsonType:
      enum:
      - Feature
      - Point
      title: Type of GeoJSON objects
      type: string
    geoJsonPoint:
      description: GeoJSon geometry
      externalDocs:
        url: http://geojson.org/geojson-spec.html#id2
      properties:
        type:
          type: string
        coordinates:
          items:
            type: number
          maxItems: 2
          minItems: 2
          title: Point of type [longitude, latitude]
          type: array
      type: object
    User:
      example:
        firstName: firstName
        lastName: lastName
        apiKeys:
        - null
        - null
        email: email
        username: username
        activated: true
      properties:
        username:
          title: Username
          type: string
        email:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        activated:
          type: boolean
        apiKeys:
          items:
            $ref: '#/components/schemas/apiKey'
          title: Array of API keys
          type: array
      title: User
      type: object
    UserCreation:
      example:
        firstName: firstName
        lastName: lastName
        password: password
        email: email
        username: username
      properties:
        username:
          title: Username
          type: string
        email:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        password:
          type: string
      required:
      - email
      - firstName
      - lastName
      - password
      - username
      title: User
      type: object
    Water:
      example:
        manager: manager
        osmId: 6
        name: name
        gauges:
        - manager: manager
          name: name
          location:
          - 5.962133916683182
          - 5.962133916683182
          comment: comment
          gaugeId: 1
        - manager: manager
          name: name
          location:
          - 5.962133916683182
          - 5.962133916683182
          comment: comment
          gaugeId: 1
        waterId: 0
      properties:
        waterId:
          format: int32
          title: Item ID
          type: integer
        name:
          title: Item Name
          type: string
        manager:
          title: Username
          type: string
        osmId:
          format: int32
          title: Item ID
          type: integer
        osmType:
          $ref: '#/components/schemas/osmType'
        gauges:
          items:
            $ref: '#/components/schemas/Gauge'
          title: Gauges
          type: array
      required:
      - name
      - waterId
      title: Water
      type: object
    WaterCreation:
      example:
        osmId: 0
        name: name
      properties:
        name:
          title: Item Name
          type: string
        osmId:
          format: int32
          title: Item ID
          type: integer
        osmType:
          $ref: '#/components/schemas/osmType'
      required:
      - name
      title: Water
      type: object
    waters:
      items:
        $ref: '#/components/schemas/Water'
      title: waters
      type: array
    Gauge:
      example:
        manager: manager
        name: name
        location:
        - 5.962133916683182
        - 5.962133916683182
        comment: comment
        gaugeId: 1
      properties:
        gaugeId:
          format: int32
          title: Item ID
          type: integer
        name:
          title: Item Name
          type: string
        manager:
          title: Username
          type: string
        location:
          items:
            type: number
          maxItems: 2
          minItems: 2
          title: Point of type [longitude, latitude]
          type: array
        comment:
          title: Comment of an item
          type: string
      required:
      - gaugeId
      - location
      - name
      title: Gauge
      type: object
    GaugeCreation:
      example:
        name: name
        location:
        - 0.8008281904610115
        - 0.8008281904610115
        comment: comment
      properties:
        name:
          title: Item Name
          type: string
        location:
          items:
            type: number
          maxItems: 2
          minItems: 2
          title: Point of type [longitude, latitude]
          type: array
        comment:
          title: Comment of an item
          type: string
      required:
      - location
      - name
      title: Gauge for Creation
      type: object
    Gauges:
      items:
        $ref: '#/components/schemas/Gauge'
      title: Gauges
      type: array
    GaugeGeoJson:
      properties:
        type:
          $ref: '#/components/schemas/geoJsonType'
        geometry:
          $ref: '#/components/schemas/geoJsonPoint'
        properties:
          $ref: '#/components/schemas/GaugeGeoJson_properties'
      required:
      - geometry
      - properties
      - type
      title: Gauge
      type: object
    GaugesGeoJson:
      items:
        $ref: '#/components/schemas/GaugeGeoJson'
      title: Gauges in GeoJson format
      type: array
    HttpError:
      properties:
        code:
          type: integer
        message:
          type: string
      required:
      - code
      - message
      title: HTTP Error Response Object
      type: object
    GaugeGeoJson_properties:
      properties:
        name:
          title: Item Name
          type: string
        manager:
          title: Username
          type: string
        comment:
          title: Comment of an item
          type: string
      required:
      - name
  securitySchemes:
    basicAuth:
      scheme: basic
      type: http
      x-basicInfoFunc: openapi_server.server_impl.security.Security.auth_basic
    apiKeyAuth:
      in: header
      name: X-API-KEY
      type: apiKey
      x-apikeyInfoFunc: openapi_server.server_impl.security.Security.auth_api
