Reference

Go Formats

Reference for go-framework format import/export — AsyncAPI, business model, and OpenAPI tool schema export.

Module: github.com/redelay/go-framework/core

The Redelay compilation pipeline supports importing from and exporting to multiple specification formats. All formats convert to/from the canonical IR before any processing.

AsyncAPI import/export

The core/asyncapi package imports AsyncAPI 2.x YAML documents and exports IR Documents to AsyncAPI 2.6 YAML.

Import

go
import "github.com/redelay/go-framework/core/asyncapi"

doc, err := asyncapi.ImportYAML(reader) // AsyncAPI YAML → *ir.Document

Converts channels to ir.Channel with publish/subscribe events and Kafka group ID bindings.

Export

go
err := asyncapi.Export(doc, writer) // *ir.Document → AsyncAPI 2.6 YAML

Export behavior:

  • IR channels with publish/subscribe events → AsyncAPI channels
  • If no channels exist but events are present, creates synthetic channels using entity_type.action as topic name
  • Kafka bindings for group IDs

AsyncAPI YAML example

yaml
asyncapi: "2.6.0"
info:
  title: My Events
  version: "1.0"
channels:
  order.created:
    description: Order creation events
    publish:
      operationId: OrderCreated
      message:
        name: OrderCreated
    bindings:
      kafka:
        groupId: order-service

Business model import/export

The core/businessmodel package parses business model YAML and converts to/from IR.

Import

go
import "github.com/redelay/go-framework/core/businessmodel"

spec, err := businessmodel.ParseYAML(reader) // YAML → *Spec
doc := businessmodel.Normalize(spec)          // *Spec → *ir.Document

Export

go
err := businessmodel.Export(doc, writer) // *ir.Document → business model YAML

Export behavior:

  • If modules exist, each module becomes a domain with entities, events, and processes (workflows)
  • If no modules exist, creates a single domain from top-level items

Business model YAML format

yaml
title: E-Commerce Platform
version: "1.0"
domains:
  - name: billing
    description: Billing domain
    entities:
      - name: invoice
        fields: [amount, currency, status]
    events:
      - name: invoice_created
        entity_type: invoice
        action: created
    processes:
      - name: payment_flow
        triggers: [invoice_created]
        steps: [validate, charge, confirm]

Domain types

TypeDescription
SpecRoot business model document
DomainBounded context / business domain
BizEntityBusiness entity with field name list
BizEventBusiness event (entity_type + action)
ActorPerson or system interacting with the domain
ProcessBusiness process with named steps and triggers

OpenAPI tool schema export

The core/openapi package provides functions for exporting IR Documents as function-calling tool definitions (JSON Schema format compatible with LLM tool-use APIs).

Export functions

go
import "github.com/redelay/go-framework/core/openapi"

tools := openapi.ExportActions(doc)      // IR actions → tool definitions
tools = openapi.ExportEntities(doc)      // IR entities → get_<name> lookup tools
tools = openapi.ExportCommands(doc)      // IR commands → tool definitions
tools = openapi.ExportAll(doc)           // all of the above combined
err := openapi.WriteTools(writer, tools) // serialize as JSON

Output format

json
[
  {
    "type": "function",
    "function": {
      "name": "create_invoice",
      "description": "Create a new invoice",
      "parameters": {
        "type": "object",
        "properties": {
          "amount": { "type": "number", "description": "Invoice amount" },
          "currency": { "type": "string" }
        },
        "required": ["amount"]
      }
    }
  }
]

Type mapping (IR → JSON Schema)

IR FieldTypeJSON Schema type
string, date, datetime, uuid"string"
integer"integer"
float"number"
boolean"boolean"
array"array"
object"object"

Supports nested properties, items for arrays, enum, format, and required fields.

Format conversion matrix

All formats can be converted via the IR hub:

FromTo
flowdsljson, yaml, flowdsl, openapi
openapijson, yaml, flowdsl, openapi
asyncapijson, yaml, flowdsl, openapi
businessmodeljson, yaml, flowdsl, openapi

Use the redelayctl CLI to convert between formats from the command line.