Skip to content

Commit

Permalink
Update asyncapi.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ash17290 authored Aug 21, 2024
1 parent 0f9d20b commit b002793
Showing 1 changed file with 29 additions and 241 deletions.
270 changes: 29 additions & 241 deletions asyncapi.yml
Original file line number Diff line number Diff line change
@@ -1,249 +1,37 @@
asyncapi: 3.0.0
id: 'urn:example:com:smartylighting:streetlights:server'
asyncapi: '2.0.0'
info:
title: AsyncAPI Sample App
version: 1.0.1
description: This is a sample app.
termsOfService: 'https://asyncapi.com/terms/'
contact:
name: API Support
url: 'https://www.asyncapi.com/support'
email: [email protected]
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.html'
tags:
- name: e-commerce
- name: another-tag
description: Description...
externalDocs:
description: Find more info here
url: 'https://www.asyncapi.com'
defaultContentType: application/json
url: 'https://www.apache.org/licenses/LICENSE-2.0'

servers:
default:
host: 'api.streetlights.smartylighting.com:{port}'
mosquitto:
url: mqtt://test.mosquitto.org
protocol: mqtt
description: Test broker
variables:
port:
description: Secure connection (TLS) is available through port 8883.
default: '1883'
enum:
- '1883'
- '8883'
security:
- $ref: '#/components/securitySchemes/apiKey'
- type: oauth2
flows:
implicit:
authorizationUrl: 'https://example.com/api/oauth/dialog'
availableScopes:
'write:pets': modify pets in your account
'read:pets': read your pets
scopes:
- 'write:pets'
- type: openIdConnect
openIdConnectUrl: https://example.com/api
scopes:
- 'some:scope:1'
- 'some:scope:2'
production:
host: 'api.streetlights.smartylighting.com:{port}'
pathname: /some/path
protocol: mqtt
description: Test broker
variables:
port:
description: Secure connection (TLS) is available through port 8883.
default: '1883'
enum:
- '1883'
- '8883'
security:
- $ref: '#/components/securitySchemes/apiKey'
withProtocol:
host: 'api.streetlights.smartylighting.com:{port}'
pathname: /some/path
protocol: mqtt
description: Test broker
variables:
port:
description: Secure connection (TLS) is available through port 8883.
default: '1883'
enum:
- '1883'
- '8883'
security:
- $ref: '#/components/securitySchemes/apiKey'

channels:
'lightingMeasured':
address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured'
messages:
lightMeasured:
payload:
type: object
servers:
- $ref: '#/servers/production'
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
'turnOn':
address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on'
messages:
lightMeasured:
$ref: '#/components/messages/lightMeasured'
subscribe.message.0:
$ref: '#/components/messages/turnOnOff'
customMessageId:
payload:
type: object
subscribe.message.2:
light/measured:
publish:
summary: Inform about environmental lighting conditions for a particular streetlight.
operationId: onLightMeasured
message:
payload:
type: object
servers:
- $ref: '#/servers/default'
- $ref: '#/servers/production'
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
customChannelId:
address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off'
messages:
turnOnOff:
$ref: '#/components/messages/turnOnOff'
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
x-channelId: customChannelId
'dim':
address: 'smartylighting/streetlights/1/0/action/{streetlightId}/dim'
messages:
dimLight:
$ref: '#/components/messages/dimLight'
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
operations:
receiveLightMeasured:
action: receive
channel:
$ref: '#/channels/lightingMeasured'
messages:
- $ref: '#/channels/lightingMeasured/messages/lightMeasured'
'receiveTurnOn':
action: receive
channel:
$ref: '#/channels/turnOn'
messages:
- $ref: '#/channels/turnOn/messages/lightMeasured'
'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.subscribe':
action: send
channel:
$ref: '#/channels/turnOn'
messages:
- $ref: '#/channels/turnOn/messages/customMessageId'
- $ref: '#/channels/turnOn/messages/subscribe.message.2'
turnOnOff:
action: send
channel:
$ref: '#/channels/customChannelId'
messages:
- $ref: '#/channels/customChannelId/messages/turnOnOff'
dimLight:
action: send
channel:
$ref: '#/channels/dim'
security:
- type: oauth2
flows:
implicit:
authorizationUrl: 'https://example.com/api/oauth/dialog'
availableScopes:
'write:pets': modify pets in your account
'read:pets': read your pets
scopes:
- 'write:pets'
messages:
- $ref: '#/channels/dim/messages/dimLight'
components:
messages:
lightMeasured:
summary: >-
Inform about environmental lighting conditions for a particular
streetlight.
payload:
$ref: '#/components/schemas/lightMeasuredPayload'
turnOnOff:
summary: Command a particular streetlight to turn the lights on or off.
payload:
$ref: '#/components/schemas/turnOnOffPayload'
dimLight:
summary: Command a particular streetlight to dim the lights.
payload:
$ref: '#/components/schemas/dimLightPayload'
schemas:
lightMeasuredPayload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
$ref: '#/components/schemas/sentAt'
turnOnOffPayload:
type: object
properties:
command:
type: string
enum:
- 'on'
- 'off'
description: Whether to turn on or off the light.
sentAt:
$ref: '#/components/schemas/sentAt'
dimLightPayload:
type: object
properties:
percentage:
type: integer
description: Percentage to which the light should be dimmed to.
minimum: 0
maximum: 100
sentAt:
$ref: '#/components/schemas/sentAt'
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
securitySchemes:
apiKey:
type: apiKey
in: user
description: Provide your API key as the user and leave the password empty.
flows:
type: oauth2
flows:
implicit:
authorizationUrl: 'https://example.com/api/oauth/dialog'
availableScopes:
'write:pets': modify pets in your account
'read:pets': read your pets
openIdConnect:
type: openIdConnect
openIdConnectUrl: https://example.com/api
scopes:
- 'some:scope:1'
- 'some:scope:2'
unusedFlows:
type: oauth2
flows:
implicit:
authorizationUrl: 'https://example.com/api/oauth/dialog'
availableScopes:
'write:pets': modify pets in your account
'read:pets': read your pets
parameters:
streetlightId:
description: The ID of the streetlight.
properties:
id:
type: integer
minimum: 0
description: Id of the streetlight.
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.

0 comments on commit b002793

Please sign in to comment.