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