swagger: '2.0'
info:
  version: 2.0.1
  title: MIP Infrastructure API
  description: >-
    This API can be used to receive information about stops and the infrastructure at these stops.
schemes:
  - https
paths:
  '/stop':
    get:
      tags:
        - Infrastructure API
      summary: Find all stops of the MIP.
      description: Find all stops of the MIP.
      security:
        - ApiKey: []
      produces:
        - application/json
      parameters: []
      responses:
        '200':
          description: ok
          schema:
            type: array
            items:
              $ref: '#/definitions/StopSummary'
        '400':
          description: Bad Request.
        '401':
          description: Authorization required.
        '403':
          description: Forbidden.
          
  '/stop/{ifopt}/infrastructure':
    get:
      tags:
        - Infrastructure API
      summary: Get the most recent known state of every infrastructure for the given stop.
      description: Get the most recent known state of every infrasdtructure for the given stop.
      security:
        - ApiKey: []
      produces:
        - application/json
      parameters:
        - in: path
          name: ifopt
          type: integer
          required: true
          description: The ifopt of the stop
      responses:
        '200':
          description: ok
          schema:
            type: array
            items:
              $ref: '#/definitions/Infrastructure'
        '400':
          description: Bad Request.
        '401':
          description: Authorization required.
        '403':
          description: Forbidden.
        '404':
          description: Not found.
          
  '/stop/all/infrastructure':
    get:
      tags:
        - Infrastructure API
      summary: Get the most recent known state of every infrastructure for every stop of the MIP.
      description: Get the most recent known state of every infrastructure for every stop of the MIP.
      security:
        - ApiKey: []
      produces:
        - application/json
      responses:
        '200':
          description: ok
          schema:
            type: array
            items:
              $ref: '#/definitions/Stop'
        '400':
          description: Bad Request.
        '401':
          description: Authorization required.
        '403':
          description: Forbidden.
        '404':
          description: Not found.
          
securityDefinitions:
  ApiKey:
    type: apiKey
    name: x-api-key
    in: header

definitions:
  Stop:
    title: Stop
    allOf:
      - $ref: '#/definitions/StopSummary'
      - type: object
      - properties:
          infrastructure:
            type: array
            items:
              $ref: '#/definitions/Infrastructure'

  StopSummary:
    title: StopSummary
    type: object
    required:
      - ifopt
      - subnet
      - name
      - place
    properties:
      ifopt:
        type: string
        description: The IFOPT number (global id) of the stop.
      subnet:
        type: string
        description: The subnet of the stop, either "OPNV", "SPNV" or "OPNV / SPNV"
      name:
        type: string
        description: The name of the stop.
      place:
        type: string
        description: The place of the stop
      latitude:
        type: number
        description: The latitude of this stop.
      longitude:
        type: number
        description: The longitude of this stop.

  Infrastructure:
    title: Infrastructure
    type: object
    properties:
      resourceId:
        type: string
        description: The resource identifier (Betriebsmittelnummer) of this infrastructure
      type:
        type: string
        description: The type of the infrastructure
      name:
        type: string
        description: The name of the infrastructure
      description:
        type: string
        description: The description of the infrastructure
      latitude:
        type: number
        description: The latitude of this infrastructure.
      longitude:
        type: number
        description: The longitude of this infrastrucutre.
      state:
        $ref: '#/definitions/State'

  State:
    title: State
    type: object
    required: 
      - timestamp
      - state
    properties:
      timestamp:
        type: string
        description: Timestamp of last state change (ISO 8601), i.e. 2019-03-31T16:45+00:00
      state:
        type: string
        description: The most recent state of the infrastructure.
      description:
        type: string
        description: The optional textual description of the most recent state of the infrastructure.