+ ```yml channels: event.lighting.measured: @@ -38,14 +44,14 @@ info: servers: production: - url: api.streetlights.smartylighting.com:{port} - protocol: mqtt + url: kafka.bootstrap:{port} + protocol: kafka variables: port: - default: '1883' + default: '9092' enum: - - '1883' - - '8883' + - '9092' + - '9093' channels: event.lighting.measured: @@ -53,9 +59,11 @@ channels: bindings: kafka: groupId: my-group + operationId: readLightMeasurement message: $ref: '#/components/messages/lightMeasured' subscribe: + operationId: updateLightMeasurement message: $ref: '#/components/messages/lightMeasured' components: @@ -79,6 +87,127 @@ components: format: date-time description: Date and time when the message was sent. ``` + +
++ +```yml +asyncapi: '2.0.0' +info: + title: Streetlights API + version: '1.0.0' + description: | + The Smartylighting Streetlights API allows you to remotely manage the city lights. + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0 + +servers: + production: + url: mqtt://localhost:{port} + protocol: mqtt + description: dummy MQTT broker + bindings: + mqtt: + clientId: guest + cleanSession: false + keepAlive: 0 + lastWill: + topic: /will + qos: 0 + message: Guest gone offline. + retain: false + variables: + port: + enum: + - '8883' + - '8884' + default: '8883' + + +defaultContentType: application/json + +channels: + smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured: + description: The topic on which measured values may be produced and consumed. + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + publish: + summary: Inform about environmental lighting conditions of a particular streetlight. + operationId: receiveLightMeasurement + message: + $ref: '#/components/messages/lightMeasured' + + smartylighting/streetlights/1/0/action/{streetlightId}/turn/on: + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + subscribe: + bindings: + mqtt: + qos: 0 + retain: false + operationId: turnOn + message: + $ref: '#/components/messages/turnOnOff' + +components: + messages: + lightMeasured: + name: lightMeasured + title: Light measured + summary: Inform about environmental lighting conditions of a particular streetlight. + payload: + $ref: "#/components/schemas/lightMeasuredPayload" + turnOnOff: + name: turnOnOff + title: Turn on/off + summary: Command a particular streetlight to turn the lights on or off. + payload: + $ref: "#/components/schemas/turnOnOffPayload" + + schemas: + lightMeasuredPayload: + type: object + properties: + lumens: + type: integer + minimum: 0 + description: Light intensity measured in lumens. + x-pi: false + sentAt: + $ref: "#/components/schemas/sentAt" + turnOnOffPayload: + type: object + properties: + command: + type: string + enum: + - on + - off + description: Whether to turn on or off the light. + x-pi: false + sentAt: + $ref: "#/components/schemas/sentAt" + sentAt: + type: string + format: date-time + description: Date and time when the message was sent. + + parameters: + streetlightId: + description: The ID of the streetlight. + schema: + type: string +``` + +
+