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

Create Async API schema from our own broker's topic hierarchy #4919

Closed
2 tasks done
Tracked by #4788
joepavitt opened this issue Dec 16, 2024 · 2 comments · Fixed by #5008
Closed
2 tasks done
Tracked by #4788

Create Async API schema from our own broker's topic hierarchy #4919

joepavitt opened this issue Dec 16, 2024 · 2 comments · Fixed by #5008
Assignees
Labels
area:api Work on the platform API size:XL - 8 Sizing estimation point
Milestone

Comments

@joepavitt
Copy link
Contributor

joepavitt commented Dec 16, 2024

Tasks

Preview Give feedback

We will auto-generate an AsyncAPI v3 schema based on the detected topic hierarchy for the team broker.

For the first iteration, this is auto-generated and uneditable. Being able to edit the schema (to provide additional descriptions/context to the entries is a future item) is out of scope but will be something we'll want to do in the future, so some consideration should be made for that.

Currently, the auto-detected topics are stored as a simple array of topics. That is likely to change in the future, but for now, we'll stick with that.

We will also be adding the ability to generate schemas for 3rd party brokers in the near future; so choices made here need to accommodate that.

I'm working on the basis that we will generate a separate schema for each broker (for now). A combined schema will be doable, but one step at a time.

Here's an first iteration of an example schema we can generate:

asyncapi: 3.0.0
info:
  version: 1.0.0
  title: dev Team Broker
  description: An auto-generated schema of the topics being used on the team broker
servers:
  team-broker:
    host: broker.example.com
    protocol: mqtt
channels:
  foo/bar:
    address: foo/bar
  top/a/b:
    address: top/a/b
  /top/c/d:
    address: /top/c/d
  top/a/b/c:
    address: top/a/b/c

Notes

  1. info.title includes the Team Name + Broker name. For this iteration 'Team Broker' is the only broker. In the future, that will be the name of the relevant 3rd party broker.
  2. version is hardcoded to 1.0.0 - its a required field for the schema. We will need to think about lifecycle of schema versions and how the value changes over time.
  3. servers.team-broker - not including any username/password details here for first iteration. Will need to think about how to do that securely (if its a requirement) - and also what credentials to include if the Team has multiple clients defined.
  4. channels - these are the individual topics. The top-level property is normally a more human-readable name for the channel and the address is the full topic string. Without any further information, I'm reusing topic for both. In a future where we allow users to edit the schema, this will be one of those editable things.

URL & Security

In my initial prototyping, I'm serving the schema from /api/v1/teams/:teamId/broker/:brokerAlias/schema.yml

The :brokerAlias property will allow us to serve schemas for the individual 3rd party brokers. For now team-broker is the hard-coded alias we'll use.

The security on this URL requires a valid session - as usual for our API.

This poses a challenge when we think about how the schema will actually be used. Typically, the URL will be fed into some AsyncAPI consuming tool; however that normally requires a the url to be publicly accessible to the tool. A workaround is the user can export the schema as a local file and then upload it to their tool of choice.

We need to spend some more time working up use-cases for the schema to identify how and where it will be used.

One obvious use case is within Node-RED itself. A custom FF Plugin could deal with the access to the schema under the covers.

Exposing the UI

As a first pass to expose it, I propose we add a suitable button to the topic hierarchy view that links to the schema. Here's my professional mock-up of that proposal:

image
@joepavitt joepavitt added this to the 2.13 milestone Dec 16, 2024
@joepavitt joepavitt added size:XL - 8 Sizing estimation point area:api Work on the platform API labels Dec 16, 2024
@joepavitt joepavitt moved this to Todo in 🛠 Development Dec 24, 2024
@knolleary knolleary moved this from Todo to In Progress in 🛠 Development Jan 7, 2025
@knolleary
Copy link
Member

Have updated the description with more details of what we can do for a first iteration. Will have a PR for much of this tomorrow.

@knolleary
Copy link
Member

UI done in #5008 - this can be closed once that is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:api Work on the platform API size:XL - 8 Sizing estimation point
Projects
Status: Closed / Done
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants