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:
  /waters:
    get:
      description: Returns all waters
      tags:
        - waters
      summary: Find waters by id
      operationId: watersGet
      parameters:
        - name: name
          in: header
          schema:
            $ref: '#/components/schemas/item_name'
        - name: manager
          in: header
          schema:
            $ref: '#/components/schemas/username'
        - $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'
    post:
      description: Adds a new water to the database
      tags:
        - waters
      summary: Add a new water
      security:
        - basicAuth: []
        - apiKeyAuth: []
      requestBody:
        description: item id of water is going to be ignored
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WaterCreation'
            examples:
              Water:
                $ref: '#/components/examples/WaterCreation'
      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: waterGetById
      parameters:
        - name: id
          in: path
          description: Item ID
          required: true
          schema:
            $ref: '#/components/schemas/item_id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Water'
              examples:
                Water:
                  $ref: '#/components/examples/Water'
        '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
    item_id:
      title: Item ID
      type: integer
      format: int32
    item_name:
      title: Item Name
      type: string
    osm_type:
      maxLength: 1
      minLength: 1
      type: string
    Water:
      title: Water
      type: object
      properties:
        water_id:
          $ref: '#/components/schemas/item_id'
        name:
          $ref: '#/components/schemas/item_name'
        manager:
          $ref: '#/components/schemas/username'
        osm_id:
          $ref: '#/components/schemas/item_id'
        osm_type:
          $ref: '#/components/schemas/osm_type'
        osm_class:
          $ref: '#/components/schemas/osm_type'
      required:
        - water_id
        - name
    WaterCreation:
      title: Water
      type: object
      properties:
        name:
          $ref: '#/components/schemas/item_name'
        osm_id:
          $ref: '#/components/schemas/item_id'
        osm_type:
          $ref: '#/components/schemas/osm_type'
      required:
        - name
    waters:
      title: waters
      type: array
      items:
        $ref: '#/components/schemas/Water'
    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
    HttpError:
      title: HTTP Error Response Object
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
      required:
        - code
        - message
  parameters:
    orderBy:
      name: orderBy
      in: query
      description: 'Order by field: name'
      schema:
        type: string
        default: name
    order:
      name: order
      in: query
      description: Order
      schema:
        $ref: '#/components/schemas/order'
    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:
    Water:
      value:
        water_id: 1
        name: Mississippi
        osm_id: 1756854
        osm_type: R
        link: 'http://gnuboat.engsas.com/mapservice/v1/waters/1'
      summary: A water example object
    WaterCreation:
      value:
        name: Mississippi
        osm_id: 1756854
        osm_type: R
      summary: A water example object for creation of a water
    waters:
      value:
        - water_id: 1
          name: Mississippi
          osm_id: 1756854
          osm_type: R
          link: 'http://gnuboat.engsas.com/mapservice/v1/waters/1'
        - water_id: 2
          name: Bodensee
          link: 'http://gnuboat.engsas.com/mapservice/v1/waters/2'
      summary: A sample list with waters
    HttpError:
      value:
        code: 404
        message: Water with id 999999 not found
  responses:
    BadRequest:
      description: Bad Request (400)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HttpError'
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
    Unauthorized:
      description: Unauthorized (401) acces to resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HttpError'
          examples:
            HttpError:
              $ref: '#/components/examples/HttpError'
    NotFound:
      description: Water with given Id not found
      content:
        application/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)
