Skip to content

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

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

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/studio/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN turbo prune --scope=@asyncapi/studio --docker
FROM base AS installer

ARG BASE_URL_PLACEHOLDER
ENV PUPPETEER_SKIP_DOWNLOAD=true

RUN apk add --no-cache libc6-compat
RUN apk update
Expand Down
19 changes: 19 additions & 0 deletions apps/studio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ 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
232 changes: 232 additions & 0 deletions apps/studio/public/docs/asyncapi/asyncapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"asyncapi": "2.6.0",
"info": {
"title": "Streetlights Kafka API",
"version": "1.0.0",
"description": "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n### Check out its awesome features:\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