---
openapi: 3.0.3
info:
  title: open-data-smn API
  version: 2.0.1-SNAPSHOT
tags:
- name: smn
  description: Methods to retrieve SwissMetNet data. The actual data is provided by
    https://opendata.swiss/de/dataset/messdaten-smn-swissmetnet. A new set of data
    is released every 10min.
paths:
  /smn:
    get:
      tags:
      - smn
      summary: Get all data from all SMN stations
      description: Data is cached with a short TTL.
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SmnRecord'
  /smn/geojson:
    get:
      tags:
      - smn
      summary: Get all data from all SMN stations represented as GeoJSON
      description: Data is cached with a short TTL.
      parameters:
      - name: projection
        in: query
        description: "geo projection i.e. CRS, either CH1903 or WGS84 (default)"
        schema:
          default: WGS84
          enum:
          - CH1903
          - WGS84
          type: string
      responses:
        "200":
          description: OK
          content:
            application/vnd.geo+json:
              schema:
                $ref: '#/components/schemas/FeatureCollection'
  /smn/{code}:
    get:
      tags:
      - smn
      summary: Get data for a single SMN station
      description: Data is cached with a short TTL.
      parameters:
      - name: code
        in: path
        description: 3-char upper-case code of an SMN station
        required: true
        schema:
          pattern: "[A-Z]{3}"
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SmnRecord'
components:
  schemas:
    Crs:
      type: object
      properties:
        type:
          type: string
        properties:
          type: object
          additionalProperties:
            type: string
    Feature:
      type: object
      properties:
        properties:
          $ref: '#/components/schemas/SmnRecord'
        type:
          type: string
        geometry:
          $ref: '#/components/schemas/Geometry'
    FeatureCollection:
      description: A GeoJSON feature collection
      type: object
      properties:
        type:
          type: string
        features:
          type: array
          items:
            $ref: '#/components/schemas/Feature'
        crs:
          $ref: '#/components/schemas/Crs'
    Geometry:
      type: object
      properties:
        coordinates:
          type: array
          items:
            type: number
        type:
          type: string
    OffsetDateTime:
      format: date-time
      type: string
      example: 2022-03-10T12:15:50-04:00
    SmnRecord:
      required:
      - code
      - dateTime
      type: object
      properties:
        station:
          allOf:
          - $ref: '#/components/schemas/Station'
          - description: The SMN weather station
            readOnly: true
        code:
          description: 3-char all upper-case station code
          type: string
          readOnly: true
        dateTime:
          allOf:
          - $ref: '#/components/schemas/OffsetDateTime'
          - description: Time in UTC
            readOnly: true
            example: 2022-08-28T10:10:00.0Z
        temperature:
          description: Air temperature 2 m above ground; current value
          type: string
          readOnly: true
        sunshine:
          description: Sunshine duration; ten minutes total
          type: string
          readOnly: true
        precipitation:
          description: Precipitation; ten minutes total
          type: string
          readOnly: true
        windDirection:
          description: Wind direction; ten minutes mean
          type: string
          readOnly: true
        windSpeed:
          description: Wind speed; ten minutes mean
          type: string
          readOnly: true
        qnhPressure:
          description: Pressure reduced to sea level according to standard atmosphere
            (QNH); current value
          type: string
          readOnly: true
        gustPeak:
          description: Gust peak (one second); maximum
          type: string
          readOnly: true
        humidity:
          description: Relative air humidity 2 m above ground; current value
          type: string
          readOnly: true
        qfePressure:
          description: Pressure at station level (QFE); current value
          type: string
          readOnly: true
        qffPressure:
          description: Pressure reduced to sea level (QFF); current value
          type: string
          readOnly: true
    Station:
      description: SMN station meta data
      type: object
      properties:
        code:
          type: string
        name:
          type: string
        ch1903Y:
          format: int32
          type: integer
        ch1903X:
          format: int32
          type: integer
        lat:
          format: double
          type: number
        lng:
          format: double
          type: number
        elevation:
          format: int32
          type: integer
