Skip to content

Commit

Permalink
fix: update the default version of the asyncapi it loads (#143) (#145)
Browse files Browse the repository at this point in the history
Co-authored-by: David Boyne <[email protected]>
  • Loading branch information
boyney123 and David Boyne authored Oct 28, 2021
1 parent 9caf6a6 commit 5b71981
Showing 1 changed file with 149 additions and 61 deletions.
210 changes: 149 additions & 61 deletions src/state/editor.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,169 @@
import { createState, useState } from '@hookstate/core';

const schema =
localStorage.getItem('document') ||
`asyncapi: '2.0.0'
id: 'urn:rpc:example:client'
defaultContentType: application/json
localStorage.getItem('document') || `asyncapi: '2.2.0'
info:
title: RPC Client Example
description: This example demonstrates how to define an RPC client.
title: Streetlights Kafka API
version: '1.0.0'
description: |
The Smartylighting Streetlights API allows you to remotely manage the city lights.
### Check out its awesome features:
* Turn a specific streetlight on/off 🌃
* Dim a specific streetlight 😎
* Receive real-time information about environmental lighting conditions 📈
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0
servers:
production:
url: rabbitmq.example.org
protocol: amqp
test:
url: test.mykafkacluster.org:8092
protocol: kafka-secure
description: Test broker
security:
- saslScram: []
defaultContentType: application/json
channels:
'{queue}':
smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured:
description: The topic on which measured values may be produced and consumed.
parameters:
queue:
schema:
type: string
pattern: '^amq\\.gen\\-.+$'
bindings:
amqp:
is: queue
queue:
exclusive: true
streetlightId:
$ref: '#/components/parameters/streetlightId'
publish:
summary: Inform about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
traits:
- $ref: '#/components/operationTraits/kafka'
message:
$ref: '#/components/messages/lightMeasured'
smartylighting.streetlights.1.0.action.{streetlightId}.turn.on:
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
subscribe:
operationId: receiveSumResult
bindings:
amqp:
ack: false
operationId: turnOn
traits:
- $ref: '#/components/operationTraits/kafka'
message:
correlationId:
location: $message.header#/correlation_id
payload:
$ref: '#/components/schemas/test'
rpc_queue:
bindings:
amqp:
is: queue
queue:
durable: false
publish:
operationId: requestSum
bindings:
amqp:
ack: true
$ref: '#/components/messages/turnOnOff'
smartylighting.streetlights.1.0.action.{streetlightId}.turn.off:
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
subscribe:
operationId: turnOff
traits:
- $ref: '#/components/operationTraits/kafka'
message:
bindings:
amqp:
replyTo:
type: string
correlationId:
location: $message.header#/correlation_id
payload:
type: object
properties:
numbers:
type: array
items:
type: number
examples:
- [4,3]
$ref: '#/components/messages/turnOnOff'
smartylighting.streetlights.1.0.action.{streetlightId}.dim:
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
subscribe:
operationId: dimLight
traits:
- $ref: '#/components/operationTraits/kafka'
message:
$ref: '#/components/messages/dimLight'
components:
messages:
lightMeasured:
name: lightMeasured
title: Light measured
summary: Inform about environmental lighting conditions of a particular streetlight.
contentType: application/json
traits:
- $ref: '#/components/messageTraits/commonHeaders'
payload:
$ref: "#/components/schemas/lightMeasuredPayload"
turnOnOff:
name: turnOnOff
title: Turn on/off
summary: Command a particular streetlight to turn the lights on or off.
traits:
- $ref: '#/components/messageTraits/commonHeaders'
payload:
$ref: "#/components/schemas/turnOnOffPayload"
dimLight:
name: dimLight
title: Dim light
summary: Command a particular streetlight to dim the lights.
traits:
- $ref: '#/components/messageTraits/commonHeaders'
payload:
$ref: "#/components/schemas/dimLightPayload"
schemas:
test:
lightMeasuredPayload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
$ref: "#/components/schemas/sentAt"
turnOnOffPayload:
type: object
properties:
result:
type: number
examples:
- 7
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:
saslScram:
type: scramSha256
description: Provide your username and password for SASL/SCRAM authentication
parameters:
streetlightId:
description: The ID of the streetlight.
schema:
type: string
messageTraits:
commonHeaders:
headers:
type: object
properties:
my-app-header:
type: integer
minimum: 0
maximum: 100
operationTraits:
kafka:
bindings:
kafka:
clientId: my-app-id
`;

export type EditorStateDocumentFrom = 'localStorage' | `URL: ${string}` | 'Base64';
Expand Down

0 comments on commit 5b71981

Please sign in to comment.