asyncapi

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateForgeDescriptor

func CreateForgeDescriptor(router any, locationType farp.LocationType, locationConfig map[string]string) (*farp.SchemaDescriptor, error)

CreateForgeDescriptor creates a schema descriptor from a Forge router This is a helper method to simplify descriptor creation.

Types

type AsyncAPISchemaProvider

type AsyncAPISchemaProvider interface {
	// AsyncAPISchema returns a base AsyncAPI schema (map[string]any) if the application provides one.
	// The returned schema will be merged with the generated schema.
	AsyncAPISchema() map[string]any
}

AsyncAPISchemaProvider is an optional interface that applications can implement to provide a base AsyncAPI schema that will be merged with the generated schema.

type AsyncAPISpecProvider

type AsyncAPISpecProvider interface {
	AsyncAPISpec() any
}

AsyncAPISpecProvider is an interface for types that can provide an AsyncAPI spec.

type ForgeProvider

type ForgeProvider struct {
	*Provider
}

ForgeProvider is a Forge-specific AsyncAPI provider that generates schemas from Forge's built-in AsyncAPI generator.

func NewForgeProvider

func NewForgeProvider(specVersion string, endpoint string) *ForgeProvider

NewForgeProvider creates a new Forge-integrated AsyncAPI provider.

func (*ForgeProvider) Generate

func (p *ForgeProvider) Generate(ctx context.Context, app farp.Application) (any, error)

Generate generates AsyncAPI schema from Forge application.

func (*ForgeProvider) GenerateFromRouter

func (p *ForgeProvider) GenerateFromRouter(provider any) (any, error)

GenerateFromRouter generates AsyncAPI schema directly from any type that provides AsyncAPI specs This is a convenience method for direct router access.

func (*ForgeProvider) Validate

func (p *ForgeProvider) Validate(schema any) error

Validate validates an AsyncAPI schema generated from Forge.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider generates AsyncAPI 2.x or 3.x schemas from applications.

func NewProvider

func NewProvider(specVersion string, endpoint string) *Provider

NewProvider creates a new AsyncAPI schema provider specVersion should be "2.6.0" or "3.0.0" (recommended).

func (*Provider) ContentType

func (p *Provider) ContentType() string

ContentType returns the content type.

func (*Provider) Endpoint

func (p *Provider) Endpoint() string

Endpoint returns the HTTP endpoint where the schema is served.

func (*Provider) Generate

func (p *Provider) Generate(ctx context.Context, app farp.Application) (any, error)

Generate generates an AsyncAPI schema from the application app should provide Routes() method that returns route information. If the app implements AsyncAPISchemaProvider, the provided schema will be merged with the generated one.

func (*Provider) GenerateDescriptor

func (p *Provider) GenerateDescriptor(ctx context.Context, app farp.Application, locationType farp.LocationType, locationConfig map[string]string) (*farp.SchemaDescriptor, error)

GenerateDescriptor generates a complete SchemaDescriptor for this schema.

func (*Provider) Hash

func (p *Provider) Hash(schema any) (string, error)

Hash calculates SHA256 hash of the schema.

func (*Provider) Serialize

func (p *Provider) Serialize(schema any) ([]byte, error)

Serialize converts schema to JSON bytes.

func (*Provider) SpecVersion

func (p *Provider) SpecVersion() string

SpecVersion returns the AsyncAPI specification version.

func (*Provider) Type

func (p *Provider) Type() farp.SchemaType

Type returns the schema type.

func (*Provider) Validate

func (p *Provider) Validate(schema any) error

Validate validates an AsyncAPI schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL