AsyncAPI 3.0 to MoonBit type and message interface generator
moon add zbhzs1/moonasyncapi///|
import {
"zbhzs1/moonasyncapi",
}let source =
"{\"asyncapi\":\"3.0.0\",\"info\":{\"title\":\"Events\"},\"channels\":{}}"
match @moonasyncapi.generate_from_json(source) {
Ok(plan) => {
for file in plan.files {
println(file.path)
}
}
Err(message) => println("parse error: " + message)
}moon run cmd/main --target js -- \
examples/order-events.json \
_build/generated-orders \
example/order-events-generated
cd _build/generated-orders
moon check --deny-warnmoon fmt --check
moon check --deny-warn
moon check --target js --deny-warn
moon build
moon testpub struct AsyncApiChannel {
address : String
messages : Map[String, AsyncApiMessage]
binding : String?
parameters : Map[String, ChannelParameter]
} derive(Eq, Debug)pub struct AsyncApiDocument {
asyncapi : String
version : String
title : String
channels : Map[String, AsyncApiChannel]
operations : Array[AsyncApiOperation]
schemas : Map[String, Schema]
messages : Map[String, AsyncApiMessage]
servers : Map[String, AsyncApiServer]
security_schemes : Map[String, SecurityScheme]
} derive(Eq, Debug)pub struct AsyncApiServer {
name : String
host : String
protocol : String
protocol_version : String?
pathname : String?
description : String?
variables : Map[String, ServerVariable]
security_requirements : Array[String]
} derive(Eq, Debug)pub(all) struct GenerationPlan {
files : Array[GeneratedFile]
diagnostics : Array[CodegenDiagnostic]
schema_count : Int
message_count : Int
operation_count : Int
} derive(Eq, Debug)pub struct OperationHeadersValidationReport {
operation_name : String
action : String
channel : String
message_count : Int
diagnostics : Array[Diagnostic]
} derive(Eq, Debug)pub struct OperationValidationReport {
operation_name : String
action : String
channel : String
protocol : String?
message_count : Int
diagnostics : Array[Diagnostic]
} derive(Eq, Debug)pub struct Schema {
kind : String?
required : Array[String]
properties : Map[String, Schema]
enum_values : Array[String]
enum_json_values : Array[Json]
const_value : Json?
format_name : String?
default_value : Json?
examples : Array[Json]
ref_name : String?
ref_cycle : Bool
items : Schema?
minimum : Double?
maximum : Double?
multiple_of : Double?
exclusive_minimum : Double?
exclusive_maximum : Double?
min_length : Double?
max_length : Double?
min_items : Double?
max_items : Double?
unique_items : Bool
min_properties : Double?
max_properties : Double?
additional_properties : Bool?
unsupported_keywords : Array[String]
} derive(Eq, Debug)fn moonbit_type_name(source : String) -> Stringfn moonbit_value_name(source : String) -> Stringfn render_channel_address(channel : AsyncApiChannel, values : Map[String, String]) -> Result[String, String]fn render_server_endpoint(server : AsyncApiServer, values : Map[String, String]) -> Result[String, String]fn validate_operation_headers(document : AsyncApiDocument, operation_name : String, headers : Json) -> Array[Diagnostic]fn validate_operation_headers_batch(document : AsyncApiDocument, headers_by_operation : Map[String, Json]) -> Array[OperationHeadersValidationReport]fn validate_operation_payload(document : AsyncApiDocument, operation_name : String, payload : Json) -> Array[Diagnostic]fn validate_operations(document : AsyncApiDocument, payloads : Map[String, Json]) -> Array[OperationValidationReport]Install
Download zipAsyncAPI 3.0 to MoonBit type and message interface generator