Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable to mount local spec for docker container #433

Closed
wants to merge 15 commits into from
Closed
1 change: 1 addition & 0 deletions Dockerfile
rikuson marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG BASE_URL_PLACEHOLDER=189b303e-37a0-4f6f-8c0a-50333bc3c36e
FROM docker.io/library/node:16.13.2 as build

ARG BASE_URL_PLACEHOLDER
ENV PUPPETEER_SKIP_DOWNLOAD=true
rikuson marked this conversation as resolved.
Show resolved Hide resolved

COPY package.json package-lock.json ./
RUN npm install --frozen-lockfile
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ docker run -it -p 8000:80 asyncapi/studio

and then go to [http://localhost:8000](http://localhost:8000).

To mount a specification, use the command:

```bash
docker run -it -p 8000:80 -v "$(pwd)/another/path/to/asyncapi:/usr/share/nginx/html/docs/asyncapi" asyncapi/studio
```

> **NOTE**: The file should be named `asyncapi.yaml` or `asyncapi.json` in the specified location.

Also docker-compose can be used:

```yaml
services:
async-studio:
image: asyncapi/studio
ports:
- "8000:80"
volumes:
- ./another/path/to/asyncapi:/usr/share/nginx/html/docs/asyncapi
```

The `asyncapi/studio` image is based on the official `nginx` image.
Please refer to the [Nginx documentation](https://registry.hub.docker.com/_/nginx/) to learn how to e.g. pass a custom `nginx` configuration or plug in additional volumes.

Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
async-studio:
build: .
container_name: events-api
restart: on-failure
ports:
- "8000:80"
volumes:
- ./public/docs/asyncapi:/usr/share/nginx/html/docs/asyncapi
232 changes: 232 additions & 0 deletions public/docs/asyncapi/asyncapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"asyncapi": "2.4.0",
"info": {
"title": "Streetlights Kafka API",
"version": "1.0.0",
"description": "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off 🌃\n* Dim a specific streetlight 😎\n* Receive real-time information about environmental lighting conditions 📈\n",
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0"
}
},
"servers": {
"test": {
"url": "test.mykafkacluster.org:8092",
"protocol": "kafka-secure",
"description": "Test broker",
"security": [
{
"saslScram": []
}
]
}
},
"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",
"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": "turnOn",
"traits": [
{
"$ref": "#/components/operationTraits/kafka"
}
],
"message": {
"$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": {
"$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": {
"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": {
"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"
}
}
}
}
}
}
Loading